Skip to content

Commit 624bf52

Browse files
gh-136155: Docs: check for EPUB fatal errors in CI (#134074)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
1 parent a02cf19 commit 624bf52

File tree

4 files changed

+39
-1
lines changed

4 files changed

+39
-1
lines changed

.github/workflows/reusable-docs.yml

Lines changed: 13 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: |
@@ -75,6 +75,18 @@ jobs:
7575
--fail-if-regression \
7676
--fail-if-improved \
7777
--fail-if-new-news-nit
78+
- name: 'Build EPUB documentation'
79+
continue-on-error: true
80+
run: |
81+
set -Eeuo pipefail
82+
make -C Doc/ PYTHON=../python SPHINXOPTS="--quiet" epub
83+
pip install epubcheck
84+
epubcheck Doc/build/epub/Python.epub &> Doc/epubcheck.txt
85+
- name: 'Check for fatal errors in EPUB'
86+
if: github.event_name == 'pull_request'
87+
continue-on-error: true # until gh-136155 is fixed
88+
run: |
89+
python Doc/tools/check-epub.py
7890
7991
# Run "doctest" on HEAD as new syntax doesn't exist in the latest stable release
8092
doctest:

Doc/conf.py

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

449449
epub_author = 'Python Documentation Authors'
450450
epub_publisher = 'Python Software Foundation'
451+
epub_exclude_files = ('index.xhtml', 'download.xhtml')
451452

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

Doc/tools/check-epub.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import sys
2+
from pathlib import Path
3+
4+
5+
def main() -> int:
6+
wrong_directory_msg = "Must run this script from the repo root"
7+
if not Path("Doc").exists() or not Path("Doc").is_dir():
8+
raise RuntimeError(wrong_directory_msg)
9+
10+
with Path("Doc/epubcheck.txt").open(encoding="UTF-8") as f:
11+
messages = [message.split(" - ") for message in f.read().splitlines()]
12+
13+
fatal_errors = [message for message in messages if message[0] == "FATAL"]
14+
15+
if fatal_errors:
16+
print("\nError: must not contain fatal errors:\n")
17+
for error in fatal_errors:
18+
print(" - ".join(error))
19+
20+
return len(fatal_errors)
21+
22+
23+
if __name__ == "__main__":
24+
sys.exit(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)