Sphinx Autodoc和NumpyDoc

Lon*_*Rob 22 numpy python-sphinx autodoc

尽管阅读了本教程,这个问题numpy docstring标准,但我无法让sphinx autodoc与numpy docstrings很好地配合.

在我的conf.py身上:

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

在我的doc文件中,我有:

 .. automodule:: python_file

 .. autoclass:: PythonClass
   :members:
Run Code Online (Sandbox Code Playgroud)

哪里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
Run Code Online (Sandbox Code Playgroud)

当我跑步时,make html我得到了ERROR: Unknown directive type "autosummary".当我加入autosummary我的时候extensions:

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

我明白了:

WARNING: toctree references unknown document u'docs/python_file.PythonClass.do_stuff'
Run Code Online (Sandbox Code Playgroud)

根据这个问题的建议,我加入numpydoc_show_class_members = False了我的conf.py.

现在我可以毫无错误地运行make html,但是ParametersReturns部分不会被解释为numpydoc部分.

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

Mac*_* D. 3

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

  • 这对我不起作用。删除并重新运行后仍然存在同样的问题。还有其他想法吗? (2认同)