@markuplint/ml-core 4.13.2 → 4.13.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/ARCHITECTURE.ja.md +467 -0
  2. package/ARCHITECTURE.md +467 -0
  3. package/CHANGELOG.md +3 -3
  4. package/README.md +5 -0
  5. package/SKILL.md +61 -0
  6. package/docs/linting-pipeline.ja.md +303 -0
  7. package/docs/linting-pipeline.md +303 -0
  8. package/docs/maintenance.ja.md +210 -0
  9. package/docs/maintenance.md +210 -0
  10. package/docs/ml-dom/attr.ja.md +95 -0
  11. package/docs/ml-dom/attr.md +95 -0
  12. package/docs/ml-dom/block.ja.md +272 -0
  13. package/docs/ml-dom/block.md +272 -0
  14. package/docs/ml-dom/document.ja.md +141 -0
  15. package/docs/ml-dom/document.md +141 -0
  16. package/docs/ml-dom/element.ja.md +176 -0
  17. package/docs/ml-dom/element.md +176 -0
  18. package/docs/ml-dom/helpers.ja.md +203 -0
  19. package/docs/ml-dom/helpers.md +203 -0
  20. package/docs/ml-dom/node.ja.md +200 -0
  21. package/docs/ml-dom/node.md +200 -0
  22. package/docs/ml-dom/others.ja.md +119 -0
  23. package/docs/ml-dom/others.md +119 -0
  24. package/docs/ml-dom/overview.ja.md +102 -0
  25. package/docs/ml-dom/overview.md +102 -0
  26. package/docs/ml-dom/pretender.ja.md +269 -0
  27. package/docs/ml-dom/pretender.md +269 -0
  28. package/docs/ml-dom/rule-mapping.ja.md +371 -0
  29. package/docs/ml-dom/rule-mapping.md +371 -0
  30. package/docs/ml-dom.ja.md +18 -0
  31. package/docs/ml-dom.md +18 -0
  32. package/docs/rule-system.ja.md +270 -0
  33. package/docs/rule-system.md +270 -0
  34. package/lib/convert-ruleset.d.ts +7 -0
  35. package/lib/convert-ruleset.js +7 -0
  36. package/lib/debug.d.ts +4 -0
  37. package/lib/debug.js +4 -0
  38. package/lib/ml-core.d.ts +36 -0
  39. package/lib/ml-core.js +29 -0
  40. package/lib/ml-dom/helper/get-indent.d.ts +4 -1
  41. package/lib/ml-dom/helper/get-indent.js +4 -1
  42. package/lib/ml-dom/node/attr.d.ts +65 -4
  43. package/lib/ml-dom/node/attr.js +53 -4
  44. package/lib/ml-dom/node/block.d.ts +21 -0
  45. package/lib/ml-dom/node/block.js +14 -0
  46. package/lib/ml-dom/node/child-node.d.ts +9 -0
  47. package/lib/ml-dom/node/child-node.js +9 -0
  48. package/lib/ml-dom/node/comment.d.ts +7 -0
  49. package/lib/ml-dom/node/comment.js +7 -0
  50. package/lib/ml-dom/node/document-fragment.d.ts +8 -0
  51. package/lib/ml-dom/node/document-fragment.js +8 -0
  52. package/lib/ml-dom/node/document-type.d.ts +22 -0
  53. package/lib/ml-dom/node/document-type.js +13 -0
  54. package/lib/ml-dom/node/document.d.ts +74 -4
  55. package/lib/ml-dom/node/document.js +57 -2
  56. package/lib/ml-dom/node/element.d.ts +136 -2
  57. package/lib/ml-dom/node/element.js +115 -2
  58. package/lib/ml-dom/node/node.d.ts +16 -0
  59. package/lib/ml-dom/node/node.js +16 -0
  60. package/lib/ml-dom/node/text.d.ts +12 -0
  61. package/lib/ml-dom/node/text.js +12 -0
  62. package/lib/ml-dom/node/types.d.ts +68 -0
  63. package/lib/ml-dom/token/token.d.ts +42 -0
  64. package/lib/ml-dom/token/token.js +36 -0
  65. package/lib/ml-rule/create-rule.d.ts +9 -0
  66. package/lib/ml-rule/create-rule.js +9 -0
  67. package/lib/ml-rule/ml-rule.d.ts +33 -0
  68. package/lib/ml-rule/ml-rule.js +30 -0
  69. package/lib/ml-rule/types.d.ts +41 -0
  70. package/lib/plugin/plugin.d.ts +8 -0
  71. package/lib/plugin/plugin.js +8 -0
  72. package/lib/plugin/types.d.ts +21 -0
  73. package/lib/ruleset/index.d.ts +10 -0
  74. package/lib/ruleset/index.js +7 -0
  75. package/lib/test/index.d.ts +42 -1
  76. package/lib/test/index.js +35 -1
  77. package/lib/types.d.ts +8 -0
  78. package/lib/violation-collector.d.ts +33 -0
  79. package/lib/violation-collector.js +33 -0
  80. package/package.json +12 -12
@@ -15,22 +15,61 @@ import { MLToken } from '../token/token.js';
15
15
  import { MLDomTokenList } from './dom-token-list.js';
16
16
  import { MLNode } from './node.js';
17
17
  import { UnexpectedCallError } from './unexpected-call-error.js';
18
+ /**
19
+ * Represents a DOM Attr (attribute) node wrapper in the markuplint DOM tree.
20
+ * Wraps an AST attribute token and provides access to the attribute's name, value,
21
+ * tokens (name, equal sign, quotes, value), and metadata such as whether
22
+ * the attribute is a directive or has a dynamic value.
23
+ *
24
+ * @template T - The rule configuration value type
25
+ * @template O - The rule options type
26
+ */
18
27
  export class MLAttr extends MLNode {
28
+ /**
29
+ * Creates a new MLAttr instance from an AST attribute token.
30
+ *
31
+ * @param astToken - The AST attribute token to wrap
32
+ * @param ownElement - The element that owns this attribute
33
+ */
19
34
  constructor(astToken,
20
35
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
21
36
  ownElement) {
22
37
  super(astToken, ownElement.ownerMLDocument);
38
+ /**
39
+ * The end quote token of the attribute value, or null if the attribute has no value or quotes.
40
+ */
23
41
  this.endQuote = null;
42
+ /**
43
+ * The equal sign token between the attribute name and value, or null if absent.
44
+ */
24
45
  this.equal = null;
25
46
  _MLAttr_localName.set(this, void 0);
47
+ /**
48
+ * The token representing the attribute name, or null for spread attributes.
49
+ */
26
50
  this.nameNode = null;
27
51
  _MLAttr_namespaceURI.set(this, void 0);
28
52
  _MLAttr_potentialName.set(this, void 0);
29
53
  _MLAttr_potentialValue.set(this, void 0);
54
+ /**
55
+ * The whitespace token after the equal sign, or null if absent.
56
+ */
30
57
  this.spacesAfterEqual = null;
58
+ /**
59
+ * The whitespace token before the equal sign, or null if absent.
60
+ */
31
61
  this.spacesBeforeEqual = null;
62
+ /**
63
+ * The whitespace token before the attribute name, or null if absent.
64
+ */
32
65
  this.spacesBeforeName = null;
66
+ /**
67
+ * The start quote token of the attribute value, or null if the attribute has no value or quotes.
68
+ */
33
69
  this.startQuote = null;
70
+ /**
71
+ * The token representing the attribute value, or null if the attribute has no value.
72
+ */
34
73
  this.valueNode = null;
35
74
  /**
36
75
  * Returns the "string" if HTML syntax. Otherwise, returns a type in its syntax.
@@ -70,9 +109,8 @@ export class MLAttr extends MLNode {
70
109
  __classPrivateFieldSet(this, _MLAttr_namespaceURI, ns.namespaceURI, "f");
71
110
  }
72
111
  /**
73
- * **IT THROWS AN ERROR WHEN CALLING THIS.**
112
+ * Returns the local name portion of the attribute (without namespace prefix).
74
113
  *
75
- * @unsupported
76
114
  * @implements DOM API: `Attr`
77
115
  * @see https://dom.spec.whatwg.org/#ref-for-dom-attr-localname
78
116
  */
@@ -80,6 +118,7 @@ export class MLAttr extends MLNode {
80
118
  return __classPrivateFieldGet(this, _MLAttr_localName, "f");
81
119
  }
82
120
  /**
121
+ * Returns the qualified attribute name (the potential name resolved by the parser).
83
122
  *
84
123
  * @implements DOM API: `Attr`
85
124
  * @see https://dom.spec.whatwg.org/#dom-attr-name
@@ -88,9 +127,8 @@ export class MLAttr extends MLNode {
88
127
  return __classPrivateFieldGet(this, _MLAttr_potentialName, "f");
89
128
  }
90
129
  /**
91
- * **IT THROWS AN ERROR WHEN CALLING THIS.**
130
+ * Returns the namespace URI of this attribute, resolved from the attribute name.
92
131
  *
93
- * @unsupported
94
132
  * @implements DOM API: `Attr`
95
133
  * @see https://dom.spec.whatwg.org/#ref-for-dom-attr-namespaceuri
96
134
  */
@@ -111,6 +149,12 @@ export class MLAttr extends MLNode {
111
149
  get nodeType() {
112
150
  return this.ATTRIBUTE_NODE;
113
151
  }
152
+ /**
153
+ * Returns the attribute value, equivalent to the `value` property.
154
+ *
155
+ * @implements DOM API: `Attr`
156
+ * @see https://dom.spec.whatwg.org/#dom-node-nodevalue
157
+ */
114
158
  get nodeValue() {
115
159
  return this.value;
116
160
  }
@@ -173,7 +217,12 @@ export class MLAttr extends MLNode {
173
217
  this.valueNode?.fix(raw);
174
218
  }
175
219
  /**
220
+ * Returns a normalized string representation of the attribute,
221
+ * stripping extraneous whitespace around the name, equal sign, and value tokens.
222
+ * Falls back to the raw string if any token is missing.
223
+ *
176
224
  * @implements `@markuplint/ml-core` API: `MLAttr`
225
+ * @returns The normalized attribute string
177
226
  */
178
227
  toNormalizeString() {
179
228
  if (this.nameNode && this.equal && this.startQuote && this.valueNode && this.endQuote) {
@@ -4,9 +4,30 @@ import type { MarkuplintPreprocessorBlockType } from './types.js';
4
4
  import type { MLASTPreprocessorSpecificBlock, MLASTPreprocessorSpecificBlockConditionalType } from '@markuplint/ml-ast';
5
5
  import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
6
6
  import { MLNode } from './node.js';
7
+ /**
8
+ * Represents a preprocessor-specific block node in the markuplint DOM tree.
9
+ * These nodes correspond to template engine constructs such as conditionals (`if`/`else`),
10
+ * loops (`each`), and other preprocessor directives that are not part of standard HTML.
11
+ *
12
+ * @template T - The rule configuration value type
13
+ * @template O - The rule options type
14
+ */
7
15
  export declare class MLBlock<T extends RuleConfigValue, O extends PlainData = undefined> extends MLNode<T, O, MLASTPreprocessorSpecificBlock> {
16
+ /**
17
+ * The type of conditional this block represents (e.g., `if`, `each`, `switch:case`).
18
+ */
8
19
  readonly conditionalType: MLASTPreprocessorSpecificBlockConditionalType;
20
+ /**
21
+ * Whether this block is transparent, meaning its children are treated
22
+ * as belonging to the parent node for tree traversal purposes.
23
+ */
9
24
  readonly isTransparent: boolean;
25
+ /**
26
+ * Creates a new MLBlock instance.
27
+ *
28
+ * @param astNode - The AST preprocessor block node to wrap
29
+ * @param document - The owning document
30
+ */
10
31
  constructor(astNode: MLASTPreprocessorSpecificBlock, document: MLDocument<T, O>);
11
32
  /**
12
33
  * Returns a string appropriate for the type of node as `MLBlock`
@@ -1,6 +1,20 @@
1
1
  import { after, before, remove, replaceWith } from '../manipulations/child-node-methods.js';
2
2
  import { MLNode } from './node.js';
3
+ /**
4
+ * Represents a preprocessor-specific block node in the markuplint DOM tree.
5
+ * These nodes correspond to template engine constructs such as conditionals (`if`/`else`),
6
+ * loops (`each`), and other preprocessor directives that are not part of standard HTML.
7
+ *
8
+ * @template T - The rule configuration value type
9
+ * @template O - The rule options type
10
+ */
3
11
  export class MLBlock extends MLNode {
12
+ /**
13
+ * Creates a new MLBlock instance.
14
+ *
15
+ * @param astNode - The AST preprocessor block node to wrap
16
+ * @param document - The owning document
17
+ */
4
18
  constructor(astNode,
5
19
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
6
20
  document) {
@@ -15,4 +15,13 @@ import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
15
15
  * @see https://dom.spec.whatwg.org/#idl-index
16
16
  */
17
17
  export type MLChildNode<T extends RuleConfigValue, O extends PlainData = undefined> = MLDocumentType<T, O> | MLCharacterData<T, O> | MLElement<T, O> | MLBlock<T, O>;
18
+ /**
19
+ * Determines whether the given node is a child node type
20
+ * (DocumentType, CDATA, Comment, Text, Element, or preprocessor block).
21
+ *
22
+ * @template T - The rule configuration value type
23
+ * @template O - The rule options type
24
+ * @param node - The node to check
25
+ * @returns True if the node is one of the child node types
26
+ */
18
27
  export declare function isChildNode<T extends RuleConfigValue, O extends PlainData = undefined>(node: MLNode<T, O>): node is MLChildNode<T, O>;
@@ -1,3 +1,12 @@
1
+ /**
2
+ * Determines whether the given node is a child node type
3
+ * (DocumentType, CDATA, Comment, Text, Element, or preprocessor block).
4
+ *
5
+ * @template T - The rule configuration value type
6
+ * @template O - The rule options type
7
+ * @param node - The node to check
8
+ * @returns True if the node is one of the child node types
9
+ */
1
10
  export function isChildNode(
2
11
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
3
12
  node) {
@@ -2,6 +2,13 @@ import type { CommentNodeType } from './types.js';
2
2
  import type { MLASTComment } from '@markuplint/ml-ast';
3
3
  import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
4
4
  import { MLCharacterData } from './character-data.js';
5
+ /**
6
+ * Represents a DOM Comment node wrapper in the markuplint DOM tree.
7
+ * Wraps an AST comment token and implements the standard DOM `Comment` interface.
8
+ *
9
+ * @template T - The rule configuration value type
10
+ * @template O - The rule options type
11
+ */
5
12
  export declare class MLComment<T extends RuleConfigValue, O extends PlainData = undefined> extends MLCharacterData<T, O, MLASTComment> implements Comment {
6
13
  /**
7
14
  * Returns a string appropriate for the type of node as `Attr`
@@ -1,4 +1,11 @@
1
1
  import { MLCharacterData } from './character-data.js';
2
+ /**
3
+ * Represents a DOM Comment node wrapper in the markuplint DOM tree.
4
+ * Wraps an AST comment token and implements the standard DOM `Comment` interface.
5
+ *
6
+ * @template T - The rule configuration value type
7
+ * @template O - The rule options type
8
+ */
2
9
  export class MLComment extends MLCharacterData {
3
10
  /**
4
11
  * Returns a string appropriate for the type of node as `Attr`
@@ -2,6 +2,14 @@ import type { DocumentFragmentNodeType } from './types.js';
2
2
  import type { MLASTNode } from '@markuplint/ml-ast';
3
3
  import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
4
4
  import { MLParentNode } from './parent-node.js';
5
+ /**
6
+ * Represents a DOM DocumentFragment node wrapper in the markuplint DOM tree.
7
+ * Used for JSX fragments and similar constructs where a set of nodes
8
+ * is grouped without a wrapping element.
9
+ *
10
+ * @template T - The rule configuration value type
11
+ * @template O - The rule options type
12
+ */
5
13
  export declare class MLDocumentFragment<T extends RuleConfigValue, O extends PlainData = undefined> extends MLParentNode<T, O, MLASTNode> implements DocumentFragment {
6
14
  /**
7
15
  * Returns a string appropriate for the type of node as `DocumentFragment`
@@ -1,5 +1,13 @@
1
1
  import { MLParentNode } from './parent-node.js';
2
2
  import { UnexpectedCallError } from './unexpected-call-error.js';
3
+ /**
4
+ * Represents a DOM DocumentFragment node wrapper in the markuplint DOM tree.
5
+ * Used for JSX fragments and similar constructs where a set of nodes
6
+ * is grouped without a wrapping element.
7
+ *
8
+ * @template T - The rule configuration value type
9
+ * @template O - The rule options type
10
+ */
3
11
  export class MLDocumentFragment extends MLParentNode {
4
12
  /**
5
13
  * Returns a string appropriate for the type of node as `DocumentFragment`
@@ -4,10 +4,32 @@ import type { DocumentTypeNodeType } from './types.js';
4
4
  import type { MLASTDoctype } from '@markuplint/ml-ast';
5
5
  import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
6
6
  import { MLNode } from './node.js';
7
+ /**
8
+ * Represents a DOM DocumentType node wrapper in the markuplint DOM tree.
9
+ * Wraps the `<!DOCTYPE ...>` declaration and implements the standard DOM `DocumentType` interface.
10
+ *
11
+ * @template T - The rule configuration value type
12
+ * @template O - The rule options type
13
+ */
7
14
  export declare class MLDocumentType<T extends RuleConfigValue, O extends PlainData = undefined> extends MLNode<T, O, MLASTDoctype> implements DocumentType {
15
+ /**
16
+ * The name of the document type (e.g., `"html"`).
17
+ */
8
18
  readonly name: string;
19
+ /**
20
+ * The public identifier of the document type, or an empty string if not specified.
21
+ */
9
22
  readonly publicId: string;
23
+ /**
24
+ * The system identifier of the document type, or an empty string if not specified.
25
+ */
10
26
  readonly systemId: string;
27
+ /**
28
+ * Creates a new MLDocumentType instance.
29
+ *
30
+ * @param astNode - The AST doctype node to wrap
31
+ * @param document - The owning document
32
+ */
11
33
  constructor(astNode: MLASTDoctype, document: MLDocument<T, O>);
12
34
  /**
13
35
  * Returns a string appropriate for the type of node as `DocumentType`
@@ -1,6 +1,19 @@
1
1
  import { after, before, remove, replaceWith } from '../manipulations/child-node-methods.js';
2
2
  import { MLNode } from './node.js';
3
+ /**
4
+ * Represents a DOM DocumentType node wrapper in the markuplint DOM tree.
5
+ * Wraps the `<!DOCTYPE ...>` declaration and implements the standard DOM `DocumentType` interface.
6
+ *
7
+ * @template T - The rule configuration value type
8
+ * @template O - The rule options type
9
+ */
3
10
  export class MLDocumentType extends MLNode {
11
+ /**
12
+ * Creates a new MLDocumentType instance.
13
+ *
14
+ * @param astNode - The AST doctype node to wrap
15
+ * @param document - The owning document
16
+ */
4
17
  constructor(astNode,
5
18
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
6
19
  document) {
@@ -14,6 +14,15 @@ import type { EndTagType, MLASTDocument } from '@markuplint/ml-ast';
14
14
  import type { PlainData, Pretender, RuleConfigValue } from '@markuplint/ml-config';
15
15
  import type { ARIAVersion, MLMLSpec } from '@markuplint/ml-spec';
16
16
  import { MLParentNode } from './parent-node.js';
17
+ /**
18
+ * Represents a DOM Document node wrapper in the markuplint DOM tree.
19
+ * Serves as the root node of the parsed document, managing the node list,
20
+ * rule mappings, pretender initialization, accessibility computation,
21
+ * and document-level configuration (end tag handling, booleanish values, etc.).
22
+ *
23
+ * @template T - The rule configuration value type
24
+ * @template O - The rule options type
25
+ */
17
26
  export declare class MLDocument<T extends RuleConfigValue, O extends PlainData = undefined> extends MLParentNode<T, O> implements Document {
18
27
  #private;
19
28
  /**
@@ -30,7 +39,9 @@ export declare class MLDocument<T extends RuleConfigValue, O extends PlainData =
30
39
  */
31
40
  readonly booleanish: boolean;
32
41
  /**
33
- *
42
+ * The rule currently being evaluated during a lint pass.
43
+ * Set by the linting engine before rule evaluation begins and used by nodes
44
+ * to retrieve their rule configuration. Null when no rule is being evaluated.
34
45
  */
35
46
  currentRule: Readonly<MLRule<T, O>> | null;
36
47
  /**
@@ -40,11 +51,13 @@ export declare class MLDocument<T extends RuleConfigValue, O extends PlainData =
40
51
  */
41
52
  readonly endTag: EndTagType;
42
53
  /**
43
- *
54
+ * Whether this document represents a fragment rather than a complete document.
55
+ * Fragment documents may lack root-level elements like `<html>`, `<head>`, or `<body>`.
44
56
  */
45
57
  readonly isFragment: boolean;
46
58
  /**
47
- * An array of markuplint DOM nodes
59
+ * A flat, ordered array of all markuplint DOM nodes in the document,
60
+ * used for sequential traversal and token-level operations.
48
61
  */
49
62
  readonly nodeList: ReadonlyArray<MLNode<T, O>>;
50
63
  readonly ontouchcancel?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined;
@@ -52,9 +65,14 @@ export declare class MLDocument<T extends RuleConfigValue, O extends PlainData =
52
65
  readonly ontouchmove?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined;
53
66
  readonly ontouchstart?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined;
54
67
  /**
55
- *
68
+ * The ML specification data used for element/attribute lookups, ARIA role resolution,
69
+ * and other spec-driven computations.
56
70
  */
57
71
  readonly specs: MLMLSpec;
72
+ /**
73
+ * Whether tag name comparisons should be case-sensitive.
74
+ * When false (default for HTML), tag names are compared case-insensitively.
75
+ */
58
76
  readonly tagNameCaseSensitive: boolean;
59
77
  /**
60
78
  *
@@ -1435,7 +1453,11 @@ export declare class MLDocument<T extends RuleConfigValue, O extends PlainData =
1435
1453
  */
1436
1454
  createTreeWalker(root: Node, whatToShow?: number, filter?: NodeFilter | null): TreeWalker;
1437
1455
  /**
1456
+ * Returns a debug-friendly string array representing the structure of the document's
1457
+ * node list, useful for debugging and test assertions.
1458
+ *
1438
1459
  * @implements `@markuplint/ml-core` API: `MLDocument`
1460
+ * @returns An array of strings describing each node in the document
1439
1461
  */
1440
1462
  debugMap(): string[];
1441
1463
  /**
@@ -1488,6 +1510,15 @@ export declare class MLDocument<T extends RuleConfigValue, O extends PlainData =
1488
1510
  * @implements DOM API: `Document`
1489
1511
  */
1490
1512
  exitPointerLock(): void;
1513
+ /**
1514
+ * Computes the accessibility properties for the given node, including its
1515
+ * ARIA role, accessible name, focusability, and ARIA property values.
1516
+ * Returns null for non-element nodes.
1517
+ *
1518
+ * @param node - The node to compute accessibility properties for
1519
+ * @param ariaVersion - The ARIA specification version to use for computation
1520
+ * @returns The computed accessibility properties, or null for non-element nodes
1521
+ */
1491
1522
  getAccessibilityProp(node: MLNode<T, O>, ariaVersion?: ARIAVersion): AccessibilityProperties | null;
1492
1523
  /**
1493
1524
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
@@ -1536,7 +1567,11 @@ export declare class MLDocument<T extends RuleConfigValue, O extends PlainData =
1536
1567
  */
1537
1568
  getSelection(): Selection | null;
1538
1569
  /**
1570
+ * Returns a flat, offset-sorted list of all tokens in the document,
1571
+ * including element close tags. The result is cached after the first call.
1572
+ *
1539
1573
  * @implements `@markuplint/ml-core` API: `MLDocument`
1574
+ * @returns A frozen array of tokens sorted by their starting offset
1540
1575
  */
1541
1576
  getTokenList(): readonly MLToken<import("@markuplint/ml-ast").MLASTToken>[];
1542
1577
  /**
@@ -1623,11 +1658,20 @@ export declare class MLDocument<T extends RuleConfigValue, O extends PlainData =
1623
1658
  */
1624
1659
  requestStorageAccess(): Promise<void>;
1625
1660
  /**
1661
+ * Searches for a node at the given source location (line and column).
1662
+ *
1626
1663
  * @implements `@markuplint/ml-core` API: `MLDocument`
1664
+ * @param line - The 1-based line number to search at
1665
+ * @param col - The 1-based column number to search at
1666
+ * @returns The node at the given location, or null if not found
1627
1667
  */
1628
1668
  searchNodeByLocation(line: number, col: number): MLNode<T, O, import("@markuplint/ml-ast").MLASTNode> | null;
1629
1669
  /**
1670
+ * Sets the currently active rule for this document. Called by the linting engine
1671
+ * before each rule evaluation pass.
1672
+ *
1630
1673
  * @implements `@markuplint/ml-core` API: `MLDocument`
1674
+ * @param rule - The rule to set as current, or null to clear
1631
1675
  */
1632
1676
  setRule(rule: Readonly<MLRule<T, O>> | null): void;
1633
1677
  /**
@@ -1638,11 +1682,25 @@ export declare class MLDocument<T extends RuleConfigValue, O extends PlainData =
1638
1682
  */
1639
1683
  startViewTransition(callbackOptions?: ViewTransitionUpdateCallback): ViewTransition;
1640
1684
  /**
1685
+ * Returns a string representation of the entire document. When `fixed` is true,
1686
+ * returns the document with all lint fixes applied by substituting
1687
+ * fixed token content at the appropriate offsets.
1688
+ *
1641
1689
  * @implements `@markuplint/ml-core` API: `MLDocument`
1690
+ * @param fixed - When true, returns the fixed content; otherwise returns the original raw content
1691
+ * @returns The string content of the document
1642
1692
  */
1643
1693
  toString(fixed?: boolean): string;
1644
1694
  /**
1695
+ * Walks the document tree, visiting nodes of the specified type and invoking
1696
+ * the walker callback for each one. Supports walking Element, Text, Comment,
1697
+ * Attr, and ElementCloseTag node types.
1698
+ *
1645
1699
  * @implements `@markuplint/ml-core` API: `MLDocument`
1700
+ * @param type - The node type to walk over
1701
+ * @param walker - The callback to invoke for each matching node
1702
+ * @param skipWhenRuleIsDisabled - When true, skips nodes where the current rule is disabled
1703
+ * @returns A promise that resolves when all matching nodes have been visited
1646
1704
  */
1647
1705
  walkOn(type: 'Element', walker: Walker<T, O, MLElement<T, O>>, skipWhenRuleIsDisabled?: boolean): Promise<void>;
1648
1706
  walkOn(type: 'Text', walker: Walker<T, O, MLText<T, O>>, skipWhenRuleIsDisabled?: boolean): Promise<void>;
@@ -1663,6 +1721,18 @@ export declare class MLDocument<T extends RuleConfigValue, O extends PlainData =
1663
1721
  * @implements DOM API: `Document`
1664
1722
  */
1665
1723
  writeln(...text: readonly string[]): void;
1724
+ /**
1725
+ * Initializes pretender contexts for all element nodes in the document.
1726
+ *
1727
+ * @param pretenders - Optional pretender configurations from the document options
1728
+ */
1666
1729
  private _pretending;
1730
+ /**
1731
+ * Maps the ruleset configuration to each node in the document.
1732
+ * Applies global rules, node-specific rules (by selector), and
1733
+ * child-node rules to build the per-node rule configuration.
1734
+ *
1735
+ * @param ruleset - The ruleset containing rules, nodeRules, and childNodeRules
1736
+ */
1667
1737
  private _ruleMapping;
1668
1738
  }
@@ -25,6 +25,15 @@ import { UnexpectedCallError } from './unexpected-call-error.js';
25
25
  const log = coreLog.extend('ml-dom');
26
26
  const docLog = log.extend('document');
27
27
  const ruleLog = docLog.extend('rule');
28
+ /**
29
+ * Represents a DOM Document node wrapper in the markuplint DOM tree.
30
+ * Serves as the root node of the parsed document, managing the node list,
31
+ * rule mappings, pretender initialization, accessibility computation,
32
+ * and document-level configuration (end tag handling, booleanish values, etc.).
33
+ *
34
+ * @template T - The rule configuration value type
35
+ * @template O - The rule options type
36
+ */
28
37
  export class MLDocument extends MLParentNode {
29
38
  /**
30
39
  *
@@ -35,11 +44,13 @@ export class MLDocument extends MLParentNode {
35
44
  // @ts-ignore
36
45
  super(ast, null);
37
46
  /**
38
- *
47
+ * The rule currently being evaluated during a lint pass.
48
+ * Set by the linting engine before rule evaluation begins and used by nodes
49
+ * to retrieve their rule configuration. Null when no rule is being evaluated.
39
50
  */
40
51
  this.currentRule = null;
41
52
  /**
42
- *
53
+ * The file path of the source document, if available.
43
54
  */
44
55
  _MLDocument_filename.set(this, void 0);
45
56
  _MLDocument_tokenList.set(this, null);
@@ -1833,7 +1844,11 @@ export class MLDocument extends MLParentNode {
1833
1844
  throw new UnexpectedCallError('Not supported "createTreeWalker" method');
1834
1845
  }
1835
1846
  /**
1847
+ * Returns a debug-friendly string array representing the structure of the document's
1848
+ * node list, useful for debugging and test assertions.
1849
+ *
1836
1850
  * @implements `@markuplint/ml-core` API: `MLDocument`
1851
+ * @returns An array of strings describing each node in the document
1837
1852
  */
1838
1853
  debugMap() {
1839
1854
  return nodeListToDebugMaps(this.nodeList, true);
@@ -1908,6 +1923,15 @@ export class MLDocument extends MLParentNode {
1908
1923
  exitPointerLock() {
1909
1924
  throw new UnexpectedCallError('Not supported "exitPointerLock" method');
1910
1925
  }
1926
+ /**
1927
+ * Computes the accessibility properties for the given node, including its
1928
+ * ARIA role, accessible name, focusability, and ARIA property values.
1929
+ * Returns null for non-element nodes.
1930
+ *
1931
+ * @param node - The node to compute accessibility properties for
1932
+ * @param ariaVersion - The ARIA specification version to use for computation
1933
+ * @returns The computed accessibility properties, or null for non-element nodes
1934
+ */
1911
1935
  getAccessibilityProp(
1912
1936
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
1913
1937
  node, ariaVersion = ARIA_RECOMMENDED_VERSION) {
@@ -2022,7 +2046,11 @@ export class MLDocument extends MLParentNode {
2022
2046
  throw new UnexpectedCallError('Not supported "getSelection" method');
2023
2047
  }
2024
2048
  /**
2049
+ * Returns a flat, offset-sorted list of all tokens in the document,
2050
+ * including element close tags. The result is cached after the first call.
2051
+ *
2025
2052
  * @implements `@markuplint/ml-core` API: `MLDocument`
2053
+ * @returns A frozen array of tokens sorted by their starting offset
2026
2054
  */
2027
2055
  getTokenList() {
2028
2056
  if (__classPrivateFieldGet(this, _MLDocument_tokenList, "f")) {
@@ -2145,7 +2173,12 @@ export class MLDocument extends MLParentNode {
2145
2173
  throw new UnexpectedCallError('Not supported "requestStorageAccess" method');
2146
2174
  }
2147
2175
  /**
2176
+ * Searches for a node at the given source location (line and column).
2177
+ *
2148
2178
  * @implements `@markuplint/ml-core` API: `MLDocument`
2179
+ * @param line - The 1-based line number to search at
2180
+ * @param col - The 1-based column number to search at
2181
+ * @returns The node at the given location, or null if not found
2149
2182
  */
2150
2183
  searchNodeByLocation(line, col) {
2151
2184
  for (const node of this.nodeList) {
@@ -2156,7 +2189,11 @@ export class MLDocument extends MLParentNode {
2156
2189
  return null;
2157
2190
  }
2158
2191
  /**
2192
+ * Sets the currently active rule for this document. Called by the linting engine
2193
+ * before each rule evaluation pass.
2194
+ *
2159
2195
  * @implements `@markuplint/ml-core` API: `MLDocument`
2196
+ * @param rule - The rule to set as current, or null to clear
2160
2197
  */
2161
2198
  setRule(rule) {
2162
2199
  this.currentRule = rule;
@@ -2171,7 +2208,13 @@ export class MLDocument extends MLParentNode {
2171
2208
  throw new UnexpectedCallError('Not supported "startViewTransition" method');
2172
2209
  }
2173
2210
  /**
2211
+ * Returns a string representation of the entire document. When `fixed` is true,
2212
+ * returns the document with all lint fixes applied by substituting
2213
+ * fixed token content at the appropriate offsets.
2214
+ *
2174
2215
  * @implements `@markuplint/ml-core` API: `MLDocument`
2216
+ * @param fixed - When true, returns the fixed content; otherwise returns the original raw content
2217
+ * @returns The string content of the document
2175
2218
  */
2176
2219
  toString(fixed = false) {
2177
2220
  if (!fixed) {
@@ -2229,6 +2272,11 @@ export class MLDocument extends MLParentNode {
2229
2272
  writeln(...text) {
2230
2273
  throw new UnexpectedCallError('Not supported "writeln" method');
2231
2274
  }
2275
+ /**
2276
+ * Initializes pretender contexts for all element nodes in the document.
2277
+ *
2278
+ * @param pretenders - Optional pretender configurations from the document options
2279
+ */
2232
2280
  _pretending(pretenders) {
2233
2281
  if (docLog.enabled) {
2234
2282
  docLog('Pretending: %O', pretenders);
@@ -2239,6 +2287,13 @@ export class MLDocument extends MLParentNode {
2239
2287
  }
2240
2288
  }
2241
2289
  }
2290
+ /**
2291
+ * Maps the ruleset configuration to each node in the document.
2292
+ * Applies global rules, node-specific rules (by selector), and
2293
+ * child-node rules to build the per-node rule configuration.
2294
+ *
2295
+ * @param ruleset - The ruleset containing rules, nodeRules, and childNodeRules
2296
+ */
2242
2297
  _ruleMapping(ruleset) {
2243
2298
  if (docLog.enabled) {
2244
2299
  docLog('Rule Mapping: %O', Object.keys(ruleset.rules));