Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

DOC: document how to created interpolated stubs #28746

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
Loading
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 29 additions & 7 deletions 36 doc/devel/document.rst
Original file line number Diff line number Diff line change
Expand Up @@ -730,13 +730,6 @@ hiding it from the rendered docs.
Keyword arguments
-----------------

.. note::

The information in this section is being actively discussed by the
development team, so use the docstring interpolation only if necessary.
This section has been left in place for now because this interpolation
is part of the existing documentation.

Since Matplotlib uses a lot of pass-through ``kwargs``, e.g., in every function
that creates a line (`~.pyplot.plot`, `~.pyplot.semilogx`, `~.pyplot.semilogy`,
etc.), it can be difficult for the new user to know which ``kwargs`` are
Expand Down Expand Up @@ -797,6 +790,35 @@ point, `.kwdoc` can list the properties and interpolate them into
``__init__.__doc__``.


Create interpolated stubs
^^^^^^^^^^^^^^^^^^^^^^^^^

If you are contributing code that will require keyword argument forwarding or creating
an object that may be returned in many places, such as the `.Line2D` artist, then you
may want to create docstrings that can be interpolated. To add documentation to the
``interpd`` lookup, add an identifier and the associated docstring:

.. code-block:: python

from matplotlib import _docstring

_docstring.interpd.update(new_artist_doc="creates smiley faces")

This now allows the string to be used in any docstring. For example:

.. code-block:: python

def plot(self, *args, **kwargs):
"""
**kwargs : new artist properties, optional
%(new_artist_doc)s
"""


The list of interpolated stubs is stored in the ``_docstring.interpd.params``
dictionary.


Inherit docstrings
------------------

Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.