gpt4 book ai didi

python - 使用 numpy 样式格式的 Sphinx 忽略的部分

转载 作者:太空宇宙 更新时间:2023-11-04 05:36:27 25 4
gpt4 key购买 nike

我正在尝试从我的模块中提取文档字符串并构建一个不错的文档。所以我在这里使用 Sphinx,但我不知道出了什么问题。

我的类文档字符串,在 _meta 文件中:

class MasterBlock(object):
"""
Main class for block architecture. All blocks should inherit this class.

Methods
-------
main()
Override it to define the main function of this block.
add_input(Link object)
Add a Link object as input.
add_output(Link object)
Add a Link as output.
start()
Start the main() method as a Process.
stop()
Stops the process.
"""

我的 .rst :

Meta
==========================

.. automodule:: crappy.blocks._meta
:members:
:undoc-members:
:show-inheritance:

我的 Sphinx 配置文件(我更改的部分):

autoclass_content = 'both'
extensions = ['sphinx.ext.autodoc','sphinx.ext.napoleon']
napoleon_numpy_docstring = True

当我尝试 make html 时,它可以工作(此模块没有错误),但它不显示“方法”部分。如果我在文档字符串中删除它,它与 html 的唯一区别是下面列出的方法不再是链接。

我错过了什么?

最佳答案

您应该尝试使用 numpydoc Sphinx extension .一旦你安装了它,你只需将它包含在你的 Sphinx 扩展列表中:

extensions = ['sphinx.ext.autodoc', 'sphinx.ext.napoleon', 'numpydoc']

conf.py 中,您可以访问以下选项:

  • numpydoc_show_class_members: bool

    Whether to show all members of a class in the Methods and Attributes sections automatically. True by default.

  • numpydoc_show_inherited_class_members: bool

    Whether to show all inherited members of a class in the Methods and Attributes sections automatically. If it's false, inherited members won't shown. True by default.

  • numpydoc_class_members_toctree: bool

    Whether to create a Sphinx table of contents for the lists of class methods and attributes. If a table of contents is made, Sphinx expects each entry to have a separate page. True by default.

关于python - 使用 numpy 样式格式的 Sphinx 忽略的部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35438697/

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