简体   繁体   English

如何在结合sphinx docstring的numpy docstring中正确添加嵌套列表

[英]how to correctly add nested list in numpy docstring in combination with sphinx docstring

I'm wondering how I can achieve the following. 我想知道如何实现以下目标。 I'm using the numpy docstring style in combination with sphinx autodoc to generate automated documenation. 我将numpy docstring样式与sphinx autodoc结合使用以生成自动文档。 However, I'm struggeling in having a nested list in the output: 但是,我正在努力在输出中具有嵌套列表:

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

the output of this docstring is complete off. 此文档字符串的输出已完成。 It doesn't recognize the list for attribute 1. 它无法识别属性1的列表。

For another thing the function description spans multiple lines: 另一方面,函数描述跨越多行:

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

Also here sphinx doesn't recognize the complete function and treats the second line independently from the first. 同样在这里,狮身人面像无法识别完整的功能,因此与第一行独立对待第二行。

What is wrong with my formatting? 我的格式有什么问题?

With NumPy docstrings in Napoleon , you need a space on both sides of the colon. 在拿破仑中使用NumPy文档字符串时 ,您需要在冒号的两侧都有一个空格。 Try this: 尝试这个:

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

I don't know if that will work, as the example NumPy strings indicates that only paragraphs are supported. 我不知道这是否行得通,因为示例NumPy字符串表明仅支持段落。 It doesn't mention anything about lists. 它没有提及列表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM