Reference

sphinx-autogen(1)

Generate autodoc stub pages

NAME

sphinx-autogen - Generate autodoc stub pages

SYNOPSIS

sphinx-autogen [options] <sourcefile> ...

DESCRIPTION

sphinx-autogen is a tool for automatic generation of Sphinx sources that, using the autodoc <#module-sphinx.ext.autodoc> extension, document items included in autosummary <#directive-autosummary> listing(s).

sourcefile is the path to one or more reStructuredText documents containing autosummary <#directive-autosummary> entries with the :toctree: option set. sourcefile can be an fnmatch <https://docs.python.org/3/library/fnmatch.html#module-fnmatch>-style pattern.

OPTIONS

-o <outputdir>

Directory to place the output file. If it does not exist, it is created. Defaults to the value passed to the :toctree: option.

-s <suffix>, --suffix <suffix>

Default suffix to use for generated files. Defaults to rst.

-t <templates>, --templates <templates>

Custom template directory. Defaults to None.

-i, --imported-members

Document imported members.

-a, --respect-module-all

Document exactly the members in a module's __all__ attribute.

--remove-old

Remove existing files in the output directory that are not generated anymore.

EXAMPLE

Given the following directory structure:

docs
├── index.rst
└── ...
foobar
├── foo
│   └── __init__.py
└── bar
    ├── __init__.py
    └── baz
        └── __init__.py

and assuming docs/index.rst contained the following:

Modules
=======
.. autosummary::
   :toctree: modules
   foobar.foo
   foobar.bar
   foobar.bar.baz

If you run the following:

$ PYTHONPATH=. sphinx-autogen docs/index.rst

then the following stub files will be created in docs:

docs
├── index.rst
└── modules
    ├── foobar.bar.rst
    ├── foobar.bar.baz.rst
    └── foobar.foo.rst

and each of those files will contain a autodoc <#module-sphinx.ext.autodoc> directive and some other information.

SEE ALSO

sphinx-build(1), sphinx-apidoc(1)

Copyright

2007-2026, the Sphinx developers

History

--imported-members since Debian 10 (Buster); --remove-old since Debian 13 (Trixie); --respect-module-all since Debian 12 (Bookworm); --suffix since Debian 7 (Wheezy); --templates since Debian 7 (Wheezy); -a since Debian 12 (Bookworm); -i since Debian 10 (Buster); -t since Debian 7 (Wheezy).

--output-dir until Debian 9 (Stretch).