-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
layout: allow arbitrary CSS attributes #1101
Conversation
Does feature for other sphinx themes? This is what the basic theme does, does this syntax work?
|
@Blendify thanks for pointing that out! I was not aware of |
The change is good, however it requires sphinx 1.8 but currently we support versions down to 1.6 so this will need to be an if else block see https://github.com/readthedocs/sphinx_rtd_theme/blob/master/sphinx_rtd_theme/layout.html#L59 or wait until #1075. If you use the if else block I will add this to the upcoming 1.0 release. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Meant to request changes
sphinx_rtd_theme/layout.html
Outdated
{%- if css|attr("rel") %} | ||
<link rel="{{ css.rel }}" href="{{ pathto(css.filename, 1) }}" type="text/css"{% if css.title is not none %} title="{{ css.title }}"{% endif %} /> | ||
{%- else %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic here is a bit messed up I'm starting to realize it is a bit more complicated than I originally thought.
<link rel="stylesheet" href="{{ pathto('_static/' + style, 1) }}" type="text/css" />
<link rel="stylesheet" href="{{ pathto('_static/pygments.css', 1) }}" type="text/css" />
{%- for css in css_files %}
{%- if sphinx_version >= "1.8.0" %}
{%- if css|attr("filename") %}
{{ css_tag(css) }}
{%- else %}
<link rel="stylesheet" href="{{ pathto(css, 1) }}" type="text/css" />
{%- endif %}
{%- else %}
{%- if css|attr("rel") %}
<link rel="{{ css.rel }}" href="{{ pathto(css.filename, 1) }}" type="text/css"{% if css.title is not none %} title="{{ css.title }}"{% endif %} />
{%- else %}
<link rel="stylesheet" href="{{ pathto(css, 1) }}" type="text/css" />
{%- endif %}
{%- endif %}
{%- endfor %}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see filename
attribute already present on 1.8.0, so why is the additional check needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure but this is what sphinx does: https://github.com/sphinx-doc/sphinx/blob/3.x/sphinx/themes/basic/layout.html#L97
The case for before 1.8 is to match the template before this commit: sphinx-doc/sphinx@c5d6942
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, should be ready now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Blendify ping
Allow arbirtrary CSS attributes when using app.add_css_file() on Sphinx. It can be useful e.g. to insert `media` or any other attribute. Only supported on Sphinx >= 1.8.0. Signed-off-by: Gerard Marull-Paretas <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good but we are going to hold off until 1.1 release.
It seems to merge is blocked however, maybe because you force pushed a commit |
We still support Sphinx 1.6 in 1.1... but will be dropped in 2.0. See: https://sphinx-rtd-theme.readthedocs.io/en/stable/development.html#release-2-0-0 |
any chance this can be merged? @Blendify |
Note, this was merged in #1519 |
Allow arbitrary CSS attributes when using app.add_css_file() on Sphinx.
It can be useful e.g. to insert
media
or any other attribute. Notethat rel and type are set by default.
Fixes #1100