mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Test for alternate stylesheets
This commit is contained in:
7
tests/roots/test-stylesheets/_templates/layout.html
Normal file
7
tests/roots/test-stylesheets/_templates/layout.html
Normal file
@@ -0,0 +1,7 @@
|
||||
{% extends "!layout.html" %}
|
||||
{% set css_files = css_files + ["_static/more_persistent.css",
|
||||
{"filename": "_static/more_persistent2.css"},
|
||||
{"filename": "_static/more_default.css", "title": "Default", "alternate": False},
|
||||
{"filename": "_static/more_alternate1.css", "title": "Alternate"},
|
||||
{"filename": "_static/more_alternate2.css", "alternate": True}] %}
|
||||
|
||||
12
tests/roots/test-stylesheets/conf.py
Normal file
12
tests/roots/test-stylesheets/conf.py
Normal file
@@ -0,0 +1,12 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
master_doc = 'index'
|
||||
html_theme = 'classic'
|
||||
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('alternate2.css', alternate=True)
|
||||
|
||||
4
tests/roots/test-stylesheets/index.rst
Normal file
4
tests/roots/test-stylesheets/index.rst
Normal file
@@ -0,0 +1,4 @@
|
||||
test-stylesheets
|
||||
================
|
||||
|
||||
Lorem ipsum dolor
|
||||
@@ -919,3 +919,46 @@ def test_numfig_with_secnum_depth(app, status, warning):
|
||||
|
||||
for xpath, check, be_found in paths:
|
||||
yield check_xpath, etree, fname, xpath, check, be_found
|
||||
|
||||
@gen_with_app(buildername='html', testroot='stylesheets')
|
||||
def test_alternate_stylesheets(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
expects = {
|
||||
'index.html': [
|
||||
(".//link[@href='_static/persistent.css']"
|
||||
"[@rel='stylesheet']", '', True),
|
||||
(".//link[@href='_static/default.css']"
|
||||
"[@rel='stylesheet']"
|
||||
"[@title='Default']", '', True),
|
||||
(".//link[@href='_static/alternate1.css']"
|
||||
"[@rel='alternate stylesheet']"
|
||||
"[@title='Alternate']", '', True),
|
||||
(".//link[@href='_static/alternate2.css']"
|
||||
"[@rel='alternate stylesheet']", '', True),
|
||||
(".//link[@href='_static/more_persistent.css']"
|
||||
"[@rel='stylesheet']", '', True),
|
||||
(".//link[@href='_static/more_persistent2.css']"
|
||||
"[@rel='stylesheet']", '', True),
|
||||
(".//link[@href='_static/more_default.css']"
|
||||
"[@rel='stylesheet']"
|
||||
"[@title='Default']", '', True),
|
||||
(".//link[@href='_static/more_alternate1.css']"
|
||||
"[@rel='alternate stylesheet']"
|
||||
"[@title='Alternate']", '', True),
|
||||
(".//link[@href='_static/more_alternate2.css']"
|
||||
"[@rel='alternate stylesheet']", '', True),
|
||||
],
|
||||
}
|
||||
|
||||
for fname, paths in iteritems(expects):
|
||||
parser = NslessParser()
|
||||
parser.entity.update(html_entities.entitydefs)
|
||||
fp = open(os.path.join(app.outdir, fname), 'rb')
|
||||
try:
|
||||
etree = ET.parse(fp, parser)
|
||||
finally:
|
||||
fp.close()
|
||||
|
||||
for xpath, check, be_found in paths:
|
||||
yield check_xpath, etree, fname, xpath, check, be_found
|
||||
|
||||
Reference in New Issue
Block a user