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

1.9k Views Asked by At

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. 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.

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?

1

There are 1 best solutions below

2
On BEST ANSWER

With NumPy docstrings in Napoleon, you need a space on both sides of the colon. 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. It doesn't mention anything about lists.