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

Theme style undefined #13429

Closed
TriangleBear opened this issue Mar 13, 2025 · 8 comments · Fixed by #13443
Closed

Theme style undefined #13429

TriangleBear opened this issue Mar 13, 2025 · 8 comments · Fixed by #13443
Labels

Comments

@TriangleBear
Copy link

TriangleBear commented Mar 13, 2025

BUG

When I'm switching to sphinx-typlog-theme specifically it keeps on getting an error

File "C:\xampp\htdocs\docs\Lib\site-packages\sphinx\builders\html\__init__.py", line 1228, in handle_page
        raise ThemeError(msg) from exc
    sphinx.errors.ThemeError: An error happened in rendering the page content/database.
    Reason: UndefinedError("'style' is undefined")

I still don't get why is that.

How to Reproduce

When I installed the theme sphinx-typlog-theme, and apply it to the sphinx html_theme it keeps on having that error.

Environment Information

Versions
========

* Platform:         win32; (Windows-11-10.0.26100-SP0)
* Python version:   3.13.2 (CPython)
* Sphinx version:   8.2.3
* Docutils version: 0.21.2
* Jinja2 version:   3.1.6
* Pygments version: 2.19.1

Last Messages
=============

    Writing evaluated template result to C:\xampp\htdocs\docs\build\html\_static\language_data.js
    Writing evaluated template result to C:\xampp\htdocs\docs\build\html\_static\theme.css
    copying static files: done
    copying extra files...
    copying extra files: done
    copying assets: done

    writing output... [ 14%]
    content/database

Loaded Extensions
=================

* sphinx.ext.mathjax (8.2.3)
* alabaster (1.0.0)
* sphinxcontrib.applehelp (2.0.0)
* sphinxcontrib.devhelp (2.0.0)
* sphinxcontrib.htmlhelp (2.1.0)
* sphinxcontrib.serializinghtml (2.0.0)
* sphinxcontrib.qthelp (2.0.0)
* myst_parser (4.0.1)
* sphinx_typlog_theme (0.8.0)

Traceback
=========

    Traceback (most recent call last):
      File "C:\xampp\htdocs\docs\Lib\site-packages\sphinx\builders\html\__init__.py", line 1212, in handle_page
        output = self.templates.render(templatename, ctx)
      File "C:\xampp\htdocs\docs\Lib\site-packages\sphinx\jinja2glue.py", line 217, in render
        return self.environment.get_template(template).render(context)
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
      File "C:\xampp\htdocs\docs\Lib\site-packages\jinja2\environment.py", line 1295, in render
        self.environment.handle_exception()
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
      File "C:\xampp\htdocs\docs\Lib\site-packages\jinja2\environment.py", line 942, in handle_exception
        raise rewrite_traceback_stack(source=source)
      File "C:\xampp\htdocs\docs\Lib\site-packages\sphinx_typlog_theme\page.html", line 21, in top-level template code
        <meta property="og:image" content="{{ src }}">
        ^^^^^^^^^^^^^^^^^^^^^
      File "C:\xampp\htdocs\docs\Lib\site-packages\sphinx_typlog_theme\layout.html", line 29, in top-level template code
        <link rel="stylesheet" href="{{ pathto('_static/' + style, 1) }}?v={{ theme_version }}" type="text/css" />
        ^^^^^^^^^^^^^^^^^^^^^^^
    jinja2.exceptions.UndefinedError: 'style' is undefined
    
    The above exception was the direct cause of the following exception:
    
    Traceback (most recent call last):
      File "C:\xampp\htdocs\docs\Lib\site-packages\sphinx\cmd\build.py", line 432, in build_main
        app.build(args.force_all, args.filenames)
        ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\xampp\htdocs\docs\Lib\site-packages\sphinx\application.py", line 426, in build
        self.builder.build_update()
        ~~~~~~~~~~~~~~~~~~~~~~~~~^^
      File "C:\xampp\htdocs\docs\Lib\site-packages\sphinx\builders\__init__.py", line 375, in build_update
        self.build(
        ~~~~~~~~~~^
            to_build,
            ^^^^^^^^^
        ...<2 lines>...
            method='update',
            ^^^^^^^^^^^^^^^^
        )
        ^
      File "C:\xampp\htdocs\docs\Lib\site-packages\sphinx\builders\__init__.py", line 454, in build
        self.write(docnames, updated_docnames, method)
        ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\xampp\htdocs\docs\Lib\site-packages\sphinx\builders\__init__.py", line 735, in write
        self.write_documents(docnames)
        ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
      File "C:\xampp\htdocs\docs\Lib\site-packages\sphinx\builders\__init__.py", line 749, in write_documents
        self._write_serial(sorted_docnames)
        ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
      File "C:\xampp\htdocs\docs\Lib\site-packages\sphinx\builders\__init__.py", line 768, in _write_serial
        self.write_doc(docname, doctree)
        ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
      File "C:\xampp\htdocs\docs\Lib\site-packages\sphinx\builders\html\__init__.py", line 677, in write_doc
        self.handle_page(docname, ctx, event_arg=doctree)
        ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\xampp\htdocs\docs\Lib\site-packages\sphinx\builders\html\__init__.py", line 1228, in handle_page
        raise ThemeError(msg) from exc
    sphinx.errors.ThemeError: An error happened in rendering the page content/database.
    Reason: UndefinedError("'style' is undefined")

Sphinx extensions

extensions = [
    'myst_parser'
]

Additional context

No response

@AA-Turner
Copy link
Member

Did you fix this @TriangleBear?

A

@TriangleBear
Copy link
Author

TriangleBear commented Mar 16, 2025

@AA-Turner What I did is to change the theme to sphinx-book-theme, previously the theme I was using was the piccolo-theme.
I still don't know what it does so I just change the theme.

I'll find the duplicate of this in a bit.

@TriangleBear TriangleBear reopened this Mar 16, 2025
@TriangleBear
Copy link
Author

@AA-Turner here it is duplicate issue

@mgeier
Copy link
Contributor

mgeier commented Mar 16, 2025

See also #11931.

@TriangleBear
Copy link
Author

Does it hurt if some of use work on this?
I'm really interested in look into the codebase and work on this in a long shot. This is making other devs frustrated and I don't like seeing a bit of bad fire in that sense, but mind you I'm still starting and this might be a good way to understand more about the error. For the #11931 lot of the devs that are using themes are not really getting maintained that much. Is this a good opportunity to understand the codebase more? and will I get better in analyzing it as well?

@AA-Turner
Copy link
Member

I welcome efforts to provide a better error message. We are unlikely to revert the deprecations and removals discussed in #11931, though. Is the sphinx-typlog-theme maintained?

A

@TriangleBear
Copy link
Author

Is the sphinx-typlog-theme maintained?

As I checked it hasn't been maintained for 4 years

@AA-Turner
Copy link
Member

I have created #13443 to improve the error message.

https://github.com/typlog/sphinx-typlog-theme is actually archived, and suggests using the Shibuya theme instead.

A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants