我正在尝试从我的模块中提取文档字符串并构建一个不错的文档。所以我和狮身人面像在一起,我不知道出了什么问题。
我的类文档字符串,在_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:
我的狮身人面像配置文件(我更改的部分(:
autoclass_content = 'both'
extensions = ['sphinx.ext.autodoc','sphinx.ext.napoleon']
napoleon_numpy_docstring = True
当我尝试make html
时,它可以工作(此模块没有错误(,但它不显示"方法"部分。如果我在文档字符串中删除它,它与 html 的唯一区别是下面列出的方法不再是链接。
我错过了什么?
您应该尝试使用numpydoc
狮身人面像扩展。安装后,您只需将其包含在狮身人面像扩展列表中:
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.napoleon', 'numpydoc']
在conf.py
中,您可以访问以下选项:
numpydoc_show_class_members: bool
是否在"方法"和"属性"部分中自动显示类的所有成员。 默认情况下
True
。
numpydoc_show_inherited_class_members: bool
是否在"方法"和"属性"部分中自动显示类的所有继承成员。如果它是假的,则继承 成员不会显示。 默认情况下
True
。
numpydoc_class_members_toctree: bool
是否为类方法和属性列表创建狮身人面像目录。如果制作了目录,狮身人面像 期望每个条目都有一个单独的页面。 默认情况下
True
。