diff --git a/.github/workflows/antsibull-docs.yml b/.github/workflows/antsibull-docs.yml index 7a10273bf..072cb164d 100644 --- a/.github/workflows/antsibull-docs.yml +++ b/.github/workflows/antsibull-docs.yml @@ -34,7 +34,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install . coverage codecov + python -m pip install . coverage codecov html5lib - name: Use antsibull-docs sphinx-init run: | @@ -59,6 +59,10 @@ jobs: run: | ./build.sh + - name: Validate HTML + run: + python .github/workflows/validate-html.py build/html/ + - name: Combine and upload coverage stats run: | coverage combine .coverage.* diff --git a/.github/workflows/validate-html.py b/.github/workflows/validate-html.py new file mode 100644 index 000000000..7af1c2762 --- /dev/null +++ b/.github/workflows/validate-html.py @@ -0,0 +1,26 @@ +#!/usr/bin/python3 + +import os +import sys + +import html5lib + + +errors = 0 +for path in sys.argv[1:]: + for dirname, _, files in os.walk(path): + for file in files: + if not file.endswith('.html'): + continue + path = os.path.join(dirname, file) + try: + parser = html5lib.HTMLParser(strict=True) + with open(path, 'rb') as f: + document = parser.parse(f) + except Exception as e: + errors += 1 + print(f'{path}: {e}') + +if errors > 0: + print(f'Found {errors} errors!') + sys.exit(1)