-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Autodoc fails to import docstrings from C extension modules, imports stub file instead #13415
Comments
Do you have a reproducible error that works on Windows? A |
Sure replace |
The relevant change is #13253 (#7630). For your case, you would want to preference importing a native module over stubs? Does the rationale in the issue apply here re signatures? sphinx/sphinx/ext/autodoc/importer.py Lines 169 to 181 in 54ab557
|
While I would love to document in the stub file. This essentially means double work. Using But I can understand the sentiment from #7630 too. |
It would be useful to have a tool to automatically update stub files with docstrings from C, but I don't know if anything like this exists. Does your current documentation render the function signatures with arguments? |
Well, it does... https://python-isal.readthedocs.io/en/stable/#module-isal.isal_zlib But only because I documented the function signature myself (or in this case modified it from existing CPython code): I rather have the function and the documentation in one place. The fact that function signatures cannot be inferred from C code is not really an argument here as the signature can be documented in the docstring. This is not essentially different from documenting it in a stub file. This is also how CPython generates function signatures in their documentation. |
For the given
CPython doesn't use autodoc, the signatures are explicitly documented.
I appreciate not wanting to duplicate this. I had hoped to avoid a configuration value here, but I will think a little more. |
Thanks for spotting the typo. The rest of the functions work though.
Oh yes that is true. Sorry, but at least it does work with the EDIT: Sorry, I could have worded that a bit more nicely. It is just frustrating when documentation gets broken to fix an issue that you never had, and turns out to be fixable by something else than changing the code. I don't have a problem with also documenting in the stub files per se, but that having that stuff in two places is almost a guarantee for them being out of sync. |
Describe the bug
The problem is that it imports the
pyi
stub file instead. I checked the install directory and the extension module files are present for importing.How to Reproduce
Environment Information
Sphinx extensions
`extensions = ["sphinx.ext.autodoc", 'sphinxarg.ext']`
Additional context
The problem does not occur in 8.1.0
The text was updated successfully, but these errors were encountered: