@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
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/formatter/feature_file
|
|
3
|
+
*
|
|
4
|
+
* Write-back for `.feature` files (epic #915, Case B). The only change
|
|
5
|
+
* `fmt` makes is to insert a missing `# Id: <ULID>` line into the header
|
|
6
|
+
* comment of a headed entry. Gherkin text, other comments and line endings
|
|
7
|
+
* stay as they are. The Markdown entry formatter and the ADR-029 prose pass
|
|
8
|
+
* never run on `.feature` text.
|
|
9
|
+
*/
|
|
10
|
+
import type { Entry } from "../model/mod.js";
|
|
11
|
+
/** Result of {@linkcode formatFeatureFile}. */
|
|
12
|
+
export interface FeatureFormatResult {
|
|
13
|
+
readonly output: string;
|
|
14
|
+
readonly changed: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Insert a missing `# Id: <ULID>` line into the header of each entry of a
|
|
18
|
+
* `.feature` file.
|
|
19
|
+
*
|
|
20
|
+
* The line goes before the first trailer line, with that line's comment
|
|
21
|
+
* prefix, so it matches the header's indentation and trailer spacing. A
|
|
22
|
+
* header without a trailer gets a `#` line (unless its last line is already
|
|
23
|
+
* an empty comment) and then the Id line, at the end of the header. An entry
|
|
24
|
+
* that has an Id, and every other part of the file, is left unchanged.
|
|
25
|
+
*
|
|
26
|
+
* @param text - The file text (LF or CRLF).
|
|
27
|
+
* @param entries - The entries parsed from `text`.
|
|
28
|
+
* @param generateUlid - ULID generator.
|
|
29
|
+
*/
|
|
30
|
+
export declare function formatFeatureFile(text: string, entries: readonly Entry[], generateUlid?: () => string): FeatureFormatResult;
|
|
31
|
+
/**
|
|
32
|
+
* Parse a `.feature` file and stamp the missing Ids of its entries. A file
|
|
33
|
+
* that does not parse has no entries, so it comes back unchanged.
|
|
34
|
+
*
|
|
35
|
+
* @param text - The file text.
|
|
36
|
+
* @param file - File path, used for parsing and diagnostics.
|
|
37
|
+
* @param generateUlid - ULID generator.
|
|
38
|
+
*/
|
|
39
|
+
export declare function formatFeatureText(text: string, file: string, generateUlid?: () => string): Promise<FeatureFormatResult>;
|
|
40
|
+
//# sourceMappingURL=feature_file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feature_file.d.ts","sourceRoot":"","sources":["../../src/formatter/feature_file.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAY7C,+CAA+C;AAC/C,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAOD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,SAAS,KAAK,EAAE,EACzB,YAAY,GAAE,MAAM,MAAoB,GACvC,mBAAmB,CA0CrB;AAED;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,YAAY,GAAE,MAAM,MAAoB,GACvC,OAAO,CAAC,mBAAmB,CAAC,CAG9B"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module core/formatter/feature_file
|
|
4
|
+
*
|
|
5
|
+
* Write-back for `.feature` files (epic #915, Case B). The only change
|
|
6
|
+
* `fmt` makes is to insert a missing `# Id: <ULID>` line into the header
|
|
7
|
+
* comment of a headed entry. Gherkin text, other comments and line endings
|
|
8
|
+
* stay as they are. The Markdown entry formatter and the ADR-029 prose pass
|
|
9
|
+
* never run on `.feature` text.
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.formatFeatureFile = formatFeatureFile;
|
|
13
|
+
exports.formatFeatureText = formatFeatureText;
|
|
14
|
+
const ulid_1 = require("@std/ulid");
|
|
15
|
+
const mod_js_1 = require("../parser/mod.js");
|
|
16
|
+
const feature_file_js_1 = require("../parser/feature_file.js");
|
|
17
|
+
const line_endings_js_1 = require("../util/line_endings.js");
|
|
18
|
+
/** Leading whitespace, `#`, and the spaces after it. */
|
|
19
|
+
const COMMENT_PREFIX_RE = /^(\s*#[ \t]*)/;
|
|
20
|
+
/** `true` when `line` is a comment line. */
|
|
21
|
+
function isComment(line) {
|
|
22
|
+
return line !== undefined && line.trimStart().startsWith("#");
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Insert a missing `# Id: <ULID>` line into the header of each entry of a
|
|
26
|
+
* `.feature` file.
|
|
27
|
+
*
|
|
28
|
+
* The line goes before the first trailer line, with that line's comment
|
|
29
|
+
* prefix, so it matches the header's indentation and trailer spacing. A
|
|
30
|
+
* header without a trailer gets a `#` line (unless its last line is already
|
|
31
|
+
* an empty comment) and then the Id line, at the end of the header. An entry
|
|
32
|
+
* that has an Id, and every other part of the file, is left unchanged.
|
|
33
|
+
*
|
|
34
|
+
* @param text - The file text (LF or CRLF).
|
|
35
|
+
* @param entries - The entries parsed from `text`.
|
|
36
|
+
* @param generateUlid - ULID generator.
|
|
37
|
+
*/
|
|
38
|
+
function formatFeatureFile(text, entries, generateUlid = ulid_1.ulid) {
|
|
39
|
+
const ending = (0, line_endings_js_1.detectLineEnding)(text);
|
|
40
|
+
const lines = (0, line_endings_js_1.normalizeLineEndings)(text).split("\n");
|
|
41
|
+
const missing = entries
|
|
42
|
+
.filter((e) => e.source.kind === "feature-file" && e.id === undefined &&
|
|
43
|
+
e.shape === "Authored")
|
|
44
|
+
.sort((a, b) => b.location.line - a.location.line);
|
|
45
|
+
if (missing.length === 0)
|
|
46
|
+
return { output: text, changed: false };
|
|
47
|
+
let changed = false;
|
|
48
|
+
for (const entry of missing) {
|
|
49
|
+
const titleIdx = entry.location.line - 1;
|
|
50
|
+
if (!isComment(lines[titleIdx]))
|
|
51
|
+
continue;
|
|
52
|
+
// End of the header run: consecutive comment lines, up to the next
|
|
53
|
+
// header start or a `# language:` line.
|
|
54
|
+
const endIdx = (0, feature_file_js_1.featureHeaderRunEnd)(lines, titleIdx) - 1;
|
|
55
|
+
const firstTrailer = entry.attributeLines?.[0];
|
|
56
|
+
const trailerIdx = firstTrailer === undefined
|
|
57
|
+
? undefined
|
|
58
|
+
: firstTrailer - 1;
|
|
59
|
+
if (trailerIdx !== undefined && trailerIdx > titleIdx &&
|
|
60
|
+
trailerIdx <= endIdx) {
|
|
61
|
+
const prefix = COMMENT_PREFIX_RE.exec(lines[trailerIdx])[1];
|
|
62
|
+
lines.splice(trailerIdx, 0, `${prefix}Id: ${generateUlid()}`);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
const indent = /^\s*/.exec(lines[titleIdx])[0];
|
|
66
|
+
const added = [];
|
|
67
|
+
if (lines[endIdx].trim() !== "#")
|
|
68
|
+
added.push(`${indent}#`);
|
|
69
|
+
added.push(`${indent}# Id: ${generateUlid()}`);
|
|
70
|
+
lines.splice(endIdx + 1, 0, ...added);
|
|
71
|
+
}
|
|
72
|
+
changed = true;
|
|
73
|
+
}
|
|
74
|
+
if (!changed)
|
|
75
|
+
return { output: text, changed: false };
|
|
76
|
+
return {
|
|
77
|
+
output: (0, line_endings_js_1.applyLineEnding)(lines.join("\n"), ending),
|
|
78
|
+
changed: true,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Parse a `.feature` file and stamp the missing Ids of its entries. A file
|
|
83
|
+
* that does not parse has no entries, so it comes back unchanged.
|
|
84
|
+
*
|
|
85
|
+
* @param text - The file text.
|
|
86
|
+
* @param file - File path, used for parsing and diagnostics.
|
|
87
|
+
* @param generateUlid - ULID generator.
|
|
88
|
+
*/
|
|
89
|
+
async function formatFeatureText(text, file, generateUlid = ulid_1.ulid) {
|
|
90
|
+
const { entries } = await (0, mod_js_1.parseFile)(text, { file });
|
|
91
|
+
return formatFeatureFile(text, entries, generateUlid);
|
|
92
|
+
}
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* @module formatter/md_equiv
|
|
3
3
|
*
|
|
4
4
|
* CommonMark-semantic Markdown equivalence — the gate for the ADR-029
|
|
5
|
-
* dprint pass. Two fragments are equivalent
|
|
6
|
-
* same mdast structure after eliding source `position`s
|
|
5
|
+
* dprint pass and entry tab-marker normalization. Two fragments are equivalent
|
|
6
|
+
* when they parse to the same mdast structure after eliding source `position`s
|
|
7
|
+
* and collapsing
|
|
7
8
|
* ASCII whitespace runs inside `text` node values. Only ASCII
|
|
8
9
|
* whitespace is collapsed — NBSP (U+00A0) and Unicode spaces are
|
|
9
10
|
* content, not wrap artifacts, and must not compare equal to a plain
|
|
@@ -15,9 +16,9 @@
|
|
|
15
16
|
* and definition `url`s stay byte-exact.
|
|
16
17
|
*
|
|
17
18
|
* DELIBERATELY weaker than ADR-015's `astEquivalent` (byte-verbatim on
|
|
18
|
-
* inline markup). Used
|
|
19
|
-
* ADR-015 relation still guards §5.2 body emission (MSL-F900) and must
|
|
20
|
-
*
|
|
19
|
+
* inline markup). Used to accept/reject dprint output and tab-marker rewrites.
|
|
20
|
+
* The ADR-015 relation still guards §5.2 body emission (MSL-F900) and must not
|
|
21
|
+
* be modified.
|
|
21
22
|
*/
|
|
22
23
|
/** True when `a` and `b` are the same Markdown, modulo presentation. */
|
|
23
24
|
export declare function markdownSemanticallyEquivalent(a: string, b: string): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"md_equiv.d.ts","sourceRoot":"","sources":["../../src/formatter/md_equiv.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"md_equiv.d.ts","sourceRoot":"","sources":["../../src/formatter/md_equiv.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAQH,wEAAwE;AACxE,wBAAgB,8BAA8B,CAC5C,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,GACR,OAAO,CAMT"}
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
* @module formatter/md_equiv
|
|
4
4
|
*
|
|
5
5
|
* CommonMark-semantic Markdown equivalence — the gate for the ADR-029
|
|
6
|
-
* dprint pass. Two fragments are equivalent
|
|
7
|
-
* same mdast structure after eliding source `position`s
|
|
6
|
+
* dprint pass and entry tab-marker normalization. Two fragments are equivalent
|
|
7
|
+
* when they parse to the same mdast structure after eliding source `position`s
|
|
8
|
+
* and collapsing
|
|
8
9
|
* ASCII whitespace runs inside `text` node values. Only ASCII
|
|
9
10
|
* whitespace is collapsed — NBSP (U+00A0) and Unicode spaces are
|
|
10
11
|
* content, not wrap artifacts, and must not compare equal to a plain
|
|
@@ -16,9 +17,9 @@
|
|
|
16
17
|
* and definition `url`s stay byte-exact.
|
|
17
18
|
*
|
|
18
19
|
* DELIBERATELY weaker than ADR-015's `astEquivalent` (byte-verbatim on
|
|
19
|
-
* inline markup). Used
|
|
20
|
-
* ADR-015 relation still guards §5.2 body emission (MSL-F900) and must
|
|
21
|
-
*
|
|
20
|
+
* inline markup). Used to accept/reject dprint output and tab-marker rewrites.
|
|
21
|
+
* The ADR-015 relation still guards §5.2 body emission (MSL-F900) and must not
|
|
22
|
+
* be modified.
|
|
22
23
|
*/
|
|
23
24
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
24
25
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* and requirement block insertion.
|
|
7
7
|
*/
|
|
8
8
|
import type { Attribute, Diagnostic } from "../model/mod.js";
|
|
9
|
+
import { type EntryExtent } from "./prose.js";
|
|
9
10
|
import { type ProseFormatter } from "./dprint.js";
|
|
10
11
|
/**
|
|
11
12
|
* Decide whether the EARS keyword at `offset` in `line` is at sentence
|
|
@@ -76,6 +77,8 @@ export interface FormatResult {
|
|
|
76
77
|
readonly diagnostics: readonly Diagnostic[];
|
|
77
78
|
/** Whether any changes were made. */
|
|
78
79
|
readonly changed: boolean;
|
|
80
|
+
/** Output line spans (0-based, end exclusive) kept unchanged after refusal. */
|
|
81
|
+
readonly preservedRanges?: readonly EntryExtent[];
|
|
79
82
|
}
|
|
80
83
|
/**
|
|
81
84
|
* Format a Markdown string — normalize attribute blocks,
|
|
@@ -90,7 +93,9 @@ export declare function format(markdown: string, options?: FormatOptions): Forma
|
|
|
90
93
|
* Expand CSV values on repeatable-type attributes into one entry per value
|
|
91
94
|
* per ADR-002 §2.6. `id-list` / `tag-list` / `external-id` accept CSV input
|
|
92
95
|
* but must round-trip as multi-line output; `citation` is left alone
|
|
93
|
-
* because locators may contain commas.
|
|
96
|
+
* because locators may contain commas. `id-list` values split with
|
|
97
|
+
* {@linkcode splitTraceValues}, so a comma inside a scenario locator does
|
|
98
|
+
* not split.
|
|
94
99
|
*/
|
|
95
100
|
export declare function expandCsvValues(attrs: Attribute[]): Attribute[];
|
|
96
101
|
/**
|
|
@@ -141,9 +146,26 @@ export declare function findItemEnd(lines: readonly string[], startIdx: number,
|
|
|
141
146
|
* for an entry starting at the given line.
|
|
142
147
|
*
|
|
143
148
|
* Scans forward from the entry start to find the list item boundary,
|
|
144
|
-
* then
|
|
149
|
+
* then passes the entry content below the last preserved range, with the
|
|
150
|
+
* list-item indent removed, to the parser's {@linkcode findTrailerStart}.
|
|
151
|
+
* The formatter and the parser therefore agree on which lines are the
|
|
152
|
+
* trailer, so `markspec fmt` never rewrites a line that the parser read as
|
|
153
|
+
* body, and never drops an attribute line that the parser read (#916).
|
|
154
|
+
* The LSP MSL-P023 quick fix uses it too.
|
|
155
|
+
*
|
|
156
|
+
* @param lines - Raw lines of the whole file.
|
|
157
|
+
* @param entryStartLine - 1-based line of the entry's title (`- [ID] ...`).
|
|
158
|
+
* @param indent - Content column of the list item: the 0-based column of
|
|
159
|
+
* the `[` that opens the display ID.
|
|
160
|
+
* @param itemEndFloor - Pass the parser's `Entry.endLine` (0 when unknown):
|
|
161
|
+
* the item end scan starts no earlier than this line index, so a lazy
|
|
162
|
+
* continuation line does not end the item early (see `findItemEnd`).
|
|
163
|
+
* @param preservedRanges - Ranges inside the entry that are kept verbatim
|
|
164
|
+
* (nested entries); the trailer is searched below the last one.
|
|
165
|
+
* @returns The 0-based, half-open line range `[start, end)` of the trailer
|
|
166
|
+
* over `lines`, or `undefined` when the entry has no trailer.
|
|
145
167
|
*/
|
|
146
|
-
export declare function findAttributeBlockRange(lines: readonly string[], entryStartLine: number, indent: number, itemEndFloor?: number): {
|
|
168
|
+
export declare function findAttributeBlockRange(lines: readonly string[], entryStartLine: number, indent: number, itemEndFloor?: number, preservedRanges?: readonly EntryExtent[]): {
|
|
147
169
|
start: number;
|
|
148
170
|
end: number;
|
|
149
171
|
} | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/formatter/mod.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EAGX,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/formatter/mod.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EAGX,MAAM,iBAAiB,CAAC;AA8BzB,OAAO,EAAE,KAAK,WAAW,EAAuB,MAAM,YAAY,CAAC;AAOnE,OAAO,EAEL,KAAK,cAAc,EACpB,MAAM,aAAa,CAAC;AAGrB;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAEvE;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE/D;AA4WD,sCAAsC;AACtC,MAAM,WAAW,aAAa;IAC5B,yCAAyC;IACzC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,6CAA6C;IAC7C,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,MAAM,CAAC;IACrC;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,MAAM,CAAC;IAC9B;;;;;;;;;;;;;;;OAeG;IACH,QAAQ,CAAC,mBAAmB,CAAC,EAAE,cAAc,CAAC;CAC/C;AAED,oCAAoC;AACpC,MAAM,WAAW,YAAY;IAC3B,mCAAmC;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,sEAAsE;IACtE,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;IAC5C,qCAAqC;IACrC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,+EAA+E;IAC/E,QAAQ,CAAC,eAAe,CAAC,EAAE,SAAS,WAAW,EAAE,CAAC;CACnD;AA2ID;;;;;;;GAOG;AACH,wBAAgB,MAAM,CACpB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,aAAa,GACtB,YAAY,CAuBd;AA2aD;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,CAuB/D;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAGnD;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC5B,UAAU,EAAE,SAAS,EAAE,GACtB,SAAS,EAAE,CA2Bb;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,SAAS,EAAE,EACvB,MAAM,EAAE,MAAM,GACb,MAAM,CAKR;AAED;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,YAAY,SAAI,GACf,MAAM,CAkBR;AA0FD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,MAAM,EACd,YAAY,SAAI,EAChB,eAAe,GAAE,SAAS,WAAW,EAAO,GAC3C;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CA8B5C"}
|