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

make packages installed in virtualenv visibile to sphinx

I am using sphinx to document my software. and I am using a virtualenv for the installation. now some packages are only installed in the virtual environment, and sphinx does not see them. I have this code in my conf.py: # If extensions (or modules…
mariotomo
  • 9,438
  • 8
  • 47
  • 66
4
votes
1 answer

Sphinx doesn't process python classes

Gooday, I'm having trouble at autogenerating python documentation. My project layout is the following: project_folder package module1.py module2.py doc make.bat build source index.rst package.rst modules.rst conf.py inside module1.py and…
Koldar
  • 1,317
  • 15
  • 35
4
votes
0 answers

python sphinx auto documenting constants

I have a bunch of non documented constants in my generated python module using SWIG. If I use pydoc I can get all these constants to be displayed, all I want is to list them out (obviously I don't want to type them manually). If they have a…
4
votes
0 answers

sphinx autodoc include subfunctions

I want to automatically include subfunctions of a function in the sphinx documentation. What is the option for this? My code looks like import numpy def mainfunc(): """ to be documented """ def subfunc(): """ to be documented…
Jan
  • 4,932
  • 1
  • 26
  • 30
4
votes
2 answers

autodoc failing on django ImageField

I'm attempting to use sphinx to document the django app I'm writing. So far I have my code.rst setup to look at models.py, and when I run make html I get the automatic documentation, however I get a warning: WARNING: autodoc can't import/find…
ptr
  • 3,292
  • 2
  • 24
  • 48
4
votes
2 answers

Swagger-PHP for generating JSON file for Swagger-UI

I am trying to use Swagger-PHP for generating JSON files , so that I can use it with Swagger-UI for auto documentation. I tried the link :- https://github.com/zircote/swagger-php Also I tried to work around with there documentation at…
user1496197
  • 43
  • 1
  • 1
  • 4
4
votes
2 answers

Sphinx autodoc dies on ImportError of third party package

There's any way to exclude the import part of a module and then document it with sphinx-python? I have a module that imports another package (other different project) and then the sphinx gives this error: """ File…
Bjorn Nunskt
  • 43
  • 1
  • 4
4
votes
1 answer

How I can define in Sphinx which .rst files and directories should be used?

How I can define in Sphinx which .rst files and directories should be used? I want to include an automatic documentation generator in my testing/building/documentation script. sphinx-quickstart was executed in my workspace and created an…
Jon
  • 11,356
  • 5
  • 40
  • 74
4
votes
0 answers

import f2py extension as 'import mymod.foo'

I've created a Python module from Fortran files with: f2py -c -m mymod file1.f90 file2.f90 file3.f90 file1.f90 contains Fortran modules: foo, bar, bar. Module foo contains functions: f,g,h. f2py automatically write docstring for function…
user744629
  • 1,961
  • 1
  • 18
  • 27
3
votes
0 answers

Hide module paths with sphinx autodoc, autosummary and autodoc_pydantic

I am using Sphinx with autodoc and autosummary to generate documentation for a pydantic model using autodoc_pydantic. The model is quite complex and has a lot of sub-models in various files and includes custom types used for validation in a separate…
3
votes
2 answers

Python Sphinx autosummary rendering of parameters like numpy

Problem I am using Sphinx and the autosummary extension to document my python 3 project with numpy style docstring. Current rendering This is my current rendering. The red box shows the current layout for parameters and returns. Desired rendering I…
3
votes
2 answers

Shorten display format of Python type annotations in Sphinx

Given the following function in a module called mymodule that I want to document using Sphinx with autodoc: from typing import Union from collections.abc import Iterable from numpy.typing import ArrayLike def foo(a: Union[str, int], b: Iterable, c:…
schtandard
  • 387
  • 4
  • 18
3
votes
1 answer

Cross reference documentation of function or class in Sphinx for Python

I want, within an explanatory documentation, a reference to the documentation of a Python class and, a little later, to its constructor. So imagine there is a file # MyLib/MyClass.py class MyClass: """Class Introduction""" def…
gilgamash
  • 862
  • 10
  • 31
3
votes
0 answers

Sphinx code documentation build failing in GitLab CI/CD

I am trying to create some documentation for some code written, specifically for a file called pipeline.py. Now I am using GitLab to host the documentation online. There are only two parts of the documentation, a step-by-step-guide and a code…
3
votes
1 answer

Sphinx Autodoc remove empty submodules and packages

I'm trying to use sphinx in order to create a documentation for my project, it is a bunch of functions divided to modules inside the project. I need only a small subset of the functions to be exposed in the documentation so I used…
Amir Rossert
  • 1,003
  • 2
  • 13
  • 33