gpt4 book ai didi

python-sphinx - Sphinx,使用自动模块查找子模块

转载 作者:行者123 更新时间:2023-12-03 10:14:55 26 4
gpt4 key购买 nike

使用 sphinx 的自动模块 (https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html) 时,

我只是写在一个 .rst 文件中:

.. automodule:: my_module
:members:

它很好地记录了 my_module,但没有找到像 my_module.inner_module0 和 my_module.inner_module1 这样的内部模块。除了 __all__ 变量之外,是否需要在 __init__.py 文件中指定一些内容?

另外,我知道 sphinx-apidoc .但是该命令的文档太多了(暴露了每个函数/文件夹,包括未记录的函数/文件夹)。

最佳答案

听起来你想给 automodule指示一个包名并让它递归到目录中并记录每个 Python 模块。这还不支持。您将需要为要记录的每个模块指定完整的点分模块名称。

例如,给定以下目录结构(来自 Python 文档)。您不能指定 .. automodule:: sound.formats并让它记录目录中的所有模块。您必须指定 automodule每个模块的命令:.. 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
...

关于python-sphinx - Sphinx,使用自动模块查找子模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11508290/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com