Questions tagged [autodoc]

Extension for the Sphinx documentation generator that imports Python modules in order to extract docstrings in a semi-automatic way.

Python Sphinx extension that can import the modules being documented, and pull in documentation from docstrings in a semi-automatic way.

The sphix.ext.autodoc extension can be used in conjunction with the sphinx.ext.napoleon extension. This allows use of NumPy and Google style docstrings. The Napoleon prepocessor will initially convert your docstrings to ReStructured text, that afterwards is processed by autodoc.

Several commonly used directives are provided by autodoc, namely ..automodule:: and ..autoclass: For examples of use see the sphinx.ext.autodoc documentation.

See also:

456 questions
7
votes
1 answer

Can I suppress variable expansion in Sphinx documentation?

In my code I have X_DEFAULT = ['a', 'long', 'list', 'of', 'values', 'that', 'is', 'really', 'ugly', 'to', 'see', 'over', 'and', 'over', 'again', 'every', 'time', 'it', 'is', 'referred', 'to', 'in', 'the', 'documentation'] and later def…
orome
  • 45,163
  • 57
  • 202
  • 418
7
votes
2 answers

Python: Generate autodoc with Sphinx on a single module?

I'm working on a Python library that only has a single .py module and I'm trying to generate documentation for it from the docstrings. I have Sphinx set up and ran through the spinx-quickstart script, but when I try to run (while in the docs…
Isaac Freeman
  • 308
  • 2
  • 16
7
votes
1 answer

Problems with autodoc and explicitly specified instance attributes

I wrote a python class and I made the documentation with sphinx. For example, the class looks like : class Aclass(object): """ my class """ def __init__(self): """ constructor """ self.a = None """ doc for attribute…
Ger
  • 9,076
  • 10
  • 37
  • 48
7
votes
1 answer

How to override constructor parameters in Sphinx with autodoc?

Let's say I have a class like this: class MyClass(object): """ Summary docs for my class. Extended documentation for my class. """ def __init__(self, *args): self.values = np.asarray(args) If I use Sphinx with the autodoc…
detly
  • 29,332
  • 18
  • 93
  • 152
7
votes
1 answer

autoclass and instance attributes

According to the sphinx documentation, the .. autoattribute directive should be able to document instance attributes. However, if I do:: .. currentmodule:: xml.etree.ElementTree .. autoclass:: ElementTree .. autoattribute::…
astrofrog
  • 32,883
  • 32
  • 90
  • 131
6
votes
2 answers

Using sphinx autodoc for a fabfile

Is it possible to use Sphinx autodoc to generate documentation for my fabfile, from the function docstrings? E.g. for a fabfile containing a setup_development task i've tried: .. automodule::fabfile :members: .. autofunction::…
Matt Austin
  • 2,613
  • 1
  • 27
  • 32
6
votes
1 answer

Sphinx: What is the cause for 'WARNING: duplicate object description'?

I am getting multiple warnings like: WARNING: duplicate object description of pyfar.signal.TimeData.times, other instance in pyfar.classes_audio, use :noindex: for one of them but can not figure out why? Someone suggested that I probably include the…
fabian
  • 103
  • 1
  • 7
6
votes
1 answer

Can I use :noindex: in Python docstring with Sphinx autodoc?

I am trying to build documentation with sphinx, and cannot figure out how to use :noindex:. Setup I'm using following extensions: extensions = [ "sphinx.ext.napoleon", "sphinx.ext.todo", "sphinx.ext.viewcode", "sphinx.ext.autodoc", …
balbok
  • 394
  • 3
  • 14
6
votes
1 answer

Sphinx's autodoc's automodule having apparently no effect

I am running Sphinx on a rst file containing automodule but it does not seem to have any effect. Here are the details: I have a Python project with a file agent.py containing a class Agent in it. I also have a subdirectory apidoc with a file…
user118967
  • 4,895
  • 5
  • 33
  • 54
6
votes
3 answers

How can I use automodule or autoclass for Sphinx in a markdown file?

I understand the Sphinx supports markdown or .md files optionally, which works great for me for my supplimental documentation. What I am trying to do is use the autoclass or automodule tags in a markdown file. Normally, in a .rst file, if I do ..…
securisec
  • 3,435
  • 6
  • 36
  • 63
6
votes
1 answer

Can Python autodoc tuple/list format be changed?

I have some Python code in a project that I want to document, however I have run into a problem with documenting class constants that are tuples or lists. See code and image below. It's very hard to read the documentation when there are several…
SimonF
  • 1,855
  • 10
  • 23
6
votes
1 answer

Readthedocs does not display docstring documentation

I have followed the getting started guide on Readthedocs and have used Sphinx using autodoc to create the documentation for my Python package on https://github.com/akdiem/bloodflow. (documentation relevant .rst files are in the docs folder) The…
glanne
  • 71
  • 5
6
votes
1 answer

Inherited attributes in docstring not displayed

I'm trying to use Sphinx to document one base class and 2 child classes with google style docstring classes. I'm particularly stuggling with inherited attributes: class Base(object): """Base class. Attributes: a (int): one…
marc_bllv
  • 63
  • 5
6
votes
0 answers

Shorter autodoc names

I am using Sphinx and autodoc for my Python package which results in nice documentation but by default the full "path" to the function, e.g.: SomeFolder.AnotherFolder.MyModule.FunctionName(arg1, arg2, arg3) Since it is clear where the module is, by…
Leevi L
  • 1,538
  • 2
  • 13
  • 28
6
votes
0 answers

Sphinx autosummary: create a summary of a module

I am having trouble getting sphinx to create a summary table for modules. I have added sphinx.ext.autosummary to my conf.py file and I am using numpydoc. Sphinx seems to create the summary table for attributes and methods on a class, but it does…
Stretch
  • 1,581
  • 3
  • 17
  • 31