Skip to content

ENH: use __text_signature__ if pydoc.doc does not reveal a signature. #73

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 17, 2016
Merged

ENH: use __text_signature__ if pydoc.doc does not reveal a signature. #73

merged 1 commit into from
Nov 17, 2016

Conversation

MSeifert04
Copy link
Contributor

@MSeifert04 MSeifert04 commented Nov 7, 2016

This allows to support the __text_signature__ property on Python 3.4+ to document C functions.

I had a problem since I started my project: I could either support IPython autocompletion for parameters or use numpydoc and have the signature.

Say, I have a C Function with a docstring:

"foo(x, y)\n\
\n\
actual docs"

IPython isn't able to parse a Signature because inspect.Signature just doesn't know what to do with it. numpydoc and sphinx however document it correctly.

If I change it to

"foo(x, y)\n\
--\n\
\n\
actual docs"

IPython and inspect.Signature do work. But they seem to remove it from the docstring. Therefore numpydoc (probably even sphinx itself) can't document the signature from pydoc.getdoc.

Accessing the __text_signature__ solves this problem! I locally get correctly rendered signatures AND IPythons autocompletion. No idea if it breaks something else, at least my project now renders correctly.

This allows to support the __text_signature__ property on Python 3.4+
to document C functions.
@MSeifert04
Copy link
Contributor Author

Does anyone want to review my PR?

@rgommers rgommers added this to the v0.7.0 milestone Nov 17, 2016
@rgommers
Copy link
Member

Looks good to me. Works as expected, and builds the SciPy docs fine. So merging. Thanks @MSeifert04

@rgommers rgommers merged commit 89fb6cd into numpy:master Nov 17, 2016
@MSeifert04 MSeifert04 deleted the textsignature-if-no-other branch November 17, 2016 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants