Skip to content

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

Merged
merged 12 commits into from
Apr 2, 2017
Merged

DOC: Several documentation fixes (broken links, incorrect sphinx syntax, duplicate sections) #8836

merged 12 commits into from
Apr 2, 2017

Conversation

MSeifert04
Copy link
Contributor

@MSeifert04 MSeifert04 commented Mar 25, 2017

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])

@eric-wieser
Copy link
Member

Guessing by :c:func: you mean :c:type:?

@MSeifert04
Copy link
Contributor Author

you're right, ... corrected.

@MSeifert04
Copy link
Contributor Author

I'm not sure about the workflow but is it okay to combine several changes (like the one about the invalid section header-warning from numpydoc) and the one fixing (or rather changing) the PyObject *-links? And is the commit message alright?

@@ -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
Copy link
Member

@eric-wieser eric-wieser Mar 25, 2017

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?

Copy link
Contributor Author

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.


Example: multiplication costs of different parenthesizations
------------------------------------------------------------
Another example: multiplication costs of different parenthesizations.
Copy link
Member

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?

Copy link
Contributor Author

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 :)

@eric-wieser
Copy link
Member

eric-wieser commented Mar 25, 2017

I'm not sure about the workflow but is it okay to combine several changes

I'd argue that usually it'd be better not to, but for something like documentation it doesn't really matter

@MSeifert04
Copy link
Contributor Author

MSeifert04 commented Mar 25, 2017

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?

@eric-wieser
Copy link
Member

One Pr might be ok, but separate commits might be sensible

@eric-wieser
Copy link
Member

Regarding PyObject * - I'd rather we fixed something like that upstream, rather than work around it and forget.

@MSeifert04
Copy link
Contributor Author

MSeifert04 commented Mar 26, 2017

@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 :)

@MSeifert04 MSeifert04 changed the title DOC: Fix links to PyObject and removed invalid section header DOC: Several documentation fixes (broken links, incorrect sphinx syntax, duplicate sections) Mar 26, 2017
@eric-wieser
Copy link
Member

That's a bit (lot) beyond my current capabilities.

Yeah, I tryed to debug this and was struggling too. My only concern is that PyObject * is possibly more useful at a glance, and realistically after this change, we'll never switch back if sphinx ever fixes it.

At some point I might try and produce a minimal testcase to file an issue against sphinx

Copy link
Member

@eric-wieser eric-wieser left a 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.

@@ -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
Copy link
Member

Choose a reason for hiding this comment

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

What happened here before?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -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
Copy link
Member

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?

Copy link
Contributor Author

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.

@MSeifert04
Copy link
Contributor Author

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
Copy link
Member

@charris charris Mar 27, 2017

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.

Copy link
Contributor Author

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?

Copy link
Member

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
Copy link
Member

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?

Copy link
Contributor Author

@MSeifert04 MSeifert04 Mar 27, 2017

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__ 😓

Copy link
Member

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

@eric-wieser
Copy link
Member

But I tried to only fix broken links and incorrect attempts to link. Not okay?

This mostly looks good to me. Thanks for keeping PyObject *and just fixing the links

Copy link
Member

@eric-wieser eric-wieser left a 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)
Copy link
Member

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?

Copy link
Contributor Author

@MSeifert04 MSeifert04 Mar 27, 2017

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?

Copy link
Contributor Author

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?

Copy link
Member

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
Copy link
Member

@eric-wieser eric-wieser Mar 27, 2017

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?

Copy link
Contributor Author

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.

Copy link
Member

@eric-wieser eric-wieser Mar 27, 2017

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...

Copy link
Contributor Author

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 :)

Copy link
Member

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

@MSeifert04
Copy link
Contributor Author

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)
Copy link
Member

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!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

😅 fixed

@MSeifert04
Copy link
Contributor Author

sorry, that last change really bloated the "number of lines changed" count.

@MSeifert04
Copy link
Contributor Author

Anything else that needs to be adressed?

@eric-wieser
Copy link
Member

If no one else chimes in, I'll merge this tomorrow

@charris
Copy link
Member

charris commented Apr 1, 2017

@eric-wieser Merge?

@eric-wieser eric-wieser merged commit 77eab40 into numpy:master Apr 2, 2017
@eric-wieser
Copy link
Member

Thanks @MSeifert04!

@MSeifert04
Copy link
Contributor Author

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?

@MSeifert04 MSeifert04 deleted the doc_fixed_some_sphinx_warnings branch April 3, 2017 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants