diff --git a/src/aria/folk/injected/ariaSnapshot.ts b/src/aria/folk/injected/ariaSnapshot.ts index 06eb375..ce8b9f6 100644 --- a/src/aria/folk/injected/ariaSnapshot.ts +++ b/src/aria/folk/injected/ariaSnapshot.ts @@ -32,6 +32,11 @@ const defaultBox: aria.AriaBox = { visible: true, inline: false } // capture – DOM -> AriaNode tree // --------------------------------------------------------------------------- +/** + * Captures the ARIA tree for a DOM subtree. + * + * The returned tree is the low-level structure used by ARIA snapshot matching. + */ export function generateAriaTree(rootElement: Element): aria.AriaNode { const visited = new Set() @@ -310,6 +315,9 @@ export function renderNodeLines( } } +/** + * Renders a captured ARIA tree to the textual snapshot format. + */ export function renderAriaTree(root: aria.AriaNode): string { const lines: string[] = [] const nodesToRender = root.role === 'fragment' ? root.children : [root] diff --git a/src/aria/index.ts b/src/aria/index.ts index af592d1..9174b47 100644 --- a/src/aria/index.ts +++ b/src/aria/index.ts @@ -12,7 +12,11 @@ import { } from './folk/isomorphic/ariaSnapshot' import * as yaml from './yaml' -export type { AriaNode, AriaTemplateNode } from './folk/isomorphic/ariaSnapshot' +export type { + AriaNode, + AriaTemplateNode, + AriaRole, +} from './folk/isomorphic/ariaSnapshot' export { generateAriaTree, renderAriaTree } from './folk/injected/ariaSnapshot' @@ -20,6 +24,9 @@ export { renderAriaTemplate } from './template' export { matchAriaTree } from './match' +/** + * Parses textual ARIA snapshot syntax into a template tree. + */ export function parseAriaTemplate(text: string): AriaTemplateNode { return parseAriaSnapshotUnsafe(yaml, text) } diff --git a/src/aria/match.ts b/src/aria/match.ts index 09c2bc6..ad47cdd 100644 --- a/src/aria/match.ts +++ b/src/aria/match.ts @@ -111,6 +111,12 @@ export interface MatchAriaResult { resolved: string } +/** + * Matches a captured ARIA tree against a parsed template. + * + * Returns whether the match passed and the resolved output used for diffing + * and snapshot updates. + */ export function matchAriaTree( root: AriaNode, template: AriaTemplateNode diff --git a/src/aria/template.ts b/src/aria/template.ts index 353b436..972ed5e 100644 --- a/src/aria/template.ts +++ b/src/aria/template.ts @@ -25,6 +25,9 @@ export function formatNameValue(name: AriaRegex | string): string { return `/${name.pattern}/` } +/** + * Renders an ARIA template back to its textual snapshot representation. + */ export function renderAriaTemplate(template: AriaTemplateNode): string { const lines: string[] = [] if (template.kind === 'text') {