-
-
Notifications
You must be signed in to change notification settings - Fork 107
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
Doesn't interact correctly with typing.overload
.
#296
Comments
I guess you also have to |
PR trying to address this is welcome 🤗 |
Are you okay with adding: from sphinx.ext.autodoc import FunctionDocumenter, MethodDocumenter
del FunctionDocumenter.format_signature
del MethodDocumenter.format_signature to |
hoodmane
added a commit
to hoodmane/pyodide
that referenced
this issue
Jan 17, 2023
… functions Two fixes: 1. the `pyodide.ffi` stuff is defined in `_pyodide._core_docs`. We don't want `_pyodide._core_docs` to appear in the documentation because this isn't where you should import things from so we override the `__name__` of `_pyodide._core_docs` to be `pyodide.ffi`. But then Sphinx fails to locate the source for the stuff defined in `_pyodide._core_docs`. This patches `ModuleAnalyzer` to tell it to look for the source of things from `pyodide.ffi` in `_pyodide._core_docs`. 2. A second problem is that if a function has a typing.overload then the code path that sphinx-autodoc takes is not one that sphinx-autodoc-typehints can handle. See tox-dev/sphinx-autodoc-typehints#296
I'm willing to try. |
Okay, PR incoming. |
hoodmane
added a commit
to hoodmane/sphinx-autodoc-typehints
that referenced
this issue
Jan 17, 2023
Merged
Closed by #297. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you provide a
@typing.overload
for a function, the output is not correct. As far as I can tell, this problem is not fixable without changes to autodoc.The is that in the presence of a
typing.overload
, autodoc will never emit an'autodoc-process-signature'
event. You can see the logic here inFunctionDocumenter.format_signature
:https://github.com/sphinx-doc/sphinx/blob/master/sphinx/ext/autodoc/__init__.py?plain=1#L2193
If
self.analyzer.overloads
has overloads for this function, it uses overloaded signatures, otherwise it callssuper().format_signature
. In this casesuper().format_signature
isDocumenter.format_signature
which actually emits the `'autodoc-process-signature' event:https://github.com/sphinx-doc/sphinx/blob/master/sphinx/ext/autodoc/__init__.py?plain=1#L513\
So when overloads exist, we fail to override default behavior. An easy fix for this is:
Example module
Actual output
Actual output
Desired output
achieved with
del FunctionDocumenter.format_signature
Desired output
The text was updated successfully, but these errors were encountered: