Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

UndefinedError("'theme_maxdepth' is undefined") after upgrading to sphinx7.2.4 #20

Open
chenkasirer opened this issue Aug 30, 2023 · 0 comments

Comments

@chenkasirer
Copy link
Member

Describe the bug

After upgrading to sphinx==7.2.4 (from 7.1.2) I'm getting an error when trying to generate docs for a COMPAS extension using the theme.

Error is:

Theme error:
An error happened in rendering the page api.
Reason: UndefinedError("'theme_maxdepth' is undefined")

Full trace:

writing output... [  1%] api
[app] emitting event: 'doctree-resolved'(<document: <section "api reference"...>>, 'api')
[app] emitting event: 'html-page-context'('api', 'page.html', {'embedded': False, 'project': 'COMPAS TIMBER', 'release': '0.2.16', 'version':
[app] emitting event: 'build-finished'(ThemeError('An error happened in rendering the page api.\nReason: UndefinedError("\'theme_maxdepth\

Traceback (most recent call last):
  File "C:\Users\ckasirer\.conda\envs\timber\lib\site-packages\sphinx\builders\html\__init__.py", line 1121, in handle_page
    output = self.templates.render(templatename, ctx)
  File "C:\Users\ckasirer\.conda\envs\timber\lib\site-packages\sphinx\jinja2glue.py", line 200, in render
    return self.environment.get_template(template).render(context)
  File "C:\Users\ckasirer\.conda\envs\timber\lib\site-packages\jinja2\environment.py", line 1301, in render
    self.environment.handle_exception()
  File "C:\Users\ckasirer\.conda\envs\timber\lib\site-packages\jinja2\environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "C:\Users\ckasirer\.conda\envs\timber\lib\site-packages\sphinx\themes\basic\page.html", line 10, in top-level template code
    {%- extends "layout.html" %}
  File "C:\Users\ckasirer\.conda\envs\timber\lib\site-packages\sphinx_compas_theme\compaspkg\layout.html", line 134, in top-level template code
    {% set toctree = toctree(maxdepth=theme_maxdepth, titles_only=True, collapse=False, includehidden=True) %}
  File "C:\Users\ckasirer\.conda\envs\timber\lib\site-packages\jinja2\sandbox.py", line 393, in call
    return __context.call(__obj, *args, **kwargs)
  File "C:\Users\ckasirer\.conda\envs\timber\lib\site-packages\sphinx\builders\html\__init__.py", line 1048, in <lambda>
    ctx['toctree'] = lambda **kwargs: self._get_local_toctree(pagename, **kwargs)
  File "C:\Users\ckasirer\.conda\envs\timber\lib\site-packages\sphinx\builders\html\__init__.py", line 946, in _get_local_toctree
    toctree = global_toctree_for_doc(self.env, docname, self, collapse=collapse, **kwargs)
  File "C:\Users\ckasirer\.conda\envs\timber\lib\site-packages\sphinx\environment\adapters\toctree.py", line 86, in global_toctree_for_doc
    maxdepth=int(maxdepth),
jinja2.exceptions.UndefinedError: 'theme_maxdepth' is undefined

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

Traceback (most recent call last):
  File "C:\Users\ckasirer\.conda\envs\timber\lib\site-packages\sphinx\cmd\build.py", line 298, in build_main
    app.build(args.force_all, args.filenames)
  File "C:\Users\ckasirer\.conda\envs\timber\lib\site-packages\sphinx\application.py", line 355, in build
    self.builder.build_update()
  File "C:\Users\ckasirer\.conda\envs\timber\lib\site-packages\sphinx\builders\__init__.py", line 293, in build_update
    self.build(to_build,
  File "C:\Users\ckasirer\.conda\envs\timber\lib\site-packages\sphinx\builders\__init__.py", line 363, in build
    self.write(docnames, list(updated_docnames), method)
  File "C:\Users\ckasirer\.conda\envs\timber\lib\site-packages\sphinx\builders\__init__.py", line 571, in write
    self._write_serial(sorted(docnames))
  File "C:\Users\ckasirer\.conda\envs\timber\lib\site-packages\sphinx\builders\__init__.py", line 581, in _write_serial
    self.write_doc(docname, doctree)
  File "C:\Users\ckasirer\.conda\envs\timber\lib\site-packages\sphinx\builders\html\__init__.py", line 655, in write_doc
    self.handle_page(docname, ctx, event_arg=doctree)
  File "C:\Users\ckasirer\.conda\envs\timber\lib\site-packages\sphinx\builders\html\__init__.py", line 1128, 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 api.
Reason: UndefinedError("'theme_maxdepth' is undefined")

To Reproduce

Steps to reproduce the behavior:

api.rst

********************************************************************************
API Reference
********************************************************************************

Packages
========

.. toctree::
    :maxdepth: 1
    :titlesonly:

    api/compas_timber
  1. install sphinx==7.2.4
  2. run invoke docs

Expected behavior

Docs generated successfully.

Desktop (please complete the following information):

  • OS: Windows 10
  • Python 3.9

Additional context

There's been some breaking changes in the API starting sphinx 7.2
maybe related to: sphinx-doc/sphinx#11608

gonzalocasas added a commit to compas-dev/compas_invocations that referenced this issue Nov 1, 2023
Going higher than 7.1.2 breaks the sphinx_compas_theme see compas-dev/sphinx_compas_theme#20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant