Sphinx Autodoc和NumpyDoc

 ranger 发布于 2023-02-13 13:19

尽管阅读了本教程,这个问题和numpy docstring标准,但我无法让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'

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

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

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

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有