@driftsys/markspec 0.12.0 → 0.13.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/esm/ast/build.d.ts.map +1 -1
- package/esm/ast/build.js +19 -5
- package/esm/ast/equivalence.js +14 -2
- package/esm/ast/nodes.d.ts +15 -3
- package/esm/ast/nodes.d.ts.map +1 -1
- package/esm/compiler/inverses.d.ts.map +1 -1
- package/esm/compiler/inverses.js +18 -3
- package/esm/compiler/mod.d.ts +34 -1
- package/esm/compiler/mod.d.ts.map +1 -1
- package/esm/compiler/mod.js +112 -48
- package/esm/compiler/schema.d.ts +3 -2
- package/esm/compiler/schema.d.ts.map +1 -1
- package/esm/compiler/schema.js +6 -3
- package/esm/config/markspec.d.ts +2 -2
- package/esm/config/mod.d.ts.map +1 -1
- package/esm/config/mod.js +47 -5
- package/esm/criteria/scenarios.d.ts +55 -0
- package/esm/criteria/scenarios.d.ts.map +1 -0
- package/esm/criteria/scenarios.js +133 -0
- package/esm/discovery/mod.d.ts +20 -1
- package/esm/discovery/mod.d.ts.map +1 -1
- package/esm/discovery/mod.js +105 -17
- package/esm/discovery/projects.d.ts +6 -4
- package/esm/discovery/projects.d.ts.map +1 -1
- package/esm/discovery/projects.js +27 -17
- package/esm/formatter/entry_body.d.ts +13 -12
- package/esm/formatter/entry_body.d.ts.map +1 -1
- package/esm/formatter/entry_body.js +25 -17
- package/esm/formatter/feature_file.d.ts +40 -0
- package/esm/formatter/feature_file.d.ts.map +1 -0
- package/esm/formatter/feature_file.js +88 -0
- package/esm/formatter/md_equiv.d.ts +6 -5
- package/esm/formatter/md_equiv.d.ts.map +1 -1
- package/esm/formatter/md_equiv.js +6 -5
- package/esm/formatter/mod.d.ts +25 -3
- package/esm/formatter/mod.d.ts.map +1 -1
- package/esm/formatter/mod.js +267 -27
- package/esm/formatter/tab_markers.d.ts +15 -0
- package/esm/formatter/tab_markers.d.ts.map +1 -0
- package/esm/formatter/tab_markers.js +133 -0
- package/esm/gates/mod.d.ts +2 -2
- package/esm/gates/mod.d.ts.map +1 -1
- package/esm/gates/mod.js +18 -3
- package/esm/gherkin/load.d.ts +35 -0
- package/esm/gherkin/load.d.ts.map +1 -0
- package/esm/gherkin/load.js +39 -0
- package/esm/gherkin/parse.d.ts +11 -0
- package/esm/gherkin/parse.d.ts.map +1 -0
- package/esm/gherkin/parse.js +311 -0
- package/esm/gherkin/position.d.ts +23 -0
- package/esm/gherkin/position.d.ts.map +1 -0
- package/esm/gherkin/position.js +21 -0
- package/esm/gherkin/procedure.d.ts +76 -0
- package/esm/gherkin/procedure.d.ts.map +1 -0
- package/esm/gherkin/procedure.js +164 -0
- package/esm/gherkin/project.d.ts +35 -0
- package/esm/gherkin/project.d.ts.map +1 -0
- package/esm/gherkin/project.js +64 -0
- package/esm/gherkin/role.d.ts +23 -0
- package/esm/gherkin/role.d.ts.map +1 -0
- package/esm/gherkin/role.js +28 -0
- package/esm/gherkin/types.d.ts +118 -0
- package/esm/gherkin/types.d.ts.map +1 -0
- package/esm/gherkin/types.js +12 -0
- package/esm/lock/acquire_compile.d.ts +12 -4
- package/esm/lock/acquire_compile.d.ts.map +1 -1
- package/esm/lock/acquire_compile.js +15 -5
- package/esm/lock/canonical_edges.d.ts +6 -2
- package/esm/lock/canonical_edges.d.ts.map +1 -1
- package/esm/lock/canonical_edges.js +10 -3
- package/esm/lock/model.d.ts +5 -0
- package/esm/lock/model.d.ts.map +1 -1
- package/esm/lock/parser.d.ts.map +1 -1
- package/esm/lock/parser.js +2 -0
- package/esm/lock/resolve.d.ts +6 -2
- package/esm/lock/resolve.d.ts.map +1 -1
- package/esm/lock/resolve.js +36 -4
- package/esm/lock/serializer.d.ts.map +1 -1
- package/esm/lock/serializer.js +7 -1
- package/esm/lock/upstream_deps.js +1 -1
- package/esm/mod.d.ts +24 -6
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +19 -5
- package/esm/model/mod.d.ts +43 -2
- package/esm/model/mod.d.ts.map +1 -1
- package/esm/model/mod.js +1 -1
- package/esm/model/relations.d.ts +9 -0
- package/esm/model/relations.d.ts.map +1 -1
- package/esm/model/relations.js +16 -1
- package/esm/parser/attributes.d.ts +82 -3
- package/esm/parser/attributes.d.ts.map +1 -1
- package/esm/parser/attributes.js +199 -32
- package/esm/parser/body_tokens.d.ts +1 -1
- package/esm/parser/body_tokens.d.ts.map +1 -1
- package/esm/parser/body_tokens.js +49 -35
- package/esm/parser/feature_file.d.ts +116 -0
- package/esm/parser/feature_file.d.ts.map +1 -0
- package/esm/parser/feature_file.js +540 -0
- package/esm/parser/markdown.d.ts +7 -0
- package/esm/parser/markdown.d.ts.map +1 -1
- package/esm/parser/markdown.js +129 -40
- package/esm/parser/mod.d.ts +18 -0
- package/esm/parser/mod.d.ts.map +1 -1
- package/esm/parser/mod.js +51 -0
- package/esm/parser/translate.d.ts.map +1 -1
- package/esm/parser/translate.js +5 -0
- package/esm/refs/mod.d.ts +8 -3
- package/esm/refs/mod.d.ts.map +1 -1
- package/esm/refs/mod.js +20 -7
- package/esm/refs/split.d.ts +58 -0
- package/esm/refs/split.d.ts.map +1 -0
- package/esm/refs/split.js +137 -0
- package/esm/reporter/mod.d.ts +7 -0
- package/esm/reporter/mod.d.ts.map +1 -1
- package/esm/reporter/mod.js +113 -3
- package/esm/sync/mapping.d.ts +4 -3
- package/esm/sync/mapping.d.ts.map +1 -1
- package/esm/sync/mapping.js +52 -9
- package/esm/util/display_id.d.ts +20 -0
- package/esm/util/display_id.d.ts.map +1 -0
- package/esm/util/display_id.js +19 -0
- package/esm/validator/attributes.d.ts.map +1 -1
- package/esm/validator/attributes.js +4 -1
- package/esm/validator/block_role.d.ts +40 -0
- package/esm/validator/block_role.d.ts.map +1 -0
- package/esm/validator/block_role.js +109 -0
- package/esm/validator/feature_ac.d.ts.map +1 -1
- package/esm/validator/feature_ac.js +6 -1
- package/esm/validator/feature_parse.d.ts +35 -0
- package/esm/validator/feature_parse.d.ts.map +1 -0
- package/esm/validator/feature_parse.js +69 -0
- package/esm/validator/locators.d.ts +36 -0
- package/esm/validator/locators.d.ts.map +1 -0
- package/esm/validator/locators.js +184 -0
- package/esm/validator/mod.d.ts +10 -1
- package/esm/validator/mod.d.ts.map +1 -1
- package/esm/validator/mod.js +38 -14
- package/esm/validator/normalize.d.ts.map +1 -1
- package/esm/validator/normalize.js +8 -3
- package/esm/validator/per_type_attrs.d.ts +3 -3
- package/esm/validator/per_type_attrs.js +3 -3
- package/esm/validator/pipeline.d.ts +10 -16
- package/esm/validator/pipeline.d.ts.map +1 -1
- package/esm/validator/pipeline.js +37 -16
- package/esm/validator/procedure.d.ts +22 -0
- package/esm/validator/procedure.d.ts.map +1 -0
- package/esm/validator/procedure.js +58 -0
- package/esm/validator/trace_types.d.ts.map +1 -1
- package/esm/validator/trace_types.js +4 -3
- package/esm/validator/traceability.d.ts.map +1 -1
- package/esm/validator/traceability.js +4 -1
- package/esm/validator/type_resolution.d.ts +5 -3
- package/esm/validator/type_resolution.d.ts.map +1 -1
- package/esm/validator/type_resolution.js +14 -2
- package/esm/validator/types.d.ts +11 -0
- package/esm/validator/types.d.ts.map +1 -1
- package/esm/validator/types.js +26 -4
- package/esm/validator/uxil_family.d.ts +1 -1
- package/package.json +3 -1
- package/script/ast/build.d.ts.map +1 -1
- package/script/ast/build.js +19 -5
- package/script/ast/equivalence.js +14 -2
- package/script/ast/nodes.d.ts +15 -3
- package/script/ast/nodes.d.ts.map +1 -1
- package/script/compiler/inverses.d.ts.map +1 -1
- package/script/compiler/inverses.js +18 -3
- package/script/compiler/mod.d.ts +34 -1
- package/script/compiler/mod.d.ts.map +1 -1
- package/script/compiler/mod.js +110 -46
- package/script/compiler/schema.d.ts +3 -2
- package/script/compiler/schema.d.ts.map +1 -1
- package/script/compiler/schema.js +6 -3
- package/script/config/markspec.d.ts +2 -2
- package/script/config/mod.d.ts.map +1 -1
- package/script/config/mod.js +47 -5
- package/script/criteria/scenarios.d.ts +55 -0
- package/script/criteria/scenarios.d.ts.map +1 -0
- package/script/criteria/scenarios.js +139 -0
- package/script/discovery/mod.d.ts +20 -1
- package/script/discovery/mod.d.ts.map +1 -1
- package/script/discovery/mod.js +106 -17
- package/script/discovery/projects.d.ts +6 -4
- package/script/discovery/projects.d.ts.map +1 -1
- package/script/discovery/projects.js +27 -17
- package/script/formatter/entry_body.d.ts +13 -12
- package/script/formatter/entry_body.d.ts.map +1 -1
- package/script/formatter/entry_body.js +25 -17
- package/script/formatter/feature_file.d.ts +40 -0
- package/script/formatter/feature_file.d.ts.map +1 -0
- package/script/formatter/feature_file.js +92 -0
- package/script/formatter/md_equiv.d.ts +6 -5
- package/script/formatter/md_equiv.d.ts.map +1 -1
- package/script/formatter/md_equiv.js +6 -5
- package/script/formatter/mod.d.ts +25 -3
- package/script/formatter/mod.d.ts.map +1 -1
- package/script/formatter/mod.js +266 -26
- package/script/formatter/tab_markers.d.ts +15 -0
- package/script/formatter/tab_markers.d.ts.map +1 -0
- package/script/formatter/tab_markers.js +141 -0
- package/script/gates/mod.d.ts +2 -2
- package/script/gates/mod.d.ts.map +1 -1
- package/script/gates/mod.js +18 -3
- package/script/gherkin/load.d.ts +35 -0
- package/script/gherkin/load.d.ts.map +1 -0
- package/script/gherkin/load.js +76 -0
- package/script/gherkin/parse.d.ts +11 -0
- package/script/gherkin/parse.d.ts.map +1 -0
- package/script/gherkin/parse.js +314 -0
- package/script/gherkin/position.d.ts +23 -0
- package/script/gherkin/position.d.ts.map +1 -0
- package/script/gherkin/position.js +24 -0
- package/script/gherkin/procedure.d.ts +76 -0
- package/script/gherkin/procedure.d.ts.map +1 -0
- package/script/gherkin/procedure.js +169 -0
- package/script/gherkin/project.d.ts +35 -0
- package/script/gherkin/project.d.ts.map +1 -0
- package/script/gherkin/project.js +67 -0
- package/script/gherkin/role.d.ts +23 -0
- package/script/gherkin/role.d.ts.map +1 -0
- package/script/gherkin/role.js +31 -0
- package/script/gherkin/types.d.ts +118 -0
- package/script/gherkin/types.d.ts.map +1 -0
- package/script/gherkin/types.js +13 -0
- package/script/lock/acquire_compile.d.ts +12 -4
- package/script/lock/acquire_compile.d.ts.map +1 -1
- package/script/lock/acquire_compile.js +15 -5
- package/script/lock/canonical_edges.d.ts +6 -2
- package/script/lock/canonical_edges.d.ts.map +1 -1
- package/script/lock/canonical_edges.js +10 -3
- package/script/lock/model.d.ts +5 -0
- package/script/lock/model.d.ts.map +1 -1
- package/script/lock/parser.d.ts.map +1 -1
- package/script/lock/parser.js +2 -0
- package/script/lock/resolve.d.ts +6 -2
- package/script/lock/resolve.d.ts.map +1 -1
- package/script/lock/resolve.js +36 -4
- package/script/lock/serializer.d.ts.map +1 -1
- package/script/lock/serializer.js +7 -1
- package/script/lock/upstream_deps.js +1 -1
- package/script/mod.d.ts +24 -6
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +48 -6
- package/script/model/mod.d.ts +43 -2
- package/script/model/mod.d.ts.map +1 -1
- package/script/model/mod.js +2 -1
- package/script/model/relations.d.ts +9 -0
- package/script/model/relations.d.ts.map +1 -1
- package/script/model/relations.js +17 -1
- package/script/parser/attributes.d.ts +82 -3
- package/script/parser/attributes.d.ts.map +1 -1
- package/script/parser/attributes.js +205 -33
- package/script/parser/body_tokens.d.ts +1 -1
- package/script/parser/body_tokens.d.ts.map +1 -1
- package/script/parser/body_tokens.js +49 -35
- package/script/parser/feature_file.d.ts +116 -0
- package/script/parser/feature_file.d.ts.map +1 -0
- package/script/parser/feature_file.js +548 -0
- package/script/parser/markdown.d.ts +7 -0
- package/script/parser/markdown.d.ts.map +1 -1
- package/script/parser/markdown.js +128 -39
- package/script/parser/mod.d.ts +18 -0
- package/script/parser/mod.d.ts.map +1 -1
- package/script/parser/mod.js +52 -1
- package/script/parser/translate.d.ts.map +1 -1
- package/script/parser/translate.js +5 -0
- package/script/refs/mod.d.ts +8 -3
- package/script/refs/mod.d.ts.map +1 -1
- package/script/refs/mod.js +20 -7
- package/script/refs/split.d.ts +58 -0
- package/script/refs/split.d.ts.map +1 -0
- package/script/refs/split.js +145 -0
- package/script/reporter/mod.d.ts +7 -0
- package/script/reporter/mod.d.ts.map +1 -1
- package/script/reporter/mod.js +113 -3
- package/script/sync/mapping.d.ts +4 -3
- package/script/sync/mapping.d.ts.map +1 -1
- package/script/sync/mapping.js +52 -9
- package/script/util/display_id.d.ts +20 -0
- package/script/util/display_id.d.ts.map +1 -0
- package/script/util/display_id.js +22 -0
- package/script/validator/attributes.d.ts.map +1 -1
- package/script/validator/attributes.js +4 -1
- package/script/validator/block_role.d.ts +40 -0
- package/script/validator/block_role.d.ts.map +1 -0
- package/script/validator/block_role.js +112 -0
- package/script/validator/feature_ac.d.ts.map +1 -1
- package/script/validator/feature_ac.js +6 -1
- package/script/validator/feature_parse.d.ts +35 -0
- package/script/validator/feature_parse.d.ts.map +1 -0
- package/script/validator/feature_parse.js +73 -0
- package/script/validator/locators.d.ts +36 -0
- package/script/validator/locators.d.ts.map +1 -0
- package/script/validator/locators.js +188 -0
- package/script/validator/mod.d.ts +10 -1
- package/script/validator/mod.d.ts.map +1 -1
- package/script/validator/mod.js +38 -14
- package/script/validator/normalize.d.ts.map +1 -1
- package/script/validator/normalize.js +8 -3
- package/script/validator/per_type_attrs.d.ts +3 -3
- package/script/validator/per_type_attrs.js +3 -3
- package/script/validator/pipeline.d.ts +10 -16
- package/script/validator/pipeline.d.ts.map +1 -1
- package/script/validator/pipeline.js +36 -16
- package/script/validator/procedure.d.ts +22 -0
- package/script/validator/procedure.d.ts.map +1 -0
- package/script/validator/procedure.js +61 -0
- package/script/validator/trace_types.d.ts.map +1 -1
- package/script/validator/trace_types.js +4 -3
- package/script/validator/traceability.d.ts.map +1 -1
- package/script/validator/traceability.js +4 -1
- package/script/validator/type_resolution.d.ts +5 -3
- package/script/validator/type_resolution.d.ts.map +1 -1
- package/script/validator/type_resolution.js +14 -2
- package/script/validator/types.d.ts +11 -0
- package/script/validator/types.d.ts.map +1 -1
- package/script/validator/types.js +27 -4
- package/script/validator/uxil_family.d.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/parser/markdown.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAa,UAAU,EAAE,KAAK,EAAc,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/parser/markdown.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAa,UAAU,EAAE,KAAK,EAAc,MAAM,iBAAiB,CAAC;AAwBhF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAU7C,6CAA6C;AAC7C,MAAM,WAAW,oBAAoB;IACnC,0CAA0C;IAC1C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC;IACnC;;;;;;OAMG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B;;;;;OAKG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;CACnC;AAsDD,oDAAoD;AACpD,MAAM,WAAW,mBAAmB;IAClC,mDAAmD;IACnD,QAAQ,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;IAC1B,4DAA4D;IAC5D,QAAQ,CAAC,WAAW,EAAE,UAAU,EAAE,CAAC;CACpC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,oBAAoB,GAC7B,mBAAmB,CAiDrB"}
|
|
@@ -17,18 +17,8 @@ const code_regions_js_1 = require("./code_regions.js");
|
|
|
17
17
|
const line_endings_js_1 = require("../util/line_endings.js");
|
|
18
18
|
const translate_js_1 = require("./translate.js");
|
|
19
19
|
const mod_js_2 = require("../typl/mod.js");
|
|
20
|
-
/**
|
|
21
|
-
|
|
22
|
-
* every authored universal attribute, every core trace relation, and the
|
|
23
|
-
* extra inverse lock key (`Verified-by`). Universal keys with
|
|
24
|
-
* `origin: "generated"` (`Contains`, `Caused`, ...) are left out: the compiler
|
|
25
|
-
* computes them and authors never write them (#706). MSL-P020 (misplaced
|
|
26
|
-
* trailer) fires only when a body line's key is in this set; any other
|
|
27
|
-
* capitalized `Word:` lead-in (`Note:`, `Example:`, `Assumption:`) is prose,
|
|
28
|
-
* not a misplaced trailer (#654).
|
|
29
|
-
*/
|
|
30
|
-
const RECOGNIZED_TRAILER_KEYS = new Set([
|
|
31
|
-
...mod_js_1.UNIVERSAL_ATTRIBUTE_KEYS.filter((key) => (0, mod_js_1.attributeSpec)(key)?.origin !== "generated"),
|
|
20
|
+
/** Keys of the core trace relations, for the MSL-P020 warning. */
|
|
21
|
+
const TRACE_RELATION_KEYS = new Set([
|
|
32
22
|
...mod_js_1.CORE_RELATIONS.map((r) => r.attr),
|
|
33
23
|
...mod_js_1.LOCK_EXTRA_INVERSE_KEYS,
|
|
34
24
|
]);
|
|
@@ -110,7 +100,7 @@ function parseMarkdown(markdown, options) {
|
|
|
110
100
|
if (list.ordered)
|
|
111
101
|
continue;
|
|
112
102
|
for (const item of list.children) {
|
|
113
|
-
const entry = extractEntry(item, markdownLines, file, definitions, isReferencesDoc, diagnostics, !!options?.lineMap);
|
|
103
|
+
const entry = extractEntry(item, markdownLines, file, definitions, isReferencesDoc, diagnostics, !!options?.lineMap, options?.allowTitleOnly === true);
|
|
114
104
|
if (entry)
|
|
115
105
|
entries.push(entry);
|
|
116
106
|
}
|
|
@@ -151,7 +141,7 @@ function detectReferencesDocument(_file, explicit) {
|
|
|
151
141
|
* Returns undefined if the list item is not an entry block.
|
|
152
142
|
* Diagnostics (e.g., deprecation warnings) are pushed into the accumulator.
|
|
153
143
|
*/
|
|
154
|
-
function extractEntry(item, markdownLines, file, definitions, isReferencesDoc, diagnostics, _hasLineMap = false) {
|
|
144
|
+
function extractEntry(item, markdownLines, file, definitions, isReferencesDoc, diagnostics, _hasLineMap = false, allowTitleOnly = false) {
|
|
155
145
|
// Task list items (remark-gfm sets checked to true/false) are not entries.
|
|
156
146
|
if (item.checked != null)
|
|
157
147
|
return undefined;
|
|
@@ -259,19 +249,40 @@ function extractEntry(item, markdownLines, file, definitions, isReferencesDoc, d
|
|
|
259
249
|
}
|
|
260
250
|
// Extract body content and attributes.
|
|
261
251
|
const bodyContent = extractBodyContent(item, markdownLines);
|
|
262
|
-
const [
|
|
252
|
+
const [rawBody, attrLines] = (0, attributes_js_1.splitBodyAndAttributes)(bodyContent);
|
|
253
|
+
const body = rawBody.trimStart();
|
|
263
254
|
const attributes = (0, attributes_js_1.parseAttributes)(attrLines);
|
|
264
255
|
const { blocks: bodyAst, tree: mdastTree } = (0, build_js_1.buildBodyAstWithTree)(body);
|
|
265
256
|
const entryLine = item.position?.start.line ?? 1;
|
|
266
|
-
// MSL-P020:
|
|
267
|
-
//
|
|
268
|
-
//
|
|
269
|
-
//
|
|
270
|
-
//
|
|
271
|
-
//
|
|
257
|
+
// MSL-P020: a body line that would carry identity or a trace link.
|
|
258
|
+
// Only `Id:` and the core trace relation keys count. Other recognized
|
|
259
|
+
// keys (`Rationale:`, `Labels:`, `Type:`) and any other capitalized
|
|
260
|
+
// lead-in (`Note:`, `Example:`) start ordinary body prose: such a line
|
|
261
|
+
// keeps its text in the body, and `markspec fmt` cannot change it, so
|
|
262
|
+
// an error there could never be cleared (#654, #916).
|
|
263
|
+
//
|
|
264
|
+
// - Error: an `Id:` or trace-relation line with other content after it
|
|
265
|
+
// (body content or the trailer block). The trailer is not at the final
|
|
266
|
+
// position, so the identity or the link is lost. A trailing run that
|
|
267
|
+
// holds an `Id:` line is always the trailer (findTrailerStart), so an
|
|
268
|
+
// `Id:` line never reaches the warning case below.
|
|
269
|
+
// - Warning: a trace-relation line in the trailing run of `Key: Value`
|
|
270
|
+
// lines of an entry with no trailer. The run was not accepted as the
|
|
271
|
+
// trailer (no blank line above it, or a key outside the core set), so
|
|
272
|
+
// the line is body text and does not create a trace link.
|
|
272
273
|
if (body.length > 0) {
|
|
273
274
|
const bodyLines = body.split("\n");
|
|
274
275
|
const fencedLines = (0, code_regions_js_1.parseCodeRegions)((0, line_endings_js_1.normalizeLineEndings)(body), mdastTree).fencedLines;
|
|
276
|
+
// Start of the trailing run of `Key: Value` lines (blank lines skipped
|
|
277
|
+
// at the end only).
|
|
278
|
+
let tailStart = bodyLines.length;
|
|
279
|
+
while (tailStart > 0 && bodyLines[tailStart - 1].trim() === "") {
|
|
280
|
+
tailStart--;
|
|
281
|
+
}
|
|
282
|
+
while (tailStart > 0 && !fencedLines.has(tailStart - 1) &&
|
|
283
|
+
attributes_js_1.ATTR_LINE_RE.test(bodyLines[tailStart - 1].trim()))
|
|
284
|
+
tailStart--;
|
|
285
|
+
let warned = false;
|
|
275
286
|
for (let i = 0; i < bodyLines.length; i++) {
|
|
276
287
|
// Reuse the LF-normalized body tree: examples cannot be misplaced trailers.
|
|
277
288
|
if (fencedLines.has(i))
|
|
@@ -279,24 +290,49 @@ function extractEntry(item, markdownLines, file, definitions, isReferencesDoc, d
|
|
|
279
290
|
const trimmed = bodyLines[i].trim();
|
|
280
291
|
if (!attributes_js_1.ATTR_LINE_RE.test(trimmed))
|
|
281
292
|
continue;
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
// (`Note:`, `Example:`, `Assumption:`) is prose, not a trailer (#654).
|
|
285
|
-
const keyMatch = trimmed.match(/^([A-Z][A-Za-z-]*):/);
|
|
286
|
-
if (!keyMatch || !RECOGNIZED_TRAILER_KEYS.has(keyMatch[1]))
|
|
293
|
+
const key = trimmed.match(/^([A-Z][A-Za-z-]*):/)?.[1];
|
|
294
|
+
if (key === undefined)
|
|
287
295
|
continue;
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
296
|
+
if (key !== mod_js_1.IDENTITY_KEY && !TRACE_RELATION_KEYS.has(key))
|
|
297
|
+
continue;
|
|
298
|
+
if (i < tailStart || attrLines.length > 0) {
|
|
299
|
+
diagnostics.push({
|
|
300
|
+
code: "MSL-P020",
|
|
301
|
+
severity: "error",
|
|
302
|
+
message: `${displayId}: trailers block is not the final indented code ` +
|
|
303
|
+
`block of the entry -- content appears after trailer-like ` +
|
|
304
|
+
`lines (spec section 4.1)`,
|
|
305
|
+
location: { file, line: entryLine, column: 1 },
|
|
306
|
+
});
|
|
307
|
+
break; // One diagnostic per entry is sufficient
|
|
308
|
+
}
|
|
309
|
+
if (!warned) {
|
|
310
|
+
warned = true;
|
|
311
|
+
diagnostics.push({
|
|
312
|
+
code: "MSL-P020",
|
|
313
|
+
severity: "warning",
|
|
314
|
+
message: `${displayId}: '${key}:' line is read as body ` +
|
|
315
|
+
`text, not as a trailer; to make it a trace link, put the ` +
|
|
316
|
+
`trailer in an indented block after a blank line ` +
|
|
317
|
+
`(spec section 4.1)`,
|
|
318
|
+
location: { file, line: entryLine, column: 1 },
|
|
319
|
+
});
|
|
320
|
+
}
|
|
298
321
|
}
|
|
299
322
|
}
|
|
323
|
+
// MSL-P020 (warning): the trailer is an `Id:` run directly under prose,
|
|
324
|
+
// with no blank line above it. It is still read as the trailer, so the entry keeps its
|
|
325
|
+
// identity, but it is not in the canonical layout (#916).
|
|
326
|
+
if ((0, attributes_js_1.isTrailerUnderProse)(bodyContent.split("\n"))) {
|
|
327
|
+
diagnostics.push({
|
|
328
|
+
code: "MSL-P020",
|
|
329
|
+
severity: "warning",
|
|
330
|
+
message: `${displayId}: trailers block is not separated from the ` +
|
|
331
|
+
`body by a blank line; run 'markspec fmt' to ` +
|
|
332
|
+
`move it to the canonical layout (spec section 4.1)`,
|
|
333
|
+
location: { file, line: entryLine, column: 1 },
|
|
334
|
+
});
|
|
335
|
+
}
|
|
300
336
|
// MSL-P021 / MSL-P022: validate trailer lines for syntax correctness.
|
|
301
337
|
// The trailer block is the final indented code block. Lines within it
|
|
302
338
|
// should all match `Key: Value` syntax. We check both the parsed
|
|
@@ -316,8 +352,57 @@ function extractEntry(item, markdownLines, file, definitions, isReferencesDoc, d
|
|
|
316
352
|
const firstNonBlank = (markdownLines[line - 1] ?? "").search(/\S/);
|
|
317
353
|
return { file, line, column: firstNonBlank >= 0 ? firstNonBlank + 1 : 1 };
|
|
318
354
|
};
|
|
355
|
+
// MSL-P023: a trailer with a line indented less than 4 columns past the
|
|
356
|
+
// list-item content (git style) is accepted but not canonical in
|
|
357
|
+
// Markdown. Every trailer line is checked, tab-aware, so a block whose
|
|
358
|
+
// later lines are not indented is reported too: `markspec fmt` rewrites
|
|
359
|
+
// it. The warning points at the trailer's first line. The legacy
|
|
360
|
+
// trailing-backslash form has its own deprecation warning, so it is
|
|
361
|
+
// skipped. A run directly under prose is reported as MSL-P020 above, so
|
|
362
|
+
// at most one of the two warnings fires for a block.
|
|
363
|
+
const contentLines = bodyContent.split("\n");
|
|
364
|
+
if (attrLines.length > 0 &&
|
|
365
|
+
!attrLines.some((line) => line.trimEnd().endsWith("\\")) &&
|
|
366
|
+
!(0, attributes_js_1.isTrailerUnderProse)(contentLines)) {
|
|
367
|
+
const trailerIndex = (0, attributes_js_1.findTrailerStart)(contentLines);
|
|
368
|
+
const indent = itemContentIndent(item);
|
|
369
|
+
let notIndented = false;
|
|
370
|
+
let hasContinuation = false;
|
|
371
|
+
for (let i = trailerIndex; i < contentLines.length; i++) {
|
|
372
|
+
const rawLine = markdownLines[trailerLineLocation(i).line - 1] ?? "";
|
|
373
|
+
if (rawLine.trim() === "")
|
|
374
|
+
continue;
|
|
375
|
+
if ((0, attributes_js_1.leadingColumns)(rawLine) - indent < 4)
|
|
376
|
+
notIndented = true;
|
|
377
|
+
if (!attributes_js_1.ATTR_LINE_RE.test(rawLine.trim()))
|
|
378
|
+
hasContinuation = true;
|
|
379
|
+
}
|
|
380
|
+
if (notIndented) {
|
|
381
|
+
// fmt and the quick fix leave a trailer with a continuation line
|
|
382
|
+
// (MSL-P021) unchanged, so the hint to run fmt applies only without
|
|
383
|
+
// one.
|
|
384
|
+
const hint = hasContinuation
|
|
385
|
+
? "fix the MSL-P021 continuation line by hand, then indent the trailer"
|
|
386
|
+
: "run `markspec fmt` to indent the trailer";
|
|
387
|
+
diagnostics.push({
|
|
388
|
+
code: "MSL-P023",
|
|
389
|
+
severity: "warning",
|
|
390
|
+
message: `${displayId}: a trailer line is not indented; ${hint} ` +
|
|
391
|
+
"(spec section 1.3)",
|
|
392
|
+
location: trailerLineLocation(trailerIndex),
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
}
|
|
319
396
|
// `attrLines` is the contiguous, blank-free tail of `bodyContent`.
|
|
320
397
|
const attrContentStart = bodyContent.split("\n").length - attrLines.length;
|
|
398
|
+
// File line of each parsed attribute. `parseAttributes` keeps one
|
|
399
|
+
// attribute per trailer line and skips blank and empty-valued lines.
|
|
400
|
+
const attributeLines = [];
|
|
401
|
+
for (const [attrIndex, rawLine] of attrLines.entries()) {
|
|
402
|
+
if ((0, attributes_js_1.parseAttributes)([rawLine]).length === 1) {
|
|
403
|
+
attributeLines.push(trailerLineLocation(attrContentStart + attrIndex).line);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
321
406
|
// Check lines that DID end up in attrLines but might have key issues
|
|
322
407
|
for (const [attrIndex, rawLine] of attrLines.entries()) {
|
|
323
408
|
const trailerLocation = trailerLineLocation(attrContentStart + attrIndex);
|
|
@@ -402,7 +487,7 @@ function extractEntry(item, markdownLines, file, definitions, isReferencesDoc, d
|
|
|
402
487
|
// whitespace and the punctuation `.`, `/`, `,`, `'`, `"` into
|
|
403
488
|
// hyphens, trimming hyphens at both ends, and checking the recognized
|
|
404
489
|
// key vocabulary.
|
|
405
|
-
const typoOfKnownKey = RECOGNIZED_TRAILER_KEYS.has(key.replace(/[\s./,'"]+/g, "-").replace(/^-+|-+$/g, ""));
|
|
490
|
+
const typoOfKnownKey = attributes_js_1.RECOGNIZED_TRAILER_KEYS.has(key.replace(/[\s./,'"]+/g, "-").replace(/^-+|-+$/g, ""));
|
|
406
491
|
// A time (`10:30`), an abbreviation (`e.g.:`), a version (`v2.0:`)
|
|
407
492
|
// or a word pair (`and/or:`) is prose. The 80-column wrap of the
|
|
408
493
|
// formatter can put one at the start of the last body line. A
|
|
@@ -497,8 +582,9 @@ function extractEntry(item, markdownLines, file, definitions, isReferencesDoc, d
|
|
|
497
582
|
// Body requirement: identified entries require a body; referenced entries
|
|
498
583
|
// may omit it. If there's only one child (the title paragraph), admit
|
|
499
584
|
// only referenced entries.
|
|
500
|
-
if (shape !== "Reference" && item.children.length < 2)
|
|
585
|
+
if (shape !== "Reference" && item.children.length < 2 && !allowTitleOnly) {
|
|
501
586
|
return undefined;
|
|
587
|
+
}
|
|
502
588
|
// Source location
|
|
503
589
|
const line = item.position?.start.line ?? 1;
|
|
504
590
|
const column = item.position?.start.column ?? 1;
|
|
@@ -543,6 +629,7 @@ function extractEntry(item, markdownLines, file, definitions, isReferencesDoc, d
|
|
|
543
629
|
location: entryLocation,
|
|
544
630
|
bodyStartLine,
|
|
545
631
|
...(endLine !== undefined ? { endLine } : {}),
|
|
632
|
+
...(attributeLines.length > 0 ? { attributeLines } : {}),
|
|
546
633
|
source: { kind: "markdown" },
|
|
547
634
|
properties: { file: { path: file, line, column } },
|
|
548
635
|
bodyTokens,
|
|
@@ -588,5 +675,7 @@ function extractBodyContent(item, lines) {
|
|
|
588
675
|
return line.slice(indent);
|
|
589
676
|
return line;
|
|
590
677
|
});
|
|
591
|
-
|
|
678
|
+
// Keep the first line's own indent: it marks an indented trailer in a
|
|
679
|
+
// body-less entry, and `markspec fmt` sees the same text (#916).
|
|
680
|
+
return stripped.join("\n").trimEnd();
|
|
592
681
|
}
|
package/script/parser/mod.d.ts
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* - source: doc comment extraction from Rust, Kotlin, C, C++, Java
|
|
11
11
|
*/
|
|
12
12
|
import type { Caption, Diagnostic, Document, Entry } from "../model/mod.js";
|
|
13
|
+
import { type GherkinApi } from "../gherkin/load.js";
|
|
13
14
|
import { type DetectCaptionsOptions } from "./captions.js";
|
|
14
15
|
export type { DetectCaptionsOptions } from "./captions.js";
|
|
15
16
|
export { detectDirectives } from "./directives.js";
|
|
@@ -56,6 +57,21 @@ export interface ParseFileResult {
|
|
|
56
57
|
*/
|
|
57
58
|
readonly diagnostics: readonly Diagnostic[];
|
|
58
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* A fenced code block whose info string starts with the word `gherkin` or
|
|
62
|
+
* `feature`, followed by whitespace or the end of the line (so
|
|
63
|
+
* `gherkin-json` does not match). The fence has three or more backticks or
|
|
64
|
+
* tildes. Before the fence, the line may hold spaces, tabs, blockquote
|
|
65
|
+
* markers and doc-comment prefixes (`>`, `///`, `//!`, ` *`, `#`), and list
|
|
66
|
+
* markers (`-`, `*`, `+`, `1.`, `1)`) followed by a space or tab. The
|
|
67
|
+
* prefix holds no newline, so the match never spans lines, and each
|
|
68
|
+
* prefix character matches only one alternative, so the scan stays linear.
|
|
69
|
+
*
|
|
70
|
+
* @internal Exported for tests.
|
|
71
|
+
*/
|
|
72
|
+
export declare const GHERKIN_FENCE_RE: RegExp;
|
|
73
|
+
/** Loads the Gherkin parser; replaced in tests. */
|
|
74
|
+
type GherkinLoader = () => Promise<GherkinApi>;
|
|
59
75
|
/**
|
|
60
76
|
* Parse a file and return entries, annotation links, and (for Markdown
|
|
61
77
|
* files) a Document with front-matter attributes.
|
|
@@ -66,6 +82,8 @@ export interface ParseFileResult {
|
|
|
66
82
|
*/
|
|
67
83
|
export declare function parseFile(content: string, options: {
|
|
68
84
|
readonly file: string;
|
|
85
|
+
/** @internal Replaces the Gherkin parser loader in tests. */
|
|
86
|
+
readonly gherkinLoader?: GherkinLoader;
|
|
69
87
|
}): Promise<ParseFileResult>;
|
|
70
88
|
/**
|
|
71
89
|
* Detect table and figure captions in a Markdown string.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/parser/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/parser/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAE5E,OAAO,EAAE,KAAK,UAAU,EAAe,MAAM,oBAAoB,CAAC;AAUlE,OAAO,EAEL,KAAK,qBAAqB,EAC3B,MAAM,eAAe,CAAC;AAEvB,YAAY,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAE3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,YAAY,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAE/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,YAAY,EACV,yBAAyB,EACzB,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,YAAY,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAE/D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,cAAc,GACf,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAElE,YAAY,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,YAAY,EACV,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE5E,qCAAqC;AACrC,MAAM,WAAW,YAAY;IAC3B,0CAA0C;IAC1C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;GAMG;AACH,wBAAgB,KAAK,CACnB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,YAAY,GACrB,KAAK,EAAE,CAOT;AAED,4EAA4E;AAC5E,MAAM,WAAW,eAAe;IAC9B,sBAAsB;IACtB,QAAQ,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;IAC1B;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAC7B;;;OAGG;IACH,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;CAC7C;AAeD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gBAAgB,QACkE,CAAC;AAEhG,mDAAmD;AACnD,KAAK,aAAa,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC;AAE/C;;;;;;;GAOG;AACH,wBAAsB,SAAS,CAC7B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE;IACP,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,6DAA6D;IAC7D,QAAQ,CAAC,aAAa,CAAC,EAAE,aAAa,CAAC;CACxC,GACA,OAAO,CAAC,eAAe,CAAC,CAwF1B;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,EAAE,CAEX"}
|
package/script/parser/mod.js
CHANGED
|
@@ -11,12 +11,14 @@
|
|
|
11
11
|
* - source: doc comment extraction from Rust, Kotlin, C, C++, Java
|
|
12
12
|
*/
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.languageIdForExtension = exports.LANGUAGE_SPECS = exports.buildBlockLineMap = exports.loadGrammar = exports.isSupportedExtension = exports.wrapAsListItem = exports.stripLineCommentPrefix = exports.stripBlockCommentPrefix = exports.parseSource = exports.detectInlineRefs = exports.extractFrontMatter = exports.detectDirectives = void 0;
|
|
14
|
+
exports.GHERKIN_FENCE_RE = exports.languageIdForExtension = exports.LANGUAGE_SPECS = exports.buildBlockLineMap = exports.loadGrammar = exports.isSupportedExtension = exports.wrapAsListItem = exports.stripLineCommentPrefix = exports.stripBlockCommentPrefix = exports.parseSource = exports.detectInlineRefs = exports.extractFrontMatter = exports.detectDirectives = void 0;
|
|
15
15
|
exports.parse = parse;
|
|
16
16
|
exports.parseFile = parseFile;
|
|
17
17
|
exports.detectCaptions = detectCaptions;
|
|
18
18
|
const path_1 = require("@std/path");
|
|
19
19
|
const line_endings_js_1 = require("../util/line_endings.js");
|
|
20
|
+
const load_js_1 = require("../gherkin/load.js");
|
|
21
|
+
const feature_file_js_1 = require("./feature_file.js");
|
|
20
22
|
const markdown_js_1 = require("./markdown.js");
|
|
21
23
|
const grammars_js_1 = require("./grammars.js");
|
|
22
24
|
const source_js_1 = require("./source.js");
|
|
@@ -70,6 +72,19 @@ function isReferencesDocument(file) {
|
|
|
70
72
|
// same as POSIX.
|
|
71
73
|
return /[\\/]references[\\/]/.test(file);
|
|
72
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* A fenced code block whose info string starts with the word `gherkin` or
|
|
77
|
+
* `feature`, followed by whitespace or the end of the line (so
|
|
78
|
+
* `gherkin-json` does not match). The fence has three or more backticks or
|
|
79
|
+
* tildes. Before the fence, the line may hold spaces, tabs, blockquote
|
|
80
|
+
* markers and doc-comment prefixes (`>`, `///`, `//!`, ` *`, `#`), and list
|
|
81
|
+
* markers (`-`, `*`, `+`, `1.`, `1)`) followed by a space or tab. The
|
|
82
|
+
* prefix holds no newline, so the match never spans lines, and each
|
|
83
|
+
* prefix character matches only one alternative, so the scan stays linear.
|
|
84
|
+
*
|
|
85
|
+
* @internal Exported for tests.
|
|
86
|
+
*/
|
|
87
|
+
exports.GHERKIN_FENCE_RE = /^(?:[ \t/*#!>]|[-+][ \t]|\d{1,9}[.)][ \t])*(`{3,}|~{3,})[ \t]*(gherkin|feature)(?=[ \t]|$)/m;
|
|
73
88
|
/**
|
|
74
89
|
* Parse a file and return entries, annotation links, and (for Markdown
|
|
75
90
|
* files) a Document with front-matter attributes.
|
|
@@ -80,7 +95,43 @@ function isReferencesDocument(file) {
|
|
|
80
95
|
*/
|
|
81
96
|
async function parseFile(content, options) {
|
|
82
97
|
const ext = (0, path_1.extname)(options.file);
|
|
98
|
+
const lowerExt = ext.toLowerCase();
|
|
83
99
|
const normalised = (0, line_endings_js_1.normalizeLineEndings)(content);
|
|
100
|
+
// A `.feature` file always needs the parser (ADR-038): entries come from
|
|
101
|
+
// its `# [ID]` header comments. A load failure gives no entries and one
|
|
102
|
+
// MSL-B062 when the file has a header line, and never throws.
|
|
103
|
+
if (lowerExt === ".feature") {
|
|
104
|
+
let api;
|
|
105
|
+
try {
|
|
106
|
+
api = await (options.gherkinLoader ?? load_js_1.loadGherkin)();
|
|
107
|
+
}
|
|
108
|
+
catch (err) {
|
|
109
|
+
const diagnostics = (0, feature_file_js_1.hasFeatureHeaderLine)(normalised)
|
|
110
|
+
? [{
|
|
111
|
+
code: "MSL-B062",
|
|
112
|
+
severity: "warning",
|
|
113
|
+
message: `Gherkin file not parsed: the Gherkin parser failed to ` +
|
|
114
|
+
`load (${err instanceof Error ? err.message : String(err)})`,
|
|
115
|
+
location: { file: options.file, line: 1, column: 1 },
|
|
116
|
+
}]
|
|
117
|
+
: [];
|
|
118
|
+
return { entries: [], diagnostics };
|
|
119
|
+
}
|
|
120
|
+
return (0, feature_file_js_1.parseFeatureFile)(normalised, { file: options.file, api });
|
|
121
|
+
}
|
|
122
|
+
// Load the Gherkin parser before the synchronous parse, and only when the
|
|
123
|
+
// text holds a gherkin or feature fence (the load is cached). A failed
|
|
124
|
+
// load is not fatal: parsing continues without the Gherkin AST, and the
|
|
125
|
+
// criteria come from the line scanner. The loader does not cache the
|
|
126
|
+
// failure, so a later file tries again.
|
|
127
|
+
if (exports.GHERKIN_FENCE_RE.test(normalised)) {
|
|
128
|
+
try {
|
|
129
|
+
await (options.gherkinLoader ?? load_js_1.loadGherkin)();
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
// Continue without the parser (ADR-038 Decision 4).
|
|
133
|
+
}
|
|
134
|
+
}
|
|
84
135
|
if ((0, grammars_js_1.isSupportedExtension)(ext)) {
|
|
85
136
|
const language = await (0, grammars_js_1.loadGrammar)(ext);
|
|
86
137
|
const languageId = (0, grammars_js_1.languageIdForExtension)(ext);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translate.d.ts","sourceRoot":"","sources":["../../src/parser/translate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAkB,MAAM,iBAAiB,CAAC;AAE7D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAI7C;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,SAAS,KAAK,EAAE,EACzB,OAAO,EAAE,OAAO,GACf,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"translate.d.ts","sourceRoot":"","sources":["../../src/parser/translate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAkB,MAAM,iBAAiB,CAAC;AAE7D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAI7C;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,SAAS,KAAK,EAAE,EACzB,OAAO,EAAE,OAAO,GACf,KAAK,EAAE,CAgET"}
|
|
@@ -45,6 +45,11 @@ function translateEntryLocations(entries, lineMap) {
|
|
|
45
45
|
endLine: lineMap.translate(entry.endLine, 1)?.line ?? entry.endLine,
|
|
46
46
|
}
|
|
47
47
|
: {}),
|
|
48
|
+
...(entry.attributeLines !== undefined
|
|
49
|
+
? {
|
|
50
|
+
attributeLines: entry.attributeLines.map((line) => lineMap.translate(line, 1)?.line ?? line),
|
|
51
|
+
}
|
|
52
|
+
: {}),
|
|
48
53
|
bodyAst: entry.bodyAst
|
|
49
54
|
? entry.bodyAst.map((block) => translateBlock(block, lineMap, fallbackPoint, warn))
|
|
50
55
|
: entry.bodyAst,
|
package/script/refs/mod.d.ts
CHANGED
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
*
|
|
10
10
|
* Architecture: composed AROUND the pure `core/formatter` by the `markspec fmt`
|
|
11
11
|
* CLI. It MUST NOT import `core/formatter`, and `core/formatter` MUST NOT import
|
|
12
|
-
*
|
|
12
|
+
* this module (WASM-migration purity guard, AGENTS.md). The formatter may
|
|
13
|
+
* import only the pure leaf `core/refs/split.ts` (ADR-026 D6).
|
|
13
14
|
*/
|
|
14
15
|
import type { Entry } from "../model/mod.js";
|
|
15
16
|
import type { LockEdge } from "../lock/mod.js";
|
|
@@ -34,9 +35,13 @@ export declare function buildRefIndex(entries: readonly Entry[]): RefIndex;
|
|
|
34
35
|
* Rewrite trace-attribute values in `content` per the canonicalise/heal rules.
|
|
35
36
|
* `entries` MUST be the parse of `content` (used to map each trailer line to its
|
|
36
37
|
* source entry's stable ULID). Returns the rewritten text and whether anything
|
|
37
|
-
* changed. Lossless: only resolvable value tokens are replaced.
|
|
38
|
+
* changed. Lossless: only resolvable value tokens are replaced. Optional
|
|
39
|
+
* `preservedRanges` exclude 0-based, end-exclusive line spans from rewriting.
|
|
38
40
|
*/
|
|
39
|
-
export declare function canonicalizeRefs(content: string, entries: readonly Entry[], index: RefIndex, ledger: readonly LockEdge[]
|
|
41
|
+
export declare function canonicalizeRefs(content: string, entries: readonly Entry[], index: RefIndex, ledger: readonly LockEdge[], preservedRanges?: readonly {
|
|
42
|
+
readonly start: number;
|
|
43
|
+
readonly end: number;
|
|
44
|
+
}[]): {
|
|
40
45
|
output: string;
|
|
41
46
|
changed: boolean;
|
|
42
47
|
};
|
package/script/refs/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/refs/mod.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/refs/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAO7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG/C;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,EAAE,WAAW,CAAC,MAAM,CAGnD,CAAC;AAEH,iFAAiF;AACjF,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,eAAe,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtD,QAAQ,CAAC,eAAe,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,SAAS,KAAK,EAAE,GAAG,QAAQ,CAajE;AAmBD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,SAAS,KAAK,EAAE,EACzB,KAAK,EAAE,QAAQ,EACf,MAAM,EAAE,SAAS,QAAQ,EAAE,EAC3B,eAAe,GAAE,SAAS;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,EACtE,GACH;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAwGtC"}
|
package/script/refs/mod.js
CHANGED
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
*
|
|
11
11
|
* Architecture: composed AROUND the pure `core/formatter` by the `markspec fmt`
|
|
12
12
|
* CLI. It MUST NOT import `core/formatter`, and `core/formatter` MUST NOT import
|
|
13
|
-
*
|
|
13
|
+
* this module (WASM-migration purity guard, AGENTS.md). The formatter may
|
|
14
|
+
* import only the pure leaf `core/refs/split.ts` (ADR-026 D6).
|
|
14
15
|
*/
|
|
15
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
17
|
exports.TRACE_ATTRIBUTE_KEYS = void 0;
|
|
@@ -54,15 +55,21 @@ const TRACE_TRAILER_RE = /^(\s{4,})([A-Z][A-Za-z-]*)(\s*:\s*)(.*)$/;
|
|
|
54
55
|
* non-empty value-rest (no `Key:` — that sat on the first physical line).
|
|
55
56
|
*/
|
|
56
57
|
const CONTINUATION_LINE_RE = /^(\s+)(\S.*)$/;
|
|
57
|
-
/**
|
|
58
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Token splitter that preserves separators between value tokens. The first
|
|
60
|
+
* alternative matches a closed scenario locator after whitespace
|
|
61
|
+
* (`STK_1 [AC one]`, #915, same grammar as `refs/split.ts`); a locator is
|
|
62
|
+
* kept verbatim, so only the target before it is rewritten.
|
|
63
|
+
*/
|
|
64
|
+
const VALUE_TOKEN_RE = /(\s\[(?:\\[\s\S]|[^\]\\])+\])|[^\s,]+/g;
|
|
59
65
|
/**
|
|
60
66
|
* Rewrite trace-attribute values in `content` per the canonicalise/heal rules.
|
|
61
67
|
* `entries` MUST be the parse of `content` (used to map each trailer line to its
|
|
62
68
|
* source entry's stable ULID). Returns the rewritten text and whether anything
|
|
63
|
-
* changed. Lossless: only resolvable value tokens are replaced.
|
|
69
|
+
* changed. Lossless: only resolvable value tokens are replaced. Optional
|
|
70
|
+
* `preservedRanges` exclude 0-based, end-exclusive line spans from rewriting.
|
|
64
71
|
*/
|
|
65
|
-
function canonicalizeRefs(content, entries, index, ledger) {
|
|
72
|
+
function canonicalizeRefs(content, entries, index, ledger, preservedRanges = []) {
|
|
66
73
|
const ledgerByKey = new Map();
|
|
67
74
|
for (const e of ledger) {
|
|
68
75
|
if (e.targetUlid === undefined)
|
|
@@ -92,7 +99,11 @@ function canonicalizeRefs(content, entries, index, ledger) {
|
|
|
92
99
|
let changed = false;
|
|
93
100
|
// Share CommonMark fence boundaries with other prose passes. Compute them
|
|
94
101
|
// once so both the main loop and continuation loop remain linear (#705).
|
|
95
|
-
const fencedLines = (0, fence_js_1.fencedCodeLines)(content);
|
|
102
|
+
const fencedLines = new Set((0, fence_js_1.fencedCodeLines)(content));
|
|
103
|
+
for (const range of preservedRanges) {
|
|
104
|
+
for (let i = range.start; i < range.end; i++)
|
|
105
|
+
fencedLines.add(i);
|
|
106
|
+
}
|
|
96
107
|
for (let i = 0; i < lines.length; i++) {
|
|
97
108
|
if (fencedLines.has(i))
|
|
98
109
|
continue;
|
|
@@ -158,7 +169,9 @@ function canonicalizeRefs(content, entries, index, ledger) {
|
|
|
158
169
|
function rewriteValuePreservingContinuation(value, sourceUlid, relation, index, ledgerByKey) {
|
|
159
170
|
const hasBackslash = value.endsWith("\\");
|
|
160
171
|
const core = hasBackslash ? value.slice(0, -1) : value;
|
|
161
|
-
const rewritten = core.replace(VALUE_TOKEN_RE, (token) =>
|
|
172
|
+
const rewritten = core.replace(VALUE_TOKEN_RE, (token, locator) => locator !== undefined
|
|
173
|
+
? token
|
|
174
|
+
: rewriteToken(token, sourceUlid, relation, index, ledgerByKey));
|
|
162
175
|
return hasBackslash ? `${rewritten}\\` : rewritten;
|
|
163
176
|
}
|
|
164
177
|
function rewriteToken(token, sourceUlid, relation, index, ledgerByKey) {
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module refs/split
|
|
3
|
+
*
|
|
4
|
+
* Bracket-aware splitting of trace attribute values. A value is
|
|
5
|
+
* `target [ 1*WSP "[" locator "]" ]`. A locator can contain commas, so a
|
|
6
|
+
* plain split on commas is wrong for it. The escapes `\]` and `\\` are
|
|
7
|
+
* valid inside a locator only; any other backslash sequence (such as `\x`)
|
|
8
|
+
* is kept as written. A locator must follow whitespace after the target,
|
|
9
|
+
* so `A[x]` has no locator. A value without a closed locator is read
|
|
10
|
+
* exactly as before scenario locators existed.
|
|
11
|
+
*/
|
|
12
|
+
/** A parsed trace value. */
|
|
13
|
+
export interface ParsedTraceValue {
|
|
14
|
+
/** The referenced entry or reference identifier. */
|
|
15
|
+
readonly target: string;
|
|
16
|
+
/** The locator after {@linkcode normalizeLocator} and unescaping. */
|
|
17
|
+
readonly locator?: string;
|
|
18
|
+
/** The locator text exactly as authored between the brackets. */
|
|
19
|
+
readonly locatorRaw?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Normalize locator text for comparison: Unicode NFC, trim, and collapse
|
|
23
|
+
* each whitespace run to one space.
|
|
24
|
+
*/
|
|
25
|
+
export declare function normalizeLocator(text: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Split a trace attribute value into its parts. When at least one part has
|
|
28
|
+
* a closed bracket locator after whitespace, commas inside a locator do not
|
|
29
|
+
* split. Otherwise the value is split on every comma, exactly as before
|
|
30
|
+
* scenario locators existed, so an unterminated `[` does not change how a
|
|
31
|
+
* value is read. Parts are trimmed and empty parts are dropped.
|
|
32
|
+
*/
|
|
33
|
+
export declare function splitTraceValues(value: string): string[];
|
|
34
|
+
/**
|
|
35
|
+
* Parse one value from {@linkcode splitTraceValues} into target and
|
|
36
|
+
* optional locator. A value without a closed locator after whitespace is
|
|
37
|
+
* kept whole as the target, as before scenario locators existed.
|
|
38
|
+
*/
|
|
39
|
+
export declare function parseTraceValue(raw: string): ParsedTraceValue;
|
|
40
|
+
/**
|
|
41
|
+
* `true` when a trace value has a `[` after whitespace that no unescaped
|
|
42
|
+
* `]` closes. Such a value has no locator.
|
|
43
|
+
*/
|
|
44
|
+
export declare function isUnterminatedLocator(raw: string): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* The target of a trace value for existence and value-type checks: the
|
|
47
|
+
* target before a closed bracket locator, else the trimmed value as
|
|
48
|
+
* written.
|
|
49
|
+
*/
|
|
50
|
+
export declare function traceTarget(raw: string): string;
|
|
51
|
+
/**
|
|
52
|
+
* The tokens of a trace value that can name another entry, for reference
|
|
53
|
+
* scans (find references, dependent counts). A closed locator is dropped,
|
|
54
|
+
* so an ID written inside a locator is not a reference. Any other part is
|
|
55
|
+
* split on whitespace and commas, as before scenario locators existed.
|
|
56
|
+
*/
|
|
57
|
+
export declare function referenceTokens(value: string): string[];
|
|
58
|
+
//# sourceMappingURL=split.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"split.d.ts","sourceRoot":"","sources":["../../src/refs/split.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,4BAA4B;AAC5B,MAAM,WAAW,gBAAgB;IAC/B,oDAAoD;IACpD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,qEAAqE;IACrE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,iEAAiE;IACjE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAErD;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAKxD;AAqCD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAU7D;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAa1D;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAWvD"}
|