Skip to content

Commit

Permalink
Add custom post_build job for PDFs on RTD
Browse files Browse the repository at this point in the history
  • Loading branch information
agriyakhetarpal committed Aug 28, 2023
1 parent a5d3da8 commit bfe7dd4
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ sphinx:
configuration: docs/conf.py
fail_on_warning: false

# PDF builds are disabled here because they are built in a custom fashion
# by extending the RTD build process, see below
formats:
- pdf
- epub
- htmlzip

Expand All @@ -31,6 +32,19 @@ build:
jobs:
post_checkout:
- git fetch --unshallow
# Altered PDF build and upload job, attributed to
# https://stackoverflow.com/a/76992101/14001839
post_build:
- mkdir --parents $READTHEDOCS_OUTPUT/pdf/
# Generate LaTeX files in docs/build/ and doctrees in docs/_build/doctrees, skipping notebooks
- python -m sphinx -T -E -b latex -d docs/_build/doctrees -D language=en docs docs/build/
- cd docs/build/
- cat latexmkrc
# Map non-zero exit codes to zero
- latexmk -r latexmkrc -pdf -f -dvi- -ps- -jobname=pybamm -interaction=nonstopmode || true
# Check if pybamm.pdf exists
- test -f pybamm.pdf && echo "pybamm.pdf exists. Copying source file to $READTHEDOCS_OUTPUT/pdf/."
- cd ../../ && cp "docs/build/pybamm.pdf" $READTHEDOCS_OUTPUT/pdf/

# Optionally declare the Python requirements required to build your docs
python:
Expand Down

0 comments on commit bfe7dd4

Please sign in to comment.