Skip to content

Having section "Notes" twice does not raise a warning, but only renders once #64

Closed

Description

@NelleV

A lot of matplotlib's plotting function have a notes section concatenated to them at runtime. That leads to docstrings such as the following:

(from plt.imshow)

blah blah blah

See also
--------
matshow : Plot a matrix or an array as an image.

Notes
-----
Unless *extent* is used, pixel centers will be located at integer
coordinates. In other words: the origin will coincide with the center
of pixel (0, 0).

Examples
--------

.. plot:: mpl_examples/pylab_examples/image_demo.py

Notes
-----

In addition to the above described arguments, this function can take a
**data** keyword argument. If such a **data** argument is given, the
following arguments are replaced by **data[<arg>]**:

* All positional and all keyword arguments.

Additional kwargs: hold = [True|False] overrides default hold state
"""

The rendered docstring is here: http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.imshow
You can notice that the second "Notes" replaced the first one.
And it does this without raising a warning.

Activity

  1. tacaswell commented on Sep 13, 2016

    @tacaswell
    Contributor

    Would the correct behavior here to concatenate the notes sections?

  2. NelleV commented on Sep 13, 2016

    @NelleV
    ContributorAuthor

    I think it should (at least) raise a warning. If I recall correctly, numpydoc requires the sections to be in a specific order, and I think raises a warning when they aren't. But apparently, it doesn't when the section appears twice.
    It be great if someone from numpydoc could confirm what the expected behavior is.

  3. rgommers commented on Sep 13, 2016

    @rgommers
    Member

    If it's not too hard, I'd be in favor of an exception for that. Because warnings are very hard to spot in the large amount of noise Sphinx tends to generate.

  4. efiring commented on Sep 13, 2016

    @efiring

    It looks to me like numpydoc can read the sections in arbitrary order; it just looks for sections, identifies what kind they are, and puts each identified section as the value in a dictionary. It might be as easy to append repeats as to raise an exception when a repeat is encountered.

  5. NelleV commented on Sep 13, 2016

    @NelleV
    ContributorAuthor

    @rgommers That's very straightforward. I'll create a PR.
    I do think that sphinx catches errors and transforms them in warnings, so that's out of our hands.

  6. NelleV commented on Sep 13, 2016

    @NelleV
    ContributorAuthor

    @efiring that would be an option (also very easy to do), but I don't think it is a good idea. The docstrings should be as readable in a python terminal as rendered by sphinx, and having several notes section makes it hard to read IMO.

  7. added 2 commits that reference this issue on Sep 13, 2016
    2855219
    2140561
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions