Use external builders to generate different formats (build.commands)

  • Use zundler to create the HTMLZip version

  • Use SimplePDF to generate the PDF version

  • Use regular sphinx-build -b epub to build ePUB version

Note

This documentation has the flyout menu integrated even when using build.commands. This is because the readthedocs-sphinx-ext extension was manually installed on purpose.


Read the Docs .readthedocs.yaml configuration file used to build this docs.

 1version: 2
 2
 3build:
 4  os: ubuntu-22.04
 5  tools:
 6    python: "3"
 7  commands:
 8    - mkdir --parents $READTHEDOCS_OUTPUT/htmlzip $READTHEDOCS_OUTPUT/pdf $READTHEDOCS_OUTPUT/epub
 9    - pip install -r requirements.txt
10    # HTML
11    - sphinx-build -b html docs/ $READTHEDOCS_OUTPUT/html
12    # HTMLZip
13    - sphinx-build -b zundler docs/ $READTHEDOCS_OUTPUT/$READTHEDOCS_PROJECT
14    - cd $READTHEDOCS_OUTPUT ; zip -r -j htmlzip/$READTHEDOCS_PROJECT.zip $READTHEDOCS_PROJECT
15    # PDF
16    - sphinx-build -M simplepdf docs/ $READTHEDOCS_OUTPUT/
17    - mv $READTHEDOCS_OUTPUT/simplepdf/"Test Builds.pdf" $READTHEDOCS_OUTPUT/pdf/$READTHEDOCS_PROJECT.pdf
18    # EPUB
19    - sphinx-build -b epub docs/ /tmp/epub
20    - mv /tmp/epub/TestBuilds.epub $READTHEDOCS_OUTPUT/epub/$READTHEDOCS_PROJECT.epub
21
22sphinx:
23  configuration: docs/conf.py
24
25python:
26  install:
27    - requirements: requirements.txt

requirements.txt used to build these docs.

 1sphinx-autorun
 2git+https://github.com/AdrianVollmer/Zundler@main#egg=Zundler
 3sphinx-simplepdf
 4sphinx-rtd-theme
 5sphinx<6
 6
 7# Installed to have the flyout and extras
 8readthedocs-sphinx-ext
 9
10# Sphinx docs requirements
11sphinxcontrib-websupport

Sphinx configuration file used to build this docs (see full file),

 1# -*- coding: utf-8 -*-
 2
 3# Default settings
 4project = 'Test Builds'
 5extensions = [
 6    # Read the Docs flyout and extras
 7    'readthedocs_ext.readthedocs',
 8
 9    'sphinx_autorun',
10    'sphinx_simplepdf',
11]
12
13latex_engine = 'xelatex'  # allow us to build Unicode chars
14
15
16# Include all your settings here
17html_theme = 'sphinx_rtd_theme'
18html_static_path = ['_static']

>>> # Build at
>>> import datetime
>>> datetime.datetime.utcnow()  # UTC
datetime.datetime(2023, 6, 8, 7, 48, 7, 216002)