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
Autosummary: Extend __all__
members to template rendering
#10811
Conversation
Fixes sphinx-doc#10809 * the option autosummary_ignore_module_all when set to False adds members to module's members entry that will be used for autodoc, but otherwise it ignores it. As such, if a class is available in the __all__, it won't be generated. * This commit aims at extending the __all__ handling not only to members, but also to corresponding attribute types (function, classes, exceptions, modules) * In short, the imported_members option is set to True if the object has __all__ member and autosummary is set to have autosummary_ignore_module_all set to False
…odule_all is True
Hi, is this improvement proposition considered ? I have created this PR as a draft to spark some discussion about changing autosummary behaviour, but otherwise it could be reviewed as is. I really think the current behaviour is not one users would expect when they use the recursive option. |
Please may you add a test of the new behaviour, and an entry to the changelog ( A |
__all__
members to template rendering
Thanks for the feedback :) here it is with test and CHANGES entry. Note that for now it does not take into account a module that would be in So it still lacks flexibility, but at least, it's better than before 😛 |
* When ignore_module_all is False, search for imported modules (possibly renamed) and in discovered modules, public modules are then the one mentioned in __all__ * In a more general usecase, skip all modules that are overwritten in the package namespace
I think I have found a solution that works. If Additionally, there is now a skip list for get_modules, to avoid tryinbg to get documentation from a module that was overwritten in the package namespace This will cause this kind of code to not crash with sphinx : (file from .a import a autosummary will now know that NB: Yes this does happen even though I would personally consider it an antipattern. Some JAVA inspired python code exist out there with only a class in the module and a class the same name of the module and then an import similar to the aforementionned one in the parent package On a more genral note, I have seen that the difference between private members and public members is the leading underscore (see https://github.com/sphinx-doc/sphinx/blob/master/sphinx/ext/autosummary/generate.py#L283). Without a proper |
Thank you @ClementPinard! A |
Fixes #10809
autosummary_ignore_module_all
when set toFalse
adds members to module's members entry that will be used for autodoc, but otherwise it ignores it. As such, if a class is available in the__all__
, it won't be generated.__all__
handling not only to members, but also to corresponding attribute types (functions, classes, exceptions, modules)imported_members
option is set toTrue
if the object has__all__
member and autosummary is set to haveautosummary_ignore_module_all
set to FalseSee an example repo where the behaviour is changed : https://github.com/ClementPinard/sphinx_autosummary_bug_example
this PR is (at least initially) just for illustration and discussion purpose. tests where not checked
Feature or Bugfix
A mix of both
Detail
autosummary_ignore_module_all
does not work as documented #10809