From f84739a7639230c8b8f77c4098ffe4b95b67a62d Mon Sep 17 00:00:00 2001 From: Jag_k <30597878+jag-k@users.noreply.github.com> Date: Fri, 28 Jul 2023 18:42:28 +0000 Subject: [PATCH 1/4] Add support `index_filename` option to `autodoc2`. --- src/autodoc2/config.py | 12 ++++++++++++ src/autodoc2/sphinx/extension.py | 4 +++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/autodoc2/config.py b/src/autodoc2/config.py index 79fe011..f1572f5 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 the output directory (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 2feb88c..fe1e329 100644 --- a/src/autodoc2/sphinx/extension.py +++ b/src/autodoc2/sphinx/extension.py @@ -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") From 779b63f1a5c7d3e37eace5bd148bc321e3335a97 Mon Sep 17 00:00:00 2001 From: Jag_k <30597878+jag-k@users.noreply.github.com> Date: Mon, 13 May 2024 13:51:59 +0400 Subject: [PATCH 2/4] Update extension.py Co-authored-by: Chris Sewell --- src/autodoc2/sphinx/extension.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/autodoc2/sphinx/extension.py b/src/autodoc2/sphinx/extension.py index 11b846b..53bda01 100644 --- a/src/autodoc2/sphinx/extension.py +++ b/src/autodoc2/sphinx/extension.py @@ -85,7 +85,7 @@ def run_autodoc(app: Sphinx) -> None: top_level=top_level_modules ) index_path = ( - Path(app.srcdir) / PurePosixPath(config.output_dir) / config.index_filename + 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) From cb124de7da97d125a20ad2d647f915e67fe51709 Mon Sep 17 00:00:00 2001 From: Jag_k <30597878+jag-k@users.noreply.github.com> Date: Mon, 13 May 2024 13:52:11 +0400 Subject: [PATCH 3/4] Update config.py Co-authored-by: Chris Sewell --- src/autodoc2/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/autodoc2/config.py b/src/autodoc2/config.py index 0a11be5..ba7e6f1 100644 --- a/src/autodoc2/config.py +++ b/src/autodoc2/config.py @@ -490,7 +490,7 @@ class Config: metadata={ "help": ( "The filename of the index file, " - "relative to the output directory (in POSIX format)." + "relative to `autodocs2_output_dir`(in POSIX format)." ), "sphinx_type": str, "category": "render", From 41be7a4e5c4be0e2fba46df3a1d954cd50a2088a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 13 May 2024 09:52:23 +0000 Subject: [PATCH 4/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/autodoc2/sphinx/extension.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/autodoc2/sphinx/extension.py b/src/autodoc2/sphinx/extension.py index 53bda01..8eb8229 100644 --- a/src/autodoc2/sphinx/extension.py +++ b/src/autodoc2/sphinx/extension.py @@ -85,7 +85,9 @@ def run_autodoc(app: Sphinx) -> None: top_level=top_level_modules ) index_path = ( - Path(app.srcdir) / PurePosixPath(config.output_dir) / PurePosixPath(config.index_filename) + 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)