Skip to content

Parsing See Also became too picky #206

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
rgommers opened this issue Apr 14, 2019 · 13 comments
Closed

Parsing See Also became too picky #206

rgommers opened this issue Apr 14, 2019 · 13 comments
Milestone

Comments

@rgommers
Copy link
Member

NumPy has a whole bunch of these in numpy/core/_add_newdocs.py, and with current master that crashes the doc build (0.8.0 works fine).

See Also
--------
The corresponding attribute of the derived class of interest. 
@rgommers
Copy link
Member Author

This must be gh-172. It explicitly enumerates the valid See Also entries, but it overlooked this case. Arguably the entry of just a sentence is wrong, but there's nothing to cross-link instead. So the alternative is just to remove all those See Also sections. I'll do some more testing, if that's the only problem in numpy and scipy, then I guess I'll just clean up the numpy issue.

@rgommers rgommers added this to the v0.9.0 milestone Apr 14, 2019
rgommers added a commit to rgommers/numpy that referenced this issue Apr 14, 2019
It used a sentence rather than an object to cross-reference.
numpydoc grew more picky (see
numpy/numpydoc#206), so cleaning this up.
It was already not rendering correctly in html.
@jnothman
Copy link
Member

I think we can try to be backwards compatible here. If there's no colon, that's hopefully a good heuristic.

@rgommers
Copy link
Member Author

I think disallowing this is fine, the generated html was wrong before anyway: https://www.numpy.org/devdocs/reference/generated/numpy.generic.diagonal.html#numpy.generic.diagonal

The more annoying bit was that commas at the end of a list of function names now generates warnings. Here is what I needed to fix in numpy: numpy/numpy#13331.

Arguably the comma at the end of the first line here is okay:

func1, func2, func3, func4,
func5

@jnothman
Copy link
Member

jnothman commented Apr 14, 2019 via email

@pvanmulbregt
Copy link
Contributor

I added the warning for the trailing comma in response to a reviewer's comments, but if the example above in #206 (comment) is acceptable, then the warning should be removed. Perhaps before adding more tests cases, the spec could be nailed down? As noted in #172 (comment) backticks require a role, and any function name with ~ requires backticks.

@jorisvandenbossche
Copy link
Contributor

I also had this issue (the original reported, not the comma's) when testing the pandas docs with numpydoc master. I first wanted to open an issue here, but it turned out to be all templating mistakes in the pandas docs, so I am also OK with keep disallowing this and not trying to be backwards compatible (in the end, it catched errors in our docs)

@mattip
Copy link
Member

mattip commented Apr 15, 2019

A docstring containing the text "See also the corresponding attribute" is failing. Could the error message at least indicate which object's docstring is being parsed? The error message below is not very helpful

``` File ".../numpy/doc/sphinxext/numpydoc/docscrape.py", line 330, in _parse_see_also raise ParseError("%s is not a item name" % line) numpydoc.docscrape.ParseError: The corresponding attribute ... .\n\nSee Also\n--------\nThe corresponding attribute ...'

Exception occurred:
File "/home/matti/pypy_stuff/numpy/doc/sphinxext/numpydoc/docscrape.py", line 330, in _parse_see_also
raise ParseError("%s is not a item name" % line)

@rgommers
Copy link
Member Author

@mattip I already commented on numpy/numpy#13331 (comment). See the \n after See Also in your traceback, you are just reporting the same thing I am in this issue.

Could the error message at least indicate which object's docstring is being parsed? The error message below is not very helpful

Yes this would be very useful. It's often really hard to do though, I think it's Sphinx' single worst issue - the whole debugging experience is awful.

@jnothman
Copy link
Member

jnothman commented Apr 15, 2019

I added the warning for the trailing comma in response to a reviewer's comments

That was me :) Comma before colon seems a problem. Finishing the line with a comma is okay without colon (and ideally if the next line is not indented etc.).

@rgommers
Copy link
Member Author

I first wanted to open an issue here, but it turned out to be all templating mistakes in the pandas docs, so I am also OK with keep disallowing this and not trying to be backwards compatible (in the end, it catched errors in our docs)

yes same here, +1 for being strict

I added the warning for the trailing comma in response to a reviewer's comments, but if the example above in #206 (comment) is acceptable, then the warning should be removed. Perhaps before adding more tests cases, the spec could be nailed down?

yes, we can more completely enumerate the allowed cases and add them to https://numpydoc.readthedocs.io/en/latest/format.html#sections

@rgommers
Copy link
Member Author

After going through all of numpy and some of scipy, I didn't find any other types of cases. So for the spec I would propose:

  1. All 4 cases in the description of What is the spec for "See Also" in docstrings? #170
  2. The case with trailing comma: func1, func2, func3, func4,. (we should probably also allow trailing dot.

Anyone else have other cases?

@larsoner
Copy link
Collaborator

Not that I've seen, I also just hit the trailing comma case.

@rgommers
Copy link
Member Author

This was fixed by gh-207, closing

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

No branches or pull requests

6 participants