@driftsys/markspec 0.3.0 → 0.5.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 +70 -0
- package/esm/ast/build.d.ts.map +1 -0
- package/esm/ast/build.js +605 -0
- package/esm/ast/equivalence.d.ts +18 -0
- package/esm/ast/equivalence.d.ts.map +1 -0
- package/esm/ast/equivalence.js +56 -0
- package/esm/ast/nodes.d.ts +221 -0
- package/esm/ast/nodes.d.ts.map +1 -0
- package/esm/ast/nodes.js +12 -0
- package/esm/ast/normalize.d.ts +67 -0
- package/esm/ast/normalize.d.ts.map +1 -0
- package/esm/ast/normalize.js +255 -0
- package/esm/ast/render.d.ts +34 -0
- package/esm/ast/render.d.ts.map +1 -0
- package/esm/ast/render.js +215 -0
- package/esm/compiler/inverses.d.ts +2 -8
- package/esm/compiler/inverses.d.ts.map +1 -1
- package/esm/compiler/inverses.js +50 -14
- package/esm/compiler/manifest.d.ts +59 -0
- package/esm/compiler/manifest.d.ts.map +1 -0
- package/esm/compiler/manifest.js +48 -0
- package/esm/compiler/mod.d.ts +9 -1
- package/esm/compiler/mod.d.ts.map +1 -1
- package/esm/compiler/mod.js +21 -2
- package/esm/compiler/ndjson_writer.d.ts +50 -0
- package/esm/compiler/ndjson_writer.d.ts.map +1 -0
- package/esm/compiler/ndjson_writer.js +73 -0
- package/esm/compiler/schema.d.ts +18 -1
- package/esm/compiler/schema.d.ts.map +1 -1
- package/esm/compiler/schema.js +18 -9
- package/esm/config/mod.d.ts.map +1 -1
- package/esm/config/mod.js +54 -0
- package/esm/formatter/mod.d.ts +56 -6
- package/esm/formatter/mod.d.ts.map +1 -1
- package/esm/formatter/mod.js +372 -41
- package/esm/formatter/synth_ulid.d.ts +21 -0
- package/esm/formatter/synth_ulid.d.ts.map +1 -0
- package/esm/formatter/synth_ulid.js +64 -0
- package/esm/lint/mod.d.ts +10 -0
- package/esm/lint/mod.d.ts.map +1 -0
- package/esm/lint/mod.js +7 -0
- package/esm/lint/rules/lexicon.d.ts +24 -0
- package/esm/lint/rules/lexicon.d.ts.map +1 -0
- package/esm/lint/rules/lexicon.js +236 -0
- package/esm/lint/rules/struct.d.ts +17 -0
- package/esm/lint/rules/struct.d.ts.map +1 -0
- package/esm/lint/rules/struct.js +55 -0
- package/esm/lint/rules/suppression.d.ts +19 -0
- package/esm/lint/rules/suppression.d.ts.map +1 -0
- package/esm/lint/rules/suppression.js +75 -0
- package/esm/lint/runner.d.ts +39 -0
- package/esm/lint/runner.d.ts.map +1 -0
- package/esm/lint/runner.js +112 -0
- package/esm/lint/types.d.ts +19 -0
- package/esm/lint/types.d.ts.map +1 -0
- package/esm/lint/types.js +9 -0
- package/esm/mod.d.ts +21 -8
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +16 -5
- package/esm/model/attributes.d.ts.map +1 -1
- package/esm/model/attributes.js +163 -2
- package/esm/model/discriminating_attr.d.ts +33 -0
- package/esm/model/discriminating_attr.d.ts.map +1 -0
- package/esm/model/discriminating_attr.js +74 -0
- package/esm/model/mod.d.ts +100 -3
- package/esm/model/mod.d.ts.map +1 -1
- package/esm/model/mod.js +58 -2
- package/esm/model/palette.d.ts +18 -0
- package/esm/model/palette.d.ts.map +1 -0
- package/esm/model/palette.js +23 -0
- package/esm/model/profile.d.ts +33 -27
- package/esm/model/profile.d.ts.map +1 -1
- package/esm/model/source_introspection.d.ts +26 -0
- package/esm/model/source_introspection.d.ts.map +1 -0
- package/esm/model/source_introspection.js +77 -0
- package/esm/model/type_hierarchy.d.ts +51 -0
- package/esm/model/type_hierarchy.d.ts.map +1 -0
- package/esm/model/type_hierarchy.js +126 -0
- package/esm/model/uri_scheme_map.d.ts +21 -0
- package/esm/model/uri_scheme_map.d.ts.map +1 -0
- package/esm/model/uri_scheme_map.js +66 -0
- package/esm/parser/attributes.d.ts.map +1 -1
- package/esm/parser/attributes.js +9 -6
- package/esm/parser/entity_refs.d.ts +53 -0
- package/esm/parser/entity_refs.d.ts.map +1 -0
- package/esm/parser/entity_refs.js +151 -0
- package/esm/parser/glossary.d.ts +43 -0
- package/esm/parser/glossary.d.ts.map +1 -0
- package/esm/parser/glossary.js +217 -0
- package/esm/parser/markdown.d.ts +10 -3
- package/esm/parser/markdown.d.ts.map +1 -1
- package/esm/parser/markdown.js +241 -11
- package/esm/parser/mod.d.ts +1 -0
- package/esm/parser/mod.d.ts.map +1 -1
- package/esm/parser/mod.js +4 -3
- package/esm/parser/source.d.ts +20 -0
- package/esm/parser/source.d.ts.map +1 -1
- package/esm/parser/source.js +4 -4
- package/esm/profile/chain.js +3 -13
- package/esm/profile/colors.d.ts +26 -0
- package/esm/profile/colors.d.ts.map +1 -0
- package/esm/profile/colors.js +46 -0
- package/esm/profile/introspect.d.ts +135 -0
- package/esm/profile/introspect.d.ts.map +1 -0
- package/esm/profile/introspect.js +378 -0
- package/esm/profile/load.d.ts.map +1 -1
- package/esm/profile/load.js +67 -0
- package/esm/profile/manifest.d.ts.map +1 -1
- package/esm/profile/manifest.js +278 -104
- package/esm/profile/merge.js +139 -39
- package/esm/profile/mod.d.ts +3 -4
- package/esm/profile/mod.d.ts.map +1 -1
- package/esm/profile/mod.js +6 -2
- package/esm/reporter/mod.js +4 -4
- package/esm/util/fence.d.ts +30 -0
- package/esm/util/fence.d.ts.map +1 -0
- package/esm/util/fence.js +40 -0
- package/esm/validator/attributes.d.ts +3 -3
- package/esm/validator/attributes.d.ts.map +1 -1
- package/esm/validator/attributes.js +1 -18
- package/esm/validator/body_blocks.d.ts +38 -0
- package/esm/validator/body_blocks.d.ts.map +1 -0
- package/esm/validator/body_blocks.js +218 -0
- package/esm/validator/caption_convention.d.ts +29 -0
- package/esm/validator/caption_convention.d.ts.map +1 -0
- package/esm/validator/caption_convention.js +58 -0
- package/esm/validator/captions.d.ts +22 -0
- package/esm/validator/captions.d.ts.map +1 -0
- package/esm/validator/captions.js +137 -0
- package/esm/validator/component_schemes.d.ts +73 -0
- package/esm/validator/component_schemes.d.ts.map +1 -0
- package/esm/validator/component_schemes.js +375 -0
- package/esm/validator/feature_ac.d.ts +28 -0
- package/esm/validator/feature_ac.d.ts.map +1 -0
- package/esm/validator/feature_ac.js +102 -0
- package/esm/validator/listing.d.ts +42 -0
- package/esm/validator/listing.d.ts.map +1 -0
- package/esm/validator/listing.js +295 -0
- package/esm/validator/mod.d.ts +2 -0
- package/esm/validator/mod.d.ts.map +1 -1
- package/esm/validator/mod.js +253 -12
- package/esm/validator/modal_keywords.d.ts +23 -0
- package/esm/validator/modal_keywords.d.ts.map +1 -0
- package/esm/validator/modal_keywords.js +137 -0
- package/esm/validator/per_type_attrs.d.ts +29 -0
- package/esm/validator/per_type_attrs.d.ts.map +1 -0
- package/esm/validator/per_type_attrs.js +75 -0
- package/esm/validator/pipeline.d.ts +7 -2
- package/esm/validator/pipeline.d.ts.map +1 -1
- package/esm/validator/pipeline.js +40 -7
- package/esm/validator/trace_types.d.ts +26 -0
- package/esm/validator/trace_types.d.ts.map +1 -0
- package/esm/validator/trace_types.js +232 -0
- package/esm/validator/traceability.d.ts +3 -4
- package/esm/validator/traceability.d.ts.map +1 -1
- package/esm/validator/traceability.js +5 -10
- package/esm/validator/type_resolution.d.ts +67 -0
- package/esm/validator/type_resolution.d.ts.map +1 -0
- package/esm/validator/type_resolution.js +140 -0
- package/esm/validator/types.d.ts +45 -0
- package/esm/validator/types.d.ts.map +1 -1
- package/esm/validator/types.js +128 -16
- package/esm/validator/value_types.d.ts +8 -0
- package/esm/validator/value_types.d.ts.map +1 -1
- package/esm/validator/value_types.js +8 -1
- package/package.json +1 -1
- package/script/ast/build.d.ts +70 -0
- package/script/ast/build.d.ts.map +1 -0
- package/script/ast/build.js +610 -0
- package/script/ast/equivalence.d.ts +18 -0
- package/script/ast/equivalence.d.ts.map +1 -0
- package/script/ast/equivalence.js +59 -0
- package/script/ast/nodes.d.ts +221 -0
- package/script/ast/nodes.d.ts.map +1 -0
- package/script/ast/nodes.js +13 -0
- package/script/ast/normalize.d.ts +67 -0
- package/script/ast/normalize.d.ts.map +1 -0
- package/script/ast/normalize.js +258 -0
- package/script/ast/render.d.ts +34 -0
- package/script/ast/render.d.ts.map +1 -0
- package/script/ast/render.js +218 -0
- package/script/compiler/inverses.d.ts +2 -8
- package/script/compiler/inverses.d.ts.map +1 -1
- package/script/compiler/inverses.js +50 -14
- package/script/compiler/manifest.d.ts +59 -0
- package/script/compiler/manifest.d.ts.map +1 -0
- package/script/compiler/manifest.js +51 -0
- package/script/compiler/mod.d.ts +9 -1
- package/script/compiler/mod.d.ts.map +1 -1
- package/script/compiler/mod.js +21 -2
- package/script/compiler/ndjson_writer.d.ts +50 -0
- package/script/compiler/ndjson_writer.d.ts.map +1 -0
- package/script/compiler/ndjson_writer.js +78 -0
- package/script/compiler/schema.d.ts +18 -1
- package/script/compiler/schema.d.ts.map +1 -1
- package/script/compiler/schema.js +18 -8
- package/script/config/mod.d.ts.map +1 -1
- package/script/config/mod.js +54 -0
- package/script/formatter/mod.d.ts +56 -6
- package/script/formatter/mod.d.ts.map +1 -1
- package/script/formatter/mod.js +375 -41
- package/script/formatter/synth_ulid.d.ts +21 -0
- package/script/formatter/synth_ulid.d.ts.map +1 -0
- package/script/formatter/synth_ulid.js +67 -0
- package/script/lint/mod.d.ts +10 -0
- package/script/lint/mod.d.ts.map +1 -0
- package/script/lint/mod.js +12 -0
- package/script/lint/rules/lexicon.d.ts +24 -0
- package/script/lint/rules/lexicon.d.ts.map +1 -0
- package/script/lint/rules/lexicon.js +240 -0
- package/script/lint/rules/struct.d.ts +17 -0
- package/script/lint/rules/struct.d.ts.map +1 -0
- package/script/lint/rules/struct.js +59 -0
- package/script/lint/rules/suppression.d.ts +19 -0
- package/script/lint/rules/suppression.d.ts.map +1 -0
- package/script/lint/rules/suppression.js +80 -0
- package/script/lint/runner.d.ts +39 -0
- package/script/lint/runner.d.ts.map +1 -0
- package/script/lint/runner.js +116 -0
- package/script/lint/types.d.ts +19 -0
- package/script/lint/types.d.ts.map +1 -0
- package/script/lint/types.js +10 -0
- package/script/mod.d.ts +21 -8
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +58 -32
- package/script/model/attributes.d.ts.map +1 -1
- package/script/model/attributes.js +163 -2
- package/script/model/discriminating_attr.d.ts +33 -0
- package/script/model/discriminating_attr.d.ts.map +1 -0
- package/script/model/discriminating_attr.js +77 -0
- package/script/model/mod.d.ts +100 -3
- package/script/model/mod.d.ts.map +1 -1
- package/script/model/mod.js +67 -3
- package/script/model/palette.d.ts +18 -0
- package/script/model/palette.d.ts.map +1 -0
- package/script/model/palette.js +26 -0
- package/script/model/profile.d.ts +33 -27
- package/script/model/profile.d.ts.map +1 -1
- package/script/model/source_introspection.d.ts +26 -0
- package/script/model/source_introspection.d.ts.map +1 -0
- package/script/model/source_introspection.js +80 -0
- package/script/model/type_hierarchy.d.ts +51 -0
- package/script/model/type_hierarchy.d.ts.map +1 -0
- package/script/model/type_hierarchy.js +130 -0
- package/script/model/uri_scheme_map.d.ts +21 -0
- package/script/model/uri_scheme_map.d.ts.map +1 -0
- package/script/model/uri_scheme_map.js +69 -0
- package/script/parser/attributes.d.ts.map +1 -1
- package/script/parser/attributes.js +9 -6
- package/script/parser/entity_refs.d.ts +53 -0
- package/script/parser/entity_refs.d.ts.map +1 -0
- package/script/parser/entity_refs.js +155 -0
- package/script/parser/glossary.d.ts +43 -0
- package/script/parser/glossary.d.ts.map +1 -0
- package/script/parser/glossary.js +221 -0
- package/script/parser/markdown.d.ts +10 -3
- package/script/parser/markdown.d.ts.map +1 -1
- package/script/parser/markdown.js +240 -10
- package/script/parser/mod.d.ts +1 -0
- package/script/parser/mod.d.ts.map +1 -1
- package/script/parser/mod.js +8 -4
- package/script/parser/source.d.ts +20 -0
- package/script/parser/source.d.ts.map +1 -1
- package/script/parser/source.js +4 -1
- package/script/profile/chain.js +3 -13
- package/script/profile/colors.d.ts +26 -0
- package/script/profile/colors.d.ts.map +1 -0
- package/script/profile/colors.js +49 -0
- package/script/profile/introspect.d.ts +135 -0
- package/script/profile/introspect.d.ts.map +1 -0
- package/script/profile/introspect.js +381 -0
- package/script/profile/load.d.ts.map +1 -1
- package/script/profile/load.js +67 -0
- package/script/profile/manifest.d.ts.map +1 -1
- package/script/profile/manifest.js +280 -106
- package/script/profile/merge.js +139 -39
- package/script/profile/mod.d.ts +3 -4
- package/script/profile/mod.d.ts.map +1 -1
- package/script/profile/mod.js +9 -6
- package/script/reporter/mod.js +4 -4
- package/script/util/fence.d.ts +30 -0
- package/script/util/fence.d.ts.map +1 -0
- package/script/util/fence.js +44 -0
- package/script/validator/attributes.d.ts +3 -3
- package/script/validator/attributes.d.ts.map +1 -1
- package/script/validator/attributes.js +1 -18
- package/script/validator/body_blocks.d.ts +38 -0
- package/script/validator/body_blocks.d.ts.map +1 -0
- package/script/validator/body_blocks.js +221 -0
- package/script/validator/caption_convention.d.ts +29 -0
- package/script/validator/caption_convention.d.ts.map +1 -0
- package/script/validator/caption_convention.js +61 -0
- package/script/validator/captions.d.ts +22 -0
- package/script/validator/captions.d.ts.map +1 -0
- package/script/validator/captions.js +140 -0
- package/script/validator/component_schemes.d.ts +73 -0
- package/script/validator/component_schemes.d.ts.map +1 -0
- package/script/validator/component_schemes.js +384 -0
- package/script/validator/feature_ac.d.ts +28 -0
- package/script/validator/feature_ac.d.ts.map +1 -0
- package/script/validator/feature_ac.js +105 -0
- package/script/validator/listing.d.ts +42 -0
- package/script/validator/listing.d.ts.map +1 -0
- package/script/validator/listing.js +298 -0
- package/script/validator/mod.d.ts +2 -0
- package/script/validator/mod.d.ts.map +1 -1
- package/script/validator/mod.js +256 -14
- package/script/validator/modal_keywords.d.ts +23 -0
- package/script/validator/modal_keywords.d.ts.map +1 -0
- package/script/validator/modal_keywords.js +140 -0
- package/script/validator/per_type_attrs.d.ts +29 -0
- package/script/validator/per_type_attrs.d.ts.map +1 -0
- package/script/validator/per_type_attrs.js +78 -0
- package/script/validator/pipeline.d.ts +7 -2
- package/script/validator/pipeline.d.ts.map +1 -1
- package/script/validator/pipeline.js +39 -6
- package/script/validator/trace_types.d.ts +26 -0
- package/script/validator/trace_types.d.ts.map +1 -0
- package/script/validator/trace_types.js +235 -0
- package/script/validator/traceability.d.ts +3 -4
- package/script/validator/traceability.d.ts.map +1 -1
- package/script/validator/traceability.js +5 -10
- package/script/validator/type_resolution.d.ts +67 -0
- package/script/validator/type_resolution.d.ts.map +1 -0
- package/script/validator/type_resolution.js +146 -0
- package/script/validator/types.d.ts +45 -0
- package/script/validator/types.d.ts.map +1 -1
- package/script/validator/types.js +131 -16
- package/script/validator/value_types.d.ts +8 -0
- package/script/validator/value_types.d.ts.map +1 -1
- package/script/validator/value_types.js +10 -2
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module validator/listing
|
|
4
|
+
*
|
|
5
|
+
* Listing-directive validator — MSL-L010 through MSL-L050.
|
|
6
|
+
*
|
|
7
|
+
* Validates four concern areas:
|
|
8
|
+
*
|
|
9
|
+
* 1. Directive placement / conflict (§2.3): L010, L011, L012
|
|
10
|
+
* 2. Glossary heading-shape grammar (§4.2): L020–L024 (delegated to
|
|
11
|
+
* `validateGlossaryStructure`)
|
|
12
|
+
* 3. Component Id-scheme parsers (§5): L030–L037 (via `parseComponentScheme`)
|
|
13
|
+
* 4. Per-directive content (§6): L040, L041, L042, L043, L050
|
|
14
|
+
*
|
|
15
|
+
* Called from the validate CLI command once per invocation, receiving one
|
|
16
|
+
* {@linkcode ListingFileContext} per validated file. The listing validator
|
|
17
|
+
* is separate from `runPipeline` because it requires per-file context
|
|
18
|
+
* (file name, raw content, directives) that the flat Entry-list pipeline
|
|
19
|
+
* does not carry.
|
|
20
|
+
*/
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.validateListingDocuments = validateListingDocuments;
|
|
23
|
+
const path_1 = require("@std/path");
|
|
24
|
+
const glossary_js_1 = require("../parser/glossary.js");
|
|
25
|
+
const component_schemes_js_1 = require("./component_schemes.js");
|
|
26
|
+
// ---------------------------------------------------------------------------
|
|
27
|
+
// Component-family and Unit-family sets
|
|
28
|
+
// ---------------------------------------------------------------------------
|
|
29
|
+
/** Core Component-family type names per ADR-003 §Part 2 / spec §6.3. */
|
|
30
|
+
const COMPONENT_FAMILY = new Set([
|
|
31
|
+
"Component",
|
|
32
|
+
"SoftwareComponent",
|
|
33
|
+
"HardwareComponent",
|
|
34
|
+
"SoftwareInterface",
|
|
35
|
+
"HardwareInterface",
|
|
36
|
+
]);
|
|
37
|
+
/** Core Unit-family type names per ADR-003 §Part 2. */
|
|
38
|
+
const UNIT_FAMILY = new Set([
|
|
39
|
+
"Unit",
|
|
40
|
+
"SoftwareUnit",
|
|
41
|
+
"HardwareUnit",
|
|
42
|
+
]);
|
|
43
|
+
// ---------------------------------------------------------------------------
|
|
44
|
+
// Filename-trigger detection
|
|
45
|
+
// ---------------------------------------------------------------------------
|
|
46
|
+
/** Listing kind implied by a file's basename, or null if not a listing file. */
|
|
47
|
+
function filenameKind(file) {
|
|
48
|
+
const base = (0, path_1.basename)(file).toLowerCase().replace(/\.[^.]+$/, "");
|
|
49
|
+
if (base === "references")
|
|
50
|
+
return "references";
|
|
51
|
+
if (base === "glossary")
|
|
52
|
+
return "glossary";
|
|
53
|
+
if (base === "components")
|
|
54
|
+
return "components";
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
/** Listing kind named by a directive, or null for non-listing directives. */
|
|
58
|
+
function directiveKind(name) {
|
|
59
|
+
if (name === "references")
|
|
60
|
+
return "references";
|
|
61
|
+
if (name === "glossary")
|
|
62
|
+
return "glossary";
|
|
63
|
+
if (name === "components")
|
|
64
|
+
return "components";
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
// ---------------------------------------------------------------------------
|
|
68
|
+
// Type-attribute helper
|
|
69
|
+
// ---------------------------------------------------------------------------
|
|
70
|
+
/** Extract the raw `Type:` attribute value from an entry, or null. */
|
|
71
|
+
function rawType(entry) {
|
|
72
|
+
for (const attr of entry.rawAttributes) {
|
|
73
|
+
if (attr.key === "Type")
|
|
74
|
+
return attr.value.trim();
|
|
75
|
+
}
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
// ---------------------------------------------------------------------------
|
|
79
|
+
// Per-file validation
|
|
80
|
+
// ---------------------------------------------------------------------------
|
|
81
|
+
function validateFile(ctx) {
|
|
82
|
+
const { file, content, entries, directives } = ctx;
|
|
83
|
+
const diagnostics = [];
|
|
84
|
+
// -------------------------------------------------------------------------
|
|
85
|
+
// Phase 1: directive placement / conflict detection (§2.3)
|
|
86
|
+
// -------------------------------------------------------------------------
|
|
87
|
+
const fileKind = filenameKind(file);
|
|
88
|
+
const listingDirectives = directives.filter((d) => directiveKind(d.name) !== null);
|
|
89
|
+
let resolvedKind = fileKind;
|
|
90
|
+
if (listingDirectives.length >= 2) {
|
|
91
|
+
// MSL-L012: multiple explicit listing directives in one file.
|
|
92
|
+
diagnostics.push({
|
|
93
|
+
code: "MSL-L012",
|
|
94
|
+
severity: "error",
|
|
95
|
+
message: `${file}:${listingDirectives[1].location.line}: ` +
|
|
96
|
+
`multiple listing directives in one file ` +
|
|
97
|
+
`('${listingDirectives[0].name}' and '${listingDirectives[1].name}') — ` +
|
|
98
|
+
`a listing file carries exactly one directive (spec §2.3)`,
|
|
99
|
+
location: listingDirectives[1].location,
|
|
100
|
+
});
|
|
101
|
+
// Use the first directive as the resolved kind so downstream checks run.
|
|
102
|
+
resolvedKind = directiveKind(listingDirectives[0].name);
|
|
103
|
+
}
|
|
104
|
+
else if (listingDirectives.length === 1) {
|
|
105
|
+
const explicitKind = directiveKind(listingDirectives[0].name);
|
|
106
|
+
if (fileKind !== null) {
|
|
107
|
+
if (fileKind === explicitKind) {
|
|
108
|
+
// MSL-L010: redundant explicit directive (matches filename trigger).
|
|
109
|
+
diagnostics.push({
|
|
110
|
+
code: "MSL-L010",
|
|
111
|
+
severity: "info",
|
|
112
|
+
message: `${file}:${listingDirectives[0].location.line}: ` +
|
|
113
|
+
`redundant directive '<!-- markspec:${explicitKind} -->' — ` +
|
|
114
|
+
`the filename '${(0, path_1.basename)(file)}' already triggers this listing ` +
|
|
115
|
+
`(spec §2.1)`,
|
|
116
|
+
location: listingDirectives[0].location,
|
|
117
|
+
});
|
|
118
|
+
resolvedKind = explicitKind;
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
// MSL-L011: explicit directive conflicts with filename trigger.
|
|
122
|
+
diagnostics.push({
|
|
123
|
+
code: "MSL-L011",
|
|
124
|
+
severity: "error",
|
|
125
|
+
message: `${file}:${listingDirectives[0].location.line}: ` +
|
|
126
|
+
`directive 'markspec:${explicitKind}' conflicts with filename ` +
|
|
127
|
+
`trigger '${fileKind}' — remove the directive or rename the file ` +
|
|
128
|
+
`(spec §2.3)`,
|
|
129
|
+
location: listingDirectives[0].location,
|
|
130
|
+
});
|
|
131
|
+
// Conflict is unresolved; use the filename trigger.
|
|
132
|
+
resolvedKind = fileKind;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
resolvedKind = explicitKind;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
// No listing kind → not a listing file, nothing more to validate.
|
|
140
|
+
if (resolvedKind === null)
|
|
141
|
+
return diagnostics;
|
|
142
|
+
// -------------------------------------------------------------------------
|
|
143
|
+
// Phase 2: Glossary heading-shape validation (§4.2)
|
|
144
|
+
// -------------------------------------------------------------------------
|
|
145
|
+
let glossaryTermCount = 0;
|
|
146
|
+
if (resolvedKind === "glossary") {
|
|
147
|
+
const glossaryResult = (0, glossary_js_1.validateGlossaryStructure)(content, { file });
|
|
148
|
+
diagnostics.push(...glossaryResult.diagnostics);
|
|
149
|
+
glossaryTermCount = glossaryResult.termCount;
|
|
150
|
+
// MSL-L042: entry blocks must not appear in a glossary file.
|
|
151
|
+
for (const entry of entries) {
|
|
152
|
+
diagnostics.push({
|
|
153
|
+
code: "MSL-L042",
|
|
154
|
+
severity: "error",
|
|
155
|
+
message: `${file}:${entry.location.line}: entry block ` +
|
|
156
|
+
`'[${entry.displayId}]' in a glossary listing — ` +
|
|
157
|
+
`the glossary shape uses headings, not entry blocks (spec §6.2)`,
|
|
158
|
+
location: entry.location,
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
// -------------------------------------------------------------------------
|
|
163
|
+
// Phase 3 & 4: per-entry validation for references and components
|
|
164
|
+
// -------------------------------------------------------------------------
|
|
165
|
+
for (const entry of entries) {
|
|
166
|
+
if (resolvedKind === "references") {
|
|
167
|
+
validateReferencesEntry(entry, file, diagnostics);
|
|
168
|
+
}
|
|
169
|
+
else if (resolvedKind === "components") {
|
|
170
|
+
validateComponentsEntry(entry, file, diagnostics);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
// -------------------------------------------------------------------------
|
|
174
|
+
// Phase 4: MSL-L050 — empty listing
|
|
175
|
+
// -------------------------------------------------------------------------
|
|
176
|
+
const isEmpty = resolvedKind === "glossary"
|
|
177
|
+
? glossaryTermCount === 0
|
|
178
|
+
: entries.length === 0;
|
|
179
|
+
if (isEmpty) {
|
|
180
|
+
diagnostics.push({
|
|
181
|
+
code: "MSL-L050",
|
|
182
|
+
severity: "info",
|
|
183
|
+
message: `${file}: empty ${resolvedKind} listing — ` +
|
|
184
|
+
`no items found (valid placeholder; spec §6.4)`,
|
|
185
|
+
location: { file, line: 1, column: 1 },
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
return diagnostics;
|
|
189
|
+
}
|
|
190
|
+
// ---------------------------------------------------------------------------
|
|
191
|
+
// References listing — per-entry checks (§6.1)
|
|
192
|
+
// ---------------------------------------------------------------------------
|
|
193
|
+
function validateReferencesEntry(entry, file, diagnostics) {
|
|
194
|
+
// MSL-L040: Authored-shape entry in a references listing (warning).
|
|
195
|
+
if (entry.shape === "Authored") {
|
|
196
|
+
diagnostics.push({
|
|
197
|
+
code: "MSL-L040",
|
|
198
|
+
severity: "warning",
|
|
199
|
+
message: `${file}:${entry.location.line}: Authored entry ` +
|
|
200
|
+
`'[${entry.displayId}]' in a references listing — ` +
|
|
201
|
+
`references should be Reference-shape (URI Id:); ` +
|
|
202
|
+
`Authored entries are project-owned, not bibliographic (spec §6.1)`,
|
|
203
|
+
location: entry.location,
|
|
204
|
+
});
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
// MSL-L041: resolved Type is in the Unit family (warning).
|
|
208
|
+
const typeVal = rawType(entry);
|
|
209
|
+
if (typeVal !== null && UNIT_FAMILY.has(typeVal)) {
|
|
210
|
+
diagnostics.push({
|
|
211
|
+
code: "MSL-L041",
|
|
212
|
+
severity: "warning",
|
|
213
|
+
message: `${file}:${entry.location.line}: entry '[${entry.displayId}]' ` +
|
|
214
|
+
`has Type: ${typeVal} (Unit family) in a references listing — ` +
|
|
215
|
+
`references should resolve to Specification or Component (spec §6.1)`,
|
|
216
|
+
location: entry.location,
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
// ---------------------------------------------------------------------------
|
|
221
|
+
// Components listing — per-entry checks (§6.3)
|
|
222
|
+
// ---------------------------------------------------------------------------
|
|
223
|
+
function validateComponentsEntry(entry, file, diagnostics) {
|
|
224
|
+
// MSL-L043: explicit Type: is not in the Component family.
|
|
225
|
+
const typeVal = rawType(entry);
|
|
226
|
+
if (typeVal !== null && !COMPONENT_FAMILY.has(typeVal)) {
|
|
227
|
+
diagnostics.push({
|
|
228
|
+
code: "MSL-L043",
|
|
229
|
+
severity: "error",
|
|
230
|
+
message: `${file}:${entry.location.line}: entry '[${entry.displayId}]' ` +
|
|
231
|
+
`has Type: ${typeVal} which is not in the Component family ` +
|
|
232
|
+
`(Component/SoftwareComponent/HardwareComponent/` +
|
|
233
|
+
`SoftwareInterface/HardwareInterface) — ` +
|
|
234
|
+
`only Component-family types are permitted in a components listing ` +
|
|
235
|
+
`(spec §6.3)`,
|
|
236
|
+
location: entry.location,
|
|
237
|
+
});
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
// For Reference-shape entries, validate the Id: scheme (§5).
|
|
241
|
+
if (entry.shape === "Reference" && entry.id) {
|
|
242
|
+
validateComponentScheme(entry.id, entry, file, diagnostics);
|
|
243
|
+
}
|
|
244
|
+
// Authored-shape components (ULID Id:) are valid per spec §6.3 — no scheme check.
|
|
245
|
+
}
|
|
246
|
+
// ---------------------------------------------------------------------------
|
|
247
|
+
// Component Id-scheme validation (§5 / §6.3)
|
|
248
|
+
// ---------------------------------------------------------------------------
|
|
249
|
+
function validateComponentScheme(idValue, entry, file, diagnostics) {
|
|
250
|
+
const result = (0, component_schemes_js_1.parseComponentScheme)(idValue);
|
|
251
|
+
if (result === null) {
|
|
252
|
+
// No known component scheme matched. If it's a valid RFC 3986 URI →
|
|
253
|
+
// MSL-L030 info (unrecognized scheme, generic fallback).
|
|
254
|
+
// `isSchemeQualifiedUri` checks the RFC 3986 scheme prefix.
|
|
255
|
+
if ((0, component_schemes_js_1.isSchemeQualifiedUri)(idValue)) {
|
|
256
|
+
diagnostics.push({
|
|
257
|
+
code: "MSL-L030",
|
|
258
|
+
severity: "info",
|
|
259
|
+
message: `${file}:${entry.location.line}: ` +
|
|
260
|
+
`entry '[${entry.displayId}]' Id: '${idValue}' — ` +
|
|
261
|
+
`unrecognized component Id scheme; classified by fallback ` +
|
|
262
|
+
`(spec §5, MSL-L030)`,
|
|
263
|
+
location: entry.location,
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
// Not a scheme-qualified URI at all → the core validator (MSL-R004) handles it.
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
if (!result.ok) {
|
|
270
|
+
diagnostics.push({
|
|
271
|
+
code: result.code,
|
|
272
|
+
severity: "error",
|
|
273
|
+
message: `${file}:${entry.location.line}: ` +
|
|
274
|
+
`entry '[${entry.displayId}]' Id: '${idValue}' — ${result.message}`,
|
|
275
|
+
location: entry.location,
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
// result.ok === true → valid scheme, no diagnostic needed here.
|
|
279
|
+
// (MSL-L030 for unknown purl types is handled inside parsePurl returning
|
|
280
|
+
// { ok: true, type: "Component" } — the caller gets no diagnostic.)
|
|
281
|
+
}
|
|
282
|
+
// ---------------------------------------------------------------------------
|
|
283
|
+
// Public API
|
|
284
|
+
// ---------------------------------------------------------------------------
|
|
285
|
+
/**
|
|
286
|
+
* Validate a set of files for listing-directive conformance.
|
|
287
|
+
*
|
|
288
|
+
* Returns diagnostics in document order (one file at a time in the order
|
|
289
|
+
* `contexts` was supplied). Call this alongside `runPipeline` — both
|
|
290
|
+
* operate independently.
|
|
291
|
+
*/
|
|
292
|
+
function validateListingDocuments(contexts) {
|
|
293
|
+
const diagnostics = [];
|
|
294
|
+
for (const ctx of contexts) {
|
|
295
|
+
diagnostics.push(...validateFile(ctx));
|
|
296
|
+
}
|
|
297
|
+
return diagnostics;
|
|
298
|
+
}
|
|
@@ -32,6 +32,8 @@ export declare function indexByDisplayId(entries: readonly Entry[]): ReadonlyMap
|
|
|
32
32
|
export declare function findAttr(attrs: readonly Attribute[], key: string): Attribute | undefined;
|
|
33
33
|
export { runPipeline } from "./pipeline.js";
|
|
34
34
|
export type { PipelineResult } from "./pipeline.js";
|
|
35
|
+
export { validateListingDocuments } from "./listing.js";
|
|
36
|
+
export type { ListingFileContext, ListingKind } from "./listing.js";
|
|
35
37
|
export { classifyEntriesStage, classifyEntry } from "./types.js";
|
|
36
38
|
export type { ClassifyResult, ClassifyStageResult } from "./types.js";
|
|
37
39
|
export { compileDisplayIdPattern } from "./pattern.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/validator/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/validator/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAmCpE,mCAAmC;AACnC,MAAM,WAAW,cAAc;IAC7B,2CAA2C;IAC3C,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;IAC5C,gDAAgD;IAChD,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,SAAS,KAAK,EAAE,GAAG,cAAc,CAQlE;AAwZD,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,SAAS,KAAK,EAAE,GACxB,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,CAM5B;AAGD,wBAAgB,QAAQ,CACtB,KAAK,EAAE,SAAS,SAAS,EAAE,EAC3B,GAAG,EAAE,MAAM,GACV,SAAS,GAAG,SAAS,CAEvB;AAED,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AACxD,YAAY,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEpE,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACjE,YAAY,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAEvD,OAAO,EAAE,cAAc,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAC7E,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,4BAA4B,GAC7B,MAAM,mBAAmB,CAAC"}
|