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

3.5.4-->4.0.0 sphinx + sphinx-websupport: #9201

Closed
Mathiasdm opened this issue May 10, 2021 · 0 comments
Closed

3.5.4-->4.0.0 sphinx + sphinx-websupport: #9201

Mathiasdm opened this issue May 10, 2021 · 0 comments

Comments

@Mathiasdm
Copy link

Mathiasdm commented May 10, 2021

Describe the bug
We get a stacktrace when trying to WebSupport(srcdir=,
builddir=,
docroot='pages',
storage=storage_backend).build()
Our storage_backend is a dummy backend.

  File "./test.py", line 48, in <module>
    support.build()
  File "/repo/mdemare/tmp/sphinxtest/env/lib/python3.6/site-packages/sphinxcontrib/websupport/core.py", line 144, in build
    app.build()
  File "/repo/mdemare/tmp/sphinxtest/env/lib/python3.6/site-packages/sphinx/application.py", line 350, in build
    self.builder.build_update()
  File "/repo/mdemare/tmp/sphinxtest/env/lib/python3.6/site-packages/sphinx/builders/__init__.py", line 294, in build_update
    len(to_build))
  File "/repo/mdemare/tmp/sphinxtest/env/lib/python3.6/site-packages/sphinx/builders/__init__.py", line 356, in build
    self.write(docnames, list(updated_docnames), method)
  File "/repo/mdemare/tmp/sphinxtest/env/lib/python3.6/site-packages/sphinx/builders/__init__.py", line 530, in write
    self._write_serial(sorted(docnames))
  File "/repo/mdemare/tmp/sphinxtest/env/lib/python3.6/site-packages/sphinx/builders/__init__.py", line 540, in _write_serial
    self.write_doc(docname, doctree)
  File "/repo/mdemare/tmp/sphinxtest/env/lib/python3.6/site-packages/sphinxcontrib/websupport/builder.py", line 102, in write_doc
    self.handle_page(docname, ctx, event_arg=doctree)
  File "/repo/mdemare/tmp/sphinxtest/env/lib/python3.6/site-packages/sphinxcontrib/websupport/builder.py", line 167, in handle_page
    templatename, event_arg)
  File "/repo/mdemare/tmp/sphinxtest/env/lib/python3.6/site-packages/sphinxcontrib/websupport/builder.py", line 156, in _render_page
    template_module = template.make_module(ctx)
  File "/repo/mdemare/tmp/sphinxtest/env/lib/python3.6/site-packages/jinja2/environment.py", line 1155, in make_module
    return TemplateModule(self, self.new_context(vars, shared, locals))
  File "/repo/mdemare/tmp/sphinxtest/env/lib/python3.6/site-packages/jinja2/environment.py", line 1238, in __init__
    body_stream = list(template.root_render_func(context))
  File "/repo/mdemare/tmp/sphinxtest/env/lib/python3.6/site-packages/sphinx/themes/basic/page.html", line 15, in root
  File "/repo/mdemare/tmp/sphinxtest/env/lib/python3.6/site-packages/alabaster/layout.html", line 58, in root
    </div>
  File "/repo/mdemare/tmp/sphinxtest/env/lib/python3.6/site-packages/sphinx/themes/basic/../basic/layout.html", line 257, in root
  File "/repo/mdemare/tmp/sphinxtest/env/lib/python3.6/site-packages/sphinx/themes/basic/../basic/layout.html", line 410, in block_css
  File "/repo/mdemare/tmp/sphinxtest/env/lib/python3.6/site-packages/jinja2/sandbox.py", line 462, in call
    return __context.call(__obj, *args, **kwargs)
  File "/repo/mdemare/tmp/sphinxtest/env/lib/python3.6/site-packages/jinja2/runtime.py", line 290, in call
    return __obj(*args, **kwargs)
  File "/repo/mdemare/tmp/sphinxtest/env/lib/python3.6/site-packages/jinja2/runtime.py", line 675, in __call__
    return self._invoke(arguments, autoescape)
  File "/repo/mdemare/tmp/sphinxtest/env/lib/python3.6/site-packages/jinja2/runtime.py", line 679, in _invoke
    rv = self._func(*arguments)
  File "/repo/mdemare/tmp/sphinxtest/env/lib/python3.6/site-packages/sphinx/themes/basic/../basic/layout.html", line 211, in macro
    {%- endblock %}
  File "/repo/mdemare/tmp/sphinxtest/env/lib/python3.6/site-packages/jinja2/sandbox.py", line 460, in call
    if not __self.is_safe_callable(__obj):
  File "/repo/mdemare/tmp/sphinxtest/env/lib/python3.6/site-packages/jinja2/sandbox.py", line 360, in is_safe_callable
    getattr(obj, "unsafe_callable", False) or getattr(obj, "alters_data", False)
  File "/repo/mdemare/tmp/sphinxtest/env/lib/python3.6/site-packages/jinja2/runtime.py", line 753, in __getattr__
    return self._fail_with_undefined_error()
  File "/repo/mdemare/tmp/sphinxtest/env/lib/python3.6/site-packages/jinja2/runtime.py", line 747, in _fail_with_undefined_error
    raise self._undefined_exception(self._undefined_message)
jinja2.exceptions.UndefinedError: 'css_tag' is undefined

To Reproduce
Steps to reproduce the behavior:

virtualenv env
source env/bin/activate
pip install sphinx==4.0.0 sphinxcontrib-websupport
chmod +x test.py
./test.py

Additional files to put in the current directory:

  1. An empty conf.py
  2. index.rst only containing the text 'foo'
  3. test.py:
#!/usr/bin/env python3

import sphinxcontrib.websupport
from sphinxcontrib.websupport import WebSupport

class DummyStorageBackend(sphinxcontrib.websupport.storage.StorageBackend):
    """Sphinx requires a storage backend -- for now, don't use an actual one as we don't use the comments"""

    def __init__(self):
        pass

    def pre_build(self):
        pass

    def add_node(self, id, document, source):
        pass

    def has_node(self, id):
        return False

    def post_build(self):
        pass

    def add_comment(self, text, displayed, username, time, proposal, node_id, parent_id, moderator):
        pass

    def delete_comment(self, comment_id, username, moderator):
        pass

    def get_data(self, node_id, username, moderator):
        pass

    def get_metadata(self, docname, moderator):
        pass

    def process_vote(self, comment_id, username, value):
        pass

    def update_username(self, old_username, new_username):
        pass

    def accept_comment(self, comment_id):
        pass


storage_backend = DummyStorageBackend()
support = WebSupport(srcdir=".", builddir="build", docroot="pages", storage=storage_backend)
support.build()

Expected behavior
Successful call of support.build()

Your project
n/a

Screenshots
n/a

Environment info

  • OS: Linux
  • Python version: 3.6
  • Sphinx version: 4.0.0
  • Sphinx extensions: sphinx-websupport
  • Extra tools: [e.g. Browser, tex or something else]

Additional context
Add any other context about the problem here.

  • [e.g. URL or Ticket]
tk0miya added a commit to tk0miya/sphinx that referenced this issue May 10, 2021
@tk0miya tk0miya added this to the 4.0.1 milestone May 10, 2021
tk0miya added a commit that referenced this issue May 10, 2021
Fix #9201: websupport: UndefinedError is raised: 'css_tag' is undefined
@tk0miya tk0miya closed this as completed May 10, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants