Skip to content

Commit 9fc4799

Browse files
authored
Do not add HTML mixin if not building html (#2076)
When attempting to build the `latexpdf` target, pydata-sphinx-theme 0.16 currently fails on Sphinx 8.1.3 with: ``` Exception occurred: File "/home/simonspa/venv/lib64/python3.13/site-packages/pydata_sphinx_theme/translator.py", line 41, in visit_table self._table_row_indices.append(0) ^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'BootstrapHTML5Translator' object has no attribute '_table_row_indices' The full traceback has been saved in /tmp/sphinx-err-7w3z72wv.log, if you want to report the issue to the developers. Please also report this if it was a user error, so that a better error message can be provided next time. A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks! make: *** [Makefile:25: latexpdf] Error 1 ``` The issue appears to be that the `BootstrapHTML5Mixin` is added despite the target not being `html`. This PR moves the check for `app.builder.format` to the top level of `setup_translators`. (cc) @stephanlachnit
1 parent 61e4e5f commit 9fc4799

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/pydata_sphinx_theme/translator.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ def setup_translators(app: Sphinx):
8383
behavior and configuration, and _only_ add the extra bootstrap rules.
8484
If we don't detect an HTML-based translator, then we do nothing.
8585
"""
86+
# Do not add the mixin if the builder format is not HTML:
87+
if app.builder.format != "html":
88+
return
89+
8690
if not app.registry.translators.items():
8791
try:
8892
default_translator_class = app.builder.default_translator_class
@@ -101,10 +105,6 @@ def setup_translators(app: Sphinx):
101105
app.set_translator(app.builder.name, translator, override=True)
102106
else:
103107
for name, klass in app.registry.translators.items():
104-
if app.builder.format != "html":
105-
# Skip translators that are not HTML
106-
continue
107-
108108
translator = types.new_class(
109109
"BootstrapHTML5Translator",
110110
(

0 commit comments

Comments
 (0)