Sphinx, using automodule to find submodules

前端 未结 2 787
青春惊慌失措
青春惊慌失措 2021-02-02 08:16

When using sphinx\'s automodule (https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html),

I simply write in a .rst file:

.. automodule:: my_m         


        
相关标签:
2条回答
  • 2021-02-02 08:43

    It sounds like you want to give the automodule directive a package name and have it recurse into the directory and document each Python module. That isn't supported yet. You will ned to specify the full dotted module name for each module you want to document.

    For example, given the following directory structure (from the Python documentation). You cannot specify .. automodule:: sound.formats and have it document all the modules in the directory. You will have to specify a automodule command for each module: .. automodule:: sound.formats.waveread, .. automodule:: sound.formats.wavewrite, etc.

    sound/                          Top-level package
          __init__.py               Initialize the sound package
          formats/                  Subpackage for file format conversions
                  __init__.py
                  wavread.py
                  wavwrite.py
                  aiffread.py
                  aiffwrite.py
                  auread.py
                  auwrite.py
                  ...
          effects/                  Subpackage for sound effects
                  __init__.py
                  echo.py
                  surround.py
                  reverse.py
                  ...
    
    0 讨论(0)
  • 2021-02-02 08:51

    It seems to me that using the :imported-members: option (non-direct link, do use search) should now be possible, if __init__.py imports those submodules.

    However, I'm personally not able to make this work (yet).

    EDIT: Possibly a known bug.

    0 讨论(0)
提交回复
热议问题