Skip to content

PR: Port Figure docstrings to numpydoc #9777

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
Nov 15, 2017

Conversation

timhoffm
Copy link
Member

PR Summary

Fixes Figure.add_subplot, Figure.add_axes from #7205 and some other Figure docstrings.

['aitoff' | 'hammer' | 'lambert' | 'mollweide' | \
'polar' | 'rectilinear'], optional
projection : {'aitoff', 'hammer', 'lambert', 'mollweide', \
'polar', 'rectilinear'}, optional
Copy link
Contributor

Choose a reason for hiding this comment

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

Please leave as it was, the new form looks ugly at the terminal / pydoc.

Copy link
Member

Choose a reason for hiding this comment

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

How about projection : string and then specifying the list of allowed strings underneath?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds like a better idea I think.

Copy link
Member Author

Choose a reason for hiding this comment

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

Specifying the list of allowed strings underneath is reasonable for long lists. I'm still not sure how you want it. Does ugly refer to changed style [ -> { or the indentation. Reverted for now.

------
axes : Axes
-------
axes : :class:`~.axes.Axes`
Copy link
Contributor

Choose a reason for hiding this comment

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

Types don't need to be marked up (just as you'd write foo : int). Please leave as it was.

Copy link
Member

Choose a reason for hiding this comment

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

Sometimes sphinx doesn't automatically put in links with out the markup though.

Copy link
Contributor

Choose a reason for hiding this comment

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

Suite, I can always strip out unnecessary markup later...

Copy link
Member Author

Choose a reason for hiding this comment

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

Reverted.

@@ -1440,22 +1443,22 @@ def legend(self, *args, **kwargs):
If shadow is activated and framealpha is ``None`` the
default value is being ignored.

facecolor : None or "inherit" or a color spec
facecolor : None or 'inherit' or a color spec
Copy link
Contributor

@anntzer anntzer Nov 14, 2017

Choose a reason for hiding this comment

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

See #8079 re quote style (in fact I prefer double quotes...).

Copy link
Member Author

Choose a reason for hiding this comment

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

Reverted.

One of the file extensions supported by the active
backend. Most backends support png, pdf, ps, eps and svg.

*transparent*:
transparent : {True, False}
Copy link
Contributor

Choose a reason for hiding this comment

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

bool

Copy link
Member

Choose a reason for hiding this comment

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

To clarify, instead of saying {True, False} it's easier to specify that the type has to be bool

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed. Thanks for the hint.

mode : {"expand", None}
If `mode` is set to ``"expand"`` the legend will be horizontally
mode : {'expand', None}
If `mode` is set to ``'expand'`` the legend will be horizontally
Copy link
Contributor

Choose a reason for hiding this comment

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

Please revert all changes up to here. I think what follows looks good.

Copy link
Member Author

Choose a reason for hiding this comment

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

This one and similar ones reverted up to here. There were however some plain mistakes above, which lead to broken Sphinx rendering. I did not revert these.

@timhoffm
Copy link
Member Author

Sorry, this is somewhat annoying. Writing documentation isn't the most fun part, but I thought I could give a little help here. But its no use if there are no clear rules.

http://matplotlib.org/devdocs/devel/documenting_mpl.html#documenting-matplotlib
https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt referenced in #7205
and your comments contradict each other in parts.

@anntzer
Copy link
Contributor

anntzer commented Nov 14, 2017

#9513 should hopefully clarify some of the rules, and I'm happy to further edit it... but I closed it to wait for another PR to be merged first (because I'd rather resolve conflicts on #9513 rather than the other way round).

@jklymak
Copy link
Member

jklymak commented Nov 14, 2017

Some of this was just "ported" 4 month ago ;-)

#8900

Copy link
Member

@dstansby dstansby left a comment

Choose a reason for hiding this comment

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

Hi @timhoffm thanks for putting together this PR; we're always keen to improve the documentation! Sorry about the confusion in places, our docstring style guides are a bit all over the place at the moment 😢

I've added a couple of suggestions for changes, overall this looks good though. Would it be okay to

  • change {True | False} to bool
  • where there are a list of strings, put them in the argument description

One of the file extensions supported by the active
backend. Most backends support png, pdf, ps, eps and svg.

*transparent*:
transparent : {True, False}
Copy link
Member

Choose a reason for hiding this comment

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

To clarify, instead of saying {True, False} it's easier to specify that the type has to be bool

['aitoff' | 'hammer' | 'lambert' | 'mollweide' | \
'polar' | 'rectilinear'], optional
projection : {'aitoff', 'hammer', 'lambert', 'mollweide', \
'polar', 'rectilinear'}, optional
Copy link
Member

Choose a reason for hiding this comment

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

How about projection : string and then specifying the list of allowed strings underneath?

------
axes : Axes
-------
axes : :class:`~.axes.Axes`
Copy link
Member

Choose a reason for hiding this comment

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

Sometimes sphinx doesn't automatically put in links with out the markup though.

Copy link
Member

@dstansby dstansby left a comment

Choose a reason for hiding this comment

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

Thanks a lot!

@dstansby
Copy link
Member

(Will merge if/when tests all pass)

@NelleV
Copy link
Member

NelleV commented Nov 15, 2017

Thanks a lot for your contribution @timhoffm !

@NelleV NelleV merged commit 5ec960b into matplotlib:v2.1.x Nov 15, 2017
@QuLogic QuLogic added this to the v2.1.1 milestone Nov 15, 2017
@choldgraf
Copy link
Contributor

woo TYVM @timhoffm !

@timhoffm timhoffm deleted the figure-docstrings branch November 28, 2017 20:36
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.

7 participants