mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Support `.jinja` for theme static templates (#11916)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1 @@
|
||||
AU REVOIR, KANIGGETS
|
||||
@@ -0,0 +1,2 @@
|
||||
<!-- testing legacy _t static templates -->
|
||||
<html><project>{{ project | lower | escape }}</project></html>
|
||||
@@ -1391,6 +1391,7 @@ def test_latex_table_custom_template_caseA(app, status, warning):
|
||||
app.build(force_all=True)
|
||||
result = (app.outdir / 'python.tex').read_text(encoding='utf8')
|
||||
assert 'SALUT LES COPAINS' in result
|
||||
assert 'AU REVOIR, KANIGGETS' in result
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='latex-table',
|
||||
|
||||
@@ -109,6 +109,11 @@ def test_nested_zipped_theme(app, status, warning):
|
||||
@pytest.mark.sphinx(testroot='theming', confoverrides={'html_theme': 'staticfiles'})
|
||||
def test_staticfiles(app, status, warning):
|
||||
app.build()
|
||||
assert (app.outdir / '_static' / 'legacytmpl.html').exists()
|
||||
assert (app.outdir / '_static' / 'legacytmpl.html').read_text(encoding='utf8') == (
|
||||
'<!-- testing legacy _t static templates -->\n'
|
||||
'<html><project>python</project></html>'
|
||||
)
|
||||
assert (app.outdir / '_static' / 'staticimg.png').exists()
|
||||
assert (app.outdir / '_static' / 'statictmpl.html').exists()
|
||||
assert (app.outdir / '_static' / 'statictmpl.html').read_text(encoding='utf8') == (
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
from unittest import mock
|
||||
|
||||
from sphinx.jinja2glue import BuiltinTemplateLoader
|
||||
from sphinx.util.fileutil import copy_asset, copy_asset_file
|
||||
from sphinx.util.fileutil import _template_basename, copy_asset, copy_asset_file
|
||||
|
||||
|
||||
class DummyTemplateLoader(BuiltinTemplateLoader):
|
||||
@@ -101,3 +101,13 @@ def test_copy_asset(tmp_path):
|
||||
assert not (destdir / '_static' / 'basic.css').exists()
|
||||
assert (destdir / '_templates' / 'layout.html').exists()
|
||||
assert not (destdir / '_templates' / 'sidebar.html').exists()
|
||||
|
||||
|
||||
def test_template_basename():
|
||||
assert _template_basename('asset.txt') is None
|
||||
assert _template_basename('asset.txt.jinja') == 'asset.txt'
|
||||
assert _template_basename('sidebar.html.jinja') == 'sidebar.html'
|
||||
|
||||
|
||||
def test_legacy_template_basename():
|
||||
assert _template_basename('asset.txt_t') == 'asset.txt'
|
||||
|
||||
Reference in New Issue
Block a user