FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[Doc]: Improve API documentation of attributes · Issue #22897 · matplotlib/matplotlib · GitHub

Repository navigation

[Doc]: Improve API documentation of attributes #22897

Open

Description

Documentation Link

No response

Problem

We currently have to resort to literals, instead of links

  • ax.transAxes / transAxes
  • ax.dataLim
  • ax.fmt_xdata / ax.fmt_ydata / ax.fmt_zdata
  • Axes.lines
  • axes.bbox
  • figure.bbox
  • cbar_axes

Suggested improvement

We should have API documentation for this, and it should be referencable in sphinx.

What needs to be done:
Figure out how this could be done. Note that some attributes are documented, but cannot be referenced (e.g. dataLim https://matplotlib.org/devdocs/api/axes_api.html#the-axes-class), while others don't have a documentation at all.

Activity

  1. mwaskom commented on Apr 26, 2022

    I think one (the?) way to get "documented attributes" is to make them properties, then sphinx autodoc will pick up the docstring. I am not sure whether cross-references work there, but I'm not sure why they wouldn't.

  2. timhoffm commented on Apr 27, 2022

    MemberAuthor

    Properties would work. However, I'm reluctant to add complexity and overhead to the code only to get documentation.

    One can add attribute documentation to the class docstring in numpydoc. And we sometimes already do that. The problem is that one cannot link to these. While that should in principle possible in sphinx, it does not work for us. Maybe the Attribute section of numpydoc does not get translated to a .. py:attribute:: directive. There's probably something broken either in numpydoc or in sphinx under the hood.

    This is something to be investigated and likely needs to be adressed upstream.

    Independent of this, we should start to consistently document public attributes as well.

  3. timhoffm commented on Sep 26, 2024

    MemberAuthor

    As a matter of fact, the entires of the Attributes section do not contain link targets. (This could be discussed upstream, but I suspect, we'd need to contribute for a change here since classes are not that heavily used/documented in numpy)

    An alternative approach, which may be reasonable for larger classes is attempted in #28825:

    • We can create explicit entries for the attributes in autosummary sections.
    • The docstring content may be retrieved from docstrings attached to type annotations of the attributes.
      T.b.c: Does this also work with doc comments? (self.attr = 1 #: A doc comment for attr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL