-
-
Notifications
You must be signed in to change notification settings - Fork 169
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
Changes from 9 commits
0beccb2
4022f5f
8e468cf
3f7f7ce
96216c0
56d621b
d2b943e
3c6d16d
aa2189d
339cf8a
5df5f28
88aaa5f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -203,12 +203,28 @@ def mangle_signature(app, what, name, obj, options, sig, retann): | |
if not hasattr(obj, '__doc__'): | ||
return | ||
doc = get_doc_object(obj, config={'show_class_members': False}) | ||
sig = doc['Signature'] or getattr(obj, '__text_signature__', None) | ||
sig = (doc['Signature'] or | ||
_clean_text_signature(getattr(obj, '__text_signature__', None))) | ||
if sig: | ||
sig = re.sub("^[^(]*", "", sig) | ||
return sig, '' | ||
|
||
|
||
def _clean_text_signature(sig): | ||
if sig is None: | ||
return None | ||
start_pattern = re.compile(r"^[^(]*\(*") | ||
start, end = start_pattern.search(sig).span() | ||
start_sig = sig[start:end] | ||
sig = sig[end:] | ||
sig = re.sub(r"\)", "", sig) | ||
thequackdaddy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
params = sig.replace(' ', '').split(',') | ||
thequackdaddy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for param in ('$self', '$module', '$type', '/'): | ||
if param in params: | ||
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 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
Is this not sufficient? 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'll confess that I have (almost) no understanding of how these C text signature things work. What you have would make it so 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Actually I think this makes sense. Let me change that. To handle Do you think that would work? 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. Sorry, didn't handle that case, did I? 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. Take a peek at this. I had to do something to check whether the |
||
params.remove(param) | ||
return start_sig + ', '.join(params) + ')' | ||
|
||
|
||
def setup(app, get_doc_object_=get_doc_object): | ||
if not hasattr(app, 'add_config_value'): | ||
return # probably called by nose, better bail out | ||
|
Uh oh!
There was an error while loading. Please reload this page.