-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
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
Conversation
Also, I'm wondering what's the point of some of the "Call signature" lines in |
The |
It looks like most of those |
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 needs a rebase. |
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, I removed it.
58f367e
to
be45da2
Compare
74d4cb5
to
94a7cd6
Compare
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? |
Better to not let the prefect be the enemy of the good. |
85a764b
to
a016430
Compare
Let's call this done for now then, and I'll work on the other stuff in another PR as time permits. |
Should we hold off on this until investigating the bugs @QuLogic alluded to on gitter? |
Once we merge the PRs from @jenshnielsen, this should work without warning on Sphinx 1.4. The 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. |
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? |
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. |
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). |
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.... |
Reopening per #11397 (comment). |
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. |
fwiw, it looks like sklearn (including one of numpydoc's maintainers...) is considering switching to napoleon (scikit-learn/scikit-learn#11440). |
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. |
That's why I said "considering", not "decided".
|
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? |
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. |
I supsect even if we want to switch to |
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.