run: |
set -Eeuo pipefail
# Build docs with the nit-picky option; write warnings to file
- make -C Doc/ PYTHON=../python SPHINXOPTS="--quiet --nitpicky --fail-on-warning --warning-file sphinx-warnings.txt" html
+ make -C Doc/ PYTHON=../python SPHINXOPTS="--quiet --nitpicky --warning-file sphinx-warnings.txt" html
- name: 'Check warnings'
if: github.event_name == 'pull_request'
run: |
# Use "xvfb-run" since some doctest tests open GUI windows
- name: 'Run documentation doctest'
run: xvfb-run make -C Doc/ PYTHON=../python SPHINXERRORHANDLING="--fail-on-warning" doctest
+
+ check-epub:
+ name: 'Check EPUB'
+ runs-on: ubuntu-latest
+ timeout-minutes: 30
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ persist-credentials: false
+ - name: 'Set up Python'
+ uses: actions/setup-python@v5
+ with:
+ python-version: '3'
+ cache: 'pip'
+ cache-dependency-path: 'Doc/requirements.txt'
+ - name: 'Install build dependencies'
+ run: |
+ make -C Doc/ venv
+ python -m pip install epubcheck
+ - name: 'Build EPUB documentation'
+ run: make -C Doc/ PYTHON=../python epub
+ - name: 'Run epubcheck'
+ continue-on-error: true
+ run: epubcheck Doc/build/epub/Python.epub &> Doc/epubcheck.txt
+ - run: cat Doc/epubcheck.txt
+ - name: 'Check for fatal errors in EPUB'
+ run: python Doc/tools/check-epub.py
epub_author = 'Python Documentation Authors'
epub_publisher = 'Python Software Foundation'
+epub_exclude_files = ('index.xhtml', 'download.xhtml')
# index pages are not valid xhtml
# https://github.com/sphinx-doc/sphinx/issues/12359
--- /dev/null
+from pathlib import Path
+
+CPYTHON_ROOT = Path(
+ __file__, # cpython/Doc/tools/check-epub.py
+ '..', # cpython/Doc/tools
+ '..', # cpython/Doc
+ '..', # cpython
+).resolve()
+EPUBCHECK_PATH = CPYTHON_ROOT / 'Doc' / 'epubcheck.txt'
+
+
+def main() -> int:
+ lines = EPUBCHECK_PATH.read_text(encoding='utf-8').splitlines()
+ fatal_errors = [line for line in lines if line.startswith('FATAL')]
+
+ if fatal_errors:
+ err_count = len(fatal_errors)
+ s = 's' * (err_count != 1)
+ print()
+ print(f'Error: epubcheck reported {err_count} fatal error{s}:')
+ print()
+ print('\n'.join(fatal_errors))
+ return 1
+
+ print('Success: no fatal errors found.')
+ return 0
+
+
+if __name__ == '__main__':
+ raise SystemExit(main())