8000 List existing rcParams in rcParams docstring. by anntzer · Pull Request #18440 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

List existing rcParams in rcParams docstring. #18440

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 15, 2020
Merged

Conversation

anntzer
Copy link
Contributor
@anntzer anntzer commented Sep 9, 2020

This is useful for those who mostly live at the command line, letting
one see the list of rcParams with pydoc matplotlib.rcParams (for
example).

Making Substitution always perform docstring dedenting simplifies the
implementation here; I'm not sure you'd ever* want to do an un-dedented
interpolation anyways... (*for certain values of "ever") Fix colorbar
docstrings indentation accordingly.

On the other hand I'm not particularly wedded to the format of the item
list either.

PR Summary

PR Checklist

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (run flake8 on changed files to check).
  • New features are documented, with examples if plot related.
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • Conforms to Matplotlib style conventions (install flake8-docstrings and pydocstyle<4 and run flake8 --docstring-convention=all).
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).

This is useful for those who mostly live at the command line, letting
one see the list of rcParams with `pydoc matplotlib.rcParams` (for
example).

Making `Substitution` always perform docstring dedenting simplifies the
implementation here; I'm not sure you'd ever\* want to do an un-dedented
interpolation anyways... (\*for certain values of "ever")  Fix colorbar
docstrings indentation accordingly.

def dedent_interpd(func):
"""Dedent *func*'s docstring, then interpolate it with ``interpd``."""
func.__doc__ = inspect.getdoc(func)
Copy link
Member

Choose a reason for hiding this comment

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

Changing getdoc to cleandoc doesn't have an effect?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

one is called on the function, the other on the docstring?

Copy link
Member

Choose a reason for hiding this comment

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

getdoc says: "If the documentation string for an object is not provided and the object is a class, a method, a property or a descriptor, retrieve the documentation string from the inheritance hierarchy."

This inheritance doesn't apply to func.__doc__, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah indeed. On the other hand this was accidentally changed in the other direction in https://github.com/matplotlib/matplotlib/pull/13125/files#diff-0b973b83a5020c0418842e20e3ffc56cR115 so I guess I can always argue it's just going back to the old behavior :)

Copy link
Member

Choose a reason for hiding this comment

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

Something broke doc build though, though I'm not sure if it was this change specifically.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops, had a fix but forgot to push it

Copy link
Member

Choose a reason for hiding this comment

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

AFAICT, I could not find any dedent_interpd on things that didn't have their own docstring.

Copy link
Member
@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

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

+0.9. I'm a bit worried (as usual) that some people are using this stuff for their docs, and this would be an API change. OTOH it's only affecting docstrings. The worst that can happen are badly indented plain text docs (could happen on user code) and bad .rst code (not so much of an issue because people could fix this before punishing their release. So nothing really bad can happen without deprecation.

We don't need dedent_interpd anymore. This should get a deprecation. It cannot be deleted directly. If some lib was using that function, removing it would break the import.

@anntzer
Copy link
Contributor Author
anntzer commented Sep 13, 2020

If you prefer I can set up the usual boilerplate to not modify the public API but instead use some private machinery to achieve the same effect (well, I guess the whole docstring module could be made private after deprecation...).

Copy link
Member
@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

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

Nah, I'm planning to make docstrings API private anyway later. Let's get this in as is.

Even though this is correctly labeled "documentation", I'd like a second positive review because this might affect users, wo use our docstring interpolation methods.


def dedent_interpd(func):
"""Dedent *func*'s docstring, then interpolate it with ``interpd``."""
func.__doc__ = inspect.getdoc(func)
Copy link
Member

Choose a reason for hiding this comment

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

AFAICT, I could not find any dedent_interpd on things that didn't have their own docstring.

@QuLogic QuLogic merged commit bd39cd7 into matplotlib:master Sep 15, 2020
@anntzer anntzer deleted the rcdoc branch September 15, 2020 10:35
timhoffm added a commit to timhoffm/matplotlib that referenced this pull request Sep 15, 2020
matplotlib#18440 removed the dedent_intepd function and replaced it with a
`Substitution` instance. API-wise this is transparent, but we cannot
reference `detent_interpd` in Sphinx docs any more. This PR changes
the only reference to a literal.
timhoffm added a commit to timhoffm/matplotlib that referenced this pull request Sep 15, 2020
matplotlib#18440 removed the dedent_intepd function and replaced it with a
`Substitution` instance. API-wise this is transparent, but we cannot
reference `detent_interpd` in Sphinx docs any more. This PR changes
the only reference to a literal.
QuLogic added a commit that referenced this pull request Sep 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0