You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to fix some issues with statsmodels documentation.
One issue that we've uncovered is that numpydoc 0.9.0 (and 0.9.1) includes self in the list of params for a method, when it would be preferable if it didn't. That's different than what 0.8.0 did.
Is it numpydoc, or sphinx version upgrade? The table is probably constructed by sphinx.ext.autosummary, signature mangling is maybe from numpydoc but I don't recall how this works exactly any more...
I don't know why running this way, the "old" way doesn't work. It must be adding the signature before it goes through this. I'm not sure how the app.connect('autodoc-process-signature', mangle_signature) line works...
(my guess is that autodoc is parsing it, and realizing that this is method and dropping the first parameter, then prepending the signature on the docs. Not sure how to setup a test of that, however.)
Ok, better guess. I think before, this was broken and didn't return signatures when they weren't explicitly stated in the docstring. Then I'm guessing sphinx added the correct one.
With the "fix" (that reverts behavior) doc['Signature'] is ''.
loading intersphinx inventory from https://docs.scipy.org/doc/numpy/objects.inv...
loading intersphinx inventory from https://docs.python.org/3/objects.inv...
loading intersphinx inventory from https://matthew-brett.github.io/pydagogue/objects.inv...
loading intersphinx inventory from https://patsy.readthedocs.io/en/latest/objects.inv...
loading intersphinx inventory from https://pandas.pydata.org/pandas-docs/stable/objects.inv...
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 90 source files that are out of date
updating environment: 376 added, 0 changed, 0 removed
> /Users/peter/git/numpydoc/numpydoc/numpydoc.py(222)mangle_signature()ar_model.GLM
-> sig = doc['Signature'] or getattr(obj, '__text_signature__', None)
(Pdb) doc
<numpydoc.docscrape_sphinx.SphinxDocString object at 0x12483ae48>
(Pdb) doc['Signature']
''
(Pdb) c
> /Users/peter/git/numpydoc/numpydoc/numpydoc.py(222)mangle_signature()ar_model.GLM.fit
-> sig = doc['Signature'] or getattr(obj, '__text_signature__', None)
(Pdb) doc
<numpydoc.docscrape_sphinx.SphinxDocString object at 0x126d64320>
(Pdb) doc['Signature']
''
(Pdb)
Now, this runs, and adds the signature that didn't exist before. Because the signature is added, my theory is that autodoc doesn't use its (slightly different) logic to add the signature.
It was broken before. SphinxDocString(pydoc.getdoc(class.method))['Signature'] would always return '' when the signature is not included in the actual docstring.
Now get_doc_object(class.method) creates an instance of SphinxFunctionDoc(obj). That inherits FuncitonDoc and runs FunctionDoc.__init__ where the code above generates a signature. So get_doc_object(class.method)['Signature'] will not be ''. There is no logic to eliminate self from method signatures in this code.
Then--and here I haven't looked at sphinx's autodoc--since a signature already exists, autodoc just relies on the provided signature.
Before #200, since there was no signature, sphinx's autodoc used its logic to create the signature and its logic was clever enough to drop self.
so you think the solution is to adopt autodoc's logic?
I guess that would make sense. Either (hard way) duplicate their logic or (easy way) create a Signature only if it already exists in the docstring. Otherwise, just create a Signature of ''.
Activity
jnothman commentedon May 27, 2019
pv commentedon May 27, 2019
Is it numpydoc, or sphinx version upgrade? The table is probably constructed by sphinx.ext.autosummary, signature mangling is maybe from numpydoc but I don't recall how this works exactly any more...
thequackdaddy commentedon May 27, 2019
Its just a numpydoc upgrade. I am using sphinx 2.0.1 on both.
From what I I can figure, you can do...
and you get the same output for both. That's just an autosummray table with just the method names (no signature/parameters).
So that looks right. But the signature is different. I can't really tell how the signature is generated from the code.
thequackdaddy commentedon May 28, 2019
Git bisect has lead me to think the issue is here:
2cdd4d9
jnothman commentedon May 28, 2019
thequackdaddy commentedon May 28, 2019
I'm pretty certain that is it. I changed that code back in a development version and it works.
I can't seem to figure out how the code works, however...
I don't know why running this way, the "old" way doesn't work. It must be adding the signature before it goes through this. I'm not sure how the
app.connect('autodoc-process-signature', mangle_signature)line works...thequackdaddy commentedon May 28, 2019
(my guess is that autodoc is parsing it, and realizing that this is method and dropping the first parameter, then prepending the signature on the docs. Not sure how to setup a test of that, however.)
thequackdaddy commentedon May 28, 2019
Ok, better guess. I think before, this was broken and didn't return signatures when they weren't explicitly stated in the docstring. Then I'm guessing sphinx added the correct one.
With the "fix" (that reverts behavior)
doc['Signature']is''.thequackdaddy commentedon May 28, 2019
Ok I think it boils down to this...
Before, this whole section got skipped... its not in the inheritance of
SphinxDocString.numpydoc/numpydoc/docscrape.py
Lines 564 to 590 in 2fa5256
Now, this runs, and adds the signature that didn't exist before. Because the signature is added, my theory is that autodoc doesn't use its (slightly different) logic to add the signature.
https://github.com/sphinx-doc/sphinx/blob/f63abac2cad2664a8af816017f0f997bae510d14/sphinx/ext/autodoc/__init__.py#L1313-L1324
jnothman commentedon May 30, 2019
What a strange interaction. I'm struggling to get my head around it.
jnothman commentedon May 30, 2019
I don't understand how #200 worked really.
thequackdaddy commentedon May 30, 2019
Let me rephrase.
It was broken before.
SphinxDocString(pydoc.getdoc(class.method))['Signature']would always return''when the signature is not included in the actual docstring.#200 "fixed" it.
Now
get_doc_object(class.method)creates an instance ofSphinxFunctionDoc(obj). That inheritsFuncitonDocand runsFunctionDoc.__init__where the code above generates a signature. Soget_doc_object(class.method)['Signature']will not be''. There is no logic to eliminateselffrom method signatures in this code.Then--and here I haven't looked at sphinx's autodoc--since a signature already exists, autodoc just relies on the provided signature.
Before #200, since there was no signature, sphinx's autodoc used its logic to create the signature and its logic was clever enough to drop
self.jnothman commentedon May 31, 2019
thequackdaddy commentedon May 31, 2019
I guess that would make sense. Either (hard way) duplicate their logic or (easy way) create a Signature only if it already exists in the docstring. Otherwise, just create a Signature of
''.thequackdaddy commentedon Jun 1, 2019
I updated #221 to add the functionality I'm thinking about. Let me know if you think this is on the right path.
(edit... wrong number)
fladd commentedon Oct 26, 2019
Is there a way to fix this for ourselves (besides reverting to 0.8.0)?
thequackdaddy commentedon Jun 27, 2020
Closed by #221