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

HTML cannot build when enable sphinx.ext.viewcode #22

Open
nchelaru opened this issue Dec 20, 2020 · 2 comments
Open

HTML cannot build when enable sphinx.ext.viewcode #22

nchelaru opened this issue Dec 20, 2020 · 2 comments

Comments

@nchelaru
Copy link

Hello!

Thank you for making this theme, it looks great!

It seems that when I enable the sphinx.ext.viewcode extension, the docs HTML will not build, giving this error message:

Theme error:
An error happened in rendering the page _modules/src/main.
Reason: UndefinedError("'metatags' is undefined")
make: *** [html] Error 2

When I disable the extension, the HTMLs build without problem.

I am using v3.4.0 for Sphinx and v0.8.0 for the typlog theme.

Do you have an idea as to why this is happening?

Thank you!

Nancy

@chrizzFTD
Copy link

Hi @nchelaru, have you found a solution for this? I had a similar issue recently, my error was:

generating indices... genindex py-modindex done
highlighting module code... [100%] grill.write

Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/grill/envs/feature-docs_examples/lib/python3.7/site-packages/sphinx/builders/html/__init__.py", line 1044, in handle_page
    output = self.templates.render(templatename, ctx)
  File "/home/docs/checkouts/readthedocs.org/user_builds/grill/envs/feature-docs_examples/lib/python3.7/site-packages/readthedocs_ext/readthedocs.py", line 185, in rtd_render
    content = old_render(template, render_context)
  File "/home/docs/checkouts/readthedocs.org/user_builds/grill/envs/feature-docs_examples/lib/python3.7/site-packages/sphinx/jinja2glue.py", line 196, in render
    return self.environment.get_template(template).render(context)
  File "/home/docs/checkouts/readthedocs.org/user_builds/grill/envs/feature-docs_examples/lib/python3.7/site-packages/jinja2/environment.py", line 1304, in render
    self.environment.handle_exception()
  File "/home/docs/checkouts/readthedocs.org/user_builds/grill/envs/feature-docs_examples/lib/python3.7/site-packages/jinja2/environment.py", line 925, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/home/docs/checkouts/readthedocs.org/user_builds/grill/envs/feature-docs_examples/lib/python3.7/site-packages/sphinx_typlog_theme/page.html", line 21, in top-level template code
    <meta property="og:image" content="{{ src }}">
  File "/home/docs/checkouts/readthedocs.org/user_builds/grill/envs/feature-docs_examples/lib/python3.7/site-packages/sphinx_typlog_theme/layout.html", line 69, in top-level template code
    {%- block extrahead %}{% endblock %}
  File "/home/docs/checkouts/readthedocs.org/user_builds/grill/envs/feature-docs_examples/lib/python3.7/site-packages/sphinx_typlog_theme/page.html", line 30, in block 'extrahead'
    {%- if theme_description and 'name="description"' not in metatags %}
jinja2.exceptions.UndefinedError: 'metatags' is undefined

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

Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/grill/envs/feature-docs_examples/lib/python3.7/site-packages/sphinx/cmd/build.py", line 280, in build_main
    app.build(args.force_all, filenames)
  File "/home/docs/checkouts/readthedocs.org/user_builds/grill/envs/feature-docs_examples/lib/python3.7/site-packages/sphinx/application.py", line 350, in build
    self.builder.build_update()
  File "/home/docs/checkouts/readthedocs.org/user_builds/grill/envs/feature-docs_examples/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 294, in build_update
    len(to_build))
  File "/home/docs/checkouts/readthedocs.org/user_builds/grill/envs/feature-docs_examples/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 359, in build
    self.finish()
  File "/home/docs/checkouts/readthedocs.org/user_builds/grill/envs/feature-docs_examples/lib/python3.7/site-packages/sphinx/builders/html/__init__.py", line 632, in finish
    self.finish_tasks.add_task(self.gen_pages_from_extensions)
  File "/home/docs/checkouts/readthedocs.org/user_builds/grill/envs/feature-docs_examples/lib/python3.7/site-packages/sphinx/util/parallel.py", line 49, in add_task
    res = task_func()
  File "/home/docs/checkouts/readthedocs.org/user_builds/grill/envs/feature-docs_examples/lib/python3.7/site-packages/sphinx/builders/html/__init__.py", line 656, in gen_pages_from_extensions
    self.handle_page(pagename, context, template)
  File "/home/docs/checkouts/readthedocs.org/user_builds/grill/envs/feature-docs_examples/lib/python3.7/site-packages/sphinx/builders/html/__init__.py", line 1052, in handle_page
    (pagename, exc)) from exc
sphinx.errors.ThemeError: An error happened in rendering the page _modules/grill/write.
Reason: UndefinedError("'metatags' is undefined")

This failed on read the docs. However, it was working completely on my local environment. After locking to the same versions I had on my environment, I noticed that the read thedocs build logged:

Collecting Jinja2>=2.3
  Downloading Jinja2-3.0.1-py3-none-any.whl

However, I locally had jinja2==2.11.2.

I gave it a try and locking my docs requirements to jinja2==2.11.2 fixes the issue for me. I didn't look deeper after that.

@BrandoZhang
Copy link

Locking jinja2==2.11.2 does not help in my case. Did I miss anything?

pip list

Package                       Version
----------------------------- -------------------
...
Jinja2                        2.11.2
...
Sphinx                        4.0.2
sphinx-copybutton             0.5.0
sphinx-multiversion           0.2.4
sphinx-typlog-theme           0.8.0
sphinxcontrib-applehelp       1.0.2
sphinxcontrib-devhelp         1.0.2
sphinxcontrib-htmlhelp        2.0.0
sphinxcontrib-jsmath          1.0.1
sphinxcontrib-mermaid         0.7.1
sphinxcontrib-qthelp          1.0.3
sphinxcontrib-serializinghtml 1.1.5

Error context:

Theme error:
An error happened in rendering the page _modules/datasets/base_dataset.
Reason: UndefinedError("'metatags' is undefined")
make: *** [html] Error 2

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

3 participants