Skip to content

Commit c9155d7

Browse files
seismanweiji14
andauthored
CI: Build PDF documentation using tectonic (#3765)
Co-authored-by: Wei Ji <[email protected]>
1 parent 17cd463 commit c9155d7

File tree

5 files changed

+30
-5
lines changed

5 files changed

+30
-5
lines changed

.github/workflows/ci_docs.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ jobs:
117117
sphinx-design
118118
sphinx-gallery
119119
sphinx_rtd_theme<3.0
120+
cairosvg
121+
sphinxcontrib-svg2pdfconverter
122+
tectonic
120123
121124
# Download cached remote files (artifacts) from GitHub
122125
- name: Download remote data from GitHub
@@ -135,9 +138,11 @@ jobs:
135138
python -m build --sdist
136139
python -m pip install dist/*
137140
138-
# Build the documentation
139-
- name: Build the documentation
140-
run: make -C doc clean all
141+
- name: Build the HTML documentation
142+
run: make -C doc clean html
143+
144+
- name: Build the PDF documentation
145+
run: make -C doc pdf
141146

142147
- name: Checkout the gh-pages branch
143148
uses: actions/[email protected]

ci/requirements/docs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,6 @@ dependencies:
3232
- sphinx-design
3333
- sphinx-gallery
3434
- sphinx_rtd_theme<3.0
35+
# Dev dependencies (building PDF documentation)
36+
# 'sphinxcontrib-svg2pdfconverter' is required since it's added to `extensions`.
37+
- sphinxcontrib-svg2pdfconverter

doc/Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ help:
1515
@echo " api generate rst source files of API documentation"
1616
@echo " html build the HTML files from the existing rst sources"
1717
@echo " html-noplot build the HTML files without running any examples"
18+
@echo " pdf build the PDF documentation"
1819
@echo " server make a local HTTP server for previewing the built documentation"
1920
@echo " clean clean up built and generated files"
2021

@@ -43,6 +44,14 @@ html-noplot: api
4344
@echo
4445
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
4546

47+
pdf: latex
48+
@echo
49+
@echo "Building PDF via Tectonic."
50+
@echo
51+
tectonic -X compile $(BUILDDIR)/latex/pygmt.tex
52+
@echo
53+
@echo "PDF build finished. The PDF file is in $(BUILDDIR)/latex/pygmt.pdf."
54+
4655
server:
4756
@echo
4857
@echo "Running a server on port 8009."

doc/conf.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,17 @@
2828
"sphinx.ext.autodoc",
2929
"sphinx.ext.autosummary",
3030
"sphinx.ext.coverage",
31-
"sphinx.ext.mathjax",
3231
"sphinx.ext.doctest",
33-
"sphinx.ext.viewcode",
3432
"sphinx.ext.extlinks",
3533
"sphinx.ext.intersphinx",
34+
"sphinx.ext.mathjax",
3635
"sphinx.ext.napoleon",
36+
"sphinx.ext.viewcode",
3737
"sphinx_autodoc_typehints",
3838
"sphinx_copybutton",
3939
"sphinx_design",
4040
"sphinx_gallery.gen_gallery",
41+
"sphinxcontrib.cairosvgconverter",
4142
]
4243

4344
# Suppress warnings
@@ -248,3 +249,6 @@
248249
"github_version": "main",
249250
"commit": commit_link,
250251
}
252+
253+
# Configurations for LaTeX
254+
latex_engine = "xelatex"

environment.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ dependencies:
4444
- sphinx-design
4545
- sphinx-gallery>=0.17.0
4646
- sphinx_rtd_theme<3.0
47+
# Dev dependencies (building PDF documentation)
48+
- cairosvg
49+
- sphinxcontrib-svg2pdfconverter
50+
- tectonic
4751
# Dev dependencies (type hints)
4852
- mypy
4953
- pandas-stubs

0 commit comments

Comments
 (0)