Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML validity tests #388

Merged
merged 4 commits into from
Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
2 changes: 2 additions & 0 deletions changelogs/fragments/388-table-html-alias.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- "When using ``--use-html-blobs``, malformed HTML was generated for parameter aliases (https://github.com/ansible-community/antsibull/pull/388)."
2 changes: 1 addition & 1 deletion src/antsibull/data/docsite/macros/parameters.rst.j2
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@
<p class="ansible-option-title"><strong>@{ key | escape }@</strong></p>
<a class="ansibleOptionLink" href="#parameter-@{ parameter_html_prefix }@{% for part in value['full_key'] %}@{ part }@{% if not loop.last %}/{% endif %}{% endfor %}" title="Permalink to this option"></a>
{% if value['aliases'] %}
<p class="ansible-option-type-line"><span class="ansible-option-aliases">aliases: @{ value['aliases']|join(', ') }@</p>
<p class="ansible-option-type-line"><span class="ansible-option-aliases">aliases: @{ value['aliases']|join(', ') }@</span></p>
{% endif %}
<p class="ansible-option-type-line">
<span class="ansible-option-type">@{ value['type'] | documented_type }@</span>
Expand Down