Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Docstring interpolation does not work correctly for indented insertions #10161

@timhoffm

Description

@timhoffm

Bug report

After switching to the numpydoc format, it's a common situation that one wants to add a docstring interpolation to the a parameter entry, e.g.

@docstring.dedent_interpd
def axhline(self, y=0, xmin=0, xmax=1, **kwargs):
    """
    Add a horizontal line across the axis.

    [...]

    Other Parameters
    ----------------
    **kwargs :
        Valid kwargs are :class:`~matplotlib.lines.Line2D` properties,
        with the exception of 'transform':

        %(Line2D)s
"""

The resulting docstring is:

Other Parameters
----------------
**kwargs :
    Valid kwargs are :class:`~matplotlib.lines.Line2D` properties,
    with the exception of 'transform':

      agg_filter: a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array 
  alpha: float (0.0 transparent through 1.0 opaque) 
  animated: bool 
  [...]

Note that the first line agg_filter is correctly indented. However, the following inserted lines are missing the indent before the %(Line2D)s in the original string.

This is a general problem if the inserted string is multi-line (basically always) and the format string should be indented as in the parameter list.

Any clever ideas to get this working?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Documentationstatus: closed as inactiveIssues closed by the "Stale" Github Action. Please comment on any you think should still be open.status: inactiveMarked by the “Stale” Github Action

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions