Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jupyter Book version bug with custom templates #635

Open
rafmudaf opened this issue Apr 25, 2023 · 3 comments
Open

Jupyter Book version bug with custom templates #635

rafmudaf opened this issue Apr 25, 2023 · 3 comments
Assignees
Labels
bug Something isn't working documentation
Milestone

Comments

@rafmudaf
Copy link
Collaborator

Jupyter Book latest version fails with custom templates

We use custom templates to compile the API documentation recursively for classes and modules through the _templates directory. This idea was taken from this SO post and incorporated in #514.

Jupyter Book versions greater than 0.13.3 break with this error:

Extension error (pydata_sphinx_theme):
Handler <function update_and_remove_templates at 0x7fdfb0437280> for event 'html-page-context' threw an exception (exception: toggle-primary-sidebar.html)
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/sphinx/events.py", line 94, in emit
    results.append(listener.handler(self.app, *args))
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/pydata_sphinx_theme/__init__.py", line 241, in update_and_remove_templates
    context[section] = list(filter(_remove_empty_templates, context[section]))
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/pydata_sphinx_theme/__init__.py", line 236, in _remove_empty_templates
    rendered = app.builder.templates.render(tname, context)
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/sphinx/jinja2glue.py", line 189, in render
    return self.environment.get_template(template).render(context)
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/jinja2/environment.py", line 1010, in get_template
    return self._load_template(name, globals)
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/jinja2/environment.py", line 969, in _load_template
    template = self.loader.load(self, name, self.make_globals(globals))
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/jinja2/loaders.py", line 126, in load
    source, filename, uptodate = self.get_source(environment, name)
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/sphinx/jinja2glue.py", line 210, in get_source
    raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: toggle-primary-sidebar.html

The bug seems to be described here and fixed here, but then it is again mentioned in a couple of other issues here and here.

Ultimately, this should be addressed one way or another in order to keep up with Jupyter Book and subsequent dependencies like the PyData Sphinx Theme.

How to reproduce

Build the documentation with Jupyter Book greater than version 0.13.3.

@TomaSusi
Copy link

Just ran into this issue. Downgrading is not a great solution.

@rafmudaf
Copy link
Collaborator Author

Just ran into this issue. Downgrading is not a great solution.

@TomaSusi just a heads up that this repository is not related to Jupyter Book, though we do use it for our documentation. Your message will get more eyes from the people working on this bug if you post in an issue such as executablebooks/sphinx-book-theme#729.

@adam-grant-hendry
Copy link

See the root cause analysis in pydata-sphinx-theme #1511 and the corresponding fix in sphinx-book-theme PR #770.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation
Projects
None yet
Development

No branches or pull requests

3 participants