Skip to content
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

Pin numpydoc to avoid doubly-escaped * #3530

Merged
merged 1 commit into from
Mar 14, 2020
Merged

Conversation

gforsyth
Copy link
Contributor

Similar to dask/dask#5961, recent changes to numpydoc lead to function
signatures displayed using autosummary to have doubly-escaped *s.

This commit swaps out numpydoc in favor of napoleon -- there are a
couple of benefits:

  • no more double-escaped function signatures
  • one less dependency for docs (napoleon is shipped with sphinx)

I've added a make target to automatically generate API docs using
sphinx-apidoc but this isn't required for autosummary compatibility.
It can always be added as a requirement of the html target at a later
time.

@gforsyth
Copy link
Contributor Author

@jrbourbeau this may be a better solution than the one I pushed up to dask/dask, but we can also pin numpydoc here, too, if that's preferred.

Copy link
Member

@jrbourbeau jrbourbeau left a comment

Choose a reason for hiding this comment

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

Thanks @gforsyth! I'm new to napoleon. It looks like the styling of API docs is slight different (not an issue IMO). For example, with numpydoc:

Screen Shot 2020-03-02 at 8 43 50 AM

with napoleon:

Screen Shot 2020-03-02 at 8 43 40 AM

It also looks like there may be support for using type annotations in generated API docs, which would be great. Do you know of other difference between numpydoc and napoleon?

Also cc @jsignell who has been working on our docs recently and @jcrist who (may?) have starting using napoleon in other projects

@gforsyth
Copy link
Contributor Author

gforsyth commented Mar 2, 2020

Do you know of other difference between numpydoc and napoleon?

Just that they're roughly equivalent. numpydoc supports adding ::plot directives which I think is then also used by extensions that autogenerate example galleries, but I don't think that's used in the dask docs anywhere.

I also don't have a preference on styling, although it should probably match across all dask projects -- if folks are ok with the general styling change I can swap this out in the other repos, too.

@jcrist
Copy link
Member

jcrist commented Mar 2, 2020

I've used both in the past. In general both seem to work fine, but they style things differently. Agree with Gil that it'd be good to standardize this across projects, no strong preferences either way.

@jsignell
Copy link
Member

jsignell commented Mar 2, 2020

This change seems reasonable to me. No strong feelings on the style change.

@jrbourbeau
Copy link
Member

Sorry for the delayed reply here. I think I'd rather stick with numpydoc for the time being. Not all of our docstrings follow the official numpydoc style for their Returns sections and so both numpydoc and napoleon outputs aren't properly formatted. However, napoleon makes things bulleted which looks a little more off to me than the numpydoc styling. For example:

Napoleon:

Screen Shot 2020-03-13 at 5 04 47 PM

Numpydoc:

Screen Shot 2020-03-13 at 5 05 01 PM

We could also reformat our docstrings, which could be done in a future PR

@gforsyth
Copy link
Contributor Author

Good with me, I don't have strong opinions on this either way. I'll change this PR to pin numpydoc instead -- also followed up in numpy/numpydoc#221 which should fix the issue in numpydoc with the double-escapes.

@gforsyth gforsyth changed the title Replace numpydoc with napoleon Pin numpydoc to avoid doubly-escaped * Mar 14, 2020
@gforsyth
Copy link
Contributor Author

Hey @jrbourbeau -- updated this to pin numpydoc instead and fixed a few small nits.

Small changes to avoid a sphinx timeout looking for an intersphinx inventory, and a fixed a misformatted code-block

Similar to dask/dask#5961, recent changes to `numpydoc` lead to function
signatures displayed using `autosummary` to have doubly-escaped `*`s.

This pins `numpydoc` to version 0.8.0 to avoid the regression until a
patch is merged upstream.

Also small changes to avoid a sphinx timeout looking for an intersphinx
inventory, and a fixed a misformatted code-block
Copy link
Member

@jrbourbeau jrbourbeau left a comment

Choose a reason for hiding this comment

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

Thanks @gforsyth!

@@ -382,7 +383,7 @@
# and the Numpy documentation.
intersphinx_mapping = {
"python": ("https://docs.python.org/3", None),
"numpy": ("http://docs.scipy.org/doc/numpy", None),
"numpy": ("https://docs.scipy.org/doc/numpy", None),
Copy link
Member

Choose a reason for hiding this comment

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

Nice 😎

@jrbourbeau jrbourbeau merged commit 806a7e9 into dask:master Mar 14, 2020
@gforsyth gforsyth deleted the docs_escape branch March 15, 2020 14:56
@jsignell
Copy link
Member

Good catch @jrbourbeau! Do we need a follow on issue to coerce all the docstrings to numpydoc style?

@jrbourbeau
Copy link
Member

I opened up #3578 for updating the docstring style

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants