Skip to content

Commit 8fd4373

Browse files
authored
Merge pull request #9546 from tk0miya/9267_JS_loaded_twice
Fix #9267: html theme: CSS and JS files added by theme were loaded twice
2 parents 8afe6ed + 3e5729b commit 8fd4373

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Bugs fixed
3434
* #9481: cpp domain: some warnings contain non-existing filenames
3535
* #9456: html search: abbreation marks are inserted to the search result if
3636
failed to fetch the content of the page
37+
* #9267: html theme: CSS and JS files added by theme were loaded twice
3738

3839
Testing
3940
--------

sphinx/builders/html/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,13 +287,14 @@ def init_highlighter(self) -> None:
287287

288288
if dark_style is not None:
289289
self.dark_highlighter = PygmentsBridge('html', dark_style)
290-
self.add_css_file('pygments_dark.css',
291-
media='(prefers-color-scheme: dark)',
292-
id='pygments_dark_css')
290+
self.app.add_css_file('pygments_dark.css',
291+
media='(prefers-color-scheme: dark)',
292+
id='pygments_dark_css')
293293
else:
294294
self.dark_highlighter = None
295295

296296
def init_css_files(self) -> None:
297+
self.css_files = []
297298
self.add_css_file('pygments.css', priority=200)
298299
self.add_css_file(self._get_style_filename(), priority=200)
299300

@@ -311,6 +312,7 @@ def add_css_file(self, filename: str, **kwargs: Any) -> None:
311312
self.css_files.append(Stylesheet(filename, **kwargs))
312313

313314
def init_js_files(self) -> None:
315+
self.script_files = []
314316
self.add_js_file('documentation_options.js', id="documentation_options",
315317
data_url_root='', priority=200)
316318
self.add_js_file('jquery.js', priority=200)

0 commit comments

Comments
 (0)