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 autodoc and OpenCV (cv2) errors (Python 3.7)

Firstly, say that I'm totally new to sphinx. I'm working on an image processing project that uses opencv. While I've been able to setup sphinx (and succesfully tested it with some simple modules), I'm struggling to make it work with my main module.…
Carlos Borau
  • 1,433
  • 1
  • 24
  • 34
0
votes
0 answers

How do I extract Python class/method as fragments?

I am using VuePress for documentation, but find the more precise formatting and support for Python code in reStructured Text useful at times. How can I use Sphinx and/or reStructuredText to generate fragments of HTML that I will later integrate? How…
JL Peyret
  • 10,917
  • 2
  • 54
  • 73
0
votes
1 answer

Where is the reference for the reStructuredText roles needed for using Sphinx and Sphinx's autodoc like Javadoc?

I would like to use reStructuredText, Sphinx, and Sphinx autodoc for Python code in the same way one uses Javadoc for Java code, that is, for specifying parameters and return values, but also for linking to other classes, methods, etc. I am finding…
user118967
  • 4,895
  • 5
  • 33
  • 54
0
votes
1 answer

Suppressing autogenerated cruft when using Sphinx autodoc with a list-typed module data member

I'm trying to use sphinx.ext.autodoc to document a module data member which is a list of objects of SomeType: class SomeType(object): pass Foo = SomeType() Bar = SomeType() foo_bar = [Foo, Bar] My autodoc directive looks like: .. autodata::…
Max Gasner
  • 1,191
  • 1
  • 12
  • 18
0
votes
1 answer

What is the correct way to structure a module directory so that the Sphinx extension autodoc can access all files found using sphinx-apidoc?

I'm trying to make documentation using Sphinx for a module which I've recently started creating. How do I organise my code so that both autodoc and python can read it properly? I have the following file structure in which inference.py imports a…
evanr70
  • 139
  • 10
0
votes
1 answer

Sphinx / ReadTheDocs still tries to build a module when I try to mock it

I am attempting to build documentation using Sphinx on ReadTheDocs, for a project that depends on a bunch of pydata packages, some of which depend on C libraries which are not available on ReadTheDocs (namely the python-snappy package, which…
0
votes
1 answer

Sphinx: how to include docstrings/comments located well within a module, but outside of class and methods

I have a comment in my python module that documents several classes that follow, e.g. ### # Classes for agents: patients and clinicians ### class EngagementLadder(transitions.Machine): """The state machine for agent states. In fact there…
David Bridgeland
  • 525
  • 1
  • 9
  • 16
0
votes
0 answers

How to create Sphinx index from a specific or custom docstring element?

Is it possible to create an index in Sphinx which is created by specific (or custom) elements in the docstring? For example, I have the following function and would like to have Sphinx to create an index from the field "Command Reference". Is this…
sven
  • 11
  • 3
0
votes
1 answer

sphinxcontrib.programoutput works locally, doesn't work on ReadTheDocs

I am trying to use sphinxcontrib.programoutput to automatically document the --help command of my software. My rst looks like this: .. command-output:: squiggle --help And works exactly as expected locally. However, when I go to put it on…
Benjamin Lee
  • 481
  • 1
  • 5
  • 15
0
votes
0 answers

how to add sphinx docs of imported libraries in python?

I have a python script "webaton.py" which imports selenium. I have doc strings for my methods in my own class in the webaton.py and i set some of the methods of selenium as the method of my class using setattr( ) method . When I generate my…
Natesh bhat
  • 12,274
  • 10
  • 84
  • 125
0
votes
0 answers

How do I document my main function with Sphinx autodoc?

I have a problem when building my documentation with Sphinx autodoc. My project consists of different modules which contain classes. The documentation for these modules is generated correctly. But there is one module (in my case called…
0
votes
2 answers

Pretty-print special methods using Sphinx Autodoc

In the Python documentation, special methods are documented differently. For instance, instead of __len__, the documentation reads len(d). How can I get Sphinx to do the same? It seems like all I have to do is override the logic producing the method…
Thom Smith
  • 13,916
  • 6
  • 45
  • 91
0
votes
1 answer

Sphinx generates documentation partially

As a result of make html command, Sphinx generates documentation only for some modules. Other modules remain undocumented. Project structure: |- my-project |--| my_project |--| docs |----| _build |------| ... |----| _static |------| ... |----|…
mr_bulrathi
  • 514
  • 7
  • 23
0
votes
2 answers

Sphinx autodoc - decorator and ReadTheDocs

I am having a little trouble with Sphinx auto-generated documentation with autodoc. I basically have the same issue as here : Python Sphinx autodoc and decorated members When I used a decorator on a function, the signature shown in the documentation…
0
votes
0 answers

Autodoc Cython/NumPy with Sphinx

I have some trouble to document my Cython (python 2.7) module with Sphinx (1.7). I set the Cython directive embedsignature to True, and I also mock numpy in my conf.py file. However, if I run sphinx-build -b html source build I get the following…
Petermailpan
  • 103
  • 1
  • 10