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
3
votes
2 answers

Documenting class-level variables in Python

I am trying to document a Python class that has some class-level member variables, but I could not get it appropriately documented using reST/Sphinx. The code is this: class OSM: """Some blah and examples""" url =…
3
votes
1 answer

How napoleon and autodoc interact documenting members

I noticed a change in behavior in how Sphinx renders class descriptions. Given this code # my example happens to be a dataclass, but the behavior for # regular classes is the same @dataclass class TestClass: """This is a test class for…
Arne
  • 17,706
  • 5
  • 83
  • 99
3
votes
2 answers

How to remove static class variable using automodule with Sphinx?

I'm currently using Sphinx (first time using it) to build the docs for my modules and I have some classes which have some class variables that are initialized with a default value. For ex: class ConfigSettings(object): """Class that manages a…
DarkImage
  • 63
  • 1
  • 8
3
votes
0 answers

Getting started with Sphinx when your source files aren't in the project base folder

Alright, I've been struggling with Sphinx not producing any documentation from the docstrings I've written in this example code. Its a simple implementation of a stack in Python. You probably need not read all of this: src/stack.py class Stack: …
3
votes
0 answers

Autodocument Airflow code with Sphinx and autodoc

When documenting Airflow DAG using operator '>>' I get some errors on the dependencies between tasks. If I mock airflow operators then I receive the error that the operator '>>' does not exist between objects in python. Is there any way to omit some…
Hantaro
  • 31
  • 1
3
votes
1 answer

Showing only private methods with Sphinx' Autodoc

There are several questions here about showing private methods using Autodoc, but I've not seen anything about showing only private methods. Private methods and regular methods can be shown as follows: .. autoclass:: my_package.my_file.MyClass …
snazzybouche
  • 2,241
  • 3
  • 21
  • 51
3
votes
1 answer

Sphinx Autodoc output order

Is it possible to change the order of the output generated with Sphinx AutoDoc? In particular, I am including private members, using the :private-members: directive. What I want is the private members to appear last in the output and not first…
SomJura
  • 336
  • 1
  • 3
  • 13
3
votes
0 answers

Sphinx autodoc including classes and methods

I have python classes and some of them are in their own files i.e. userdata.py: class userdata: """User input class for reading...""" def __init__(self, fname): self.fname = fname def trykey(self,name,injson): .... I…
user2375049
  • 350
  • 2
  • 15
3
votes
2 answers

How to ignore 'src' directory in python project when making sphinx autodoc

(alternative description could be 'how to rename a sphinx-autodoc package name?') using sphinx version 1.7 on Python 2.7.13 I would like to automatically create documentation using docstrings and sphinx-apidoc. My project structure is as…
Siete
  • 328
  • 3
  • 14
3
votes
0 answers

Document members for inherited classes in Sphinx

I am using Sphinx's autodoc module for Python documentation. I want my inherited classes to show details of its member functions as well as its docstrings. So I set the following option: export…
Akshay Shah
  • 323
  • 2
  • 16
3
votes
1 answer

Exclude static members from documentation in Sphinx autodoc extension

I am using the Sphinx autodoc extension for documenting my Python project. I have the following in my docs for a class: .. automodule:: ClassName :members: :undoc-members: :show-inheritance: The class I am documenting has static members…
3
votes
1 answer

How do I selectively hide module docstrings in sphinx autodoc?

In autodoc, I know you can hide the docstrings for all modules as described here: Exclude module docstring in autodoc But is there a way to do this for some modules and not others, possibly with some parameter passed to automodule? In other words,…
sb933
  • 101
  • 7
3
votes
1 answer

sphinx autodoc for python doesn't show anything (on readthedocs)

I have this python package that I'd like to automatically document using Sphinx. I've inserted docstrings in every functions and classes. I made an account on ReadTheDocs, and did the setup accordingly (i.e., a docs/ dir with a conf.py file). Then,…
Dominique Makowski
  • 1,511
  • 1
  • 13
  • 30
3
votes
1 answer

Autodoc Inheritance - Don't show members from 'Object'

I'm using autodoc to document some classes and so far, :members:, :private-members:, and :special-members: get me exactly what I want. However, I would also like to see members that are inherited. There is an additional option, :inherited-members:,…
J. Massey
  • 41
  • 2
3
votes
0 answers

Sphinx: How can I put code block in a specific variable description in autodoc?

I want to put few lines of code sample in description of a parameter. It's possible to add :param, the :type, etc. But is it possible to add a block of comments in front of the :param? Here's the code that I'm using now: :param…
Kennet Celeste
  • 4,593
  • 3
  • 25
  • 34