Module

analysis.a11y

Accessibility linting for Kida templates.

Static analysis to detect common accessibility issues:

  • <img> without altattribute
  • <input>/<select>/<textarea> without associated <label> or aria-label
  • Heading hierarchy violations (skipping levels)
  • Missinglang attribute on <html>

Usage::

from kida.analysis.a11y import check_a11y
issues = check_a11y(template_ast)
for issue in issues:
    print(f"Line {issue.lineno}: [{issue.rule}] {issue.message}")

Classes

A11yIssue 5
A single accessibility finding.

A single accessibility finding.

Attributes

Name Type Description
lineno int
col_offset int
rule str
message str
severity str
_A11yVisitor 9
AST visitor that collects accessibility issues.

AST visitor that collects accessibility issues.

Methods

visit_Data 1
def visit_Data(self, node: Data) -> None
Parameters
Name Type Description
node
visit_Output 1
def visit_Output(self, node: Output) -> None
Parameters
Name Type Description
node
finalize 0
Post-traversal checks (e.g., input-label association).
def finalize(self) -> None
Internal Methods 6
__init__ 0
def __init__(self) -> None
_check_img_alt 1
Check tags have alt attributes.
def _check_img_alt(self, node: Data) -> None
Parameters
Name Type Description
node
_check_headings 1
Check heading hierarchy (no skipping levels).
def _check_headings(self, node: Data) -> None
Parameters
Name Type Description
node
_check_html_lang 1
Check tag has lang attribute.
def _check_html_lang(self, node: Data) -> None
Parameters
Name Type Description
node
_collect_labels 1
Collect label for= IDs for input association checking.
def _collect_labels(self, node: Data) -> None
Parameters
Name Type Description
node
_collect_inputs 1
Collect input/select/textarea elements for label association.
def _collect_inputs(self, node: Data) -> None
Parameters
Name Type Description
node

Functions

check_a11y 1 list[A11yIssue]
Run accessibility checks on a parsed template AST.
def check_a11y(template: Template) -> list[A11yIssue]
Parameters
Name Type Description
template Template

Parsed Template AST node.

Returns
list[A11yIssue]