尽管阅读了this tutorial,this question和numpy docstring standard,但我无法让sphinx autodoc与numpy docstrings很好地配合使用。
在conf.py
我有:
extensions = ['sphinx.ext.autodoc', 'numpydoc']
在我的doc文件中我有:
.. 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部分。
有没有办法解决这个烂摊子?
答案 0 :(得分:3)
尝试删除之前的整个html
输出。然后重新生成文档。