尽管阅读了this tutorial、this question和numpy docstring standard,我还是无法让sphinx autodoc很好地处理numpy文档字符串。
在我的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"
。当我向我的extensions
添加autosummary
时,如下所示:
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部分。
有没有办法摆脱这个烂摊子?
发布于 2013-12-30 02:35:31
尝试删除之前的整个html
输出。然后重新生成文档。
https://stackoverflow.com/questions/20334804
复制相似问题