Rewrite and simplify stylesheet handling

Thanks to tk0miya's comment, I learnt one can add stuff to template
blocks, that allows a much simpler stylesheet configuration, considering
that changes at the template level will be more... well, low-level.
Hopefully this is now acceptable.
This commit is contained in:
Jellby
2017-04-15 17:07:33 +02:00
parent 1cfed262d2
commit e59a8028d7
9 changed files with 38 additions and 70 deletions

View File

@@ -1,7 +1,8 @@
{% extends "!layout.html" %}
{% set css_files = css_files + ["_static/more_persistent.css", "_static/more_persistent2.css", "_static/more_default.css", "_static/more_alternate1.css", "_static/more_alternate2.css"] %}
{% set _dummy = css_props.update(
{"_static/more_default.css": {"title": "Default", "alternate": False},
"_static/more_alternate1.css": {"title": "Alternate"},
"_static/more_alternate2.css": {"alternate": True} }
) %}
{%- block csss %}
{{ super() }}
<link rel="stylesheet" href="_static/more_persistent.css" type="text/css" />
<link rel="stylesheet" href="_static/more_default.css" type="text/css" title="Default" />
<link rel="alternate stylesheet" href="_static/more_alternate1.css" type="text/css" title="Alternate" />
<link rel="alternate stylesheet" href="_static/more_alternate2.css" type="text/css" />
{%- endblock %}

View File

@@ -6,7 +6,7 @@ templates_path = ['_templates']
def setup(app):
app.add_stylesheet('persistent.css')
app.add_stylesheet('default.css', title="Default", alternate=False)
app.add_stylesheet('alternate1.css', title="Alternate")
app.add_stylesheet('default.css', title="Default")
app.add_stylesheet('alternate1.css', title="Alternate", alternate=True)
app.add_stylesheet('alternate2.css', alternate=True)

View File

@@ -1181,7 +1181,7 @@ def test_html_inventory(app):
'http://example.com/index.html',
'The basic Sphinx documentation for testing')
@pytest.mark.sphinx('html', testroot='directives-raw')
def test_html_raw_directive(app, status, warning):
app.builder.build_all()
@@ -1194,8 +1194,8 @@ def test_html_raw_directive(app, status, warning):
# with substitution
assert '<p>HTML: abc def ghi</p>' in result
assert '<p>LaTeX: abc ghi</p>' in result
@pytest.mark.parametrize("fname,expect", flat_dict({
'index.html': [
(".//link[@href='_static/persistent.css']"