23

尽管阅读了本教程这个问题numpy 文档字符串标准,但我无法让 sphinx autodoc 与 numpy 文档字符串很好地配合使用。

在我的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'

按照这个问题的建议,我添加numpydoc_show_class_members = False到我的conf.py.

现在我可以正常运行make html了,但是ParametersandReturns部分不会被解释为 numpydoc 部分。

有没有办法摆脱这种混乱?

4

1 回答 1

3

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

于 2013-12-29T18:35:31.050 回答