Skip to content

Commit

Permalink
Validate generated HTML.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein committed Jan 14, 2022
1 parent 22a26f4 commit 85fdae7
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
6 changes: 5 additions & 1 deletion .github/workflows/antsibull-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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.*
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/validate-html.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 85fdae7

Please sign in to comment.