尽管读取this tutorial,this question和numpy docstring standard,但我无法使Sphinx autodoc与numpy docstring一起很好地播放。
在我的conf.py
中,我有:
extensions = ['sphinx.ext.autodoc', 'numpydoc']
并且在我的文档文件中,我有:
.. automodule:: python_file
.. autoclass:: PythonClass
:members:
python_file.py
具有:
class PythonClass(object):
def do_stuff(x):
"""
This does good stuff.
Here are the details about the good stuff it does.
Parameters
----------
x : int
An integer which has amazing things done to it
Returns
-------
y : int
Some other thing
"""
return x + 1
[运行make html
时,我会得到ERROR: Unknown directive type "autosummary"
。因此,当我将autosummary
添加到extensions
时:
extensions = ['sphinx.ext.autodoc', 'numpydoc', 'sphinx.ext.autosummary']
我得到:
WARNING: toctree references unknown document u'docs/python_file.PythonClass.do_stuff'
根据this question的建议,我将numpydoc_show_class_members = False
添加到我的conf.py
。
现在,我可以无错误地运行make html
,但是Parameters
和Returns
节不会被解释为numpydoc节。
有没有解决办法?
尝试删除整个先前的html
输出。然后重新生成文档。