Sphinx Autodoc和NumpyDoc

时间:2013-12-02 17:59:58

标签: numpy python-sphinx autodoc

尽管阅读了this tutorialthis questionnumpy 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,但ParametersReturns部分不会被解释为numpydoc部分。

有没有办法解决这个烂摊子?

1 个答案:

答案 0 :(得分:3)

尝试删除之前的整个html输出。然后重新生成文档。