mafw.devtools.toolchain.tools.sphinx
Concrete ProjectTool implementation for Sphinx.
Sphinx is a project tool whose version lower bound is declared in
project.optional-dependencies.doc. This module manages the >=
specifier for Sphinx and validates updates by running the documentation
build via hatch.
Update logic (inherited from ProjectTool):
Query PyPI for the latest stable Sphinx release.
Compare against the current lower bound in pyproject.toml.
If a newer version exists, update the
>=specifier.
Post-update validation (overridden here):
Determine the highest supported Python version dynamically.
Recreate the
dev.py<version>hatch environment to force fresh dependency resolution.Run
hatch run dev.py<version>:docto build the documentation.If the build fails, revert pyproject.toml to its previous content.
The revert pattern uses _revert()
which restores the raw pyproject.toml content saved before the update.
Classes
|
Manage Sphinx's version lower bound in pyproject.toml. |
- class mafw.devtools.toolchain.tools.sphinx.SphinxTool(project_root: Path | None = None)[source]
Bases:
ProjectToolManage Sphinx’s version lower bound in pyproject.toml.
Sphinx is categorized as a project tool because its version is controlled through the
docoptional-dependencies group inpyproject.toml. After an update, thedochatch environment is recreated and the documentation build is executed to validate compatibility. If the build fails, pyproject.toml is reverted to its pre-update state.All standard behaviour (version detection, update, verify, bootstrap) is provided by
ProjectTool. Onlypost_update()is overridden to run the documentation build.- Parameters:
project_root (Path | None) – Path to the project root directory containing
pyproject.toml. Defaults to the current working directory.
- post_update() None[source]
Recreate the doc environment and run the documentation build.
Forces recreation of the
dochatch environment to ensure the newly specified dependency versions are resolved and installed. Then executeshatch run dev.py3.14:docfrom the project root.If the documentation build fails (non-zero exit code), the pyproject.toml is reverted to its saved pre-update content and a
DevtoolsErroris raised. The error message includes the conflicting package name when the failure is caused by a dependency resolution conflict.- Raises:
DevtoolsError – If environment recreation or the documentation build fails after the update.
- property env_name: str
Hatch environment where sphinx documentation is built.
- Returns:
"dev"- Return type:
str
- property package_name: str
PyPI package name for Sphinx.
- Returns:
"sphinx"- Return type:
str
- property section_path: str
Dot-separated TOML path to the dependency array containing Sphinx.
- Returns:
"project.optional-dependencies.doc"- Return type:
str