10000 Write all ACCEPTS markers in docstrings as comments. by timhoffm · Pull Request #15074 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Write all ACCEPTS markers in docstrings as comments. #15074

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
Aug 19, 2019

Conversation

timhoffm
Copy link
Member
@timhoffm timhoffm commented Aug 17, 2019

PR Summary

They are not needed anymore because he information can nowadays be read from numpydoc-style docstrings.

This PR does not remove the parser logic nor the tests of the ACCEPTS mechanism (may be done separately).

Need for accepts (current state)

As @anntzer pointed out #15074 (review) the info from ACCEPTS is still needed in some cases.

In particular, we need ACCEPTS if more than one parameter needs to be set for a property. The current implementation for it goes like this:

  • The first argument accepts a tuple as well, which will be expanded to the following paramters. Therefore set_foo((a, b, c)) is equivalent to set_foo(a, b, c) and setp('foo', (a, b, c)) works.
  • To announce this behavior for documentation purposes, we have to define .. ACCEPTS: (a, b, c) in the docstring. This allows setp to provide a proper parameter description and also shows up in property lists.

Docstring cleanup in this PR

This PR moves plain ACCEPTS to comments .. ACCEPTS. Thus, these lines do not show up in the rendered HTML docs. This is preferable as the plain ACCEPTS statements are more confusing than helpful for a regular reader of the docs.

Additionally, some docstrings have been improved.

Possible future improvements

Handling the tuple unpacking and parameter assignment inside the function is quite cumbersome and mixes concerns. I'm considering to move this to a decorator. The decorator could also take the data information so that the docstring can be cleaned from this .. ACCEPTS cruft. But that's for another PR (this one could still go in 3.2.0, the decorator stuff would be for 3.3).

clipping box to the corresponding rectangle and set the clipping path
to ``None``.

For technical reasons (support of ``setp``), a tuple
Copy link
Member Author

Choose a reason for hiding this comment

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

I assume that's the reason. Don't know about the actual history.

Copy link
Member

Choose a reason for hiding this comment

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

Seems true, given the note on set_boxstyle.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would skip the discouragement here, unless you want to put the same in set_xlim and friends...

Copy link
Member Author

Choose a reason for hiding this comment

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

removed.

clipping box to the corresponding rectangle and set the clipping path
to ``None``.

For technical reasons (support of ``setp``), a tuple
Copy link
Member

Choose a reason for hiding this comment

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

Seems true, given the note on set_boxstyle.

Copy link
Contributor
@anntzer anntzer left a comment

Choose a reason for hiding this comment

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

Unless I am mistaken (in which case please dismiss this), this doesn't work: previously one had

In [1]: plt.setp(plt.gca(), 'xlim')                                                             
  xlim: (left: float, right: float)

but now

In [2]: plt.setp(plt.gca(), 'xlim')                                                             
  xlim: float, optional

which is wrong
(this also shows up in the big properties table appended to the Axes docstring).

@timhoffm timhoffm force-pushed the remove-accepts branch 2 times, most recently from 8caca1c to 4df7647 Compare August 18, 2019 14:59
@timhoffm timhoffm changed the title Remove remaining ACCEPTS markers from docstrings Write all ACCEPTS markers in docstrings as comments. Aug 18, 2019
@timhoffm
Copy link
Member Author

@anntzer Thanks, you are right. I've re-targeted the PR; see the first comment above.

@anntzer anntzer dismissed their stale review August 18, 2019 15:39

handled

@anntzer anntzer added this to the v3.2.0 milestone Aug 19, 2019
@anntzer anntzer merged commit 5f40aba into matplotlib:master Aug 19, 2019
@timhoffm timhoffm deleted the remove-accepts branch August 19, 2019 20:07
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