Skip to content

Commit 0529246

Browse files
miss-islingtonm-aciekblurb-it[bot]AA-Turner
authored
[3.13] gh-136155: Docs: check for EPUB fatal errors in CI (GH-134074) (#137538)
Co-authored-by: Maciej Olko <[email protected]> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Adam Turner <[email protected]>
1 parent 74c3805 commit 0529246

File tree

4 files changed

+60
-1
lines changed

4 files changed

+60
-1
lines changed

.github/workflows/reusable-docs.yml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
run: |
6767
set -Eeuo pipefail
6868
# Build docs with the nit-picky option; write warnings to file
69-
make -C Doc/ PYTHON=../python SPHINXOPTS="--quiet --nitpicky --fail-on-warning --warning-file sphinx-warnings.txt" html
69+
make -C Doc/ PYTHON=../python SPHINXOPTS="--quiet --nitpicky --warning-file sphinx-warnings.txt" html
7070
- name: 'Check warnings'
7171
if: github.event_name == 'pull_request'
7272
run: |
@@ -102,3 +102,30 @@ jobs:
102102
# Use "xvfb-run" since some doctest tests open GUI windows
103103
- name: 'Run documentation doctest'
104104
run: xvfb-run make -C Doc/ PYTHON=../python SPHINXERRORHANDLING="--fail-on-warning" doctest
105+
106+
check-epub:
107+
name: 'Check EPUB'
108+
runs-on: ubuntu-latest
109+
timeout-minutes: 30
110+
steps:
111+
- uses: actions/checkout@v4
112+
with:
113+
persist-credentials: false
114+
- name: 'Set up Python'
115+
uses: actions/setup-python@v5
116+
with:
117+
python-version: '3'
118+
cache: 'pip'
119+
cache-dependency-path: 'Doc/requirements.txt'
120+
- name: 'Install build dependencies'
121+
run: |
122+
make -C Doc/ venv
123+
python -m pip install epubcheck
124+
- name: 'Build EPUB documentation'
125+
run: make -C Doc/ PYTHON=../python epub
126+
- name: 'Run epubcheck'
127+
continue-on-error: true
128+
run: epubcheck Doc/build/epub/Python.epub &> Doc/epubcheck.txt
129+
- run: cat Doc/epubcheck.txt
130+
- name: 'Check for fatal errors in EPUB'
131+
run: python Doc/tools/check-epub.py

Doc/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,7 @@
440440

441441
epub_author = 'Python Documentation Authors'
442442
epub_publisher = 'Python Software Foundation'
443+
epub_exclude_files = ('index.xhtml', 'download.xhtml')
443444

444445
# index pages are not valid xhtml
445446
# https://github.com/sphinx-doc/sphinx/issues/12359

Doc/tools/check-epub.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from pathlib import Path
2+
3+
CPYTHON_ROOT = Path(
4+
__file__, # cpython/Doc/tools/check-epub.py
5+
'..', # cpython/Doc/tools
6+
'..', # cpython/Doc
7+
'..', # cpython
8+
).resolve()
9+
EPUBCHECK_PATH = CPYTHON_ROOT / 'Doc' / 'epubcheck.txt'
10+
11+
12+
def main() -> int:
13+
lines = EPUBCHECK_PATH.read_text(encoding='utf-8').splitlines()
14+
fatal_errors = [line for line in lines if line.startswith('FATAL')]
15+
16+
if fatal_errors:
17+
err_count = len(fatal_errors)
18+
s = 's' * (err_count != 1)
19+
print()
20+
print(f'Error: epubcheck reported {err_count} fatal error{s}:')
21+
print()
22+
print('\n'.join(fatal_errors))
23+
return 1
24+
25+
print('Success: no fatal errors found.')
26+
return 0
27+
28+
29+
if __name__ == '__main__':
30+
raise SystemExit(main())
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
We are now checking for fatal errors in EPUB builds in CI.

0 commit comments

Comments
 (0)