You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
utilizing template overrides with the sphinx-book-theme results in the error:
Handler <function update_and_remove_templates at 0x000001A18C5BF700> for event 'html-page-context' threw an exception (exception: toggle-primary-sidebar.html)
The root cause was identified as PR #691, which reverted the following changes to __init__.py in PR #566:
app.connect("config-inited", update_general_config) changed to app.connect("builder-inited", update_general_config)
update_general_config parameter config removed (config-inited events issue two parameters)
The Sphinx class (from sphinx-docs) calls config.init_values()after the sphinx-book-theme extension is loaded, causing templates_path to be overridden and the path to sphinx_book_theme/theme/sphinx_book_theme/components lost.
Reproduce the bug
Install sphinx-book-theme add add it to conf.pyextensions
Traceback (most recent call last):
File "C:\Users\hendra11\Code\external\poetry_plugin_constrain.venv\lib\site-packages\sphinx\events.py", line 96, in emit
results.append(listener.handler(self.app, *args))
File "C:\Users\hendra11\Code\external\poetry_plugin_constrain.venv\lib\site-packages\pydata_sphinx_theme_init_.py", line 224, in update_and_remove_templates
context[section] = list(filter(remove_empty_templates, context[section]))
File "C:\Users\hendra11\Code\external\poetry_plugin_constrain.venv\lib\site-packages\pydata_sphinx_theme_init.py", line 219, in _remove_empty_templates
rendered = app.builder.templates.render(tname, context)
File "C:\Users\hendra11\Code\external\poetry_plugin_constrain.venv\lib\site-packages\sphinx\jinja2glue.py", line 196, in render
return self.environment.get_template(template).render(context)
File "C:\Users\hendra11\Code\external\poetry_plugin_constrain.venv\lib\site-packages\jinja2\environment.py", line 1010, in get_template
return self._load_template(name, globals)
File "C:\Users\hendra11\Code\external\poetry_plugin_constrain.venv\lib\site-packages\jinja2\environment.py", line 969, in _load_template
template = self.loader.load(self, name, self.make_globals(globals))
File "C:\Users\hendra11\Code\external\poetry_plugin_constrain.venv\lib\site-packages\jinja2\loaders.py", line 126, in load
source, filename, uptodate = self.get_source(environment, name)
File "C:\Users\hendra11\Code\external\poetry_plugin_constrain.venv\lib\site-packages\sphinx\jinja2glue.py", line 217, in get_source
raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: toggle-primary-sidebar.html
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\hendra11\Code\external\poetry_plugin_constrain.venv\lib\site-packages\sphinx\cmd\build.py", line 285, in build_main
app.build(args.force_all, args.filenames)
File "C:\Users\hendra11\Code\external\poetry_plugin_constrain.venv\lib\site-packages\sphinx\application.py", line 353, in build
self.builder.build_update()
File "C:\Users\hendra11\Code\external\poetry_plugin_constrain.venv\lib\site-packages\sphinx\builders_init_.py", line 311, in build_update
self.build(to_build,
File "C:\Users\hendra11\Code\external\poetry_plugin_constrain.venv\lib\site-packages\sphinx\builders_init_.py", line 378, in build
self.write(docnames, list(updated_docnames), method)
File "C:\Users\hendra11\Code\external\poetry_plugin_constrain.venv\lib\site-packages\sphinx\builders_init_.py", line 586, in write
self.write_serial(sorted(docnames))
File "C:\Users\hendra11\Code\external\poetry_plugin_constrain.venv\lib\site-packages\sphinx\builders_init.py", line 596, in write_serial
self.write_doc(docname, doctree)
File "C:\Users\hendra11\Code\external\poetry_plugin_constrain.venv\lib\site-packages\sphinx\builders\html_init.py", line 672, in write_doc
self.handle_page(docname, ctx, event_arg=doctree)
File "C:\Users\hendra11\Code\external\poetry_plugin_constrain.venv\lib\site-packages\sphinx\builders\html_init_.py", line 1076, in handle_page
newtmpl = self.app.emit_firstresult('html-page-context', pagename,
File "C:\Users\hendra11\Code\external\poetry_plugin_constrain.venv\lib\site-packages\sphinx\application.py", line 481, in emit_firstresult
return self.events.emit_firstresult(event, *args,
File "C:\Users\hendra11\Code\external\poetry_plugin_constrain.venv\lib\site-packages\sphinx\events.py", line 117, in emit_firstresult
for result in self.emit(name, *args, allowed_exceptions=allowed_exceptions):
File "C:\Users\hendra11\Code\external\poetry_plugin_constrain.venv\lib\site-packages\sphinx\events.py", line 107, in emit
raise ExtensionError(__("Handler %r for event %r threw an exception") %
sphinx.errors.ExtensionError: Handler <function update_and_remove_templates at 0x000001B8B89F7AF0> for event 'html-page-context' threw an exception (exception: toggle-primary-sidebar.html)
Extension error (pydata_sphinx_theme):
Handler <function update_and_remove_templates at 0x000001B8B89F7AF0> for event 'html-page-context' threw an exception (exception: toggle-primary-sidebar.html)
Thanks for opening your first issue here! Engagement like this is essential for open source projects! 🤗
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Describe the bug
As noted in:
pydata-sphinx-theme
: Puttingversion-switcher
in Primary Sidebar results in Extension Error #1511utilizing template overrides with the
sphinx-book-theme
results in the error:The root cause was identified as PR #691, which reverted the following changes to
__init__.py
in PR #566:app.connect("config-inited", update_general_config)
changed toapp.connect("builder-inited", update_general_config)
update_general_config
parameterconfig
removed (config-inited
events issue two parameters)The
Sphinx
class (fromsphinx-docs
) callsconfig.init_values()
after thesphinx-book-theme
extension is loaded, causingtemplates_path
to be overridden and the path tosphinx_book_theme/theme/sphinx_book_theme/components
lost.Reproduce the bug
sphinx-book-theme
add add it toconf.py
extensions
sphinx-build -b html src build
Results in the following (see also
pydata-sphinx-theme
Issue #1511):traceback:
Traceback (most recent call last):
File "C:\Users\hendra11\Code\external\poetry_plugin_constrain.venv\lib\site-packages\sphinx\events.py", line 96, in emit
results.append(listener.handler(self.app, *args))
File "C:\Users\hendra11\Code\external\poetry_plugin_constrain.venv\lib\site-packages\pydata_sphinx_theme_init_.py", line 224, in update_and_remove_templates
context[section] = list(filter(remove_empty_templates, context[section]))
File "C:\Users\hendra11\Code\external\poetry_plugin_constrain.venv\lib\site-packages\pydata_sphinx_theme_init.py", line 219, in _remove_empty_templates
rendered = app.builder.templates.render(tname, context)
File "C:\Users\hendra11\Code\external\poetry_plugin_constrain.venv\lib\site-packages\sphinx\jinja2glue.py", line 196, in render
return self.environment.get_template(template).render(context)
File "C:\Users\hendra11\Code\external\poetry_plugin_constrain.venv\lib\site-packages\jinja2\environment.py", line 1010, in get_template
return self._load_template(name, globals)
File "C:\Users\hendra11\Code\external\poetry_plugin_constrain.venv\lib\site-packages\jinja2\environment.py", line 969, in _load_template
template = self.loader.load(self, name, self.make_globals(globals))
File "C:\Users\hendra11\Code\external\poetry_plugin_constrain.venv\lib\site-packages\jinja2\loaders.py", line 126, in load
source, filename, uptodate = self.get_source(environment, name)
File "C:\Users\hendra11\Code\external\poetry_plugin_constrain.venv\lib\site-packages\sphinx\jinja2glue.py", line 217, in get_source
raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: toggle-primary-sidebar.html
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\hendra11\Code\external\poetry_plugin_constrain.venv\lib\site-packages\sphinx\cmd\build.py", line 285, in build_main
app.build(args.force_all, args.filenames)
File "C:\Users\hendra11\Code\external\poetry_plugin_constrain.venv\lib\site-packages\sphinx\application.py", line 353, in build
self.builder.build_update()
File "C:\Users\hendra11\Code\external\poetry_plugin_constrain.venv\lib\site-packages\sphinx\builders_init_.py", line 311, in build_update
self.build(to_build,
File "C:\Users\hendra11\Code\external\poetry_plugin_constrain.venv\lib\site-packages\sphinx\builders_init_.py", line 378, in build
self.write(docnames, list(updated_docnames), method)
File "C:\Users\hendra11\Code\external\poetry_plugin_constrain.venv\lib\site-packages\sphinx\builders_init_.py", line 586, in write
self.write_serial(sorted(docnames))
File "C:\Users\hendra11\Code\external\poetry_plugin_constrain.venv\lib\site-packages\sphinx\builders_init.py", line 596, in write_serial
self.write_doc(docname, doctree)
File "C:\Users\hendra11\Code\external\poetry_plugin_constrain.venv\lib\site-packages\sphinx\builders\html_init.py", line 672, in write_doc
self.handle_page(docname, ctx, event_arg=doctree)
File "C:\Users\hendra11\Code\external\poetry_plugin_constrain.venv\lib\site-packages\sphinx\builders\html_init_.py", line 1076, in handle_page
newtmpl = self.app.emit_firstresult('html-page-context', pagename,
File "C:\Users\hendra11\Code\external\poetry_plugin_constrain.venv\lib\site-packages\sphinx\application.py", line 481, in emit_firstresult
return self.events.emit_firstresult(event, *args,
File "C:\Users\hendra11\Code\external\poetry_plugin_constrain.venv\lib\site-packages\sphinx\events.py", line 117, in emit_firstresult
for result in self.emit(name, *args, allowed_exceptions=allowed_exceptions):
File "C:\Users\hendra11\Code\external\poetry_plugin_constrain.venv\lib\site-packages\sphinx\events.py", line 107, in emit
raise ExtensionError(__("Handler %r for event %r threw an exception") %
sphinx.errors.ExtensionError: Handler <function update_and_remove_templates at 0x000001B8B89F7AF0> for event 'html-page-context' threw an exception (exception: toggle-primary-sidebar.html)
Extension error (pydata_sphinx_theme):
Handler <function update_and_remove_templates at 0x000001B8B89F7AF0> for event 'html-page-context' threw an exception (exception: toggle-primary-sidebar.html)
List your environment
OS:
Windows 10, 20H2
python:
3.8.10
Sphinx:
6.2.1
jinja2:
3.1.2
sphinx-book-theme:
1.0.1
pydata-sphinx-theme:
0.14.1
The text was updated successfully, but these errors were encountered: