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

How to configure Sphinx autodoc to document classes in __init__.py?

I have Python codes with NumPy docstrings. Manage to use Sphinx for the API documentation, however, classes in the __init__.py file not documented successfully. Example: xxx/__init__.py from __future__ import annotations import sys import re from…
CarolL
  • 59
  • 2
  • 8
0
votes
1 answer

Sphinx autosummary: How to remove automember for __init__

Problem I am using sphinx.ext.autosummary for my python package. The problem is that .. autosummary:: adds .. automethod:: __init__ at all times, even if undocumented. In the mean time I have found various ways to include it a third time (as a…
0
votes
0 answers

Readthedocs autodoc working in pdf but not html

I'm unable to get autodoc to work with ReadTheDocs. Everything works normally locally, and ReadTheDocs shows no errors in raw view. Moreover pdf version of the docs looks like I intended with functions documented, while html refuses to include the…
Radost
  • 309
  • 3
  • 11
0
votes
1 answer

Documenting jit-compiled PyTorch Class Method (Sphinx)

I am having a problem trying to document custom PyTorch models with Sphinx: methods that are jit-compiled show up without docstrings in the documentation. How do I fix this? I checkoed out Python Sphinx autodoc and decorated members and How to…
Hyperplane
  • 1,422
  • 1
  • 14
  • 28
0
votes
1 answer

I can't seem to get Sphinx to get modules from a nexus repository

So I have a Python application I'm trying to document with Sphinx. I've created the directory structure, run sphinx-quickstart, and sphinx-apidoc, and changed my config.py for: sys.path.insert(0, os.path.abspath('../..')) My main problem is this…
cteljr
  • 25
  • 4
0
votes
0 answers

SQLAlchemy error when autogenerating documentation for database module using pdoc3

I'm creating documentation for a project using pydoc3 but am encountering an odd error from SQLAlchemy when running against my database module. Background Project layout: PROJECT_NAME/ |-- __init__.py | |-- api | |-- main.py | |-- database | |--…
Yaakov Bressler
  • 9,056
  • 2
  • 45
  • 69
0
votes
1 answer

Sphinx gives warning as it cannot find imported file

I am trying to generate docs but am running into a warning in the command line. I've been searching the site and can't find a working solution for me. I narrowed the cause down to the import in ClassB. My folder structure is: The __init__.py files…
SomeDutchGuy
  • 2,249
  • 4
  • 16
  • 42
0
votes
0 answers

Sphinx cannot find pandas

I am trying to document a Python class using sphinx. I am used Python 3.9.2 and sphinx-build 3.5.2. I am running the command sphinx-build -b html source build to transform the .rst files into .html files. I have already successfully executed this…
Jon
  • 1,621
  • 5
  • 23
  • 46
0
votes
1 answer

Cross reference a Python function generated by Sphinx's automodule directive from Jupyter notebook

Using Sphinx's automodule directive, I am creating an API documentation for all functions in my module from their respective docstrings. The respective .rst file comprises just the following lines: API Reference ============= .. automodule::…
Andi
  • 3,196
  • 2
  • 24
  • 44
0
votes
0 answers

Sphinx not displaying code documentation properly

Problem: Sphinx does not display documented code -only table of contents. I have isolated this down to Sphinx not generating the *.rst files for each documented *.py file when calling sphinx-apidoc. Note: I am using vscode with autodoc, the autodoc…
Dean
  • 141
  • 1
  • 7
0
votes
0 answers

Sphinx exclude torch.tensor as T

I'm aware of how to exclude files from Sphinx. However, a handful of my code uses the standard pattern of: import torch.tensor as T T then ends up getting the torch tensor documentation in my modules. How can I avoid this? I am using these sphinx…
Joseph Turian
  • 15,430
  • 14
  • 47
  • 62
0
votes
0 answers

How do I make sphinx recognize packages that the source code recognizes

I am using Sphinx to document a web-scraping project I am working on with Python 3.9. As part of the process I read an API key in from a yaml file. The code works fine when I test it; however, when I try to document the code with sphinx I get an…
Jon
  • 1,621
  • 5
  • 23
  • 46
0
votes
1 answer

Why isn't Sphinx showing inherited members?

I have a base class Base and a derived class Derived. Using Sphinx, I want the class attributes of Base to appear in the documentation of Derived; I thought :inherited-members: would do the trick, but I'm having no luck so far. Note that unlike this…
Dori
  • 1,035
  • 1
  • 12
  • 22
0
votes
1 answer

Ignore Sphinx autodoc warnings for rtype values

Right now autodoc seems to throw warnings for any rtype value that is not just an object type (a class instance, int, list, dictionary, etc). So a return value such as "list of tuples" will throw a warning. Is there any way to ignore these warnings…
0
votes
1 answer

Default arguments using mocked objects

I am using Sphinx v1.8.5 to build documentation for Python 2 code that has external dependencies that I mock using autodoc_mock_imports. I get an error message when I try to use the mocked object (RAMP) as a default argument: def foo(name,…
honey_badger
  • 472
  • 3
  • 10