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
10
votes
2 answers

Python Sphinx autodoc not rendering on readthedocs

I have a Python package hosted on Github called spike2py. I have prepared my docs using Sphinx and .rst files. These files are hosted on GitHub here. I am able to successfully run make html locally and obtain the desired output. That is, the…
Martin Héroux
  • 145
  • 2
  • 10
10
votes
4 answers

Sphinx autodoc fails to import module

I'm trying to document a project using Sphinx, and am running into an issue where only some modules are being imported from a folder. My project structure looks like this: Project | |--Main | |--Scripts | __init__.py | …
Alex Cavanaugh
  • 415
  • 1
  • 5
  • 16
10
votes
1 answer

Sphinx does not recognize subfolders

I'm new in using Sphinx. I'm able to create HTML documentations as long as my files are in the source top folder. As soon as I'm putting them in a subfolder in the source directory, Sphinx does not include the document into the build. Sphinx tells…
Stephan
  • 242
  • 4
  • 16
10
votes
1 answer

How to avoid inherited members using autosummary and custom templates?

I generate a python documentation using sphinx.ext.autosummary. The autodoc and autosummary is configured as follow in conf.py : autodoc_member_order = 'bysource' ## Default flags used by autodoc directives autodoc_default_flags =…
A.Vignon
  • 365
  • 1
  • 10
10
votes
1 answer

Can type hint in python 3 be used to generate docstring?

We can indicate the types of function parameters using docstring in python: def f1(a): """ :param a: an input. :type a: int :return: the input integer. :rtype: int """ return a For f1, autodoc generates the following…
Jinho Choi
  • 1,841
  • 2
  • 10
  • 12
10
votes
0 answers

Sphinx Autodoc vs. Coverage: Am I missing something here?

I'm trying to use Sphinx to document a Python package which contains various sub-packages and sub-modules. I followed the stock Sphinx quickstart script which produced various files with autodoc directives that, in turn, with the html generator,…
ipmcc
  • 29,581
  • 5
  • 84
  • 147
10
votes
1 answer

Exclude module docstring in autodoc

I'm trying to use autodoc in Sphinx to print out the docstrings of every functions in a specific module but exclude the module's docstring. Is it possible? The reason is that I'm using the modules docstring to specify command line options (with the…
Jonatan
  • 1,096
  • 1
  • 18
  • 28
9
votes
2 answers

Including docstring in Sphinx Documentation

I'd like to include just the docstring of a specific function in my Sphinx documentation. However there seem to be no options to just display these details without associated class and function definitions using…
geographika
  • 6,458
  • 4
  • 38
  • 56
9
votes
5 answers

Sphinx cannot find my python files. Says 'no module named ...'

I have a question regarding the Sphinx autodoc generation. I feel that what I am trying to do should be very simple, but for some reason, it won't work. I have a Python project of which the directory is named slotting_tool. This directory is…
Sam
  • 113
  • 1
  • 1
  • 5
9
votes
1 answer

How does one specify a type for variables in Python docstrings for Sphinx?

You can specify types of parameters in Python docstrings like this: def __init__(self, canvas, segments): """Class constructor. :param canvas: the PDF canvas object :param segment: The layer segments to be drawn. :type canvas:…
Torsten Bronger
  • 9,899
  • 7
  • 34
  • 41
9
votes
1 answer

Autodoc works locally, but does not on the ReadTheDocs

I documented some functions using autodoc. Locally it works well. When I commit to GitHub, the documentation is built on ReadTheDocs, but there are no functions that I documented with "automodule". I added in my conf.py: import mock MOCK_MODULES =…
natalia
  • 309
  • 2
  • 11
9
votes
1 answer

Sphinx autodoc functions within module

I am just getting started with sphinx and willing to learn. I would like to break up my various functions into different sections within my index.rst file. So each function has it's own header. So for example if I have a python file named test.py…
Ken Carrier
  • 91
  • 1
  • 1
  • 2
9
votes
2 answers

How can I just list undocumented members with sphinx/autodoc?

I am using sphinx with the autodoc extension, and would like to generate a list only containing the undocumented member functions in several modules, and not the documented members. I can successfully create a list that includes both documented…
Bonlenfum
  • 19,101
  • 2
  • 53
  • 56
8
votes
1 answer

How do I exclude jars from a leiningen project?

While using Leiningen, I got the following abrupt error: Exception in thread "main" java.lang.NoSuchMethodError: org.apache.tools.ant.util.FileUtils.getFileUtils()Lorg/apache/tools/ant/util/FileUtils; (core.clj:1) I found the following answer at…
Gregg Williams
  • 868
  • 1
  • 8
  • 15
8
votes
2 answers

How to generate HTML Documentation with Python-Sphinx?

I'm working on a Python project using PyCharm and now I need to generate the corresponding API documentation. I'm documenting the code methods and classes using docstrings. I read about Sphinx and Doxygen, with Sphinx being the most recommended…
Juan Carlos
  • 367
  • 2
  • 8
  • 16