-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Doc warnings #14699
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 warnings #14699
Conversation
@@ -128,7 +128,7 @@ What can be converted to a data-type object is described below: | |||
|
|||
Used as-is. | |||
|
|||
:const:`None` | |||
`None` |
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 think you want double backticks or no backticks for all of these. Not sure if this turns it into a link, but that's weird anyway.
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.
Here is the source as to why :const:
is wrong - it should be :data:
. In any case, sphinx makes this a link with no directive needed
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.
To be clear, what I'm saying is: the normal thing to do is to not make None
a link at all.
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.
git grep "\`None\`"
turns up many more cases of this. Should the default be not to link?
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'd say so. I remember a discussion about this when we first drew up the docstring standard.
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.
done
linspace : Evenly spaced numbers with careful handling of endpoints. | ||
ogrid: Arrays of evenly spaced numbers in N-dimensions. | ||
mgrid: Grid-shaped arrays of evenly spaced numbers in N-dimensions. | ||
numpy.linspace : Evenly spaced numbers with careful handling of endpoints. |
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 is weird. I think this fix, and the many like it, are indicating a bug crept into numpydoc
or add_newdoc
. This used to work, and while these changes fix warnings I'd prefer to solve the real issue instead.
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.
Perhaps it has to do with the place
argument to add_newdoc
. For example for this function, it uses add_newdoc('numpy.core.multiarray', 'arange', ...)
. Would the issue be fixed if using add_newdoc('numpy', 'arange', ...)
instead?
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 would call this a feature, not a bug. Explicit beats implicit, especially with documentation. For the on-line documentation the extra 6 letters don't matter, they are turned into a link. For the off-line documentation, a bare linspace
can be confusing, especially when just getting started.
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 works in many places in the same file without the prefix. Example: https://numpy.org/devdocs/reference/generated/numpy.array.html#numpy.array
If there's a good reason it needs to be this way I have no problem with adding six characters, but I want to understand why something that used to work reliably (I think) now sometimes fails.
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.
Something is off. The rendered documentation for this fix is creating the links even without it. Maybe I overdid it with adding numpy.
where not needed.
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 rebased without this commit, will look at it again later
For methods I think this sounds right. For functions however it doesn't, something like |
The last commit gets us down to 859 warnings, which means they all are displayed (less than the 1000 limit). This was my original goal; in PR gh-14608 there were bad references I missed since the warnings were not shown. |
My understanding is that the short versions only works when it's defined in the same place, or at least available in the namespace of the given file. |
Okay this is a major improvement in the doc build status, so let's get it in and worry about the prefix thing later. Merged, thanks @mattip |
Solve some of the WARNINGS when building documentation with
SPHINXOPTS=-n make html
. xref gh-13114. Here is how I found and fixed these:The last line sorts and prints out the frequency of the WARNINGS. It seems sphinx is limited to about 1000 WARNINGS. We had over that limit, after this PR it is down to about 600.
In order to detect what the reference should be, I use this to search the inverse index of references, i.e for
ndarray.all
:which prints
The first line is the important one:
numpy.ndarray.all
is apy:method
reference, so usingndarray.all
is not sufficient, either use the full name or add a.. currentmodule:: numpy
directive. I chose to add the explicit namespace to many of the "See Also" references since I think it looks better when using console-basedhelp(numpy.any)