@timiagama/ecr 0.0.1 → 0.1.0
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.
- package/LICENSE +202 -0
- package/NOTICE +16 -0
- package/README.md +411 -7
- package/dist/bin.d.ts +20 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +26 -0
- package/dist/bin.js.map +1 -0
- package/dist/cli/corpus-loader.d.ts +198 -0
- package/dist/cli/corpus-loader.d.ts.map +1 -0
- package/dist/cli/corpus-loader.js +351 -0
- package/dist/cli/corpus-loader.js.map +1 -0
- package/dist/cli/corpus-statistics.d.ts +113 -0
- package/dist/cli/corpus-statistics.d.ts.map +1 -0
- package/dist/cli/corpus-statistics.js +119 -0
- package/dist/cli/corpus-statistics.js.map +1 -0
- package/dist/cli/diagnostic-reporter.d.ts +103 -0
- package/dist/cli/diagnostic-reporter.d.ts.map +1 -0
- package/dist/cli/diagnostic-reporter.js +254 -0
- package/dist/cli/diagnostic-reporter.js.map +1 -0
- package/dist/cli/project-ignore.d.ts +113 -0
- package/dist/cli/project-ignore.d.ts.map +1 -0
- package/dist/cli/project-ignore.js +199 -0
- package/dist/cli/project-ignore.js.map +1 -0
- package/dist/cli/safe-text.d.ts +25 -0
- package/dist/cli/safe-text.d.ts.map +1 -0
- package/dist/cli/safe-text.js +34 -0
- package/dist/cli/safe-text.js.map +1 -0
- package/dist/cli/supervisor.d.ts +108 -0
- package/dist/cli/supervisor.d.ts.map +1 -0
- package/dist/cli/supervisor.js +139 -0
- package/dist/cli/supervisor.js.map +1 -0
- package/dist/cli.d.ts +247 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +591 -0
- package/dist/cli.js.map +1 -0
- package/dist/corpus-validator.d.ts +183 -0
- package/dist/corpus-validator.d.ts.map +1 -0
- package/dist/corpus-validator.js +479 -0
- package/dist/corpus-validator.js.map +1 -0
- package/dist/document-identity-rule.d.ts +198 -0
- package/dist/document-identity-rule.d.ts.map +1 -0
- package/dist/document-identity-rule.js +244 -0
- package/dist/document-identity-rule.js.map +1 -0
- package/dist/ecr.d.ts +103 -0
- package/dist/ecr.d.ts.map +1 -0
- package/dist/ecr.js +216 -0
- package/dist/ecr.js.map +1 -0
- package/dist/glob-pattern.d.ts +94 -0
- package/dist/glob-pattern.d.ts.map +1 -0
- package/dist/glob-pattern.js +188 -0
- package/dist/glob-pattern.js.map +1 -0
- package/dist/heading-source-form.d.ts +77 -0
- package/dist/heading-source-form.d.ts.map +1 -0
- package/dist/heading-source-form.js +129 -0
- package/dist/heading-source-form.js.map +1 -0
- package/dist/identifier-grammar.d.ts +212 -0
- package/dist/identifier-grammar.d.ts.map +1 -0
- package/dist/identifier-grammar.js +273 -0
- package/dist/identifier-grammar.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/inline-reference-rule.d.ts +557 -0
- package/dist/inline-reference-rule.d.ts.map +1 -0
- package/dist/inline-reference-rule.js +802 -0
- package/dist/inline-reference-rule.js.map +1 -0
- package/dist/meta-documents.d.ts +91 -0
- package/dist/meta-documents.d.ts.map +1 -0
- package/dist/meta-documents.js +133 -0
- package/dist/meta-documents.js.map +1 -0
- package/dist/per-document-visitor.d.ts +510 -0
- package/dist/per-document-visitor.d.ts.map +1 -0
- package/dist/per-document-visitor.js +1032 -0
- package/dist/per-document-visitor.js.map +1 -0
- package/dist/references-section-rule.d.ts +482 -0
- package/dist/references-section-rule.d.ts.map +1 -0
- package/dist/references-section-rule.js +777 -0
- package/dist/references-section-rule.js.map +1 -0
- package/dist/section-hierarchy-rule.d.ts +299 -0
- package/dist/section-hierarchy-rule.d.ts.map +1 -0
- package/dist/section-hierarchy-rule.js +482 -0
- package/dist/section-hierarchy-rule.js.map +1 -0
- package/dist/source-alignment.d.ts +41 -0
- package/dist/source-alignment.d.ts.map +1 -0
- package/dist/source-alignment.js +166 -0
- package/dist/source-alignment.js.map +1 -0
- package/dist/source-lines.d.ts +69 -0
- package/dist/source-lines.d.ts.map +1 -0
- package/dist/source-lines.js +104 -0
- package/dist/source-lines.js.map +1 -0
- package/dist/spec-version.d.ts +19 -0
- package/dist/spec-version.d.ts.map +1 -0
- package/dist/spec-version.js +19 -0
- package/dist/spec-version.js.map +1 -0
- package/dist/types.d.ts +219 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +11 -0
- package/dist/types.js.map +1 -0
- package/examples/docs/0. Orientation/0.0 - System Overview.md +34 -0
- package/examples/docs/0. Orientation/0.0.1 - Glossary.md +21 -0
- package/examples/docs/0. Orientation/0.0.2 - Quality Gates.md +22 -0
- package/examples/docs/3. Ingestion/3.1 - Ingestion - Validation Rules.md +33 -0
- package/examples/docs/4. Payments/4.10 - Settlement.md +22 -0
- package/examples/docs/4. Payments/4.2 - Payment Processing Contract.md +33 -0
- package/examples/docs/8. Orchestration/8.1 - Workflow Orchestration Contract.md +38 -0
- package/examples/docs/8. Orchestration/8.1.3 - Retry Policy.md +17 -0
- package/examples/docs/8. Orchestration/8.10 - Dead Letter Queue.md +20 -0
- package/examples/docs/README.md +7 -0
- package/package.json +65 -7
- package/protocol/navigation-protocol.md +223 -0
- package/spec/v2/1 - ECR - Structural Specification.md +1467 -0
- package/spec/v2/2 - ECR - User Guide.md +845 -0
- package/spec/v2/3 - Design Rationale - The Section Separator.md +243 -0
- package/src/bin.ts +30 -0
- package/src/cli/corpus-loader.ts +482 -0
- package/src/cli/corpus-statistics.ts +196 -0
- package/src/cli/diagnostic-reporter.ts +344 -0
- package/src/cli/project-ignore.ts +238 -0
- package/src/cli/safe-text.ts +39 -0
- package/src/cli/supervisor.ts +204 -0
- package/src/cli.ts +836 -0
- package/src/corpus-validator.ts +642 -0
- package/src/document-identity-rule.ts +422 -0
- package/src/ecr.ts +298 -0
- package/src/glob-pattern.ts +242 -0
- package/src/heading-source-form.ts +173 -0
- package/src/identifier-grammar.ts +380 -0
- package/src/index.ts +78 -0
- package/src/inline-reference-rule.ts +1235 -0
- package/src/meta-documents.ts +159 -0
- package/src/per-document-visitor.ts +1528 -0
- package/src/references-section-rule.ts +1182 -0
- package/src/section-hierarchy-rule.ts +705 -0
- package/src/source-alignment.ts +209 -0
- package/src/source-lines.ts +123 -0
- package/src/spec-version.ts +19 -0
- package/src/types.ts +267 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"references-section-rule.js","sourceRoot":"","sources":["../src/references-section-rule.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAUH,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAI5D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,8EAA8E;AAC9E,2BAA2B;AAC3B,8EAA8E;AAE9E;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAW,QAAQ,CAAC;AAmJ3D,8EAA8E;AAC9E,kDAAkD;AAClD,8EAA8E;AAE9E,wEAAwE;AACxE,MAAM,CAAC,MAAM,oCAAoC,GAAW,gCAAgC,CAAC;AAE7F,iFAAiF;AACjF,MAAM,CAAC,MAAM,0BAA0B,GAAW,sBAAsB,CAAC;AAEzE,4EAA4E;AAC5E,MAAM,CAAC,MAAM,kCAAkC,GAAW,8BAA8B,CAAC;AAEzF,kFAAkF;AAClF,MAAM,CAAC,MAAM,iCAAiC,GAAW,6BAA6B,CAAC;AAEvF,mFAAmF;AACnF,MAAM,CAAC,MAAM,sBAAsB,GAAW,kBAAkB,CAAC;AAQjE;;;;GAIG;AACH,MAAM,iBAAiB,GAAW,gCAAgC,CAAC;AAEnE;;;GAGG;AACH,MAAM,kBAAkB,GAAW,WAAW,CAAC;AAE/C,8EAA8E;AAC9E,4DAA4D;AAC5D,8EAA8E;AAE9E;;;;;GAKG;AACH,MAAM,sCAAsC,GAAuB,OAAO,CAAC;AAE3E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GAAG,EAAE,IAAI,CAAC,GAAG;YACb,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACzC,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACxC,CAAC;QAEF,OAAO,UAAU,CAAC;IACpB,CAAC;IAED;;;;;;;;OAQG;IACK,iBAAiB,CAAC,SAAiB;QACzC,MAAM,mBAAmB,GAAW,SAAS;aAC1C,OAAO,CAAC,SAAS,EAAE,gBAAgB,CAAC;aACpC,OAAO,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;QAExC,OAAO,IAAI,mBAAmB,GAAG,CAAC;IACpC,CAAC;CAEF"}
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Section Hierarchy Rule (ECR102)
|
|
3
|
+
*
|
|
4
|
+
* Validates the section structure constraint defined in the ECR specification:
|
|
5
|
+
* - 1#9.4 -- Section Structure Rules
|
|
6
|
+
* - 1#9.8 -- Per-Document Structural Invariants ("SectionIDs unique within document")
|
|
7
|
+
*
|
|
8
|
+
* This rule consumes heading node data from an AST traversal and validates
|
|
9
|
+
* the section hierarchy for headings with depth \>= 2. It delegates identifier
|
|
10
|
+
* parsing and segment-count logic to {@link IdentifierGrammar} and emits
|
|
11
|
+
* {@link Diagnostic} objects for any violations.
|
|
12
|
+
*
|
|
13
|
+
* Validations performed:
|
|
14
|
+
* 1. A separator (any dash variant) must follow the identifier
|
|
15
|
+
* 2. Heading text prefix must parse as a valid SectionID
|
|
16
|
+
* 3. The SectionID's DocID must equal the document's DocID
|
|
17
|
+
* 4. The section path must have d - 1 segments, where d = heading depth
|
|
18
|
+
* 5. SectionIDs must be unique within the document (no duplicates)
|
|
19
|
+
* 6. Heading levels must not be skipped (e.g., H3 directly after H1 is invalid)
|
|
20
|
+
*
|
|
21
|
+
* Extracted artefacts:
|
|
22
|
+
* - {@link SectionNode} for each valid heading, with parentId derived from the heading stack
|
|
23
|
+
*/
|
|
24
|
+
import type { DocID, Diagnostic, SectionNode } from './types.js';
|
|
25
|
+
import { IdentifierGrammar } from './identifier-grammar.js';
|
|
26
|
+
import type { HeadingNodeData } from './document-identity-rule.js';
|
|
27
|
+
/**
|
|
28
|
+
* Canonical rule identifier for the Section Hierarchy Rule.
|
|
29
|
+
*
|
|
30
|
+
* Referenced as [ECR102] in the ECR specification (1#9.4).
|
|
31
|
+
*/
|
|
32
|
+
export declare const SECTION_HIERARCHY_RULE_ID: string;
|
|
33
|
+
/**
|
|
34
|
+
* Configuration options for constructing a {@link SectionHierarchyRule} instance.
|
|
35
|
+
*/
|
|
36
|
+
export interface SectionHierarchyRuleOptions {
|
|
37
|
+
/**
|
|
38
|
+
* The opaque, host-provided URI identifying the document being validated.
|
|
39
|
+
* Attached to all emitted diagnostics.
|
|
40
|
+
*/
|
|
41
|
+
readonly uri: string;
|
|
42
|
+
/**
|
|
43
|
+
* The DocID established by the {@link DocumentIdentityRule} for this document.
|
|
44
|
+
* Used as the required prefix for all SectionIDs and to compute expected segment counts.
|
|
45
|
+
*/
|
|
46
|
+
readonly docId: DocID;
|
|
47
|
+
/**
|
|
48
|
+
* The {@link IdentifierGrammar} instance used for SectionID parsing,
|
|
49
|
+
* prefix validation, segment counting, and separator validation.
|
|
50
|
+
*/
|
|
51
|
+
readonly grammar: IdentifierGrammar;
|
|
52
|
+
/**
|
|
53
|
+
* The document's raw Markdown, for the heading source-form check of 1#9.11
|
|
54
|
+
* rule 1. When absent, as in unit tests that supply only parsed heading
|
|
55
|
+
* text, the check is skipped.
|
|
56
|
+
*/
|
|
57
|
+
readonly sourceText?: string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The complete result produced by finalising the Section Hierarchy Rule
|
|
61
|
+
* after all headings have been evaluated.
|
|
62
|
+
*
|
|
63
|
+
* Contains zero or more diagnostics and the list of successfully extracted
|
|
64
|
+
* section nodes, including the root H1 node.
|
|
65
|
+
*/
|
|
66
|
+
export interface SectionHierarchyRuleResult {
|
|
67
|
+
/** Diagnostics emitted during evaluation (errors for violations). */
|
|
68
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
69
|
+
/**
|
|
70
|
+
* Section nodes extracted from valid headings, in document traversal order.
|
|
71
|
+
*
|
|
72
|
+
* Includes the root H1 node (whose id is the DocID and has no parentId)
|
|
73
|
+
* and all valid sub-heading nodes with their derived parentId.
|
|
74
|
+
*/
|
|
75
|
+
readonly sections: readonly SectionNode[];
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Validates the Section Hierarchy Rule as defined in the ECR specification (1#9.4, 1#9.8).
|
|
79
|
+
*
|
|
80
|
+
* The rule enforces that every heading with depth \>= 2 has a valid SectionID
|
|
81
|
+
* whose DocID is the document's own, carries a separator, has a section path of
|
|
82
|
+
* one segment per heading level below the H1, and is unique within the document.
|
|
83
|
+
*
|
|
84
|
+
* For each valid heading, the rule extracts a {@link SectionNode} with its
|
|
85
|
+
* parentId derived from the heading stack (the nearest preceding heading at
|
|
86
|
+
* depth - 1).
|
|
87
|
+
*
|
|
88
|
+
* The root H1 heading is registered via {@link registerRootHeading} to establish
|
|
89
|
+
* the heading stack base and produce the root {@link SectionNode}.
|
|
90
|
+
*
|
|
91
|
+
* Usage:
|
|
92
|
+
* 1. Construct a rule instance with the document URI, established DocID,
|
|
93
|
+
* and an {@link IdentifierGrammar}.
|
|
94
|
+
* 2. Call {@link registerRootHeading} once with the H1 heading data to
|
|
95
|
+
* establish the root of the heading stack.
|
|
96
|
+
* 3. Call {@link evaluateHeading} for every heading node with depth \>= 2
|
|
97
|
+
* encountered during AST traversal.
|
|
98
|
+
* 4. Call {@link finalise} after all headings have been evaluated to obtain
|
|
99
|
+
* the complete result.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```ts
|
|
103
|
+
* const grammar = new IdentifierGrammar();
|
|
104
|
+
* const rule = new SectionHierarchyRule({
|
|
105
|
+
* uri: 'file:///doc.md',
|
|
106
|
+
* docId: '3.1',
|
|
107
|
+
* grammar,
|
|
108
|
+
* });
|
|
109
|
+
*
|
|
110
|
+
* rule.registerRootHeading({ depth: 1, text: '3.1 - My Document' });
|
|
111
|
+
* rule.evaluateHeading({ depth: 2, text: '3.1#1 - Section One' });
|
|
112
|
+
* rule.evaluateHeading({ depth: 3, text: '3.1#1.1 - Sub-Section' });
|
|
113
|
+
* rule.evaluateHeading({ depth: 2, text: '3.1#2 - Section Two' });
|
|
114
|
+
*
|
|
115
|
+
* const result: SectionHierarchyRuleResult = rule.finalise();
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
export declare class SectionHierarchyRule {
|
|
119
|
+
/** The opaque, host-provided URI identifying the document being validated. */
|
|
120
|
+
private readonly uri;
|
|
121
|
+
/** The established DocID for this document. */
|
|
122
|
+
private readonly docId;
|
|
123
|
+
/** The grammar instance used for SectionID parsing and validation. */
|
|
124
|
+
private readonly grammar;
|
|
125
|
+
/** Diagnostics accumulated during heading evaluation. */
|
|
126
|
+
private readonly collectedDiagnostics;
|
|
127
|
+
/** Section nodes extracted from valid headings, in traversal order. */
|
|
128
|
+
private readonly collectedSections;
|
|
129
|
+
/**
|
|
130
|
+
* Depth-aware heading stack for parent-child derivation.
|
|
131
|
+
*
|
|
132
|
+
* Maintained so that each entry's depth is strictly increasing from
|
|
133
|
+
* bottom to top. When a heading at depth d is encountered, all entries
|
|
134
|
+
* with depth \>= d are popped before the new entry is pushed.
|
|
135
|
+
*/
|
|
136
|
+
private readonly headingStack;
|
|
137
|
+
/**
|
|
138
|
+
* Set of SectionIDs already encountered, for duplicate detection.
|
|
139
|
+
*/
|
|
140
|
+
private readonly encounteredSectionIds;
|
|
141
|
+
/** Checks each heading's source line against the section recipe. */
|
|
142
|
+
private readonly headingSourceForm;
|
|
143
|
+
/**
|
|
144
|
+
* Constructs a new Section Hierarchy Rule evaluator.
|
|
145
|
+
*
|
|
146
|
+
* @param options - Configuration including the document URI, established DocID,
|
|
147
|
+
* and grammar instance
|
|
148
|
+
*/
|
|
149
|
+
constructor(options: SectionHierarchyRuleOptions);
|
|
150
|
+
/**
|
|
151
|
+
* Registers the root H1 heading to establish the heading stack base.
|
|
152
|
+
*
|
|
153
|
+
* This produces the root {@link SectionNode} (id = DocID, headingDepth = 1,
|
|
154
|
+
* no parentId) and pushes the H1 onto the heading stack so that subsequent
|
|
155
|
+
* depth-2 headings can derive their parentId.
|
|
156
|
+
*
|
|
157
|
+
* Must be called exactly once, before any calls to {@link evaluateHeading}.
|
|
158
|
+
*
|
|
159
|
+
* @param headingNodeData - Data extracted from the H1 heading AST node.
|
|
160
|
+
* The depth must be 1. The title text is extracted
|
|
161
|
+
* from the heading content after the separator.
|
|
162
|
+
*/
|
|
163
|
+
registerRootHeading(headingNodeData: HeadingNodeData): void;
|
|
164
|
+
/**
|
|
165
|
+
* Evaluates a single heading node with depth \>= 2 against the section
|
|
166
|
+
* hierarchy constraints.
|
|
167
|
+
*
|
|
168
|
+
* For each heading, the method validates:
|
|
169
|
+
* 1. A separator (any dash variant) follows the identifier
|
|
170
|
+
* 2. The textual prefix parses as a valid SectionID
|
|
171
|
+
* 3. The SectionID's DocID equals the document's DocID
|
|
172
|
+
* 4. The section path has d - 1 segments, where d is the heading depth
|
|
173
|
+
* 5. The SectionID has not been seen before in this document
|
|
174
|
+
* 6. No heading levels are skipped (depth must not exceed parent depth + 1)
|
|
175
|
+
*
|
|
176
|
+
* When all validations pass, a {@link SectionNode} is extracted with its
|
|
177
|
+
* parentId derived from the heading stack (the nearest preceding heading
|
|
178
|
+
* at depth - 1), and the heading stack is updated.
|
|
179
|
+
*
|
|
180
|
+
* When any validation fails, an error diagnostic is emitted and the heading
|
|
181
|
+
* stack is still updated to maintain correct parent derivation for
|
|
182
|
+
* subsequent headings.
|
|
183
|
+
*
|
|
184
|
+
* Headings with depth === 1 are ignored (H1 is handled by
|
|
185
|
+
* {@link registerRootHeading}).
|
|
186
|
+
*
|
|
187
|
+
* @param headingNodeData - Data extracted from a heading AST node with depth \>= 2
|
|
188
|
+
*/
|
|
189
|
+
evaluateHeading(headingNodeData: HeadingNodeData): void;
|
|
190
|
+
/**
|
|
191
|
+
* Finalises the rule evaluation and produces the complete result.
|
|
192
|
+
*
|
|
193
|
+
* This method must be called after all heading nodes have been supplied
|
|
194
|
+
* via {@link registerRootHeading} and {@link evaluateHeading}. It returns
|
|
195
|
+
* all accumulated diagnostics and extracted section nodes.
|
|
196
|
+
*
|
|
197
|
+
* @returns The complete rule result including all diagnostics and extracted sections
|
|
198
|
+
*/
|
|
199
|
+
finalise(): SectionHierarchyRuleResult;
|
|
200
|
+
/**
|
|
201
|
+
* Validates that a heading string carries a separator, and returns an
|
|
202
|
+
* error diagnostic when none is found.
|
|
203
|
+
*
|
|
204
|
+
* Delegates to {@link IdentifierGrammar.validateSeparator}.
|
|
205
|
+
*
|
|
206
|
+
* @param headingText - The plain text content of the heading node
|
|
207
|
+
* @param range - Optional positional range for the diagnostic
|
|
208
|
+
* @returns A diagnostic if the separator is invalid, or `undefined` if valid
|
|
209
|
+
*/
|
|
210
|
+
private validateHeadingSeparator;
|
|
211
|
+
/**
|
|
212
|
+
* Checks that a sub-section's path continues the path of the heading it
|
|
213
|
+
* sits under, so that a SectionID locates itself: `3.1#2.1` must sit under
|
|
214
|
+
* `3.1#2`, not under `3.1#1`.
|
|
215
|
+
*
|
|
216
|
+
* Only a parent that was itself extracted is checked against. A parent
|
|
217
|
+
* that failed validation has already been reported, and measuring its
|
|
218
|
+
* children against it would repeat that error rather than add one.
|
|
219
|
+
*
|
|
220
|
+
* @param sectionPath - The section path of the heading being evaluated
|
|
221
|
+
* @param parentId - The identifier of the heading it sits under, if any
|
|
222
|
+
* @param sectionId - The SectionID of the heading being evaluated
|
|
223
|
+
* @param range - Optional positional range for the diagnostic
|
|
224
|
+
* @returns A diagnostic if the path does not continue its parent's, or `undefined`
|
|
225
|
+
*/
|
|
226
|
+
private validatePathAgainstParent;
|
|
227
|
+
/**
|
|
228
|
+
* Extracts the SectionID candidate string from a heading's text.
|
|
229
|
+
*
|
|
230
|
+
* The candidate is the portion of the heading text before the first
|
|
231
|
+
* occurrence of a separator (any dash variant). If no separator
|
|
232
|
+
* is found, the entire trimmed text is returned as the candidate.
|
|
233
|
+
*
|
|
234
|
+
* @param headingText - The plain text content of the heading node
|
|
235
|
+
* @returns The SectionID candidate string
|
|
236
|
+
*/
|
|
237
|
+
private extractSectionIdCandidate;
|
|
238
|
+
/**
|
|
239
|
+
* Extracts the title text from a heading's text.
|
|
240
|
+
*
|
|
241
|
+
* The title is the portion of the heading text after the first
|
|
242
|
+
* occurrence of a separator (any dash variant). If no separator
|
|
243
|
+
* is found, an empty string is returned.
|
|
244
|
+
*
|
|
245
|
+
* @param headingText - The plain text content of the heading node
|
|
246
|
+
* @returns The extracted title string
|
|
247
|
+
*/
|
|
248
|
+
private extractHeadingTitle;
|
|
249
|
+
/**
|
|
250
|
+
* Looks up the parent identifier from the heading stack for a heading
|
|
251
|
+
* at the given depth.
|
|
252
|
+
*
|
|
253
|
+
* The parent is the nearest preceding heading whose depth is exactly
|
|
254
|
+
* `headingDepth - 1`. Returns `undefined` if no such heading exists
|
|
255
|
+
* in the stack (which should not happen for well-formed documents
|
|
256
|
+
* after the root H1 is registered).
|
|
257
|
+
*
|
|
258
|
+
* @param headingDepth - The depth of the heading whose parent is sought
|
|
259
|
+
* @returns The parent's identifier, or `undefined` if not found
|
|
260
|
+
*/
|
|
261
|
+
private lookUpParentId;
|
|
262
|
+
/**
|
|
263
|
+
* Returns the depth of the topmost entry on the heading stack.
|
|
264
|
+
*
|
|
265
|
+
* Used to detect skipped heading levels: if the incoming heading depth
|
|
266
|
+
* exceeds the top-of-stack depth by more than 1, an intermediate heading
|
|
267
|
+
* level has been skipped.
|
|
268
|
+
*
|
|
269
|
+
* Returns 0 if the heading stack is empty (should not occur after
|
|
270
|
+
* {@link registerRootHeading} has been called).
|
|
271
|
+
*
|
|
272
|
+
* @returns The depth of the topmost heading stack entry, or 0 if empty
|
|
273
|
+
*/
|
|
274
|
+
private peekHeadingStackDepth;
|
|
275
|
+
/**
|
|
276
|
+
* Updates the heading stack when a new heading is encountered.
|
|
277
|
+
*
|
|
278
|
+
* All entries with depth \>= the new heading's depth are removed,
|
|
279
|
+
* then the new heading is pushed. This ensures the stack always
|
|
280
|
+
* reflects the current structural nesting.
|
|
281
|
+
*
|
|
282
|
+
* @param id - The DocID or SectionID of the heading
|
|
283
|
+
* @param depth - The Markdown heading depth
|
|
284
|
+
*/
|
|
285
|
+
private updateHeadingStack;
|
|
286
|
+
/**
|
|
287
|
+
* Creates a diagnostic object for the Section Hierarchy Rule.
|
|
288
|
+
*
|
|
289
|
+
* All diagnostics share the same rule ID ({@link SECTION_HIERARCHY_RULE_ID}),
|
|
290
|
+
* severity (error), and document URI.
|
|
291
|
+
*
|
|
292
|
+
* @param message - Human-readable description of the issue
|
|
293
|
+
* @param range - Optional positional range of the heading within the source document
|
|
294
|
+
* @param sectionId - Optional SectionID providing structural context
|
|
295
|
+
* @returns A fully populated diagnostic object
|
|
296
|
+
*/
|
|
297
|
+
private createDiagnostic;
|
|
298
|
+
}
|
|
299
|
+
//# sourceMappingURL=section-hierarchy-rule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"section-hierarchy-rule.d.ts","sourceRoot":"","sources":["../src/section-hierarchy-rule.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAa,UAAU,EAAqC,WAAW,EAAE,MAAM,YAAY,CAAC;AAK/G,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAQnE;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,EAAE,MAAiB,CAAC;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