spatialaudio / nbsphinx

:ledger: Sphinx source parser for Jupyter notebooks
https://nbsphinx.readthedocs.io/
MIT License
450 stars 130 forks source link

Error with pydata-sphinx-theme-0.10.1 #669

Closed verdimrc closed 2 years ago

verdimrc commented 2 years ago

Hi, using nbsphinx with pydata-sphinx-theme-0.10.1 generates this errors below. The one-version before (pydata-sphinx-theme-0.9.0) works just fine.

Traceback (most recent call last):
  File "/venv/myenv-p310/lib/python3.10/site-packages/sphinx/builders/html/__init__.py", line 1095, in handle_page
    output = self.templates.render(templatename, ctx)
  File "/venv/myenv-p310/lib/python3.10/site-packages/sphinx/jinja2glue.py", line 189, in render
    return self.environment.get_template(template).render(context)
  File "/venv/myenv-p310/lib/python3.10/site-packages/jinja2/environment.py", line 1291, in render
    self.environment.handle_exception()
  File "/venv/myenv-p310/lib/python3.10/site-packages/jinja2/environment.py", line 925, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/venv/myenv-p310/lib/python3.10/site-packages/sphinx/themes/basic/page.html", line 10, in top-level template code
    {%- extends "layout.html" %}
  File "/venv/myenv-p310/lib/python3.10/site-packages/pydata_sphinx_theme/theme/pydata_sphinx_theme/layout.html", line 25, in top-level template code
    {% set remove_sidebar_secondary = (meta is defined and meta is not none
  File "/venv/myenv-p310/lib/python3.10/site-packages/sphinx/themes/basic/../basic/layout.html", line 170, in top-level template code
    {%- block content %}
  File "/venv/myenv-p310/lib/python3.10/site-packages/pydata_sphinx_theme/theme/pydata_sphinx_theme/layout.html", line 75, in block 'content'
    {% block docs_navbar %}
  File "/venv/myenv-p310/lib/python3.10/site-packages/pydata_sphinx_theme/theme/pydata_sphinx_theme/layout.html", line 77, in block 'docs_navbar'
    {%- include "sections/header.html" %}
  File "/venv/myenv-p310/lib/python3.10/site-packages/pydata_sphinx_theme/theme/pydata_sphinx_theme/sections/header.html", line 16, in top-level template code
    {% include navbar_item %}
  File "/venv/myenv-p310/lib/python3.10/site-packages/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/navbar-nav.html", line 6, in top-level template code
    {{ generate_header_nav_html(n_links_before_dropdown=theme_header_links_before_dropdown) }}
  File "/venv/myenv-p310/lib/python3.10/site-packages/jinja2/sandbox.py", line 393, in call
    return __context.call(__obj, *args, **kwargs)
  File "/venv/myenv-p310/lib/python3.10/site-packages/pydata_sphinx_theme/__init__.py", line 250, in generate_header_nav_html
    title = app.env.titles[page].astext()
KeyError: 'self'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/venv/myenv-p310/lib/python3.10/site-packages/sphinx/cmd/build.py", line 277, in build_main
    app.build(args.force_all, filenames)
  File "/venv/myenv-p310/lib/python3.10/site-packages/sphinx/application.py", line 349, in build
    self.builder.build_update()
  File "/venv/myenv-p310/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 301, in build_update
    self.build(to_build,
  File "/venv/myenv-p310/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 367, in build
    self.write(docnames, list(updated_docnames), method)
  File "/venv/myenv-p310/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 559, in write
    self._write_serial(sorted(docnames))
  File "/venv/myenv-p310/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 569, in _write_serial
    self.write_doc(docname, doctree)
  File "/venv/myenv-p310/lib/python3.10/site-packages/sphinx/builders/html/__init__.py", line 671, in write_doc
    self.handle_page(docname, ctx, event_arg=doctree)
  File "/venv/myenv-p310/lib/python3.10/site-packages/sphinx/builders/html/__init__.py", line 1102, in handle_page
    raise ThemeError(__("An error happened in rendering the page %s.\nReason: %r") %
sphinx.errors.ThemeError: An error happened in rendering the page auto-notebooks/backtest.
Reason: KeyError('self')
mgeier commented 2 years ago

Does this only happen when nbsphinx is used?

Can you provide a minimal example including source files and config file?

According to the error message, the error originates within the code of pydata_sphinx_theme, but it might well be an unintended interaction with nbsphinx.

verdimrc commented 2 years ago

Hi, looks like you're right this is not from nbsphinx. I opened a new issue (pydata/pydata-sphinx-theme#926), and going to close this one. Many thanks for your help.