Skip to content

Commit 5e9c772

Browse files
committed
Control included JavaScript in templates
1 parent fb943ec commit 5e9c772

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

pep_sphinx_extensions/__init__.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,6 @@
1919
}
2020

2121

22-
# Monkeypatch StandaloneHTMLBuilder to not include JS libraries (underscore.js & jQuery)
23-
def init_less_js(self: sphinx.builders.html.StandaloneHTMLBuilder) -> None:
24-
js_files = [
25-
("js/doctools.js", {}),
26-
("language_data.js", {}),
27-
*self.app.registry.js_files,
28-
*self.get_builder_config("js_files", default="html")
29-
]
30-
for filename, attrs in js_files:
31-
self.add_js_file(filename, **attrs)
32-
33-
3422
def copy_theme_static_override(self: sphinx.builders.html.StandaloneHTMLBuilder, _: dict) -> None:
3523
if self.theme:
3624
source = pathlib.Path(self.theme.themedir, "static")
@@ -39,7 +27,6 @@ def copy_theme_static_override(self: sphinx.builders.html.StandaloneHTMLBuilder,
3927
shutil.rmtree(dest / "templates", ignore_errors=True)
4028

4129

42-
sphinx.builders.html.StandaloneHTMLBuilder.init_js_files = init_less_js
4330
sphinx.builders.html.StandaloneHTMLBuilder.copy_theme_static_files = copy_theme_static_override
4431
# Cache pygments formatters
4532
sphinx.highlighting.PygmentsBridge.get_formatter = functools.cache(sphinx.highlighting.PygmentsBridge.get_formatter)

pep_sphinx_extensions/theme/static/templates/layout.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
<link rel="stylesheet" href="{{ pathto('_static/pygments.css', 1) }}" type="text/css" />
1515
{%- endblock %}
1616

17+
{%- block scripts %}
18+
<script src="{{ pathto('_static/js/doctools.js', 1) }}"></script>
19+
{%- endblock %}
20+
1721
{%- block body_tag %}<body class="python pages pep-page">{% endblock %}
1822
{%- block header %}<header style="height: 219px; background-color: #2b5b84;"></header>{% endblock %}
1923
{%- block relbar1 %}{% endblock %}

0 commit comments

Comments
 (0)