Skip to content

Commit abfe718

Browse files
authored
Merge pull request #3286 from sommersoft/docs_build_pdf
Build PDF Docs on RTD
2 parents 19706a7 + e0fd85b commit abfe718

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

.github/workflows/build.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
- name: Install deps
3737
run: |
3838
sudo apt-get install -y eatmydata
39-
sudo eatmydata apt-get install -y gettext librsvg2-bin mingw-w64
39+
sudo eatmydata apt-get install -y gettext librsvg2-bin mingw-w64 latexmk texlive-fonts-recommended texlive-latex-recommended texlive-latex-extra
4040
pip install requests sh click setuptools cpp-coveralls "Sphinx<4" sphinx-rtd-theme recommonmark sphinx-autoapi sphinxcontrib-svg2pdfconverter polib pyyaml astroid isort black awscli
4141
- name: Versions
4242
run: |
@@ -73,12 +73,19 @@ jobs:
7373
with:
7474
name: stubs
7575
path: circuitpython-stubs*
76-
- name: Docs
76+
- name: Test Documentation Build (HTML)
7777
run: sphinx-build -E -W -b html -D version=${{ env.CP_VERSION }} -D release=${{ env.CP_VERSION }} . _build/html
7878
- uses: actions/upload-artifact@v2
7979
with:
8080
name: docs
8181
path: _build/html
82+
- name: Test Documentation Build (LaTeX/PDF)
83+
run: |
84+
make latexpdf
85+
- uses: actions/upload-artifact@v2
86+
with:
87+
name: docs
88+
path: _build/latex
8289
- name: Translations
8390
run: make check-translate
8491
- name: New boards check

.readthedocs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ submodules:
1212
include:
1313
- extmod/ulab
1414

15+
formats:
16+
- pdf
17+
1518
python:
1619
version: 3
1720
install:

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)