Sphinx自生菌

简介

sphinx-autogen [options] <sourcefile>…

描述

sphinx-autogen 是一个用于自动生成Sphinx源代码的工具,它使用 autodoc 扩展名,文档项目包含在 autosummary 上市(S)。

源文件 是指向一个或多个包含 autosummary 条目 :toctree:: 选项集。 源文件 可以是 fnmatch 样式模式。

选项

-o <outputdir>

放置输出文件的目录。如果它不存在,则创建它。默认为传递给 :toctree: 选择权。

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

用于生成文件的默认后缀。默认为 rst .

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

自定义模板目录。默认为 None .

-i, --imported-members

记录导入的成员。

-a, --respect-module-all

准确记录模块的 __all__ 属性。

例子

给定以下目录结构:

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

并假设 docs/index.rst 包含以下内容:

Modules
=======

.. autosummary::
   :toctree: modules

   foobar.foo
   foobar.bar
   foobar.bar.baz

如果运行以下命令:

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

然后将在中创建以下存根文件 docs ::

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

并且每个文件都将包含一个 autodoc 指令和其他一些信息。

也见

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