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 remove the "Parameters" section from Sphinx autoclass output

When using autoclass to document a dataclass you get a "Parameters" section after the class docstrings. How can you remove this? Here is a visual of what I'd like to achieve: Edit: here is the class definition from the example: class…
Cristian Garcia
  • 9,630
  • 6
  • 54
  • 75
0
votes
0 answers

Sphinx: unable to import internal modules

My project (written in python 2.7) has a complex structure and most modules are interlinked. There is no direct entry or link to this project to execute. It works as toolbox for other project. When I tried to use sphinx to create the documentation…
arya
  • 35
  • 3
0
votes
1 answer

Sphinx: how to show attributes as in scipy

Let's say we have the following module testmodule.py with a TestClass definition: """This is a test module""" class TestClass: """ This is a simple description. Attributes ---------- egg : int An egg. Should be from a…
Breno
  • 748
  • 8
  • 18
0
votes
1 answer

Napoleon overescapes trailing underscore in parameter name leading to Unknown target name error

I now have exactly the problem that was described in this issue: https://github.com/sphinx-doc/sphinx/issues/7734. An MWE is also provided in that issue. My problem is just that the fix doesn't seem to be activated by default. In the source code I…
0
votes
0 answers

Sphinx Documentation WARNING: autodoc: failed to import module

After generating html file by make html command, documention is not generated properly. I followed all the steps of sphnix documentation. Where did it go wrong? My project directory: |--web_app |--accounts |--__pycache__ …
Asif Exe
  • 111
  • 8
0
votes
1 answer

autodoc_pydantic: Show fields from parent model

I'm using the autodoc_pydantic plugin for Sphinx to document my pydantic.BaseModel classes. However, there are cases where I have something like class Foo(pydantic.BaseModel): '''Foo class''' x: str = pydantic.Field(description='The…
Daniel Walker
  • 6,380
  • 5
  • 22
  • 45
0
votes
1 answer

Autodoc failing with class that has nested pydantic model

As my MRE, I've got the following file: blah.py '''Blah module''' import pydantic class Foo: '''Foo class''' class Bar(pydantic.BaseModel): '''Bar class''' x: str = pydantic.Field(description='The x.') …
Daniel Walker
  • 6,380
  • 5
  • 22
  • 45
0
votes
0 answers

Sphinx-autodoc Error: Failed to import module. A very basic structure but not able to generate documentation

So I have been working on this for two days but not able to solve the issue. I have a very basic file structure. Utils | ├───docs │ │ │ ├───build │ └───conf.py │ index.rst │ modules.rst │ stack.rst │ _static │ …
Shivam Singh
  • 87
  • 2
  • 11
0
votes
1 answer

Sphinx "autodoc" extension unable to even find standard modules guaranteed to exist

I'm attempting to document the public API of beartype, a berry fun runtime type checker for Python. I am failing utterly. Sphinx's autodoc extension fails to find standard pure-Python CPython modules that are both guaranteed to exist and be…
Cecil Curry
  • 9,789
  • 5
  • 38
  • 52
0
votes
0 answers

Sphinx automodule: class method not documented when decorated with mocked function

I have a class with decorated methods. The function used as a decorator is provided by a module not available when building the documentation, hence this module is mocked in conf.py using autodoc_mock_imports = ['module_with_decorator']. ..…
Guti_Haz
  • 2,528
  • 2
  • 15
  • 20
0
votes
1 answer

Using autodocs with WCF REST Service Template 40

I'm looking for a documentation tool for REST services created using the 'WCF REST Service Template 40' and came across Autodocs (http://autodocs.codeplex.com/), however I'm not sure if they'll work together.... Anyone who has made it work or any…
smolesen
  • 1,153
  • 3
  • 11
  • 29
0
votes
0 answers

Sphinx: Literal Blocks in class description causes overlap with Attributes/Methods table

Hi I have issue with Sphinx where my description text seems to overlap with the attributes and methods table. This happens when I add an indentation (Literal Block) to the class description. If my class description does not have any indentation,…
0
votes
1 answer

Function appears two times in Sphinx autodoc generated documentation

Background information I generate documentation from docstrings via Sphinx autodoc. There is a function mypackage.mypackage.foo() located in source file mypackage/mypackage.py. It is imported implicite in the __init__.py, so the user can it use as…
buhtz
  • 10,774
  • 18
  • 76
  • 149
0
votes
1 answer

Sphinx autodoc/napoleon doesn't generate docstrings

I'm doing a really simple example and can't get it to work. I just have one file, simulator.py that I added numpy style docstrings to. It does not import any other libraries. It has an __init__ and I can import it from a python interpreter. My…
Katie
  • 21
  • 1
  • 7
0
votes
1 answer

Sphinx Autodoc Without Submodules

I'm developing a Python package that allows users to import its functions like this: import mymodule mymodule.afunction() I'm documenting the code with sphinx. I first ran sphinx-quickstart, then I changed conf.py to include sys.path.insert(0,…
Danny
  • 35
  • 4