diff --git a/src/autodoc2/config.py b/src/autodoc2/config.py index 0970e6e..ba7e6f1 100644 --- a/src/autodoc2/config.py +++ b/src/autodoc2/config.py @@ -485,6 +485,18 @@ class Config: }, ) + index_filename: str = dc.field( + default="index.rst", + metadata={ + "help": ( + "The filename of the index file, " + "relative to `autodocs2_output_dir`(in POSIX format)." + ), + "sphinx_type": str, + "category": "render", + }, + ) + # TODO regexes # module_summary: bool | None = None # class_inheritance: bool | None = None diff --git a/src/autodoc2/sphinx/extension.py b/src/autodoc2/sphinx/extension.py index 44db12a..8eb8229 100644 --- a/src/autodoc2/sphinx/extension.py +++ b/src/autodoc2/sphinx/extension.py @@ -84,7 +84,11 @@ def run_autodoc(app: Sphinx) -> None: content_str = jinja2.Template(config.index_template).render( top_level=top_level_modules ) - index_path = Path(app.srcdir) / PurePosixPath(config.output_dir) / "index.rst" + index_path = ( + Path(app.srcdir) + / PurePosixPath(config.output_dir) + / PurePosixPath(config.index_filename) + ) if not (index_path.exists() and index_path.read_text("utf8") == content_str): index_path.parent.mkdir(parents=True, exist_ok=True) index_path.write_text(content_str, "utf8")