Questions tagged [numpydoc]

Numpydoc is a set of extensions for the Sphinx documentation generator, it adds support for docstrings formatted according to the NumPy documentation format.

Numpydoc is a set of extensions for the Sphinx documentation generator, it adds support for docstrings formatted according to the NumPy documentation format. It is licensed under the BSD license.

The parsing of NumPy style docstrings can be made by the Napoleon extension of Sphinx. NumPy style docstrings are converted to ReStructuredText before they are processed by Sphinx into documentation. This allows use of both reStructuredText in docstrings together with the addition of NumPy style docstrings.

Official Numpydoc site.

Sphinx support for NumPy and Google docstrings.

65 questions
3
votes
1 answer

Verify code and documentation match

Using Sphinx extension NumpyDoc, is there some way to automatically make sure that the documentation matches the code it's documenting? For example, the following documentation does not match the code due to a typo: def myfunc(apples, bears): """ …
Seanny123
  • 8,776
  • 13
  • 68
  • 124
3
votes
1 answer

Sphinx autosummary produces two summaries for each class

I'm using Sphinx+autodoc+autosummary to generate documentation for my project (mrpy). I am doing a two-layer summary, where in the index.rst I have (minimally) mrpy ==== .. autosummary:: :toctree: _autosummary :template: modules.rst …
StevenMurray
  • 742
  • 2
  • 7
  • 18
3
votes
1 answer

Indicating keyworded-ness of arguments in NumpyDoc DocStrings?

In trying to follow the NumpyDoc format for my DocStrings, I can't seem to figure out how to tell the user that an argument is a keyword argument (ie. specified as SomeFunc(theKeyWordArg=100) as opposed to SomeFunc(100) ). The documentation I've…
Demis
  • 5,278
  • 4
  • 23
  • 34
3
votes
1 answer

Documenting a duck-typed parameter in numpydoc

According to the convention in guide to numpy/scipy documentation function parameters should be documented in the following way: def foo(x): """" This function does nothing Parameters ---------- x : type Description of…
MB-F
  • 22,770
  • 4
  • 61
  • 116
2
votes
1 answer

Sphinx hiding modules imported in __init__.py

My package has a structure, similar to the following: ├── README.md ├── __init__.py ├── module1 │ └── submodule1.py │ └── submodule2.py ├── module2 │ ├── __init__.py │ ├── _hiden_submodule1.py │ ├── _hiden_submodule2.py │ └──…
Liris
  • 1,399
  • 3
  • 11
  • 29
2
votes
1 answer

Furo Sphinx theme keeps uppercasing too much in API documentation

I am facing the same problem discussed in this question: Furo Sphinx theme uppercases too much in API documentation. However, the accepted solution did not work, it seems that the Furo template is somehow overwriting the custom.css: I appreciate…
2
votes
1 answer

Is there a method for displaying plots after plt.show() with sphinx or keep scope after .. plot::

I am using sphinx with numpydocs, doctest, and the scipy theme. When using .. plot:: in a docstring, the plots are all created, except instead of showing where they are called, they all move to the end of the documentation. Is there a way to force…
001001
  • 530
  • 1
  • 4
  • 13
2
votes
2 answers

Pycharm warning: Class 'Iterable' does not define '__getitem__'

I have recently been learning python and I was trying out some things in Pycharm when I noticed the following warning caused by this piece of code: Class 'Iterable' does not define '_getitem_', so the operator '[]' cannot be used on its…
Demophilus
  • 129
  • 3
2
votes
1 answer

How to get the same output from sphinx napoleon and numpy style docs as with the default rst way?

If I take the very simple python file: def magic_function(parameter1): """ Do magic with parameter1. :param parameter1: The first of all paramters :type parameter1: nd_array """ return parameter1 I get the type right after…
NOhs
  • 2,780
  • 3
  • 25
  • 59
2
votes
1 answer

Does \r stand for something in sphinx?

I'm writing my docstring following the numpy docstring guidelines. Then I use sphinx's autodoc to generate my documentation. Within some docstrings I'm using LaTeX formulas (sphinx.ext.mathjax). It seems that \r means something special like a new…
math
  • 1,868
  • 4
  • 26
  • 60
2
votes
2 answers

Sphinx docs for composite data types

Is there a standard or best practice in Sphinx for providing more exact specifications for composite Python data types? For example, I have a function that returns a dict mapping str to str and am using numpydoc style. Should I do something…
Marshall Farrier
  • 947
  • 2
  • 11
  • 20
1
vote
0 answers

numpydoc: Can I omit the type declaration in the docstring when I use type hints?

When using type hints in the function signature, do I need to specify the parameter types in the docstring, too, if I were to comply with numpydoc style? def add(a: float, b: int) -> float: """ Parameters ---------- a Fist…
Andi
  • 3,196
  • 2
  • 24
  • 44
1
vote
1 answer

Python: document property to specify type

Let's consider the following example: from typing import Union import numpy as np class MyClass: def __init__(self): self._x = None @property def x(self) -> Union[float, np.ndarray]: if len(self._x) == 1: …
mauro
  • 504
  • 3
  • 14
1
vote
0 answers

Sphinx doesn't inherit docstring from parent class

There are a lot of questions here on SO asking how to avoid inheriting the docstring of the parent when building docs with sphinx. I have the opposite problem: I want my class-level docstring to be inherited, but that isn't happening. I built a toy…
1
vote
1 answer

Numpydoc style convention when returning an instance of a class

I'm following the numpydoc style guide to document my code but I cannot find the convention for returning an instance of a class : """Create an index in the meilisearch API. If the argument \`uid\` isn't passed in, it will be generated by…
Bidoubiwa
  • 910
  • 2
  • 12
  • 25