-
-
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
sphinx.ext.autosummary with automatic recursion doesn't follow legitimate import statement in __init__.py file #9069
Comments
hey everyone! I found the problematic code: sphinx/sphinx/ext/autosummary/__init__.py Lines 633 to 650 in 952866c
it's totally non-trivial I'd say. I try to explain it with a minimal example that you can access here https://github.com/Chilipp/autosummary-issue, or as zip file here. Assume your code looks like this:
with
when the The loop now goes through the sphinx/sphinx/ext/autosummary/__init__.py Line 649 in 952866c
Here, the |
Hey @Chilipp , thanks for looking into this and glad you managed to find something... One of the things that's puzzling me is that I ran Sphinx over a sister repo that also has So perhaps a better title for this issue would be: why does Sphinx fail to follow some legitimate import statements in |
Hey @JamesALeedham ! Did you use the same rst file in both cases? Because the critical thing in my example from above is the combination
If you drop the automodule thing, or put the automodule behind the autosummary, everything works well |
Just to be clear about my setup, I'm not handcrafting the .rst, I'm relying on I guess Autosummary is then using my custom module template and class template to do the actual doc generation... (At this point, I've probably reached my limit in understanding how Sphinx works... 😞 ) But yes, the Sphinx setup is 100% identical for both repos - one in which |
Having this problem as well. |
#8963 |
Switching automodule after autosummary manually worked for me. With the option "autosummary_generate_overwrite = False" allows to have something workable (more or less) and manage only the module level manually. |
Not sure whether I got the topic correctly. I was trying to get functions imported in the __init__.py documented also at the corresponding module level. sphinx/sphinx/ext/autosummary/generate.py Line 254 in 952866c
changing this to if imported or obj.__name__ in getattr(value, '__module__', None): will work. |
Is there a workaround for this in the meanwhile? |
For anyone dealing with this issue as well, I found a solution that worked for me. My auto generated rst looked like this:
The problem, as @Chilipp discovered, lies with
Notice that the functions are given fully qualified import paths. Hope this helps someone else! |
Describe the bug
Sphinx fails to import & document a module that is itself imported in an
__init__.py
file. I'm at a loss as to understand why; on the face of it, there's nothing wrong with this import statement. If I comment out the import statement, Sphinx imports & documents the module perfectly. Why is this?To Reproduce
git@github.com:JamesALeedham/lusid-python-tools.git
and checkout thesphinx-bug-query
branch.lusidtools.logger.LusidLogger
class is not documented (ie. page is empty).lusidtools/logger/__init__.py
and comment out the single import statement, ie.# from lusidtools.logger.LusidLogger import LusidLogger
.With the import statement in
__init__.py
commented out, Sphinx documents thelusidtools.logger.LusidLogger
class perfectly. (Here's an example of what this page then looks like).Environment info
sphinx.ext.autosummary
with the brilliant:recursive:
optionThe text was updated successfully, but these errors were encountered: