) own their own markup and are
+# not in scope, as before.
+#
+# Implementation: scripts/lib/check_table_headers.py, tests in
+# scripts/lib/test_check_table_headers.py.
#
# References:
# - openspec/architecture/wcag-coverage.md SC 1.3.1
# ---------------------------------------------------------------------------
-if [ -d src ]; then
+if _a11y_has_markup_dir; then
_th_log=${HYDRA_GATE_LOG_DIR}/hydra-gate-table-headers.log
: > "${_th_log}"
+ _th_ran=1
+ _th_helper="${SCRIPT_DIR}/lib/check_table_headers.py"
+ _th_files=()
+ # `_a11y_markup_files`, not `find src -name '*.vue'` (#225 / #261). An
+ # unscoped header is the same defect in a .php template as in a .vue one.
while IFS= read -r vue; do
_in_scope "${vue}" || continue
- python3 - "$vue" <<'PYTH' >> "${_th_log}" 2>/dev/null
-import re, sys
-fname = sys.argv[1]
-try:
- src = open(fname).read()
-except Exception:
- sys.exit(0)
-txt = src.replace('\n', ' ')
-for m in re.finditer(r'', txt, re.IGNORECASE | re.DOTALL):
- body = m.group(2) or ''
- if re.search(r'| ]*\bscope\s*=', body, re.IGNORECASE):
- continue
- if re.search(r' | rule=th-without-scope')
- elif re.search(r' | rule=table-without-th')
-PYTH
+ _th_files+=("${vue}")
done < <(_a11y_markup_files)
- _th_fail=$(wc -l < "${_th_log}" 2>/dev/null || echo 0)
- if [ "${_th_fail}" -eq 0 ]; then
- _pass 43 "table-headers"
+ if [ "${#_th_files[@]}" -eq 0 ]; then
+ : # nothing in scope; the PASS below describes the diff, as everywhere else.
+ elif [ ! -f "${_th_helper}" ]; then
+ # A MISSING HELPER MUST NOT REPORT PASS (#147).
+ _th_ran=0
+ _skip 43 "table-headers" wiring "check_table_headers.py not found at ${_th_helper} — ${#_th_files[@]} markup file(s) were in scope and NONE were inspected; unassociated table headers (WCAG 1.3.1) are UNVERIFIED by this run."
else
- _fail 43 "table-headers" "${_th_fail} (s) missing — see ${_th_log}"
+ # Exit code is a STATUS, findings are STDOUT (gate-19 / #249); stderr
+ # is kept so a traceback is visible instead of becoming a clean sheet.
+ # `set +e` only, never `set -e` after — errexit is OFF for this whole
+ # script and nothing may turn it on (see the invariant at the top).
+ set +e
+ python3 "${_th_helper}" "${_th_files[@]}" >> "${_th_log}" 2>>"${_th_log}.err"
+ _th_rc=$?
+ if [ "${_th_rc}" -ne 0 ]; then
+ _th_ran=0
+ _skip 43 "table-headers" wiring "check_table_headers.py exited ${_th_rc} — ${#_th_files[@]} markup file(s) were in scope and no verdict was produced; unassociated table headers (WCAG 1.3.1) are UNVERIFIED by this run. See ${_th_log}.err."
+ fi
+ fi
+ _th_fail=$(wc -l < "${_th_log}" 2>/dev/null || echo 0)
+ if [ "${_th_ran}" -eq 1 ]; then
+ if [ "${_th_fail}" -eq 0 ]; then
+ _pass 43 "table-headers"
+ else
+ _fail 43 "table-headers" "${_th_fail} (s) with a | missing scope= — see ${_th_log}"
+ fi
fi
fi
| | |