【问题标题】:Sphinx Autodoc and NumpyDocSphinx Autodoc 和 NumpyDoc
【发布时间】:2013-12-02 17:59:57
【问题描述】:

尽管阅读了 this tutorialthis questionnumpy 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"。当我将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】:

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

    【讨论】:

    • 这对我不起作用。删除并重新运行后存在相同的问题。还有其他想法吗?
    猜你喜欢
    • 2018-10-20
    • 2023-03-26
    • 1970-01-01
    • 2011-04-10
    • 1970-01-01
    • 1970-01-01
    • 2012-02-09
    • 2012-05-09
    • 2011-02-11
    相关资源
    最近更新 更多