From 21adcf94ca0e09e7fbce21bf87734435520169f2 Mon Sep 17 00:00:00 2001 From: Angus Hollands Date: Tue, 12 Dec 2023 10:09:20 +0000 Subject: [PATCH] FIX: rework 104 to support e.g. PDFHTML (#105) --- sphinx_external_toc/events.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sphinx_external_toc/events.py b/sphinx_external_toc/events.py index aa78fd6..8d468f4 100644 --- a/sphinx_external_toc/events.py +++ b/sphinx_external_toc/events.py @@ -329,12 +329,11 @@ def ensure_index_file(app: Sphinx, exception: Optional[Exception]) -> None: root_name = remove_suffix(app.config.master_doc, app.config.source_suffix) - if app.builder.name == "html": - redirect_url = f"{root_name}.html" - elif app.builder.name == "dirhtml": + if app.builder.name == "dirhtml": redirect_url = f"{root_name}/index.html" else: - return + # Assume a single index for all non dir-HTML builders + redirect_url = f"{root_name}.html" redirect_text = f'\n' index_path.write_text(redirect_text, encoding="utf8")