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
1 answer

Documenting python script entry (__name__ == '__main__') using sphinx

Is there a way, ideally using autodoc, to get sphinx to document a Python script? The section of the script I want documented is the portion protected by: if __name__ == '__main__': i.e. the bit that only runs if the module is used as a script…
Papadeltasierra
  • 233
  • 1
  • 9
3
votes
1 answer

Check if Java Class is commented in SVN Precommit hook

I want to ensure that a Java class is commented, before someone commits something into the SVN repository. So I want to realize the following workflow: User changes something in a class User wants to commit class Before executing the commit to the…
Hendric
  • 101
  • 9
3
votes
1 answer

How do you make a Sphinx doc with one .py file that has only functions?

How do I make a Sphinx doc with one .py file that has only functions? I have a .py file with multiple functions that have docstrings in them already but don't want to make a :function:: console.someFunction for all the functions. Is there a smarter…
user805981
  • 9,979
  • 8
  • 44
  • 64
3
votes
0 answers

How to use Sphinx's autodoc to generate api documentation for multiple source code?

How do we use autodoc? I did python setup.py for both my of projects and their namespaces are importable.. I tried: .. automodule:: project.backend .. automodule:: project.api But I am only getting project.backend alias of…
User007
  • 1,519
  • 6
  • 22
  • 35
3
votes
2 answers

Will Sphinx work with code that doesn't import well?

Will the Sphinx documentation engine successfully generate documentation on a project that doesn't import well? In particular my project has an exotic dependency. I don't want document generation to depend on this dependency. Does Sphinx need to…
MRocklin
  • 55,641
  • 23
  • 163
  • 235
3
votes
0 answers

Include module synopsis in docstring for sphinx autodoc

I'm using Sphinx autodoc to generate the documentation for a python module from the docstrings in the source. I know I can include a :synopsis: in the automodule directive, but that kind of defeats the purpose of using autodoc, which is to put all…
brianmearns
  • 9,581
  • 10
  • 52
  • 79
3
votes
1 answer

Formatting multiline docstrings with Sphinx

Using sphinx autodoc, is there a way to format a first line of a multiline docstring in a special way? Consider: def whatever(): """This function does something. This really should have a full function definition, but I am too lazy. …
georg
  • 211,518
  • 52
  • 313
  • 390
2
votes
1 answer

ImportError when trying to autodoc a package

I'm trying to start using Sphinx to document some little projects of mine, but it seems like I can't get it to work. I've already searched around but everything I tried until now didn't fix the import erro. Here's exactly what I'm…
Bakuriu
  • 98,325
  • 22
  • 197
  • 231
2
votes
1 answer

Building html documentation with SPHINX, FURO, AUTODOC. Error stylesheet

i try to use SPHINX with the FURO html-theme in my python project. As i try to build the html, the build fails. I use following conf.py: # Configuration file for the Sphinx documentation builder. import os import sys sys.path.insert(0,…
Tarzan42
  • 23
  • 2
2
votes
1 answer

Sphinx: Autodocs for classes inheriting from base classes implemented in C

I am running into an error/warning when inheriting from collections.deque. Sphinx complains: utils.py:docstring of utils.Test.count:1: WARNING: py:class reference target not found: integer -- return number of occurrences of value For this example,…
Peter Nerlich
  • 225
  • 1
  • 11
2
votes
0 answers

How to create a new document in Sphinx/docutils by API?

I' writing a new extension for Sphinx as a domain offering multiple directives, roles and indices for the hardware description language VHDL. This extension shall be able to auto document language constructs. In VHDL, we have e.g.…
Paebbels
  • 15,573
  • 13
  • 70
  • 139
2
votes
0 answers

How to autodoc a custom descriptor like a property in sphinx?

I have a custom descriptor @runtime_checkable class ROProperty(Protocol[T_co]): """Protocol for a read-only descriptor.""" def __get__(self, instance: Any, owner: Any = None) -> T_co | None: ... class…
demberto
  • 489
  • 5
  • 15
2
votes
1 answer

Sphinx Documentation (autodoc) not working after uploading to Github

I have built sphinx documentation for my package. It is working fine when testing localhost. But after uploading it to Github and building docs on readthedocs.org the documentation page is not working which uses autodoc. Here is the link to the…
2
votes
0 answers

Why does sphinx autosummary not create a toctree when used inside a class?

I am trying to use ..autosummary to document a module that replaces itself with a class upon import (lazy importing). Without lazy imports the module looks like this: """ The demp_project package The demp_project consists of the following…
FirefoxMetzger
  • 2,880
  • 1
  • 18
  • 32
2
votes
0 answers

TypeVar object not documented as expected in method signature

The problem I'm wanting to document some modules in a package I'm developing using Sphinx. Throughout the modules I've imported some TypeVar objects from a module within the package - these objects refer to different types of data objects. I've done…