sunpy / sunpy-sphinx-theme

A Sphinx theme for SunPy and its affiliated packages.
BSD 2-Clause "Simplified" License
7 stars 14 forks source link

Recent change broke parfive doc build #127

Closed dstansby closed 3 years ago

dstansby commented 3 years ago

Downstream issue is https://github.com/Cadair/parfive/issues/64. Error is:

Theme error:
An error happened in rendering the page api/parfive.Downloader.
Reason: UndefinedError("'str object' has no attribute 'items'")

This bisects to 4005959805e1fb097059d49c0dabc11b7960d94d

dstansby commented 3 years ago

Full traceback is

Traceback (most recent call last):
  File "/Users/dstansby/miniconda3/envs/dev/lib/python3.9/site-packages/sphinx/builders/html/__init__.py", line 1022, in handle_page
    output = self.templates.render(templatename, ctx)
  File "/Users/dstansby/miniconda3/envs/dev/lib/python3.9/site-packages/sphinx/jinja2glue.py", line 192, in render
    return self.environment.get_template(template).render(context)
  File "/Users/dstansby/miniconda3/envs/dev/lib/python3.9/site-packages/jinja2/environment.py", line 1090, in render
    self.environment.handle_exception()
  File "/Users/dstansby/miniconda3/envs/dev/lib/python3.9/site-packages/jinja2/environment.py", line 832, in handle_exception
    reraise(*rewrite_traceback_stack(source=source))
  File "/Users/dstansby/miniconda3/envs/dev/lib/python3.9/site-packages/jinja2/_compat.py", line 28, in reraise
    raise value.with_traceback(tb)
  File "/Users/dstansby/miniconda3/envs/dev/lib/python3.9/site-packages/sphinx/themes/basic/page.html", line 10, in top-level template code
    {%- extends "layout.html" %}
  File "/Users/dstansby/miniconda3/envs/dev/lib/python3.9/site-packages/sunpy_sphinx_theme/sunpy/layout.html", line 23, in top-level template code
    {{ (seo_description or theme_seo_description )|striptags }}
  File "/Users/dstansby/miniconda3/envs/dev/lib/python3.9/site-packages/sphinx_bootstrap_theme/bootstrap/../bootstrap/layout.html", line 42, in top-level template code
    {%- include sidebartemplate %}
  File "/Users/dstansby/miniconda3/envs/dev/lib/python3.9/site-packages/sphinx/themes/basic/../basic/layout.html", line 174, in top-level template code
    {%- block content %}
  File "/Users/dstansby/miniconda3/envs/dev/lib/python3.9/site-packages/sphinx_bootstrap_theme/bootstrap/../bootstrap/layout.html", line 71, in block "content"
    {%- block sidebar1 %}{{ bsidebar() }}{% endblock %}
  File "/Users/dstansby/miniconda3/envs/dev/lib/python3.9/site-packages/sphinx_bootstrap_theme/bootstrap/../bootstrap/layout.html", line 71, in block "sidebar1"
    {%- block sidebar1 %}{{ bsidebar() }}{% endblock %}
  File "/Users/dstansby/miniconda3/envs/dev/lib/python3.9/site-packages/jinja2/sandbox.py", line 462, in call
    return __context.call(__obj, *args, **kwargs)
  File "/Users/dstansby/miniconda3/envs/dev/lib/python3.9/site-packages/jinja2/runtime.py", line 679, in _invoke
    rv = self._func(*arguments)
  File "/Users/dstansby/miniconda3/envs/dev/lib/python3.9/site-packages/sphinx_bootstrap_theme/bootstrap/../bootstrap/layout.html", line 30, in template
    {%- include sidebartemplate %}
  File "/Users/dstansby/miniconda3/envs/dev/lib/python3.9/site-packages/sunpy_sphinx_theme/sunpy/docsidebar.html", line 3, in top-level template code
    {% for config_prefix, config_depth in theme_page_toctree_depths.items() %}
  File "/Users/dstansby/miniconda3/envs/dev/lib/python3.9/site-packages/jinja2/sandbox.py", line 460, in call
    if not __self.is_safe_callable(__obj):
  File "/Users/dstansby/miniconda3/envs/dev/lib/python3.9/site-packages/jinja2/sandbox.py", line 360, in is_safe_callable
    getattr(obj, "unsafe_callable", False) or getattr(obj, "alters_data", False)
jinja2.exceptions.UndefinedError: 'str object' has no attribute 'items'

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

Traceback (most recent call last):
  File "/Users/dstansby/miniconda3/envs/dev/lib/python3.9/site-packages/sphinx/cmd/build.py", line 280, in build_main
    app.build(args.force_all, filenames)
  File "/Users/dstansby/miniconda3/envs/dev/lib/python3.9/site-packages/sphinx/application.py", line 352, in build
    self.builder.build_update()
  File "/Users/dstansby/miniconda3/envs/dev/lib/python3.9/site-packages/sphinx/builders/__init__.py", line 296, in build_update
    self.build(to_build,
  File "/Users/dstansby/miniconda3/envs/dev/lib/python3.9/site-packages/sphinx/builders/__init__.py", line 360, in build
    self.write(docnames, list(updated_docnames), method)
  File "/Users/dstansby/miniconda3/envs/dev/lib/python3.9/site-packages/sphinx/builders/__init__.py", line 534, in write
    self._write_serial(sorted(docnames))
  File "/Users/dstansby/miniconda3/envs/dev/lib/python3.9/site-packages/sphinx/builders/__init__.py", line 544, in _write_serial
    self.write_doc(docname, doctree)
  File "/Users/dstansby/miniconda3/envs/dev/lib/python3.9/site-packages/sphinx/builders/html/__init__.py", line 603, in write_doc
    self.handle_page(docname, ctx, event_arg=doctree)
  File "/Users/dstansby/miniconda3/envs/dev/lib/python3.9/site-packages/sphinx/builders/html/__init__.py", line 1029, 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/parfive.Downloader.
Reason: UndefinedError("'str object' has no attribute 'items'")
kapooramit commented 2 years ago

@nabobalis : I am facing the same error today with read the docs theme customizations I have done. What did I do wrong? In the dev environment - it works fine but when installed in different environment to different project, I get this error...

nabobalis commented 2 years ago

@nabobalis : I am facing the same error today with read the docs theme customizations I have done. What did I do wrong? In the dev environment - it works fine but when installed in different environment to different project, I get this error...

What error and where is it happening?

kapooramit commented 2 years ago

When I run make html in a project to create HTML, the last stage as shown below throws this error. I am using a customized version of https://github.com/readthedocs/sphinx_rtd_theme theme from latest release.

looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [  0%] Python_1to5_Converter/index
Theme error:
An error happened in rendering the page Python_2to3_Converter/index.
Reason: UndefinedError("'str object' has no attribute 'items'")
nabobalis commented 2 years ago

Does it use this theme?

What project are you building?

nabobalis commented 2 years ago

If I recall, we had to add:

    html_theme_options = {
        "page_toctree_depths": {}
    }

to work around it. But its been a very long time now.

kapooramit commented 2 years ago

Thanks. I just tried this change but no go. No, I am using a custom version of RTD theme....

nabobalis commented 2 years ago

You will need to figure out what changes you made to your custom theme that caused it to happen.

kapooramit commented 2 years ago

Figured out. Man!! I disabled the newly added two options to theme.conf and error was gone. Still not sure why.. The options worked in dev environment just fine.

Thank you!!

nabobalis commented 2 years ago

That is good news.