My package has a structure, similar to the following:
├── README.md
├── __init__.py
├── module1
│ └── submodule1.py
│ └── submodule2.py
├── module2
│ ├── __init__.py
│ ├── _hiden_submodule1.py
│ ├── _hiden_submodule2.py
│ └── _hiden_submodule3.py
I have managed to document all of it from the docstrings using sphinx, with the autosummary and recursive option:
.. autosummary::
:toctree: _autosummary
:template: custom-module-template.rst
:recursive:
mymodule
which gives me very nice toctrees from modules to functions.
However, _hiden_submodules*.py
functions are imported into the __init__.py
of module2:
from mymodule.module2._hiden_submodules1 import *
from mymodule.module2._hiden_submodules2 import *
from mymodule.module2._hiden_submodules3 import *
I would like these functions to appear directly in the documentation as being part of module2, and not part of module2.hiden_submodules*
. How can I achieve that ?
Simply set
autosummary_imported_members = True # Also documents imports in __init__.py
in your conf.py
file. See here.