Merge pull request #4796 from jfbu/latex_fix_mangled_template_path

Fix broken LateX customization via templates (closes: #4795)
This commit is contained in:
Jean-François B 2018-03-29 19:00:10 +02:00 committed by GitHub
commit 14bef5d8ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 2 deletions

View File

@ -927,8 +927,9 @@ class LaTeXTranslator(nodes.NodeVisitor):
def render(self, template_name, variables):
# type: (unicode, Dict) -> unicode
for template_path in self.builder.config.templates_path:
template = path.join(template_path, template_name)
for template_dir in self.builder.config.templates_path:
template = path.join(self.builder.confdir, template_dir,
template_name)
if path.exists(template):
return LaTeXRenderer().render(template, variables)

View File

@ -0,0 +1 @@
SALUT LES COPAINS

View File

@ -1098,6 +1098,30 @@ def test_latex_table_complex_tables(app, status, warning):
assert actual == expected
@pytest.mark.sphinx('latex', testroot='latex-table',
confoverrides={'templates_path': ['_mytemplates/latex']})
def test_latex_table_custom_template_caseA(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'test.tex').text(encoding='utf8')
assert 'SALUT LES COPAINS' in result
@pytest.mark.sphinx('latex', testroot='latex-table',
confoverrides={'templates_path': ['_mytemplates']})
def test_latex_table_custom_template_caseB(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'test.tex').text(encoding='utf8')
assert 'SALUT LES COPAINS' not in result
@pytest.mark.sphinx('latex', testroot='latex-table')
@pytest.mark.test_params(shared_result='latex-table')
def test_latex_table_custom_template_caseC(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'test.tex').text(encoding='utf8')
assert 'SALUT LES COPAINS' not in result
@pytest.mark.sphinx('latex', testroot='directives-raw')
def test_latex_raw_directive(app, status, warning):
app.builder.build_all()