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

Issue log messages from jinja template #2157

Closed
eli-collins opened this issue Dec 5, 2015 · 1 comment
Closed

Issue log messages from jinja template #2157

eli-collins opened this issue Dec 5, 2015 · 1 comment
Labels
html theme type:proposal a feature suggestion
Milestone

Comments

@eli-collins
Copy link

It'd be helpful if there was a way to call app.warn() / builder.warn() from jinja template (maybe .debug() and .info() as well). This would be particularly helpful for theme development... I've got a .css_t file which does some parsing / numeric calculations, and would like to be able to display a cmdline warning to the user that some of the theme.conf inputs couldn't be parsed / were invalid.

E.g:

{% set theme_var = 'notanumber' %}
{% if not theme_var|float %}
    {{ sphinx_warning("theme_var must non-zero float: %r"|format(theme_var)) }}
{% endif %}

Something further, like an ability to abort compilation with an error message, would be icing, but looking at jinja2glue.py's environment setup, it looked like inserting builder.warn() into the jinja environment wouldn't be hard, presuming there weren't security / design considerations I'm not aware of.

tk0miya added a commit to tk0miya/sphinx that referenced this issue Mar 18, 2018
@tk0miya tk0miya added type:proposal a feature suggestion html theme labels Mar 18, 2018
@tk0miya tk0miya added this to the 1.8 milestone Mar 18, 2018
tk0miya added a commit that referenced this issue Mar 19, 2018
Closes #2157: helper function ``warning()`` for HTML themes is added
@tk0miya
Copy link
Member

tk0miya commented Mar 19, 2018

Fixed by #4751
Thank you for your proposal!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
html theme type:proposal a feature suggestion
Projects
None yet
Development

No branches or pull requests

2 participants