Quick Start¶
Installation¶
Install sphinx-autodoc-toml using pip:
pip install sphinx-autodoc-toml
Configuration¶
Add the extension to your Sphinx conf.py:
extensions = [
'sphinx_autodoc_toml',
# ... other extensions
]
For requirements tracking, also add sphinx-needs:
extensions = [
'sphinx_autodoc_toml',
'sphinx_needs',
# ... other extensions
]
Usage¶
Basic Example¶
Add doc-comments to your TOML file:
[project] name = "my-project" version = "1.0.0" #: This section defines the project dependencies. #: All dependencies should be pinned to specific versions. [project.dependencies] requests = "==2.31.0"
In your
.rstdocumentation file, use theautodoc-tomldirective:.. autodoc-toml:: ../pyproject.toml
Build your documentation:
sphinx-build -b html docs docs/_build/html
With Requirements Tracking¶
You can embed sphinx-needs directives in your doc-comments:
#: Documentation for the project dependencies.
#:
#: .. req:: All dependencies MUST be pinned to specific versions.
#: :id: R_DEPS_001
#: :status: open
#: :tags: security
[project.dependencies]
requests = "==2.31.0"
When Sphinx builds your documentation, the .. req:: directive will be processed by sphinx-needs, creating a trackable requirement that appears in your documentation.
Next Steps¶
Learn about the TOML-Doc Specification
Explore Configuration Reference options
Check out the Requirements & Specifications extracted from our own
pyproject.toml