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

Deduplicate inherited docstrings. #12255

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 1 commit into from
Sep 25, 2018

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Sep 24, 2018

Since Py3.5, inspect.getdoc inherits method docstrings from
super-methods (pydoc, sphinx, and IPython's ? do the same).

Take advantage of this to deduplicate some docstrings that were already
defined for the Artist base methods. Note that Text.set_clip_path's
docstring had actually not been updated when we updated the docstring of
Artist.set_clip_path...

We could add a decorator to check that the docstring is actually
getting inherited but that seems totally overkill.

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

----------
clipbox : `matplotlib.transforms.Bbox`
"""
def set_clip_box(self, clipbox): # inherited docstring.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's good to have a comment for the inherited docstring. This documents the intention not to have a docstring there and prevents future accidential additions. Can we move the comment
to the place where the docstring should usually be:

def set_clip_box(self, clipbox):
    # docstring inherited

That way it's easy to see and we don't run into linewidth limitations with longer signatures.

Also, for some reason, I'd prefer # docstring inherited over # inherited docstring if you don't mind. (Can't really explain, but it feels more appropriate.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@timhoffm
Copy link
Member

Btw. thanks for bringing this up. Handling inherited docstrings was on my todo list 😄

@anntzer anntzer force-pushed the inherit-docstrings branch 2 times, most recently from 62b7059 to 7b5924b Compare September 25, 2018 11:32
Since Py3.5, inspect.getdoc inherits method docstrings from
super-methods (pydoc, sphinx, and IPython's ? do the same).

Take advantage of this to deduplicate some docstrings that were already
defined for the Artist base methods.  Note that Text.set_clip_path's
docstring had actually not been updated when we updated the docstring of
Artist.set_clip_path...

We could add a decorator to check that the docstring is *actually*
getting inherited but that seems totally overkill.
@dopplershift dopplershift merged commit 33ccf9b into matplotlib:master Sep 25, 2018
@anntzer anntzer deleted the inherit-docstrings branch September 25, 2018 16:14
@QuLogic QuLogic added this to the v3.1 milestone Sep 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.