Skip to content

DOC: Use napoleon sphinx extension #5743

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

Closed
wants to merge 6 commits into from

Conversation

QuLogic
Copy link
Member

@QuLogic QuLogic commented Dec 24, 2015

This is now building without warning, but there are a few differences. For some reason, some images are not consistent between this and v2.x; I think some of the documentation scripts are missing sorting (I'm using Python 3).

The biggest difference seems to be with parameter listings. The existing result seems to be a bunch of paragraphs and blockquotes, but the new result is a bunch of bullet lists. I think this may actually be more correct, but it does change the look somewhat.

Fixes #5731.

@QuLogic QuLogic added this to the next major release (2.0) milestone Dec 24, 2015
@QuLogic
Copy link
Member Author

QuLogic commented Dec 24, 2015

Also, I'm wondering what's the point of some of the "Call signature" lines in axes/_axes.py because they seem to be redundant?

@tacaswell
Copy link
Member

The Call signature lines probably pre-date sphinx.

@efiring
Copy link
Member

efiring commented Dec 25, 2015

It looks like most of those Call signature blocks can be deleted, but there are exceptions such as barbs, quiver, contour, and clabel where there are multiple signatures hidden within *args that Sphinx cannot handle automatically.

@QuLogic
Copy link
Member Author

QuLogic commented Dec 25, 2015

I spent a little time looking into the different images, and it seems like, e.g., the tight layout demo, just picks font sizes at random. It makes the doc build a bit unreproducible; can we stop doing that?

@mdboom
Copy link
Member

mdboom commented Dec 29, 2015

I spent a little time looking into the different images, and it seems like, e.g., the tight layout demo, just picks font sizes at random. It makes the doc build a bit unreproducible; can we stop doing that?

Yes! In this case, I don't see any reason why it's random, let's just hardcode the values in the example. In other cases where the example really does want to use random data, we should at least seed the random number generator so the results are predictable.

This was referenced Dec 30, 2015
@tacaswell
Copy link
Member

This needs a rebase.

@QuLogic
Copy link
Member Author

QuLogic commented Jan 4, 2016

Yes, waiting for #5769 as well.

if sphinx older than 1.3, sphinxcontrib-napoleon, then type "python make.py
html" in this directory. Wait for the initial run (which builds the example
gallery) to be done, then run "python make.py html" again. The top file of the
results will be ./build/html/index.html
Copy link
Member

Choose a reason for hiding this comment

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

