【问题标题】:how to correctly add nested list in numpy docstring in combination with sphinx docstring如何结合 sphinx docstring 在 numpy docstring 中正确添加嵌套列表
【发布时间】:2017-09-19 15:28:55
【问题描述】:

我想知道如何实现以下目标。我将 numpy docstring 样式与 sphinx autodoc 结合使用来生成自动文档。但是,我很难在输出中有一个嵌套列表:

Attributes
----------
attribute 1: pandas data frame
    * `index:` Array-like, integer valued representing
          days. Has to be sorted and increasing.
    * `dtype:` float64. Value of temperature.
    * `columns:` location description, e.g. 'San Diego'
attribute 2: `int`
    nice and sunny days in California

此文档字符串的输出已完成。它无法识别属性 1 的列表。

另一方面,功能描述跨越多行:

def generate_temp(self, n, freq, very_long_variable_name,
                  type_temp=None, method=None):

这里的 sphinx 也不能识别完整的函数,并独立于第一行处理第二行。

我的格式有什么问题?

【问题讨论】:

标签: python python-sphinx autodoc sphinx-napoleon


【解决方案1】:

使用NumPy docstrings in Napoleon,您需要在冒号两侧留一个空格。试试这个:

Attributes
----------
attribute 1 : pandas data frame
    * `index:` Array-like, integer valued representing
      days. Has to be sorted and increasing.
    * `dtype:` float64. Value of temperature.
    * `columns:` location description, e.g. 'San Diego'
attribute 2 : `int`
    nice and sunny days in California

我不知道这是否可行,因为example NumPy strings 表示仅支持段落。它没有提到任何关于列表的内容。

【讨论】:

  • 感谢您的回答。不幸的是,这并不能解决问题。我真的想知道在这种情况下是否可以包含一个列表
  • 你是否至少在冒号两边留了一个空格?我还查看了source code,似乎支持项目符号列表。我认为第一项的第二行的缩进存在问题,我刚刚通过编辑修复了该问题。
猜你喜欢
  • 2022-09-27
  • 2021-12-26
  • 1970-01-01
  • 2018-05-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-24
相关资源
最近更新 更多