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>
This commit is contained in:
Maciej Olko
2025-07-15 14:26:24 +02:00
committed by GitHub
parent a02cf19dee
commit 624bf52c83
4 changed files with 39 additions and 1 deletions

View File

@@ -66,7 +66,7 @@ jobs:
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: |
@@ -75,6 +75,18 @@ jobs:
--fail-if-regression \
--fail-if-improved \
--fail-if-new-news-nit
- name: 'Build EPUB documentation'
continue-on-error: true
run: |
set -Eeuo pipefail
make -C Doc/ PYTHON=../python SPHINXOPTS="--quiet" epub
pip install epubcheck
epubcheck Doc/build/epub/Python.epub &> Doc/epubcheck.txt
- name: 'Check for fatal errors in EPUB'
if: github.event_name == 'pull_request'
continue-on-error: true # until gh-136155 is fixed
run: |
python Doc/tools/check-epub.py
# Run "doctest" on HEAD as new syntax doesn't exist in the latest stable release
doctest:

View File

@@ -448,6 +448,7 @@ latex_appendices = ['glossary', 'about', 'license', 'copyright']
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

24
Doc/tools/check-epub.py Normal file
View File

@@ -0,0 +1,24 @@
import sys
from pathlib import Path
def main() -> int:
wrong_directory_msg = "Must run this script from the repo root"
if not Path("Doc").exists() or not Path("Doc").is_dir():
raise RuntimeError(wrong_directory_msg)
with Path("Doc/epubcheck.txt").open(encoding="UTF-8") as f:
messages = [message.split(" - ") for message in f.read().splitlines()]
fatal_errors = [message for message in messages if message[0] == "FATAL"]
if fatal_errors:
print("\nError: must not contain fatal errors:\n")
for error in fatal_errors:
print(" - ".join(error))
return len(fatal_errors)
if __name__ == "__main__":
sys.exit(main())

View File

@@ -0,0 +1 @@
We are now checking for fatal errors in EPUB builds in CI.