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

Sphinx "exception: No module named" error persists after autodoc_mock_imports is used

I am adding rst files to an existing repository using Sphinx v6.1.3 with sphinx.ext.autodoc extension. when running make html the new rst file causes an error: Extension error (sphinx_automodapi.automodsumm): Handler
Sapps
  • 1
  • 1
0
votes
0 answers

How to fix "No module named..." error in Sphinx?

I am getting the following error : WARNING: autodoc: failed to import module 'create_alias' from module 'src.create_alias'; the following exception was raised: No module named 'helpers' Project Structure looks like project-1 | |---src …
Tanu
  • 1,286
  • 4
  • 16
  • 35
0
votes
0 answers

How to create hyperlinks in a sphinx documentation when using type aliases?

I have a function with type annotations using type aliases in Python ExampleArrayLike = Union[list, np.ndarray] def module_level_function_5( array_like: ArrayLike, array: numpy.ndarray ) -> ExampleArrayLike: Sphinx autodoc provides…
0
votes
0 answers

Sphinx: using autodoc without name

I want to use, let's say, .. autoclass:: Foo in my docstring, but as a result, I want to obtain only Foos docstring, not the name + signature + docstring. I tried to use .. autodata:: etc., but the result didn't change - it always results with at…
0
votes
1 answer

Sphinx autodoc : show-inheritance full name

I have a hierarchy of modules with classes of the same name that subclass each other, e.g. # foo.py class Box: ... # bar.py class Box: ... # foobar.py import foo, bar class Box(foo.Box, bar.Box): ... My template for classes is setup with objname…
0
votes
0 answers

TypeVar class references in Sphinx docs, using Autodoc and Autodoc Typehints

I'm working on the docs of my project and struggling to get internal classes properly referenced in the output files produced by Sphinx. Below my project structure: project/ |-- docs/ | |-- build/ | |-- source/ | |-- conf.py | |--…
Tommaso Belluzzo
  • 23,232
  • 8
  • 74
  • 98
0
votes
1 answer

local sphinx generates autodoc members from docstrings, readthedocs does not

I have a small project at github. The package does not have external dependencies, and all the source is included in a single __init__.py file. In the ./docs folder, I just have 2 rst files: an index.rst with some intro and a nix_shell_utils.rst…
Alberto Garcia
  • 324
  • 1
  • 11
0
votes
1 answer

Python docstrings broken, requires parameter first

I got a strange error using python's docstrings in combination with Sphinx Autodoc/Napoleon: When using docstrings, the formatting is broken as soon as i put the comment above the parameters. """ This yields in a wrongly formatted doc page. :param…
Kevin
  • 27
  • 1
  • 4
0
votes
0 answers

Set option of autodoc directive for members of another autodoc directive

Problem To fully use the autodoc potential, I want to document my code with something like: .. automodule :: mymodule However, mymodule is made of a class that has it's own documenter. One of my project's dependencies created a subclass of…
Aule Mahal
  • 688
  • 5
  • 10
0
votes
1 answer

Python Path Issues with Sphinx?

I'm running into a lot of trouble trying to use Sphinx autodoc for a python package, and I think the issue is a path one, but I'm not sure how to solve? Wondering if anyone might know? I'm trying it out with just a super basic module setup with a…
Ed May
  • 75
  • 3
0
votes
0 answers

Sphinx autodoc doesn't recognize a TypedDict key with the name "values"

Say that I have the following code: import numpy as np from typing import TypedDict class Signal(TypedDict): """My signal.""" name: str #: Signal name. values: np.ndarray #: Signal values. signal_unit: str #: Signal unit. …
Barzi2001
  • 989
  • 8
  • 24
0
votes
0 answers

Exclude all attrs auto-generated methods from sphinx

I have a simple attrs data class: from attrs import frozen @frozen class Person raw: str I document it with the simplest *.rst file: .. autoclass:: api.main.person.Person :members: :exclude-members: __init__ but if I need to remove…
OrenIshShalom
  • 5,974
  • 9
  • 37
  • 87
0
votes
0 answers

How to use autodoc in sphinx to show docStrings?

How to configure project so it will use Sphinx autodoc to get DocString from python code and show it on html? Its is not clear from the documentation what to add where to make autodoc get all my docStrings. here is my conf.py import os import…
Akshat Tamrakar
  • 2,193
  • 2
  • 13
  • 21
0
votes
0 answers

Function docstrings not included in generated HTML

I am starting a new Sphinx project to generate documentation from docstrings. I am not able to post my code structure here due to the sensitivity of my project. I have successfully built and generated the HTML with the following…
wang larry
  • 11
  • 2
0
votes
1 answer

Sphinx includes private attributes even though not instructed to

I did not include the :private-members: option anywhere, but Sphinx still includes private attributes in the docs for the class. What am I doing wrong? MWE: mypackage/foo.py: class MyClass(object): """A class. Attributes ---------- …
LarrySnyder610
  • 2,277
  • 12
  • 24