Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/autodoc2/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,18 @@ class Config:
},
)

index_filename: str = dc.field(
default="index.rst",
metadata={
"help": (
"The filename of the index file, "
"relative to the output directory (in POSIX format)."
),
"sphinx_type": str,
"category": "render",
},
)

# TODO regexes
# module_summary: bool | None = None
# class_inheritance: bool | None = None
Expand Down
4 changes: 3 additions & 1 deletion src/autodoc2/sphinx/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ 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) / 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")
Expand Down