-
-
Notifications
You must be signed in to change notification settings - Fork 165
BUG: Defer to autodoc for signatures #221
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
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
0beccb2
TST: Desired test
thequackdaddy 4022f5f
ENH: Allow numpydoc to defer signature creation to autodoc
thequackdaddy 8e468cf
Python 2.7 signatures for lcass methods are different
thequackdaddy 3f7f7ce
Don't generate signatures. Default to autodoc signatures
thequackdaddy 96216c0
TST: Correct for escapes before * and self in methods
thequackdaddy 56d621b
Remove $ from __text_signature__
thequackdaddy d2b943e
Fix python C sigangure $ issues. Revert removal of star test.
thequackdaddy 3c6d16d
Add helper funciton to clean-up C __text_signatures__
thequackdaddy aa2189d
PEP-8 fixes and readability
thequackdaddy 339cf8a
Additional tests and less-strict space checking
thequackdaddy 5df5f28
Use more gentle regexp to remove $ and forward slash
thequackdaddy 88aaa5f
DOC: Add change to release notes [skip ci]
thequackdaddy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# -*- encoding:utf-8 -*- | ||
from copy import deepcopy | ||
from numpydoc.numpydoc import mangle_docstrings | ||
from numpydoc.numpydoc import mangle_docstrings, _clean_text_signature | ||
from numpydoc.xref import DEFAULT_LINKS | ||
from sphinx.ext.autodoc import ALL | ||
|
||
|
@@ -36,7 +36,7 @@ class MockApp(): | |
|
||
|
||
def test_mangle_docstrings(): | ||
s =''' | ||
s = ''' | ||
A top section before | ||
|
||
.. autoclass:: str | ||
|
@@ -64,6 +64,32 @@ def test_mangle_docstrings(): | |
assert 'upper' not in [x.strip() for x in lines] | ||
|
||
|
||
def test_clean_text_signature(): | ||
assert _clean_text_signature(None) is None | ||
assert _clean_text_signature('func($self)') == 'func()' | ||
assert (_clean_text_signature('func($self, *args, **kwargs)') | ||
== 'func(*args, **kwargs)') | ||
assert _clean_text_signature('($self)') == '()' | ||
assert _clean_text_signature('()') == '()' | ||
assert _clean_text_signature('func()') == 'func()' | ||
assert (_clean_text_signature('func($self, /, *args, **kwargs)') | ||
== 'func(*args, **kwargs)') | ||
assert _clean_text_signature('($module)') == '()' | ||
assert _clean_text_signature('func($type)') == 'func()' | ||
assert (_clean_text_signature('func($self, foo="hello world")') | ||
== 'func(foo="hello world")') | ||
assert (_clean_text_signature("func($self, foo='hello world')") | ||
== "func(foo='hello world')") | ||
assert (_clean_text_signature('func(foo="hello world")') | ||
== 'func(foo="hello world")') | ||
assert (_clean_text_signature('func(foo="$self")') | ||
== 'func(foo="$self")') | ||
assert (_clean_text_signature('func($self, foo="$self")') | ||
== 'func(foo="$self")') | ||
assert _clean_text_signature('func(self, other)') == 'func(self, other)' | ||
assert _clean_text_signature('func(self, $self)') == 'func(self)' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure this is a thing :) |
||
|
||
thequackdaddy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if __name__ == "__main__": | ||
import pytest | ||
pytest.main() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it'll happen often, but I'm still not comfortable with the fact that this processes all parts of the sig. Can't we check explicitly that the
/
precedes a*
, and that the$
is at the beginning, rather than use the split and join logic?Is this not sufficient?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll confess that I have (almost) no understanding of how these C text signature things work.
What you have would make it so
func($self)
would still befunc($self)
. Is that alright? I have no idea what the possible syntax is for this.If you (or someone else) has some kind of documentation on what is possible, that would make this back-and-forth much easier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I meant to apply those substitutions after
They're just a bit more careful than splitting on every comma.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I think this makes sense. Let me change that.
To handle
func($self)
, I guess you could just add a’, ‘
right before your code. Then use regex to strip off a trailing’, ‘
if it exists.Do you think that would work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, didn't handle that case, did I?
Can use
r'^\$(self|module|type)(, |$))?'
which will strip a comma, or check that we're at the end.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Take a peek at this. I had to do something to check whether the
/
was the start of the string or preceded by a,
.