-
-
Notifications
You must be signed in to change notification settings - Fork 11.2k
DOC: Several documentation fixes (broken links, incorrect sphinx syntax, duplicate sections) #8836
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: Several documentation fixes (broken links, incorrect sphinx syntax, duplicate sections) #8836
Conversation
Guessing by |
you're right, ... corrected. |
I'm not sure about the workflow but is it okay to combine several changes (like the one about the |
@@ -173,7 +173,7 @@ each array is for PyArray_ITER_NEXT to be called for each of the inputs. This | |||
incrementing is automatically performed by | |||
:c:func:`PyArray_MultiIter_NEXT` ( ``obj`` ) macro (which can handle a | |||
multiterator ``obj`` as either a :c:type:`PyArrayMultiObject *` or a |
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.
Does PyArrayMultiObject *
work just fine here then? The issue is specifically with intersphinx and not :c:type:
somepointer *` in general?
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.
Haha! That's funny because there is no PyArrayMultiObject
defined so any link (with or without *
) couldn't work. 😄
However from my understanding :c:type::
-declared variables can have the *
and link correctly. See https://docs.scipy.org/doc/numpy/reference/c-api.array.html#data-type-checking for working PyArrayObject *
-link.
numpy/linalg/linalg.py
Outdated
|
||
Example: multiplication costs of different parenthesizations | ||
------------------------------------------------------------ | ||
Another example: multiplication costs of different parenthesizations. |
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.
Not really an example at all - perhaps notes, or more details or something. Perhaps a third-level heading (~~~
) under notes 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 can also put it in a Notes
-section :)
I'd argue that usually it'd be better not to, but for something like documentation it doesn't really matter |
So if I had 10 other documentation-related fixes then it would be fine to amend them? Or will that be hellish to review? Or should these be seperate commits/PRs? |
One Pr might be ok, but separate commits might be sensible |
Regarding |
@eric-wieser I don't think that's so easy to fix upstream. I'm not sure but there is something weird going on with name-mangling in numpydoc. That's a bit (lot) beyond my current capabilities. I actually added a lot of additional "link" fixes. I grouped them by the kind of change (should be easy to review commit-by-commit), just let me know if I need to squash them :) |
Yeah, I tryed to debug this and was struggling too. My only concern is that At some point I might try and produce a minimal testcase to file an issue against sphinx |
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.
Great set of fixes - thanks. Few nits.
doc/source/reference/c-api.array.rst
Outdated
@@ -204,7 +204,7 @@ From scratch | |||
new array is *descr*. | |||
|
|||
If *subtype* is of an array subclass instead of the base | |||
:c:data:`&PyArray_Type`, then *obj* is the object to pass to | |||
:c:data:`&PyArray_Type<PyArray_Type>`, then *obj* is the object to pass to |
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.
What happened here before?
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.
It just wasn't rendered as link: https://docs.scipy.org/doc/numpy/reference/c-api.array.html#c.PyArray_NewFromDescr
doc/source/reference/c-api.array.rst
Outdated
@@ -1545,7 +1545,7 @@ Conversion | |||
|
|||
.. c:function:: PyObject* PyArray_GetField(PyArrayObject* self, PyArray_Descr* dtype, int offset) | |||
|
|||
Equivalent to :meth:`ndarray.getfield` (*self*, *dtype*, *offset*). Return | |||
Equivalent to :meth:`ndarray.getfield<numpy.ndarray.getfield>` (*self*, *dtype*, *offset*). Return |
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.
Putting ~numpy.
before here doesn't work then?
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.
It would work! But it would render as getfield
instead of ndarray.getfield
.
[skip ci]
and fixed two broken links because they started with "&". [skip ci]
I addessed some additional issues. However I don't want to make this a "work in progress" so I'll stop now 😄 |
@@ -6,7 +6,7 @@ Python Types and C-Structures | |||
|
|||
Several new types are defined in the C-code. Most of these are | |||
accessible from Python, but a few are not exposed due to their limited | |||
use. Every new Python type has an associated :c:type:`PyObject *` with an | |||
use. Every new Python type has an associated :c:type:`PyObject *<PyObject>` with an |
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'd rewrite that as "has a pointer to an associated :c:type:PyObject
,,,"? However, I think this whole section is somewhat lacking, what we usually get is a pointer to a PyTypeObject
that subclasses the PyObject
type. I think it would be better to quote something from the Python documentation.
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.
However, I think this whole section is somewhat lacking
I thought this passage is about the difference between PyLongType
and PyLongObject
. So to say every python type (long type) has an associated object (long object). I don't quite understand what you mean about every type has a pointer to an associated object?
But I tried to only fix broken links and incorrect attempts to link. Not okay?
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.
A generic PyObject
is a C struct
that begins with a PyObject
(i.e., subclasses PyObject), which in turn is a struct that contains a reference count and a pointer to a PyObjectType
struct. I don't know how that fits with the rest of the paragraph 8-)
@@ -460,12 +460,12 @@ Ufuncs allow other array-like classes to be passed seamlessly through | |||
the interface in that inputs of a particular class will induce the | |||
outputs to be of that same class. The mechanism by which this works is | |||
the following. If any of the inputs are not ndarrays and define the | |||
:obj:`__array_wrap__` method, then the class with the largest | |||
:obj:`__array_priority__` attribute determines the type of all the | |||
:obj:`~numpy.class.__array_wrap__` method, then the class with the largest |
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.
What is class
referring to here? Is this some weird sphinx feature, or a quick hack? What does this end up linking to?
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.
No, that is actually called class
in the numpy documentation on subclassing: numpy.class.__array_wrap__
😓
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.
Ok, that's pretty weird! Still, I guess if this PR is all about fixing links, then this is the right thing to do
This mostly looks good to me. Thanks for keeping |
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'm sure there's more to do with fixing docs, but as an exercise in fixing links, this looks great.
@@ -124,9 +122,7 @@ Functions | |||
:param unused: | |||
Unused and present for backwards compatibility of the C-API. | |||
|
|||
.. c:function:: PyObject* PyUFunc_FromFuncAndDataAndSignature(PyUFuncGenericFunction* func, | |||
void** data, char* types, int ntypes, int nin, int nout, int identity, | |||
char* name, char* doc, int unused, char *signature) |
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.
Line wrapping is not possible then? Backslashes at EOL?
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 haven't checked but c-api.iterator
also contains longish lines (>250 chars). I can see what happens with backslashes. Is there a line-length-limit for .rst
files?
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.
Backslashes seem to work, should I use them 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.
Yes please!
Example: multiplication costs of different parenthesizations | ||
------------------------------------------------------------ | ||
|
||
Notes |
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.
We already have a notes section higher up. Best not to have two of them.
Also, the changes to this file kinda feel different to all the rest - maybe put them in their own PR?
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.
maybe I'm blind but I can't find the other Notes
-section.
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.
No, it is I who is blind...
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 will open another PR for this change then :)
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.
Feel free to leave this in, since it's correct. Just add the backslashes on the lines you unwrapped, and this'll be good to merge
I used EOL-backslashes so the function signature lines wrap at roughly 80 characters. |
.. c:function:: PyObject *PyUFunc_FromFuncAndData( PyUFuncGenericFunction* func, | ||
void** data, char* types, int ntypes, int nin, int nout, int identity, | ||
char* name, char* doc, int unused) | ||
.. c:function:: PyObject *PyUFunc_FromFuncAndData( PyUFuncGenericFunction* func, void** data, char* types, int ntypes, int nin, int nout, int identity, char* name, char* doc, int unused) |
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.
You missed the one that started this conversation!
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.
😅 fixed
[skip ci]
sorry, that last change really bloated the "number of lines changed" count. |
Anything else that needs to be adressed? |
If no one else chimes in, I'll merge this tomorrow |
@eric-wieser Merge? |
Thanks @MSeifert04! |
Thanks for reviewing and merging it 👍 I just noticed that the PR has no "component: documentation" tag, I don't know how you do bookkeeping here but maybe it was simply forgotten? |
The PR links PyObject references in narrative documentation and also fixes "invalid section header" warning in "linalg.multi_dot" docstring.
It seems weird that
:c:type:'PyObject *'
can't be resolved as link while:c:type:'PyObject'
works. 😕 Is there something wrong in the intersphinx?(This time with
[ci skip]
)