Skip to content

List in a parameter docstring not properly displayed in sphinx.ext.napoleon? #4220

@mathhtam

Description

@mathhtam

Subject: Python docstring allowing in list in Parameters / Returns section

Problem

I'm using sphinx autodoc extension together with sphinx.ext.napoleon. I'm following numpydoc style guide since I think it is more readable than google's one. However, I've noticed the following issue which I wasn't able to fix.

If I want to put a list in the Parameter section I get a weird display. The font is too big and the location is not properly placed next to "-". The picture with the code below should highlight and better explain what's the issue. I've asked this question on stackexchange with assigning a bounty to it. However, no one was able to answer the question. That's why I open the issue here.

Procedure to reproduce the problem

This is a sample code I've used to produce the documentation:

class Test:

def f(param_1, param_2):

    r"""
    This is a test docstring.

    Parameters
    ----------
    param_1 : pandas data frame
        This would be really cool to allow the following list and make
        it more readable:

        * **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'
    param_2 : int
        nice number!
    """
    pass

Error logs / results

The output of the above code is the following:

![qjywg](https://user-images.githubusercontent.com/33424776/32447496-950e9edc-c30c-11e7-980c-730f89384c2d.png)


This gives the issue that the font of "This would be..." is too large and not placed next to param_1 as for param_2. Removing the blank line before the index doesn't change the output.

Expected results

If I remove the list I get a correct font size and placing:

ljudg

However I would like to have the list.

Environment info

  • OS: Linux Debian Stretch
  • Python version: 2.7.13
  • Sphinx version: 1.5.2

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions