Skip to content

Commit ffffccf

Browse files
committed
docs/rstjinja.py: add jinja processing for building latex (pdf) docs
1 parent a28d0f6 commit ffffccf

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

docs/rstjinja.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,28 @@ def rstjinja(app, docname, source):
66
Render our pages as a jinja template for fancy templating goodness.
77
"""
88
# Make sure we're outputting HTML
9-
if app.builder.format != 'html':
9+
if app.builder.format not in ("html", "latex"):
1010
return
1111

1212
# we only want our one jinja template to run through this func
1313
if "shared-bindings/support_matrix" not in docname:
1414
return
1515

16-
src = source[0]
16+
src = rendered = source[0]
1717
print(docname)
18-
rendered = app.builder.templates.render_string(
19-
src, app.config.html_context
20-
)
18+
19+
if app.builder.format == "html":
20+
rendered = app.builder.templates.render_string(
21+
src, app.config.html_context
22+
)
23+
else:
24+
from sphinx.util.template import BaseRenderer
25+
renderer = BaseRenderer()
26+
rendered = renderer.render_string(
27+
src,
28+
app.config.html_context
29+
)
30+
2131
source[0] = rendered
2232

2333
def setup(app):

0 commit comments

Comments
 (0)