相关疑难解决方法(0)

NumPy如何将docstrings处理成参数的sphinx文档?

我想使用sphinx构建我们的文档,并获得与NumPy文档相同的参数格式(https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt)

我发现有两种方法可以用sphinx记录第一种样式的参数,其中一种是

:param name: description
Run Code Online (Sandbox Code Playgroud)

要么

:keyword name: description
Run Code Online (Sandbox Code Playgroud)

和另一个(这是NumPy风格)

Parameters
----------
name: type
    description
Run Code Online (Sandbox Code Playgroud)

以下是一个示例:

http://docs.scipy.org/doc/numpy/reference/distutils.html#module-numpy.distutils

和来源

def get_subpackage(self,subpackage_name,
                   subpackage_path=None,
                   parent_name=None,
                   caller_level = 1):
    """Return list of subpackage configurations.

    Parameters
    ----------
    subpackage_name: str,None
        Name of the subpackage to get the configuration. '*' in
        subpackage_name is handled as a wildcard.
    subpackage_path: str
        If None, then the path is assumed to be the local path plus the
        subpackage_name. If a setup.py file is not found in the
        subpackage_path, then …
Run Code Online (Sandbox Code Playgroud)

numpy docstring python-sphinx

7
推荐指数
1
解决办法
1690
查看次数

Sphinx 的“意外章节标题”——问题是 numpy 吗?

跑步时

sphinx-build . html/
Run Code Online (Sandbox Code Playgroud)

在我的doc/目录中,我得到以下输出:

$ sphinx-build . html/
Running Sphinx v0.6.4
No builder selected, using default: html
loading pickled environment... done
building [html]: targets for 0 source files that are out of date
updating environment: 0 added, 1 changed, 0 removed
reading sources... [100%] index                 
reST markup error:
HIDDEN/PATH/matplotlib_visualization.py:docstring of simulator.extensions.matplotlib_visualization.beta:20: (SEVERE/4) Unexpected section title.
Run Code Online (Sandbox Code Playgroud)

这个文件有numpy导入,经过一些研究,似乎 sphinx 使用的 RST 标记在记录方式上有问题numpy。当我取出 numpy 导入时,html 构建良好。

解决此问题的最佳方法是什么?

python restructuredtext numpy python-sphinx

4
推荐指数
1
解决办法
7359
查看次数