Skip to content

Commit 8fbb76c

Browse files
jdsalaropre-commit-ci[bot]agoose77
authored
* fixes jupyter-book/jupyter-book#1414 * (use "git restore --staged <file>..." to unstage) modified: .pre-commit-config.yaml modified: sphinx_external_toc/events.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Angus Hollands <[email protected]>
1 parent 31d28ea commit 8fbb76c

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

CONTRIBUTING.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Contributing
2+
3+
`sphinx-external-toc` is part of the executablebooks project, who also are responsible for `jupyter-book`.
4+
5+
We're excited you're here and want to contribute.
6+
7+
The Jupyter Book project is run by a community of people like you, we'd love to have you
8+
help out!
9+
10+
Please take a look at the [Jupyter Book contributor guide](https://jupyterbook.org/en/stable/contribute/intro.html)
11+
which steps you through the codebase and how to contribute to this project.
12+
If you have any questions that aren't answered there, please let us know by
13+
[opening an issue][link_issues]!
14+
15+
Thank you for you interest in contributing ✨

sphinx_external_toc/events.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -322,13 +322,18 @@ def ensure_index_file(app: Sphinx, exception: Optional[Exception]) -> None:
322322
exception is not None
323323
or "html" not in app.builder.format
324324
or app.config.master_doc == "index"
325-
# TODO rewrite the redirect if master_doc has changed since last build
325+
# TODO: rewrite the redirect if master_doc has changed since last build
326326
or index_path.exists()
327327
):
328328
return
329+
329330
root_name = remove_suffix(app.config.master_doc, app.config.source_suffix)
330-
# TODO the other way to do this would be to
331-
# simply copy the contents of the root file? (this method was taken from jupyter-book)
332-
redirect_text = f'<meta http-equiv="Refresh" content="0; url={root_name}.html" />\n'
331+
332+
if app.builder.name == "html":
333+
redirect_url = f"{root_name}.html"
334+
elif app.builder.name == "dirhtml":
335+
redirect_url = f"{root_name}/index.html"
336+
337+
redirect_text = f'<meta http-equiv="Refresh" content="0; url={redirect_url}" />\n'
333338
index_path.write_text(redirect_text, encoding="utf8")
334339
logger.info("[etoc] missing index.html written as redirect to '%s.html'", root_name)

0 commit comments

Comments
 (0)