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
222
votes
6 answers

Automatically document all modules recursively with Sphinx autodoc

I'm trying to use Sphinx to document a 5,000+ line project in Python. It has about 7 base modules. As far as I know, In order to use autodoc I need to write code like this for each file in my project: .. automodule:: mods.set.tests :members: …
Cory Walker
  • 4,809
  • 4
  • 28
  • 32
142
votes
10 answers

sphinx-build fail - autodoc can't import/find module

I'm trying to get started with Sphinx and seem to have relentless problems. Command: docs/sphinx-quickstart I answer all the questions and everything works fine. Command: docs/ls Everything looks normal. Result: build Makefile source Command:…
Rico
  • 5,692
  • 8
  • 46
  • 63
136
votes
8 answers

What is the correct way to document a **kwargs parameter?

I'm using Sphinx and the autodoc extension to generate API documentation for my Python modules. Whilst I can see how to nicely document specific parameters, I cannot find an example of how to document a **kwargs parameter. Does anyone have a good…
jkp
  • 78,960
  • 28
  • 103
  • 104
123
votes
6 answers

How to use Sphinx's autodoc to document a class's __init__(self) method?

Sphinx doesn't generate docs for __init__(self) by default. I have tried the following: .. automodule:: mymodule :members: and ..autoclass:: MyClass :members: In conf.py, setting the following only appends the __init__(self) docstring to…
Jacob Marble
  • 28,555
  • 22
  • 67
  • 78
103
votes
5 answers

What's the proper way to document callbacks with jsdoc?

I've spent quite a while scouring the internet looking for the best way to properly document callbacks with jsdoc, but unfortunately, I haven't found a great one yet. Here's my question: I'm writing a Node.js library for developers. This library…
rdegges
  • 32,786
  • 20
  • 85
  • 109
99
votes
1 answer

Sphinx error: Unknown directive type "automodule" or "autoclass"

I need to document my Python project using Sphinx. But I can't use autodoc. When I config my project I select the option "extension autodoc", but now if I use .. autoclass:: Class I get an error: ERROR: Unknown directive type "autoclass" I…
edgarzamora
  • 1,472
  • 1
  • 9
  • 17
82
votes
2 answers

How would I cross-reference a function generated by autodoc in Sphinx?

I am using the Sphinx autodoc feature to generate documentation based on the docstrings of my Python library. The syntax for cross referencing is found here A label must precede the section in order to allow that section to be referenced from other…
Matthew Stamy
  • 1,114
  • 1
  • 7
  • 9
40
votes
2 answers

Documenting class attributes with type annotations

I want to autogenerate documentation to my code from docstrings. I have some basic class meant to store some data: class DataHolder: """ Class to hold some data Attributes: batch: Run without GUI debug (bool): Show…
Djent
  • 2,877
  • 10
  • 41
  • 66
33
votes
2 answers

Sphinx automodule: how to reference classes in same module?

I am trying to use the sphinx autodoc extension and specifically the automodule directive to automatically generate documentation for django app I am working on. The problem is that I want to create internal references to different classes within…
dino
  • 3,093
  • 4
  • 31
  • 50
33
votes
3 answers

Connect Sphinx autodoc-skip-member to my function

I want to use sphinx's autodoc-skip-member event to select a portion of the members on a certain python class for documentation. But it isn't clear from the sphinx docs, and I can't find any examples that illustrate: where do I put the code to…
bstpierre
  • 30,042
  • 15
  • 70
  • 103
33
votes
9 answers

Python Sphinx autodoc and decorated members

I am attempting to use Sphinx to document my Python class. I do so using autodoc: .. autoclass:: Bus :members: While it correctly fetches the docstrings for my methods, those that are decorated: @checkStale def open(self): """ …
Freddie Witherden
  • 2,369
  • 1
  • 26
  • 41
33
votes
3 answers

Sphinx: how to exclude imports in automodule?

I have a Raspberry Pi project written in Python that uses RPi.GPIO module. All the work on the code is done on a Windows box where RPi.GPIO will not install and every time I try to run autodoc it crashes saying it cannot import…
pandasauce
  • 1,136
  • 2
  • 9
  • 11
32
votes
6 answers

Sphinx Autodoc skip member from docstring

I am documenting a class with Sphinx and simple want to skip one of the classes members: class StatusUpdateAdapter(logging.LoggerAdapter): """ """ def __init__(self, status_update_func, logger, extra={}): """ """ …
32
votes
9 answers

How can I use Sphinx' Autodoc-extension for private methods?

I am using Sphinx for documenting my python project. I have the autodoc extension enabled and have the following in my docs. .. autoclass:: ClassName :members: The problem is, it only documents the non-private methods in the class. How do I…
cnu
  • 36,135
  • 23
  • 65
  • 63
29
votes
7 answers

How to properly write cross-references to external documentation with intersphinx?

I'm trying to add cross-references to external API into my documentation but I'm facing three different behaviors. I am using sphinx(1.3.1) with Python(2.7.3) and my intersphinx mapping is configured as: { 'python': ('https://docs.python.org/2.7',…
Gall
  • 1,595
  • 1
  • 14
  • 22
1
2 3
30 31