Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

DOC: make legend docstring interpolated#10799

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

jklymak
Copy link
Member

@jklymakjklymak commentedMar 15, 2018
edited
Loading

PR Summary

The three legend docstrings (legend.py,ax.legend,fig.legend) have the same "Other Parameters" section. These had drifted apart over the years (as had their acceptable kwargs). We unified them#9324,but there was some protest about using the docstring interp method, so I cut and pasted the docstrings, and added a test totest_legend that made sure the strings were identical.

Not surprisingly, this has caused problems. The test routinely fails when someone has edited one of the three docstrings. Good, its catching inconsistencies, but its a bit hard to tell folks to cut and paste the same thing three time.

I (somewhat strongly) think docstring interpolation is the better option here. Faced with the mysteries of%(_legend_kw_doc)s I think its save to assume the naive user will search the code base for this string and see thats where to put their new description of (yet another) kwarg for legend.

Could be convinced that just referencinglegend.__init__ would be OK, but I do like the kwargs to appear in the local docstring.

PR Checklist

  • Code is PEP 8 compliant
  • Documentation is sphinx and numpydoc compliant

@jklymak
Copy link
MemberAuthor

https://7779-1385122-gh.circle-artifacts.com/0/home/circleci/project/doc/build/html/api/legend_api.html

Does "Other Parameters" not behave the same as Parameters? Or is this an indenting issue?

@jklymak
Copy link
MemberAuthor

OTOH, this looks the same as the current docs, so I'll argue is an improvement.

https://matplotlib.org/api/_as_gen/matplotlib.axes.Axes.legend.html#matplotlib.axes.Axes.legend

@jklymakjklymak added this to thev3.0 milestoneMar 15, 2018
@timhoffm
Copy link
Member

Does "Other Parameters" not behave the same as Parameters? Or is this an indenting issue?

It should behave the same. Probably an indenting issue.

@jklymak
Copy link
MemberAuthor

OK, well, I'll try to hack until its fixed...

@jklymak
Copy link
MemberAuthor

@timhoffm when I had this stuff hardcoded in (before this change) it also failed to look the same as Parameters. So, I'm not sure this PR isn't OK as is, though I'd be happy to fix the issue if its easy to fix.

@jklymakjklymakforce-pushed thedoc-interp-legenddocstring branch from9b359ce toda1763cCompareMarch 16, 2018 01:21
@timhoffm
Copy link
Member

@jklymak
Copy link
MemberAuthor

I agree with that. But it had issues before this PR as well. Ie look at the current version of the docs (linked above).

So the problem isn’t the docstring interpolation.

OTOH I’m willing to fix the problem, I just have no idea what it is

@jklymak
Copy link
MemberAuthor

@timhoffm all the "Other Parameter" blocks look like this one: i.e.https://matplotlib.org/api/_as_gen/matplotlib.axes.Axes.text.html#matplotlib.axes.Axes.text

So I think thats just how other-parameters ends up looking.

@timhoffm
Copy link
Member

@jklymak Do you mean that the grey bar extends to the right instead of down? This is probably a bug in numpydoc. See#6924.

jklymak reacted with thumbs up emoji

@jklymak
Copy link
MemberAuthor

@timhoffm Thats indeed what I meant.

This PR doesn't make the formatting worse, and makes the docstring currating substantially easier. The "Other Parameters" bug is a different battle.

The custom dictionary mapping instances or types to a legend
handler. This `handler_map` updates the default handler map
found at :func:`matplotlib.legend.Legend.get_legend_handler_map`.
%(_legend_kw_doc)s
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I see what you and@timhoffm mean now - you mean in theParameter sectionabove this change. Silly me, only checking the part of the doctoring I edited...

I cannot see why either. Very strange as theAxes.legend andFigure.legend docstrings are fine, and I don't see how they are any different than this doctoring...

@@ -348,7 +348,6 @@ def __init__(self, parent, handles, labels,
handler_map=None,
):
"""

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

This extra space was causing the hiccup in the formatting. Sphinx is pretty fragile....

@jklymak
Copy link
MemberAuthor

@timhoffmtimhoffm merged commit4257416 intomatplotlib:masterMar 18, 2018
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@tacaswelltacaswelltacaswell left review comments

@anntzeranntzeranntzer approved these changes

@timhoffmtimhoffmtimhoffm approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
v3.0.0
Development

Successfully merging this pull request may close these issues.

4 participants
@jklymak@timhoffm@tacaswell@anntzer

[8]ページ先頭

©2009-2025 Movatter.jp