|
19 | 19 | }
|
20 | 20 |
|
21 | 21 |
|
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 |
| - |
| 22 | +# Monkeypatch StandaloneHTMLBuilder to whitelist child theme files only |
34 | 23 | def copy_theme_static_override(self: sphinx.builders.html.StandaloneHTMLBuilder, _: dict) -> None:
|
| 24 | + """Include all files from theme/static except the templates folder.""" |
35 | 25 | if self.theme:
|
36 | 26 | source = pathlib.Path(self.theme.themedir, "static")
|
37 | 27 | dest = pathlib.Path(self.outdir, "_static")
|
38 | 28 | shutil.copytree(source, dest, dirs_exist_ok=True)
|
39 | 29 | shutil.rmtree(dest / "templates", ignore_errors=True)
|
40 | 30 |
|
41 | 31 |
|
42 |
| -sphinx.builders.html.StandaloneHTMLBuilder.init_js_files = init_less_js |
43 | 32 | sphinx.builders.html.StandaloneHTMLBuilder.copy_theme_static_files = copy_theme_static_override
|
44 | 33 | # Cache pygments formatters
|
45 | 34 | sphinx.highlighting.PygmentsBridge.get_formatter = functools.cache(sphinx.highlighting.PygmentsBridge.get_formatter)
|
|
0 commit comments