Accessibility (axe-core) API¶
Deterministic WCAG 2.1 A/AA accessibility checks via a vendored axe-core bundle, injected into a Playwright-rendered page. This engine requires no API key or LLM call.
AxeAuditor¶
- class layoutlens.AxeAuditor(run_only=None, disabled_rules=None)[source]¶
Bases:
objectRun axe-core against a Playwright page and return structured findings.
- async audit_page(page, source=None, viewport='desktop')[source]¶
Inject axe-core into an already-loaded page and run the audit.
- Parameters:
- Returns:
The structured accessibility report.
- Raises:
AnalysisError – If axe injection or execution fails.
- Return type:
- async audit(source, viewport='desktop')[source]¶
Audit a URL or local HTML file, owning the browser lifecycle.
- Parameters:
source (str | Path) – A URL or path to a local HTML file.
viewport (ViewportType) – Viewport name or
Viewportenum member.
- Returns:
The structured accessibility report.
- Raises:
AnalysisError – If axe injection or execution fails.
- Return type:
Report Types¶
Field documentation for these dataclasses lives in the class docstrings below
(:members: is scoped to methods only, to avoid duplicating the
dataclass-field docs that Napoleon already renders from the docstring).
- class layoutlens.A11yReport(source, viewport, engine_version, violations, incomplete, passes_count, timestamp=<factory>)[source]¶
Bases:
objectStructured accessibility report for a single page and viewport.
- Parameters:
source (str)
viewport (str)
engine_version (str)
violations (list[A11yFinding])
incomplete (list[A11yFinding])
passes_count (int)
timestamp (str)
- violations¶
Findings that definitively fail a rule.
- incomplete¶
Findings axe could not decide automatically (needs review).
- class layoutlens.A11yFinding(rule_id, impact, wcag_refs, description, help_url, nodes, engine='axe-core')[source]¶
Bases:
objectA single accessibility rule outcome affecting one or more DOM nodes.
- Parameters:
- impact¶
Severity as reported by axe:
"critical","serious","moderate", or"minor"(may be an empty string for incomplete results without a determined impact).- Type:
- nodes¶
Affected DOM nodes, each a dict with
"target"(list of selectors) and"html"(truncated outer HTML snippet).
Engine Version¶
- layoutlens.AXE_VERSION = '4.10.3'¶
str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.