使用NumPyDoc样式的带有Napoleon Sphinx扩展的类方法列表

Pie*_*esi 7 python documentation numpydoc sphinx-napoleon

我正在使用NumPyDoc样式的文档字符串来记录Python软件包。我想从'numpydoc'Sphinx扩展名切换到Napoleon,因为我发现它以更紧凑,更易读的方式格式化docstring。但是,它没有在文档顶部列出类的方法,我发现numpydoc具有非常有价值的功能。有谁知道如何在拿破仑手动将其打开?

Wil*_*ant -1

我对拿破仑/狮身人面像很陌生,但我认为答案可能在狮身人面像,而不是拿破仑。

如果您在conf.py中启用了autodoc,例如。

extensions = ['sphinx.ext.autodoc',
    'sphinx.ext.napoleon',
    'sphinx.ext.coverage']
Run Code Online (Sandbox Code Playgroud)

然后添加到你的index.rst(比如说):

.. autoclass:: module_name.class_name
    :members:
    :undoc-members:
Run Code Online (Sandbox Code Playgroud)

wheremodule_name包含有问题的类,然后class_name将与其所有方法一起出现在文档中,即使它们当前没有文档字符串。