-
-
Notifications
You must be signed in to change notification settings - Fork 18k
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
DOC: Use official numpydoc extension #24098
DOC: Use official numpydoc extension #24098
Conversation
- Replace custom numpydoc in `doc/sphinxext/numpydoc` with official numpydoc release - Remove `numpydoc_use_blockquotes` parameter Signed-off-by: Fabian Haase <haase.fabian@gmail.com>
Signed-off-by: Fabian Haase <haase.fabian@gmail.com>
Hello @FHaase! Thanks for updating the PR.
Comment last updated on December 14, 2018 at 18:25 Hours UTC |
@datapythonista is this what you meant in #23763 with:
|
Some xref issues for context #11257, #6003, numpy/numpydoc#106 (comment). @FHaase can you verify that those docstrings (e.g. Index.str) are rendering correctly? |
Signed-off-by: Fabian Haase <haase.fabian@gmail.com>
Codecov Report
@@ Coverage Diff @@
## master #24098 +/- ##
=======================================
Coverage 42.52% 42.52%
=======================================
Files 161 161
Lines 51697 51697
=======================================
Hits 21982 21982
Misses 29715 29715
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #24098 +/- ##
=======================================
Coverage 92.22% 92.22%
=======================================
Files 162 162
Lines 51828 51828
=======================================
Hits 47798 47798
Misses 4030 4030
Continue to review full report at Codecov.
|
We had an option to use a The option is removed in favor of having this behavior always. So pandas.Index renders unchanged. |
'notes': self._str_section('Notes'), | ||
'references': self._str_references(), | ||
'examples': self._str_examples(), | ||
'attributes': self._str_member_list('Attributes'), |
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.
Previously a condition existed:
'attributes':
self._str_param_list('Attributes', fake_autosummary=True)
if self.attributes_as_param_list
else self._str_member_list('Attributes'),
I assumed that self.attributes_as_param_list
was always set as False
I don't understand this PR. Removing our copy of But what you're doing is have it as a dependency, and create an intermediate module to monkeypatch it? What is the advantage? |
Regarding the blockquotes, the html wraps lists with a |
Signed-off-by: Fabian Haase <haase.fabian@gmail.com>
Moved the patching to |
doc/source/conf.py
Outdated
@@ -420,6 +413,36 @@ | |||
] | |||
|
|||
|
|||
# Modify numpydoc to show Attributes section like Methods section | |||
# PANDAS HACK: Replace attributes param_list by member_list |
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.
This looks much better. But I don't think the comment is clear enough to understand what/why we are doing this. I'd probably move it to the docstring of alternative_str
and expand it (and I'd probably rename alternative_str
to sphinxdocstring_str
).
Signed-off-by: Fabian Haase <haase.fabian@gmail.com>
@datapythonista I've compared the text in
|
I think the reStructuredText standard requires no indentation for first level lists, and 4 for sublists. We had some problems with the rendering in the past, you can take a look at #21520 and referenced issues, I don't remember the details. |
<ul>
<li><p class="first">if the dtype is unsupported (e.g. <code class="docutils literal notranslate"><span class="pre">np.complex</span></code>) then the <code class="docutils literal notranslate"><span class="pre">default_handler</span></code>, if provided, will be called
for each value, otherwise an exception is raised.</p>
</li>
<li><p class="first">if an object is unsupported it will attempt the following:</p>
<blockquote>
<div><ul class="simple">
<li>check if the object has defined a <code class="docutils literal notranslate"><span class="pre">toDict</span></code> method and call it.
A <code class="docutils literal notranslate"><span class="pre">toDict</span></code> method should return a <code class="docutils literal notranslate"><span class="pre">dict</span></code> which will then be JSON serialized.</li>
<li>invoke the <code class="docutils literal notranslate"><span class="pre">default_handler</span></code> if one was provided.</li>
<li>convert the object to a <code class="docutils literal notranslate"><span class="pre">dict</span></code> by traversing its contents. However this will often fail
with an <code class="docutils literal notranslate"><span class="pre">OverflowError</span></code> or give unexpected results.</li>
</ul>
</div></blockquote>
</li>
</ul> vs <ul class="simple">
<li>if the dtype is unsupported (e.g. <code class="docutils literal notranslate"><span class="pre">np.complex</span></code>) then the <code class="docutils literal notranslate"><span class="pre">default_handler</span></code>, if provided, will be called
for each value, otherwise an exception is raised.</li>
<li>if an object is unsupported it will attempt the following:<ul>
<li>check if the object has defined a <code class="docutils literal notranslate"><span class="pre">toDict</span></code> method and call it.
A <code class="docutils literal notranslate"><span class="pre">toDict</span></code> method should return a <code class="docutils literal notranslate"><span class="pre">dict</span></code> which will then be JSON serialized.</li>
<li>invoke the <code class="docutils literal notranslate"><span class="pre">default_handler</span></code> if one was provided.</li>
<li>convert the object to a <code class="docutils literal notranslate"><span class="pre">dict</span></code> by traversing its contents. However this will often fail
with an <code class="docutils literal notranslate"><span class="pre">OverflowError</span></code> or give unexpected results.</li>
</ul>
</li>
</ul> |
From A ReStructuredText Primer at
From Sphinx Documentation
Both use 2 spaces as indent. |
See #21518 (the problem I fixed at that time was that some top level lists were indented). Not sure where I checked the standard, but for what I saw, while sphinx is flexible, the standard is 4 spaces, and other software may fail to render the lists with a different number. |
Signed-off-by: Fabian Haase <haase.fabian@gmail.com>
You mentioned
I don't know from where you took 4 spaces as indentation for sublists, but docutils, sphinx, pandoc, ... pandoc uses 4 spaces for verbatim text:
|
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.
lgtm, thanks @FHaase
Regarding the lists indentation, I guess I was wrong, not sure where I got the information from. But let's better move the discussion to the appropriate issue, so we have it there when someone works in it.
I haven't had a chance to look at this yet. Will try to next week. |
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 @jorisvandenbossche needs to have a look at this. IIRC there were some rationale for using the vendored version.
@@ -21,6 +21,7 @@ dependencies: | |||
- notebook | |||
- numexpr | |||
- numpy=1.13* | |||
- numpydoc |
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 have a min version required?
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.
I don't know exactly. Currently it uses the latest which is 0.8.0.
I am certainly fine with monkeypatching upstream numpydoc, instead of vendoring the full package as we do now. That makes it a bit more explicit which hacks we added / where the changes are compared to upstream. I think in the past we had more hacks than just the attributes listing, but it might be that the others already have been solved in the meantime. |
Reading through #20383, it seems I have updated our vendored version to the upstream one earlier this year, with the attribute listing as the only 'hack' afterwards. And in that way removing the patches we had previously (#11257) There is a note there (#20383 (comment)) about the
@FHaase yes, fine to remove that. I originally did it like that in the hope to push that change upstream (for which there is a PR: numpy/numpydoc#161) |
@jorisvandenbossche over to you; merge when satisfied |
There are two pictures added above. With a before and after comparison. The vendored version was 0.8.0.dev0 (something like that) now it's 0.8.0. I guess they fixed all those issues for the release version. |
Signed-off-by: Fabian Haase <haase.fabian@gmail.com>
Patched numpy/numpydoc#150 into Happened those issues were cut off after all the Warnings regarding the toctree were shown. |
@FHaase you have one linting error: https://dev.azure.com/pandas-dev/pandas/_build/results?buildId=5106 |
Signed-off-by: Fabian Haase <haase.fabian@gmail.com>
lgtm. can you merge master and ping on green. any issues closed by this? |
Ping @jreback |
https://travis-ci.org/pandas-dev/pandas/jobs/468121566 this failed building docs, and didn't fail the jobs: @datapythonista |
I saw that couple of days ago working in some fixes to the doc build. We're using That will be fixed in the changes I'm doing, hopefully I'll be able to open a PR very soon, just need to fix some problems I'm getting with sphinx-autogen. |
ok, but it appears our docs are completely broken now. so let's fix that before merging anything else. |
I thought the failure was in this PR. Let me take a look then. |
locally it fails because of the |
I've got a different error locally, but I think something is wrong in my system (I'm getting pytest segfaults in an unrelated branch). I opened #24287 which with some luck fixed the problem. And in any case should let us know if the doc build fails. |
thanks @FHaase |
* Use official numpydoc package - Replace custom numpydoc in `doc/sphinxext/numpydoc` with official numpydoc release - Remove `numpydoc_use_blockquotes` parameter Signed-off-by: Fabian Haase <haase.fabian@gmail.com> * Add numpydoc package to travis Signed-off-by: Fabian Haase <haase.fabian@gmail.com> * Use member listing for attributes Signed-off-by: Fabian Haase <haase.fabian@gmail.com> * Move modification of SphinxDocString to conf.py Signed-off-by: Fabian Haase <haase.fabian@gmail.com> * Update comments to be more descriptive Signed-off-by: Fabian Haase <haase.fabian@gmail.com> * Fix linting Signed-off-by: Fabian Haase <haase.fabian@gmail.com> * Review of @jorisvandenbossche Signed-off-by: Fabian Haase <haase.fabian@gmail.com> * Fix linting Signed-off-by: Fabian Haase <haase.fabian@gmail.com>
* Use official numpydoc package - Replace custom numpydoc in `doc/sphinxext/numpydoc` with official numpydoc release - Remove `numpydoc_use_blockquotes` parameter Signed-off-by: Fabian Haase <haase.fabian@gmail.com> * Add numpydoc package to travis Signed-off-by: Fabian Haase <haase.fabian@gmail.com> * Use member listing for attributes Signed-off-by: Fabian Haase <haase.fabian@gmail.com> * Move modification of SphinxDocString to conf.py Signed-off-by: Fabian Haase <haase.fabian@gmail.com> * Update comments to be more descriptive Signed-off-by: Fabian Haase <haase.fabian@gmail.com> * Fix linting Signed-off-by: Fabian Haase <haase.fabian@gmail.com> * Review of @jorisvandenbossche Signed-off-by: Fabian Haase <haase.fabian@gmail.com> * Fix linting Signed-off-by: Fabian Haase <haase.fabian@gmail.com>
doc/sphinxext/numpydoc
with officialnumpydoc release
numpydoc_use_blockquotes
parameter