Do we really still need to run it twice? I think this is left over from some old setup which should be removed. Travis only runs python make once and that seems to work fine.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yea, I wondered about that, but I don't know for sure why it's there.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah -- I had forgotten that was there. I vaguely recall that was once true (back in ancient times when we didn't even use Sphinx extensions), but I haven't had to do that in years. Let's take it out while we're in here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Alright, I removed it.

@QuLogic QuLogic force-pushed the sphinx-napoleon branch 2 times, most recently from 58f367e to be45da2 Compare January 5, 2016 08:01
@QuLogic QuLogic force-pushed the sphinx-napoleon branch 2 times, most recently from 74d4cb5 to 94a7cd6 Compare January 6, 2016 03:39
@QuLogic
Copy link
Member Author

QuLogic commented Jan 6, 2016

I was going to add in fixes to several docstrings with incorrect headings and such, but that might balloon this PR to something rather big. The changes here are enough to get the build to pass without error, so maybe that should be left to some later PR?

@tacaswell
Copy link
Member

Better to not let the prefect be the enemy of the good.

@QuLogic QuLogic changed the title [WIP] DOC: Use napoleon sphinx extension DOC: Use napoleon sphinx extension Jan 6, 2016
@QuLogic QuLogic force-pushed the sphinx-napoleon branch 2 times, most recently from 85a764b to a016430 Compare January 6, 2016 08:36
@QuLogic
Copy link
Member Author

QuLogic commented Jan 6, 2016

Let's call this done for now then, and I'll work on the other stuff in another PR as time permits.

@mdboom
Copy link
Member

mdboom commented Jan 7, 2016

Should we hold off on this until investigating the bugs @QuLogic alluded to on gitter?

@tacaswell tacaswell modified the milestones: 2.1 (next point release), 2.0 (style change major release) Feb 8, 2016
@QuLogic
Copy link
Member Author

QuLogic commented Mar 30, 2016

Once we merge the PRs from @jenshnielsen, this should work without warning on Sphinx 1.4. The napoleon_use_param=False setting also makes the bugs go away with 1.3, but there are still some warnings.

I don't know whether or not you still wish to put this on 2.0, but it shouldn't break anything at this point.

@tacaswell tacaswell changed the base branch from v2.x to v2.0.x January 20, 2017 16:04
@tacaswell tacaswell reopened this Jan 20, 2017
@QuLogic QuLogic changed the base branch from v2.0.x to master January 20, 2017 22:08
@tacaswell tacaswell modified the milestones: 2.1 (next point release), 2.1.1 (next bug fix release) Sep 24, 2017
@tacaswell tacaswell modified the milestones: 2.1.1 (next bug fix release), 2.2 (next feature release) Oct 9, 2017
@jklymak
Copy link
Member

jklymak commented Jan 19, 2018

Is this something that will ever happen? Folks have been putting a lot of documentation effort in recently. If the standard is supposed to be slightly different it'd be good to know sooner rather than later. If this won't happen, this can be closed?

@efiring
Copy link
Member

efiring commented Jan 20, 2018

There are two parts to this: docstring cleanups and the switch to Napoleon. I suspect most of the docstring cleanups have been done by now in other PRs, but I haven't checked. As for the switch to Napoleon, the advantage is that it removes a dependency; the disadvantage is that Napoleon might not perfectly track numpydoc.
@QuLogic, what are your thoughts on this now?

@timhoffm
Copy link
Member

timhoffm commented Apr 17, 2018

Indeed, most docstring cleanups from here are already merged. #11064 handles the remaining docstring changes, so that this PR can be significantly simplified and focus only on a possible switch to napoleon (or be closed, if there are no longer plans for switching to napoleon).

@jklymak
Copy link
Member

jklymak commented May 24, 2018

Closing as it doesn't seem there is any appetite to switch to napoleon. OTOH, if someone wants to take the "switch" part of the PR on, that'd be fine w/ me....

@anntzer
Copy link
Contributor

anntzer commented Jun 15, 2018

Reopening per #11397 (comment).

@anntzer anntzer reopened this Jun 15, 2018
@timhoffm
Copy link
Member

If we want to switch to napoleon, we'd need a careful look at the changes that may introduce in the generated files. While technically implementing the same specification, napoleon and numpydoc interpret it differently, sometimes stricter, sometimes more strict. We're probably knowingly and unknowingly adapting our docstrings to the numpydoc interpretation by just using it and checking what works and what doesn't. This "learned" formatting has to be reevaluated when swiching to napoleon.

@anntzer
Copy link
Contributor

anntzer commented Oct 23, 2018

fwiw, it looks like sklearn (including one of numpydoc's maintainers...) is considering switching to napoleon (scikit-learn/scikit-learn#11440).

@matthew-brett
Copy link
Contributor

But - reading that thread - they are pretty ambiguous about it. The main argument for Napoleon seems to be 'it comes with sphinx' - but that's not a very powerful argument on its own, given that numpydoc is so easy to install.

@anntzer
Copy link
Contributor

anntzer commented Oct 23, 2018

That's why I said "considering", not "decided".
However I agree with Gael's points:

Is there a long-term reason that Napoleon would get less maintenance than
numpydocs if projects switch to it? It's embedded in sphinx, so it will
get a lot of exposure. Of course, it's a question of community dynamics,
and there is a lot of social in there.

That it's included in sphinx. I tend to hope that it is more likely to
become a community standard. Everybody who does sphinx docs has napoleon.

@matthew-brett
Copy link
Contributor

Sure, but I don't know if it's really true the Napoleon really gets better maintenance. Among the big scientific Python projects, Numpy, Scipy, Pandas, Scikit-image, Scikit-learn, Sympy and Astropy all use Numpydoc, with Statsmodels being the only one I know of that uses Napoleon. Pauli Virtanen leads Scipy, and maintains Numpydoc, so I think it's reasonable to hope it will stay fit for purpose for a while. How about waiting with a plan to review in a year's time?

@timhoffm
Copy link
Member

There are some subtle differences in the parsers concerning name and type detection and formatting.

e.g. numpy/numpydoc#72 (comment)

We now tune the docs to be numpydoc compliant. So we really would have to test how napoleon behaves. Nevertheless, I have the feeling that napoleon has a more sane parser.

@dstansby
Copy link
Member

I supsect even if we want to switch to napoleon, this PR is so out of date that attempting to rebase it will be more hassle than it's worth; if no-one objects in a week or so I'll close this but leave the issue open.

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.

Move from numpydoc to sphinxcontrib-napoleon