Sphinx,使用自动模块找出子模块 [英] Sphinx, using automodule to find submodules

查看:21
本文介绍了Sphinx,使用自动模块找出子模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

我只需编写一个.rst文件:

.. automodule:: my_module
    :members:

它很好地记录了my_MODULE,但它找不到像my_mode.ner_mode0和my_mode.ner_mode1这样的内部模块。除了__all__变量之外,还需要在__init__.py文件中指定什么吗?

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

推荐答案

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

例如,给定以下目录结构(摘自Python文档)。您不能指定.. automodule:: sound.formats并让它记录目录中的所有模块。您必须为每个模块指定automodule命令:.. automodule:: sound.formats.waveread.. automodule:: sound.formats.wavewrite等。

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
              ...

这篇关于Sphinx,使用自动模块找出子模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