repomatic.docs module¶
Regenerate Sphinx API docs and dynamic documentation content.
Backs the update-docs command: orchestrates sphinx-apidoc, the RST-to-MyST
conversion, the project’s docs/docs_update.py script, and the self-updating
directive-block refresh. Configuration is read from [tool.repomatic.docs].
- repomatic.docs.validate_docs_script_path(script, repo_root)[source]¶
Validate and resolve a docs update script path.
- Parameters:
- Return type:
- Returns:
The resolved path, or
Nonewhen the configured value is empty.- Raises:
ClickException – If the path escapes the repository root or is not a
.pyfile underdocs/.
- repomatic.docs.DIRECTIVE_BLOCK_MARKERS: tuple[str, ...] = ('{matrix}', '<!-- matrix', ':mirror:', '<!-- mirror')¶
Markers of a self-updating block
click-extra refresh-directivesrewrites.Every form the refresh recognizes: the
{matrix}MyST fence (live-rendered by Sphinx), the<!-- matrix -->comment region (whose embedded table renders on GitHub too), and thepython:render:mirror:region (<!-- mirror -->, whose generator Python the refresh executes).
- repomatic.docs.has_directive_block(path)[source]¶
Whether path carries a self-updating block worth refreshing.
- Parameters:
path (
Path) – Markdown file to scan.- Return type:
- Returns:
Truewhen anyDIRECTIVE_BLOCK_MARKERSentry appears.
- repomatic.docs.update_docs(config, *, check=False)[source]¶
Regenerate Sphinx autodoc stubs and run the project’s update script.
Orchestrates four phases:
Run
sphinx-apidocto generate RST stubs for all modules.If MyST-Parser is detected, convert the RST stubs to MyST markdown with
{eval-rst}blocks.Run the project-specific
docs/docs_update.pyscript (if present) to generate dynamic content.Refresh self-updating blocks (
{matrix}compatibility tables andpython:render:mirror:regions) found indocs/pages andreadme.md, viaclick-extra refresh-directives.
- Parameters:
config (
Config) – The resolved[tool.repomatic]configuration.check (
bool) – Report out-of-date content without writing, for CI drift detection. Phases 1–2 regenerate files and have no dry-run mode, so they are skipped; the self-updating phases run in their own check modes (docs_update.py --checkandrefresh-directives --check) and any drift raises aClickException. The update script must accept a--checkflag to participate: a script that ignores it will still write.
- Return type: