Use numpydoc to render the API reference - #3059
Conversation
|
View rendered docs @ https://intelpython.github.io/dpnp/pull/3059/index.html |
|
Array API standard conformance tests for dpnp=0.21.0dev8=py314ha0e2e8e_13 ran successfully. |
|
Small rendering mismatch vs the legacy build worth a fix: parameter/return types now render upright + semibold instead of italic.
Cause is purely CSS. numpydoc emits the type as Proposed fix, add to /* numpydoc param/return types: italic like NumPy, not bold */
.classifier {
font-style: italic;
font-weight: 400;
} |
| # Napoleon extension can't properly render "Returns" section in case of | ||
| # namedtuple as a return type. That patch proposes to extend the parse logic | ||
| # which allows text in a header of "Returns" section. | ||
| def _parse_returns_section_patched(self, section: str) -> list[str]: |
There was a problem hiding this comment.
Please edit the docstrings so Returns contains only name : type items, relocating the intro sentence. Example for qr:
Before:
Returns
-------
When mode is "reduced" or "complete", the result will be a namedtuple with
the attributes `Q` and `R`:
Q : dpnp.ndarray of float or complex, optional
...
After (move the sentence into a Notes section — or the extended summary):
Returns
-------
Q : dpnp.ndarray of float or complex, optional
...
R : dpnp.ndarray of float or complex, optional
...
(h, tau) : tuple of dpnp.ndarray of float or complex, optional
...
Notes
-----
When `mode` is ``"reduced"`` or ``"complete"``, the result is a namedtuple
with the attributes ``Q`` and ``R``. When `mode` is ``"raw"``, it returns
``(h, tau)``.
Same pattern for the other 8 (for the unique_*/eig/eigh/slogdet/lu cases, the intro is just "A namedtuple with the following attributes:" — that line can simply be deleted, since listing the named returns already conveys it).
This PR switches the documentation build from
sphinx.ext.napoleontonumpydocto render the API reference.numpydocrenders theParametersandReturnssections as definition lists out of the box, which lets us remove:doc/_static/dpnp-custom.jsthat reformatted parameterdescriptions, together with the CSS rules that only supported it;
Returns(numpydoc handles itnatively).
A small hook keeps the dpnp-specific
Limitationssection and a some docstrings are adjusted for numpydoc's stricter parser.