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

Document inheriting docstrings #12278

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

Merged
Merged
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
23 changes: 23 additions & 0 deletions 23 doc/devel/documenting_mpl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,29 @@ definition. There are some some manual hacks in this case, violating the
"single entry point" requirement above -- see the ``docstring.interpd.update``
calls in `matplotlib.patches`.


Inheriting docstrings
---------------------

If a subclass overrides a method but does not change the semantics, we can
reuse the parent docstring for the method of the child class. Python does this
automatically, if the subclass method does not have a docstring.

Use a plain comment `# docstring inherited` to denote the intention to reuse
the parent docstring. That way we do not accidentially create a docstring in
the future::

class A:
def foo():
"""The parent docstring."""
pass

class B(A):
def foo():
# docstring inherited
pass


.. _docstring-adding-figures:

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