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
8
votes
0 answers

Autosummary: How to control which methods are used in generated docs?

I am using sphinx to generate my documentation and the autosummary extension takes care of generating little stubs for all classes not explicitly written by myself. Take the class Foo and assume it has a mixin Base that adds more methods very basic…
jhp
  • 519
  • 3
  • 13
8
votes
1 answer

Why is toctree not updating with RTD theme?

I have an programmatically generated sphinx-doc source that uses the Read-The-Docs theme. The source tree looks like: source ├── conf.py ├── index.rst ├── models │   ├── 1lin │   │   ├── 1lin_Amplero.rst │   │   ├── 1lin_Blodgett.rst │   │   ├──…
naught101
  • 18,687
  • 19
  • 90
  • 138
8
votes
1 answer

Sphinx cross referencing breaks for inherited objects imported and documented in a parent module

I'm trying to get my Sphinx documentation build correctly and have cross-references (including those from inherited relations) work right. In my project, I have a situation which is depicted in the example below, which I replicated for convenience…
André Anjos
  • 4,641
  • 2
  • 27
  • 34
8
votes
1 answer

How does 'autodoc_default_flags' work in python Sphinx configuration?

I am trying to generate documentation for my python classes using Sphinx 1.4 and sphinx-apidoc and the sphinx.ext.autodoc extension. I have a lot of modules and I want each to only show class names, but not the full list of methods in the class…
sgt_pats
  • 161
  • 3
  • 8
8
votes
2 answers

How to stop Sphinx automethod prefixing method name with class name

When I use Sphinx automethod to document a specific method like so: .. automethod:: my_module.MyClass.my_method The resulting docs append the class name to the method name like this: MyClass.my_method(kwarg1=None, kwarg2=None) This is the…
amorphic
  • 722
  • 8
  • 12
8
votes
1 answer

intersphinx link to pandas autodoc API

I'm attempting to link to the apply() autodoc documentation at: http://pandas.pydata.org/pandas-docs/dev/generated/pandas.DataFrame.apply.html. I can link to the release page at: http://pandas.pydata.org/pandas-docs/dev/release.html by…
chancyk
  • 358
  • 4
  • 10
8
votes
2 answers

How to annotate a member as abstract in Sphinx documentation?

The following two property definitions show up exactly the same in Sphinx autodoc HTML output: @property def concrete(self): """This is the concrete docstring""" pass @abstractproperty def abstract(self): """This is the abstract…
cdwilson
  • 4,310
  • 4
  • 26
  • 32
8
votes
1 answer

Sorting display by class using sphinx with 'autodoc'?

Is there a way to display a "Classes" list / tab using Sphinx, or to organize the html pages generated to show members by class, classes being visually well separated? I use Sphinx 1.1.3, an try to document a Python extension (a custom one created…
Gauthier Boaglio
  • 10,054
  • 5
  • 48
  • 85
8
votes
1 answer

Why is CPython not using `sphinx.autodoc` for the standard library?

I am developing a python library and I am using sphinx.autodoc to generate the documentation as I think that this is a good way to don`t repeat yourself and to have documentation and code in agreement. In a comment to Emit reStructuredText from…
bmu
  • 35,119
  • 13
  • 91
  • 108
7
votes
1 answer

How to make line breaks in long function signature and format it prettily in Sphinx autodoc

I have a function with a long signature with type hint, like def set_parameters( tokenizer: Union[None, "Tokenizer", str] = None, vocab: Optional["Vocab"] = None, vocab_from: Optional[Dict[str, str]] = None, …
7
votes
1 answer

Sphinx autodoc with mypy type annotations

Currently, I have some code that uses mypy type annotations like this: def translate(self, text, mark_unknown=False, format=None, deformat='txt', reformat='txt'): # type: (Translator, str, bool, Optional[str], str, str) -> str I want to…
Andi Qu
  • 186
  • 1
  • 10
7
votes
1 answer

Structuring Sphinx autodoc documentation in Python modules with sections

I'm trying to improve the structure of the documentation of my python modules. Right now I have an Sphinx index.rst file that looks like this: Contents: .. toctree:: :maxdepth: 3 .. automodule:: myModule1 :members: .. automodule:: myModule2 …
5Ke
  • 1,209
  • 11
  • 28
7
votes
2 answers

sphinx-apidoc picks up submodules, but autodoc doesn't document them

I've been working on a project for PyQt5 ( found here: https://github.com/MaVCArt/StyledPyQt5 ) which uses a package structure to make imports a bit more logical. I've been relatively successful in documenting the code so far with Sphinx, at least…
MaVCArt
  • 745
  • 8
  • 21
7
votes
2 answers

Autosummary with toctree not creating documentation for methods

I'm using sphinx with the numpydoc extension and autosummary. After some experimentation, I added the following options to my conf.py file. autosummary_generate = True numpydoc_show_class_members = False This is giving me a new file for each class…
kesmit
  • 121
  • 1
  • 4
7
votes
2 answers

Sphinx autodoc not importing anything?

I'm trying to use sphinx (in conjunction with autodoc and numpydoc) to document my module, but after the basic setup, running make html produces just the basic html with nothing from the docstrings included. I'm running Python 3.3, the outline of…
George Oblapenko
  • 878
  • 1
  • 10
  • 23