Skip to content

Commit 07aa1b4

Browse files
committed
fix(theme): use builder.add_js_file for Sphinx 7+ compatibility
- Bump to 1.2.3. - Register translations.js via builder.add_js_file() instead of mutating builder.script_files. In Sphinx 7+, script_files holds JavaScript objects rather than strings, so the old 'not in' duplicate-guard never matched and the file was re-appended on every build. Signed-off-by: Gabriel Harris-Rouquette <gabizou@me.com>
1 parent ed26feb commit 07aa1b4

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## 1.2.3
4+
5+
- Register `translations.js` via `builder.add_js_file()` instead of appending to
6+
`builder.script_files`. In Sphinx 7+, `script_files` contains `JavaScript`
7+
objects rather than strings, so the old duplicate-guard check no longer
8+
matched and caused the file to be re-appended on every build.
9+
310
## 1.2.2
411

512
- Bump `install_requires` ceiling to `sphinx>=4.5,<10` so the theme installs

src/theme/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION = (1, 2, 2)
1+
VERSION = (1, 2, 3)
22
__version__ = '.'.join(str(v) for v in VERSION)
33

44

src/theme/theme.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ def init(app):
5050
app.config.html_search_language = strip_country(app.config.language)
5151

5252
# Add translations.js for our JavaScript translations
53-
if '_static/translations.js' not in app.builder.script_files:
54-
app.builder.script_files.append('_static/translations.js')
53+
app.builder.add_js_file('translations.js')
5554

5655
app.connect('build-finished', copy_js_translations)
5756

0 commit comments

Comments
 (0)