Sphinx Autodoc和NumpyDoc

问题描述 投票:22回答:1

尽管读取this tutorialthis questionnumpy docstring standard,但我无法使Sphinx autodoc与numpy docstring一起很好地播放。

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

根据this question的建议,我将numpydoc_show_class_members = False添加到我的conf.py

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

有没有解决办法?

numpy python-sphinx autodoc numpydoc
1个回答
3
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.