sphinx-autogen¶
概要¶
sphinx-autogen [選項] <sourcefile> …
描述¶
sphinx-autogen 是一個用於自動產生 Sphinx 來源檔案的工具,它使用 autodoc
擴充功能,來記錄包含在 autosummary
清單中的項目 (多個)。
sourcefile 是一個或多個 reStructuredText 文件的路徑,其中包含 autosummary
條目,並設定了 :toctree:
選項。 sourcefile 可以是 fnmatch
風格的模式。
選項¶
- -o <outputdir>¶
放置輸出檔案的目錄。如果目錄不存在,則會建立它。預設為傳遞給
:toctree:
選項的值。
- -s <suffix>, --suffix <suffix>¶
用於產生檔案的預設後綴。預設為
rst
。
- -t <templates>, --templates <templates>¶
自訂範本目錄。預設為
None
。
- -i, --imported-members¶
記錄匯入的成員。
- -a, --respect-module-all¶
精確地記錄模組
__all__
屬性中的成員。
- --remove-old¶
移除輸出目錄中不再產生的現有檔案。
範例¶
給定以下目錄結構
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
則以下 Stub 檔案將在 docs
中建立
docs
├── index.rst
└── modules
├── foobar.bar.rst
├── foobar.bar.baz.rst
└── foobar.foo.rst
並且每個檔案都將包含一個 autodoc
指令和其他資訊。
參見¶
sphinx-build(1), sphinx-apidoc(1)