@driftsys/markspec 0.4.0 → 0.6.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/README.md +74 -20
- package/esm/ast/build.d.ts +60 -0
- package/esm/ast/build.d.ts.map +1 -0
- package/esm/ast/build.js +516 -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 +189 -0
- package/esm/ast/nodes.d.ts.map +1 -0
- package/esm/ast/nodes.js +17 -0
- package/esm/ast/normalize.d.ts +58 -0
- package/esm/ast/normalize.d.ts.map +1 -0
- package/esm/ast/normalize.js +197 -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/constants.d.ts +16 -0
- package/esm/compiler/constants.d.ts.map +1 -0
- package/esm/compiler/constants.js +26 -0
- package/esm/compiler/discipline_classifier.d.ts +55 -0
- package/esm/compiler/discipline_classifier.d.ts.map +1 -0
- package/esm/compiler/discipline_classifier.js +191 -0
- package/esm/compiler/inverses.d.ts +2 -1
- package/esm/compiler/inverses.d.ts.map +1 -1
- package/esm/compiler/inverses.js +33 -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 +38 -1
- package/esm/compiler/mod.d.ts.map +1 -1
- package/esm/compiler/mod.js +202 -50
- 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 +33 -1
- package/esm/compiler/schema.d.ts.map +1 -1
- package/esm/compiler/schema.js +30 -9
- package/esm/config/markspec.d.ts +5 -0
- package/esm/config/markspec.d.ts.map +1 -1
- package/esm/config/markspec.js +17 -2
- package/esm/config/mod.d.ts.map +1 -1
- package/esm/config/mod.js +54 -0
- package/esm/formatter/mod.d.ts +55 -4
- package/esm/formatter/mod.d.ts.map +1 -1
- package/esm/formatter/mod.js +423 -46
- 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/lexicons/loader.d.ts +35 -0
- package/esm/lexicons/loader.d.ts.map +1 -0
- package/esm/lexicons/loader.js +51 -0
- package/esm/lexicons/mod.d.ts +13 -0
- package/esm/lexicons/mod.d.ts.map +1 -0
- package/esm/lexicons/mod.js +12 -0
- package/esm/lint/glossary.d.ts +45 -0
- package/esm/lint/glossary.d.ts.map +1 -0
- package/esm/lint/glossary.js +85 -0
- package/esm/lint/mod.d.ts +14 -0
- package/esm/lint/mod.d.ts.map +1 -0
- package/esm/lint/mod.js +9 -0
- package/esm/lint/range_util.d.ts +25 -0
- package/esm/lint/range_util.d.ts.map +1 -0
- package/esm/lint/range_util.js +50 -0
- package/esm/lint/rules/ears.d.ts +39 -0
- package/esm/lint/rules/ears.d.ts.map +1 -0
- package/esm/lint/rules/ears.js +316 -0
- package/esm/lint/rules/incose_sentence.d.ts +46 -0
- package/esm/lint/rules/incose_sentence.d.ts.map +1 -0
- package/esm/lint/rules/incose_sentence.js +417 -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/modal_sentence.d.ts +46 -0
- package/esm/lint/rules/modal_sentence.d.ts.map +1 -0
- package/esm/lint/rules/modal_sentence.js +146 -0
- package/esm/lint/rules/passive.d.ts +64 -0
- package/esm/lint/rules/passive.d.ts.map +1 -0
- package/esm/lint/rules/passive.js +282 -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 +54 -0
- package/esm/lint/rules/suppression.d.ts.map +1 -0
- package/esm/lint/rules/suppression.js +129 -0
- package/esm/lint/rules/xref.d.ts +19 -0
- package/esm/lint/rules/xref.d.ts.map +1 -0
- package/esm/lint/rules/xref.js +248 -0
- package/esm/lint/runner.d.ts +59 -0
- package/esm/lint/runner.d.ts.map +1 -0
- package/esm/lint/runner.js +153 -0
- package/esm/lint/score.d.ts +64 -0
- package/esm/lint/score.d.ts.map +1 -0
- package/esm/lint/score.js +163 -0
- package/esm/lint/segmenter.d.ts +32 -0
- package/esm/lint/segmenter.d.ts.map +1 -0
- package/esm/lint/segmenter.js +79 -0
- package/esm/lint/types.d.ts +31 -0
- package/esm/lint/types.d.ts.map +1 -0
- package/esm/lint/types.js +9 -0
- package/esm/lock/canonical_edges.d.ts +31 -0
- package/esm/lock/canonical_edges.d.ts.map +1 -0
- package/esm/lock/canonical_edges.js +57 -0
- package/esm/lock/check.d.ts +24 -0
- package/esm/lock/check.d.ts.map +1 -0
- package/esm/lock/check.js +127 -0
- package/esm/lock/hash.d.ts +12 -0
- package/esm/lock/hash.d.ts.map +1 -0
- package/esm/lock/hash.js +32 -0
- package/esm/lock/mod.d.ts +19 -0
- package/esm/lock/mod.d.ts.map +1 -0
- package/esm/lock/mod.js +14 -0
- package/esm/lock/model.d.ts +81 -0
- package/esm/lock/model.d.ts.map +1 -0
- package/esm/lock/model.js +7 -0
- package/esm/lock/parser.d.ts +26 -0
- package/esm/lock/parser.d.ts.map +1 -0
- package/esm/lock/parser.js +195 -0
- package/esm/lock/resolve.d.ts +142 -0
- package/esm/lock/resolve.d.ts.map +1 -0
- package/esm/lock/resolve.js +389 -0
- package/esm/lock/serializer.d.ts +14 -0
- package/esm/lock/serializer.d.ts.map +1 -0
- package/esm/lock/serializer.js +104 -0
- package/esm/mod.d.ts +28 -8
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +23 -4
- package/esm/model/attributes.d.ts +6 -0
- package/esm/model/attributes.d.ts.map +1 -1
- package/esm/model/attributes.js +200 -2
- package/esm/model/discipline.d.ts +53 -0
- package/esm/model/discipline.d.ts.map +1 -0
- package/esm/model/discipline.js +50 -0
- 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 +267 -14
- package/esm/model/mod.d.ts.map +1 -1
- package/esm/model/mod.js +99 -3
- package/esm/model/profile.d.ts +102 -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 +10 -16
- package/esm/parser/body_tokens.d.ts +35 -0
- package/esm/parser/body_tokens.d.ts.map +1 -0
- package/esm/parser/body_tokens.js +232 -0
- package/esm/parser/glossary.d.ts +51 -0
- package/esm/parser/glossary.d.ts.map +1 -0
- package/esm/parser/glossary.js +219 -0
- package/esm/parser/grammars.d.ts +5 -3
- package/esm/parser/grammars.d.ts.map +1 -1
- package/esm/parser/grammars.js +12 -4
- package/esm/parser/language_spec.d.ts +55 -0
- package/esm/parser/language_spec.d.ts.map +1 -0
- package/esm/parser/language_spec.js +419 -0
- package/esm/parser/line_map.d.ts +60 -0
- package/esm/parser/line_map.d.ts.map +1 -0
- package/esm/parser/line_map.js +41 -0
- package/esm/parser/markdown.d.ts +9 -0
- package/esm/parser/markdown.d.ts.map +1 -1
- package/esm/parser/markdown.js +317 -25
- package/esm/parser/mod.d.ts +5 -0
- package/esm/parser/mod.d.ts.map +1 -1
- package/esm/parser/mod.js +31 -8
- package/esm/parser/source.d.ts +53 -2
- package/esm/parser/source.d.ts.map +1 -1
- package/esm/parser/source.js +158 -68
- package/esm/parser/translate.d.ts +24 -0
- package/esm/parser/translate.d.ts.map +1 -0
- package/esm/parser/translate.js +99 -0
- package/esm/profile/chain.d.ts +8 -0
- package/esm/profile/chain.d.ts.map +1 -1
- package/esm/profile/chain.js +32 -14
- package/esm/profile/colors.js +1 -1
- package/esm/profile/default_profile.d.ts +25 -0
- package/esm/profile/default_profile.d.ts.map +1 -0
- package/esm/profile/default_profile.js +43 -0
- package/esm/profile/discipline_mode.d.ts +64 -0
- package/esm/profile/discipline_mode.d.ts.map +1 -0
- package/esm/profile/discipline_mode.js +133 -0
- package/esm/profile/discipline_registry.d.ts +41 -0
- package/esm/profile/discipline_registry.d.ts.map +1 -0
- package/esm/profile/discipline_registry.js +67 -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 +3 -1
- package/esm/profile/load.d.ts.map +1 -1
- package/esm/profile/load.js +91 -5
- package/esm/profile/manifest.d.ts.map +1 -1
- package/esm/profile/manifest.js +512 -90
- package/esm/profile/merge.d.ts.map +1 -1
- package/esm/profile/merge.js +251 -39
- package/esm/profile/mod.d.ts +4 -4
- package/esm/profile/mod.d.ts.map +1 -1
- package/esm/profile/mod.js +7 -2
- package/esm/reporter/mod.js +4 -4
- package/esm/sync/locked_attributes.d.ts +19 -0
- package/esm/sync/locked_attributes.d.ts.map +1 -0
- package/esm/sync/locked_attributes.js +27 -0
- package/esm/sync/log.d.ts +34 -0
- package/esm/sync/log.d.ts.map +1 -0
- package/esm/sync/log.js +48 -0
- package/esm/sync/mapping.d.ts +66 -0
- package/esm/sync/mapping.d.ts.map +1 -0
- package/esm/sync/mapping.js +165 -0
- package/esm/sync/mod.d.ts +16 -0
- package/esm/sync/mod.d.ts.map +1 -0
- package/esm/sync/mod.js +12 -0
- package/esm/sync/status.d.ts +23 -0
- package/esm/sync/status.d.ts.map +1 -0
- package/esm/sync/status.js +21 -0
- package/esm/typl/ast.d.ts +87 -0
- package/esm/typl/ast.d.ts.map +1 -0
- package/esm/typl/ast.js +21 -0
- package/esm/typl/bridge.d.ts +32 -0
- package/esm/typl/bridge.d.ts.map +1 -0
- package/esm/typl/bridge.js +27 -0
- package/esm/typl/bullet.d.ts +34 -0
- package/esm/typl/bullet.d.ts.map +1 -0
- package/esm/typl/bullet.js +44 -0
- package/esm/typl/diagnostics.d.ts +43 -0
- package/esm/typl/diagnostics.d.ts.map +1 -0
- package/esm/typl/diagnostics.js +61 -0
- package/esm/typl/fence.d.ts +31 -0
- package/esm/typl/fence.d.ts.map +1 -0
- package/esm/typl/fence.js +24 -0
- package/esm/typl/grammar.d.ts +20 -0
- package/esm/typl/grammar.d.ts.map +1 -0
- package/esm/typl/grammar.js +471 -0
- package/esm/typl/inline.d.ts +34 -0
- package/esm/typl/inline.d.ts.map +1 -0
- package/esm/typl/inline.js +48 -0
- package/esm/typl/lexer.d.ts +37 -0
- package/esm/typl/lexer.d.ts.map +1 -0
- package/esm/typl/lexer.js +234 -0
- package/esm/typl/mod.d.ts +23 -0
- package/esm/typl/mod.d.ts.map +1 -0
- package/esm/typl/mod.js +16 -0
- package/esm/typl/registry.d.ts +42 -0
- package/esm/typl/registry.d.ts.map +1 -0
- package/esm/typl/registry.js +26 -0
- package/esm/typl/validator.d.ts +29 -0
- package/esm/typl/validator.d.ts.map +1 -0
- package/esm/typl/validator.js +141 -0
- 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/util/line_endings.d.ts +33 -0
- package/esm/util/line_endings.d.ts.map +1 -0
- package/esm/util/line_endings.js +53 -0
- package/esm/util/modals.d.ts +29 -0
- package/esm/util/modals.d.ts.map +1 -0
- package/esm/util/modals.js +38 -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/discipline.d.ts +35 -0
- package/esm/validator/discipline.d.ts.map +1 -0
- package/esm/validator/discipline.js +204 -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 +3 -1
- package/esm/validator/mod.d.ts.map +1 -1
- package/esm/validator/mod.js +275 -13
- package/esm/validator/modal_keywords.d.ts +25 -0
- package/esm/validator/modal_keywords.d.ts.map +1 -0
- package/esm/validator/modal_keywords.js +54 -0
- package/esm/validator/pattern.d.ts +15 -8
- package/esm/validator/pattern.d.ts.map +1 -1
- package/esm/validator/pattern.js +42 -19
- 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 +18 -2
- package/esm/validator/pipeline.d.ts.map +1 -1
- package/esm/validator/pipeline.js +76 -21
- 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 +162 -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 +2 -2
- package/script/ast/build.d.ts +60 -0
- package/script/ast/build.d.ts.map +1 -0
- package/script/ast/build.js +521 -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 +189 -0
- package/script/ast/nodes.d.ts.map +1 -0
- package/script/ast/nodes.js +18 -0
- package/script/ast/normalize.d.ts +58 -0
- package/script/ast/normalize.d.ts.map +1 -0
- package/script/ast/normalize.js +200 -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/constants.d.ts +16 -0
- package/script/compiler/constants.d.ts.map +1 -0
- package/script/compiler/constants.js +29 -0
- package/script/compiler/discipline_classifier.d.ts +55 -0
- package/script/compiler/discipline_classifier.d.ts.map +1 -0
- package/script/compiler/discipline_classifier.js +196 -0
- package/script/compiler/inverses.d.ts +2 -1
- package/script/compiler/inverses.d.ts.map +1 -1
- package/script/compiler/inverses.js +33 -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 +38 -1
- package/script/compiler/mod.d.ts.map +1 -1
- package/script/compiler/mod.js +206 -54
- 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 +33 -1
- package/script/compiler/schema.d.ts.map +1 -1
- package/script/compiler/schema.js +30 -8
- package/script/config/markspec.d.ts +5 -0
- package/script/config/markspec.d.ts.map +1 -1
- package/script/config/markspec.js +17 -2
- package/script/config/mod.d.ts.map +1 -1
- package/script/config/mod.js +54 -0
- package/script/formatter/mod.d.ts +55 -4
- package/script/formatter/mod.d.ts.map +1 -1
- package/script/formatter/mod.js +426 -46
- 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/lexicons/loader.d.ts +35 -0
- package/script/lexicons/loader.d.ts.map +1 -0
- package/script/lexicons/loader.js +55 -0
- package/script/lexicons/mod.d.ts +13 -0
- package/script/lexicons/mod.d.ts.map +1 -0
- package/script/lexicons/mod.js +17 -0
- package/script/lint/glossary.d.ts +45 -0
- package/script/lint/glossary.d.ts.map +1 -0
- package/script/lint/glossary.js +88 -0
- package/script/lint/mod.d.ts +14 -0
- package/script/lint/mod.d.ts.map +1 -0
- package/script/lint/mod.js +17 -0
- package/script/lint/range_util.d.ts +25 -0
- package/script/lint/range_util.d.ts.map +1 -0
- package/script/lint/range_util.js +53 -0
- package/script/lint/rules/ears.d.ts +39 -0
- package/script/lint/rules/ears.d.ts.map +1 -0
- package/script/lint/rules/ears.js +320 -0
- package/script/lint/rules/incose_sentence.d.ts +46 -0
- package/script/lint/rules/incose_sentence.d.ts.map +1 -0
- package/script/lint/rules/incose_sentence.js +421 -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/modal_sentence.d.ts +46 -0
- package/script/lint/rules/modal_sentence.d.ts.map +1 -0
- package/script/lint/rules/modal_sentence.js +150 -0
- package/script/lint/rules/passive.d.ts +64 -0
- package/script/lint/rules/passive.d.ts.map +1 -0
- package/script/lint/rules/passive.js +286 -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 +54 -0
- package/script/lint/rules/suppression.d.ts.map +1 -0
- package/script/lint/rules/suppression.js +136 -0
- package/script/lint/rules/xref.d.ts +19 -0
- package/script/lint/rules/xref.d.ts.map +1 -0
- package/script/lint/rules/xref.js +251 -0
- package/script/lint/runner.d.ts +59 -0
- package/script/lint/runner.d.ts.map +1 -0
- package/script/lint/runner.js +157 -0
- package/script/lint/score.d.ts +64 -0
- package/script/lint/score.d.ts.map +1 -0
- package/script/lint/score.js +167 -0
- package/script/lint/segmenter.d.ts +32 -0
- package/script/lint/segmenter.d.ts.map +1 -0
- package/script/lint/segmenter.js +82 -0
- package/script/lint/types.d.ts +31 -0
- package/script/lint/types.d.ts.map +1 -0
- package/script/lint/types.js +10 -0
- package/script/lock/canonical_edges.d.ts +31 -0
- package/script/lock/canonical_edges.d.ts.map +1 -0
- package/script/lock/canonical_edges.js +61 -0
- package/script/lock/check.d.ts +24 -0
- package/script/lock/check.d.ts.map +1 -0
- package/script/lock/check.js +130 -0
- package/script/lock/hash.d.ts +12 -0
- package/script/lock/hash.d.ts.map +1 -0
- package/script/lock/hash.js +36 -0
- package/script/lock/mod.d.ts +19 -0
- package/script/lock/mod.d.ts.map +1 -0
- package/script/lock/mod.js +31 -0
- package/script/lock/model.d.ts +81 -0
- package/script/lock/model.d.ts.map +1 -0
- package/script/lock/model.js +10 -0
- package/script/lock/parser.d.ts +26 -0
- package/script/lock/parser.d.ts.map +1 -0
- package/script/lock/parser.js +198 -0
- package/script/lock/resolve.d.ts +142 -0
- package/script/lock/resolve.d.ts.map +1 -0
- package/script/lock/resolve.js +397 -0
- package/script/lock/serializer.d.ts +14 -0
- package/script/lock/serializer.d.ts.map +1 -0
- package/script/lock/serializer.js +107 -0
- package/script/mod.d.ts +28 -8
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +129 -32
- package/script/model/attributes.d.ts +6 -0
- package/script/model/attributes.d.ts.map +1 -1
- package/script/model/attributes.js +201 -3
- package/script/model/discipline.d.ts +53 -0
- package/script/model/discipline.d.ts.map +1 -0
- package/script/model/discipline.js +53 -0
- 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 +267 -14
- package/script/model/mod.d.ts.map +1 -1
- package/script/model/mod.js +111 -3
- package/script/model/profile.d.ts +102 -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 +10 -16
- package/script/parser/body_tokens.d.ts +35 -0
- package/script/parser/body_tokens.d.ts.map +1 -0
- package/script/parser/body_tokens.js +235 -0
- package/script/parser/glossary.d.ts +51 -0
- package/script/parser/glossary.d.ts.map +1 -0
- package/script/parser/glossary.js +224 -0
- package/script/parser/grammars.d.ts +5 -3
- package/script/parser/grammars.d.ts.map +1 -1
- package/script/parser/grammars.js +15 -8
- package/script/parser/language_spec.d.ts +55 -0
- package/script/parser/language_spec.d.ts.map +1 -0
- package/script/parser/language_spec.js +423 -0
- package/script/parser/line_map.d.ts +60 -0
- package/script/parser/line_map.d.ts.map +1 -0
- package/script/parser/line_map.js +44 -0
- package/script/parser/markdown.d.ts +9 -0
- package/script/parser/markdown.d.ts.map +1 -1
- package/script/parser/markdown.js +315 -23
- package/script/parser/mod.d.ts +5 -0
- package/script/parser/mod.d.ts.map +1 -1
- package/script/parser/mod.js +36 -7
- package/script/parser/source.d.ts +53 -2
- package/script/parser/source.d.ts.map +1 -1
- package/script/parser/source.js +159 -69
- package/script/parser/translate.d.ts +24 -0
- package/script/parser/translate.d.ts.map +1 -0
- package/script/parser/translate.js +102 -0
- package/script/profile/chain.d.ts +8 -0
- package/script/profile/chain.d.ts.map +1 -1
- package/script/profile/chain.js +32 -14
- package/script/profile/colors.js +1 -1
- package/script/profile/default_profile.d.ts +25 -0
- package/script/profile/default_profile.d.ts.map +1 -0
- package/script/profile/default_profile.js +46 -0
- package/script/profile/discipline_mode.d.ts +64 -0
- package/script/profile/discipline_mode.d.ts.map +1 -0
- package/script/profile/discipline_mode.js +138 -0
- package/script/profile/discipline_registry.d.ts +41 -0
- package/script/profile/discipline_registry.d.ts.map +1 -0
- package/script/profile/discipline_registry.js +70 -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 +3 -1
- package/script/profile/load.d.ts.map +1 -1
- package/script/profile/load.js +91 -5
- package/script/profile/manifest.d.ts.map +1 -1
- package/script/profile/manifest.js +511 -89
- package/script/profile/merge.d.ts.map +1 -1
- package/script/profile/merge.js +251 -39
- package/script/profile/mod.d.ts +4 -4
- package/script/profile/mod.d.ts.map +1 -1
- package/script/profile/mod.js +12 -6
- package/script/reporter/mod.js +4 -4
- package/script/sync/locked_attributes.d.ts +19 -0
- package/script/sync/locked_attributes.d.ts.map +1 -0
- package/script/sync/locked_attributes.js +30 -0
- package/script/sync/log.d.ts +34 -0
- package/script/sync/log.d.ts.map +1 -0
- package/script/sync/log.js +52 -0
- package/script/sync/mapping.d.ts +66 -0
- package/script/sync/mapping.d.ts.map +1 -0
- package/script/sync/mapping.js +169 -0
- package/script/sync/mod.d.ts +16 -0
- package/script/sync/mod.d.ts.map +1 -0
- package/script/sync/mod.js +21 -0
- package/script/sync/status.d.ts +23 -0
- package/script/sync/status.d.ts.map +1 -0
- package/script/sync/status.js +24 -0
- package/script/typl/ast.d.ts +87 -0
- package/script/typl/ast.d.ts.map +1 -0
- package/script/typl/ast.js +24 -0
- package/script/typl/bridge.d.ts +32 -0
- package/script/typl/bridge.d.ts.map +1 -0
- package/script/typl/bridge.js +30 -0
- package/script/typl/bullet.d.ts +34 -0
- package/script/typl/bullet.d.ts.map +1 -0
- package/script/typl/bullet.js +47 -0
- package/script/typl/diagnostics.d.ts +43 -0
- package/script/typl/diagnostics.d.ts.map +1 -0
- package/script/typl/diagnostics.js +65 -0
- package/script/typl/fence.d.ts +31 -0
- package/script/typl/fence.d.ts.map +1 -0
- package/script/typl/fence.js +27 -0
- package/script/typl/grammar.d.ts +20 -0
- package/script/typl/grammar.d.ts.map +1 -0
- package/script/typl/grammar.js +474 -0
- package/script/typl/inline.d.ts +34 -0
- package/script/typl/inline.d.ts.map +1 -0
- package/script/typl/inline.js +51 -0
- package/script/typl/lexer.d.ts +37 -0
- package/script/typl/lexer.d.ts.map +1 -0
- package/script/typl/lexer.js +237 -0
- package/script/typl/mod.d.ts +23 -0
- package/script/typl/mod.d.ts.map +1 -0
- package/script/typl/mod.js +29 -0
- package/script/typl/registry.d.ts +42 -0
- package/script/typl/registry.d.ts.map +1 -0
- package/script/typl/registry.js +29 -0
- package/script/typl/validator.d.ts +29 -0
- package/script/typl/validator.d.ts.map +1 -0
- package/script/typl/validator.js +144 -0
- 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/util/line_endings.d.ts +33 -0
- package/script/util/line_endings.d.ts.map +1 -0
- package/script/util/line_endings.js +58 -0
- package/script/util/modals.d.ts +29 -0
- package/script/util/modals.d.ts.map +1 -0
- package/script/util/modals.js +42 -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/discipline.d.ts +35 -0
- package/script/validator/discipline.d.ts.map +1 -0
- package/script/validator/discipline.js +207 -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 +3 -1
- package/script/validator/mod.d.ts.map +1 -1
- package/script/validator/mod.js +278 -14
- package/script/validator/modal_keywords.d.ts +25 -0
- package/script/validator/modal_keywords.d.ts.map +1 -0
- package/script/validator/modal_keywords.js +57 -0
- package/script/validator/pattern.d.ts +15 -8
- package/script/validator/pattern.d.ts.map +1 -1
- package/script/validator/pattern.js +42 -19
- 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 +18 -2
- package/script/validator/pipeline.d.ts.map +1 -1
- package/script/validator/pipeline.js +78 -22
- 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 +168 -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
|
@@ -9,7 +9,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.parseMarkdown = parseMarkdown;
|
|
10
10
|
const mod_js_1 = require("../model/mod.js");
|
|
11
11
|
const attributes_js_1 = require("./attributes.js");
|
|
12
|
+
const body_tokens_js_1 = require("./body_tokens.js");
|
|
12
13
|
const remark_js_1 = require("./remark.js");
|
|
14
|
+
const build_js_1 = require("../ast/build.js");
|
|
15
|
+
const translate_js_1 = require("./translate.js");
|
|
16
|
+
const mod_js_2 = require("../typl/mod.js");
|
|
13
17
|
/**
|
|
14
18
|
* Slug pattern for referenced-entry display IDs.
|
|
15
19
|
*
|
|
@@ -20,6 +24,10 @@ const remark_js_1 = require("./remark.js");
|
|
|
20
24
|
const SLUG_RE = /^[A-Za-z]([A-Za-z0-9._/-]*[A-Za-z0-9])?$/;
|
|
21
25
|
/** Match `[...]` at the start of a list item paragraph. Captures: [1] = display ID, [2] = title. */
|
|
22
26
|
const ENTRY_START_RE = /^\[([^\]]+)\]\s*(.*)$/;
|
|
27
|
+
/** Match `[]` at the start — empty brackets. */
|
|
28
|
+
const EMPTY_BRACKET_RE = /^\[\]\s*(.*)$/;
|
|
29
|
+
/** Match `[` at the start without a closing `]` on the same logical content — unterminated. */
|
|
30
|
+
const UNTERMINATED_BRACKET_RE = /^\[[^\]]*$/;
|
|
23
31
|
/**
|
|
24
32
|
* Find the `Id:` attribute on an entry. Returns undefined when absent. If
|
|
25
33
|
* more than one `Id:` is present, returns the first — the validator flags
|
|
@@ -50,6 +58,9 @@ function parseMarkdown(markdown, options) {
|
|
|
50
58
|
const tree = remark_js_1.processor.parse(markdown);
|
|
51
59
|
const entries = [];
|
|
52
60
|
const diagnostics = [];
|
|
61
|
+
// Pre-split once so every extractBodyContent call shares the same array
|
|
62
|
+
// instead of re-splitting for each list item (O(N×L) → O(N+L)).
|
|
63
|
+
const markdownLines = markdown.split("\n");
|
|
53
64
|
// Collect link definition identifiers for shortcut reference exclusion.
|
|
54
65
|
const definitions = new Set(tree.children
|
|
55
66
|
.filter((n) => n.type === "definition")
|
|
@@ -62,31 +73,32 @@ function parseMarkdown(markdown, options) {
|
|
|
62
73
|
if (list.ordered)
|
|
63
74
|
continue;
|
|
64
75
|
for (const item of list.children) {
|
|
65
|
-
const entry = extractEntry(item,
|
|
76
|
+
const entry = extractEntry(item, markdownLines, file, definitions, isReferencesDoc, diagnostics, !!options?.lineMap);
|
|
66
77
|
if (entry)
|
|
67
78
|
entries.push(entry);
|
|
68
79
|
}
|
|
69
80
|
}
|
|
70
|
-
|
|
81
|
+
const finalEntries = options?.lineMap
|
|
82
|
+
? (0, translate_js_1.translateEntryLocations)(entries, options.lineMap)
|
|
83
|
+
: entries;
|
|
84
|
+
return { entries: finalEntries, diagnostics };
|
|
71
85
|
}
|
|
72
86
|
/**
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
87
|
+
* Resolve whether this is a references document.
|
|
88
|
+
*
|
|
89
|
+
* The caller (`parseFile` in `parser/mod.ts`) always passes an explicit
|
|
90
|
+
* value computed via the canonical `isReferencesDocument` helper, so the
|
|
91
|
+
* auto-detection fallback is never needed here.
|
|
77
92
|
*/
|
|
78
|
-
function detectReferencesDocument(
|
|
79
|
-
|
|
80
|
-
return explicit;
|
|
81
|
-
const basename = file.split("/").pop() ?? "";
|
|
82
|
-
return basename === "references.md" || file.includes("/references/");
|
|
93
|
+
function detectReferencesDocument(_file, explicit) {
|
|
94
|
+
return explicit ?? false;
|
|
83
95
|
}
|
|
84
96
|
/**
|
|
85
97
|
* Attempt to extract a MarkSpec entry from a list item.
|
|
86
98
|
* Returns undefined if the list item is not an entry block.
|
|
87
99
|
* Diagnostics (e.g., deprecation warnings) are pushed into the accumulator.
|
|
88
100
|
*/
|
|
89
|
-
function extractEntry(item,
|
|
101
|
+
function extractEntry(item, markdownLines, file, definitions, isReferencesDoc, diagnostics, hasLineMap = false) {
|
|
90
102
|
// Task list items (remark-gfm sets checked to true/false) are not entries.
|
|
91
103
|
if (item.checked != null)
|
|
92
104
|
return undefined;
|
|
@@ -108,11 +120,36 @@ function extractEntry(item, markdown, file, definitions, isReferencesDoc, diagno
|
|
|
108
120
|
let title;
|
|
109
121
|
if (firstInline.type === "text") {
|
|
110
122
|
// remark may parse `[ID] Title` as a single text node
|
|
111
|
-
const
|
|
123
|
+
const textValue = firstInline.value;
|
|
124
|
+
const match = ENTRY_START_RE.exec(textValue);
|
|
112
125
|
if (match) {
|
|
113
126
|
displayId = match[1];
|
|
114
127
|
title = match[2].trim();
|
|
115
128
|
}
|
|
129
|
+
else if (EMPTY_BRACKET_RE.test(textValue)) {
|
|
130
|
+
// MSL-P001: bracketed content is empty — `- [] Title`
|
|
131
|
+
const entryLine = item.position?.start.line ?? 1;
|
|
132
|
+
diagnostics.push({
|
|
133
|
+
code: "MSL-P001",
|
|
134
|
+
severity: "error",
|
|
135
|
+
message: "list item starts with `[]` but the bracketed content is empty " +
|
|
136
|
+
"(spec section 4.1)",
|
|
137
|
+
location: { file, line: entryLine, column: 1 },
|
|
138
|
+
});
|
|
139
|
+
return undefined;
|
|
140
|
+
}
|
|
141
|
+
else if (UNTERMINATED_BRACKET_RE.test(textValue)) {
|
|
142
|
+
// MSL-P003: display-ID brackets unterminated (missing `]`)
|
|
143
|
+
const entryLine = item.position?.start.line ?? 1;
|
|
144
|
+
diagnostics.push({
|
|
145
|
+
code: "MSL-P003",
|
|
146
|
+
severity: "error",
|
|
147
|
+
message: "display-ID brackets unterminated -- missing `]` before end of " +
|
|
148
|
+
"title line (spec section 4.1)",
|
|
149
|
+
location: { file, line: entryLine, column: 1 },
|
|
150
|
+
});
|
|
151
|
+
return undefined;
|
|
152
|
+
}
|
|
116
153
|
}
|
|
117
154
|
// Try linkReference pattern: remark sometimes parses [ID] as a linkReference
|
|
118
155
|
if (!displayId && firstInline.type === "linkReference") {
|
|
@@ -143,10 +180,168 @@ function extractEntry(item, markdown, file, definitions, isReferencesDoc, diagno
|
|
|
143
180
|
// citation compatibility. Canonical slug never contains `@`.
|
|
144
181
|
if (displayId.startsWith("@"))
|
|
145
182
|
displayId = displayId.slice(1);
|
|
183
|
+
// MSL-I005: Display ID is empty (after `@` stripping).
|
|
184
|
+
if (displayId.length === 0) {
|
|
185
|
+
const entryLine = item.position?.start.line ?? 1;
|
|
186
|
+
diagnostics.push({
|
|
187
|
+
code: "MSL-I005",
|
|
188
|
+
severity: "error",
|
|
189
|
+
message: "display ID is empty (spec section 4.2)",
|
|
190
|
+
location: { file, line: entryLine, column: 1 },
|
|
191
|
+
});
|
|
192
|
+
return undefined;
|
|
193
|
+
}
|
|
194
|
+
// MSL-P002: title text missing after `]`. The title capture is empty
|
|
195
|
+
// and was not populated from subsequent nodes (linkReference path sets
|
|
196
|
+
// title from rest nodes).
|
|
197
|
+
if (title !== undefined && title.length === 0) {
|
|
198
|
+
const entryLine = item.position?.start.line ?? 1;
|
|
199
|
+
diagnostics.push({
|
|
200
|
+
code: "MSL-P002",
|
|
201
|
+
severity: "error",
|
|
202
|
+
message: `${displayId}: title line missing title text after ']' (spec section 4.1)`,
|
|
203
|
+
location: { file, line: entryLine, column: 1 },
|
|
204
|
+
});
|
|
205
|
+
// Continue parsing — entry is still structurally valid for downstream
|
|
206
|
+
// validation (MSL-P010 also fires from the validator for empty titles).
|
|
207
|
+
}
|
|
146
208
|
// Extract body content and attributes.
|
|
147
|
-
const bodyContent = extractBodyContent(item,
|
|
209
|
+
const bodyContent = extractBodyContent(item, markdownLines);
|
|
148
210
|
const [body, attrLines] = (0, attributes_js_1.splitBodyAndAttributes)(bodyContent);
|
|
149
211
|
const attributes = (0, attributes_js_1.parseAttributes)(attrLines);
|
|
212
|
+
const { blocks: bodyAst, tree: mdastTree } = (0, build_js_1.buildBodyAstWithTree)(body);
|
|
213
|
+
const entryLine = item.position?.start.line ?? 1;
|
|
214
|
+
// MSL-P020: trailers block is not the final indented code block.
|
|
215
|
+
// Detect `Key: Value` lines in the body that likely should be trailers
|
|
216
|
+
// but are not at the final position (body content follows them).
|
|
217
|
+
// Exclude caption keywords (Figure:, Table:, etc.) which are legitimate
|
|
218
|
+
// body content, not misplaced trailer attributes.
|
|
219
|
+
const CAPTION_KEYWORDS = new Set([
|
|
220
|
+
"Figure",
|
|
221
|
+
"Table",
|
|
222
|
+
"Listing",
|
|
223
|
+
"Feature",
|
|
224
|
+
"Equation",
|
|
225
|
+
"List",
|
|
226
|
+
]);
|
|
227
|
+
if (body.length > 0) {
|
|
228
|
+
const bodyLines = body.split("\n");
|
|
229
|
+
let inFencedBlock = false;
|
|
230
|
+
for (let i = 0; i < bodyLines.length; i++) {
|
|
231
|
+
const trimmed = bodyLines[i].trim();
|
|
232
|
+
// Track fenced code blocks (``` or ~~~) to skip their contents
|
|
233
|
+
if (/^(`{3,}|~{3,})/.test(trimmed)) {
|
|
234
|
+
inFencedBlock = !inFencedBlock;
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
if (inFencedBlock)
|
|
238
|
+
continue;
|
|
239
|
+
if (!attributes_js_1.ATTR_LINE_RE.test(trimmed))
|
|
240
|
+
continue;
|
|
241
|
+
// Extract the key portion to check against caption keywords
|
|
242
|
+
const keyMatch = trimmed.match(/^([A-Z][A-Za-z-]*):/);
|
|
243
|
+
if (keyMatch && CAPTION_KEYWORDS.has(keyMatch[1]))
|
|
244
|
+
continue;
|
|
245
|
+
// Found a Key: Value line in the body — non-final position
|
|
246
|
+
diagnostics.push({
|
|
247
|
+
code: "MSL-P020",
|
|
248
|
+
severity: "error",
|
|
249
|
+
message: `${displayId}: trailers block is not the final indented code ` +
|
|
250
|
+
`block of the entry -- content appears after trailer-like ` +
|
|
251
|
+
`lines (spec section 4.1)`,
|
|
252
|
+
location: { file, line: entryLine, column: 1 },
|
|
253
|
+
});
|
|
254
|
+
break; // One diagnostic per entry is sufficient
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
// MSL-P021 / MSL-P022: validate trailer lines for syntax correctness.
|
|
258
|
+
// The trailer block is the final indented code block. Lines within it
|
|
259
|
+
// should all match `Key: Value` syntax. We check both the parsed
|
|
260
|
+
// attrLines AND the trailing body lines that might be in a code block
|
|
261
|
+
// but failed ATTR_LINE_RE (thus stayed in the body).
|
|
262
|
+
const TRAILER_KEY_RE = /^[A-Za-z][A-Za-z0-9-]*$/;
|
|
263
|
+
const COLON_SPLIT_RE = /^([^:]+):\s*(.*)$/;
|
|
264
|
+
// Check lines that DID end up in attrLines but might have key issues
|
|
265
|
+
for (const rawLine of attrLines) {
|
|
266
|
+
const trimmed = rawLine.trim();
|
|
267
|
+
if (!trimmed)
|
|
268
|
+
continue;
|
|
269
|
+
if (!attributes_js_1.ATTR_LINE_RE.test(trimmed)) {
|
|
270
|
+
const colonMatch = COLON_SPLIT_RE.exec(trimmed);
|
|
271
|
+
if (colonMatch) {
|
|
272
|
+
const key = colonMatch[1].trim();
|
|
273
|
+
if (!TRAILER_KEY_RE.test(key)) {
|
|
274
|
+
diagnostics.push({
|
|
275
|
+
code: "MSL-P022",
|
|
276
|
+
severity: "error",
|
|
277
|
+
message: `${displayId}: trailer key '${key}' contains characters ` +
|
|
278
|
+
`outside [A-Za-z][A-Za-z0-9-]* (spec section 4.1)`,
|
|
279
|
+
location: { file, line: entryLine, column: 1 },
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
diagnostics.push({
|
|
284
|
+
code: "MSL-P021",
|
|
285
|
+
severity: "error",
|
|
286
|
+
message: `${displayId}: trailer line does not match 'Key: Value' ` +
|
|
287
|
+
`syntax (spec section 4.1): "${trimmed}"`,
|
|
288
|
+
location: { file, line: entryLine, column: 1 },
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
diagnostics.push({
|
|
294
|
+
code: "MSL-P021",
|
|
295
|
+
severity: "error",
|
|
296
|
+
message: `${displayId}: trailer line does not match 'Key: Value' ` +
|
|
297
|
+
`syntax (spec section 4.1): "${trimmed}"`,
|
|
298
|
+
location: { file, line: entryLine, column: 1 },
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
// Also scan trailing body lines for suspected misplaced trailers.
|
|
304
|
+
// If the body's last non-empty lines look like they belong to an
|
|
305
|
+
// indented code block with colon-separated content that has invalid
|
|
306
|
+
// keys, emit P022. Lines without colons that appear in what looks
|
|
307
|
+
// like a trailer block emit P021.
|
|
308
|
+
if (body.length > 0) {
|
|
309
|
+
const bodyLines = body.split("\n");
|
|
310
|
+
// Walk backward from the end of the body to find lines in a trailing
|
|
311
|
+
// code-block-like region that have colons (suspected trailers).
|
|
312
|
+
for (let i = bodyLines.length - 1; i >= 0; i--) {
|
|
313
|
+
const trimmed = bodyLines[i].trim();
|
|
314
|
+
if (!trimmed)
|
|
315
|
+
continue; // skip trailing blanks
|
|
316
|
+
const colonMatch = COLON_SPLIT_RE.exec(trimmed);
|
|
317
|
+
if (!colonMatch)
|
|
318
|
+
break; // stop at non-colon line
|
|
319
|
+
const key = colonMatch[1].trim();
|
|
320
|
+
if (attributes_js_1.ATTR_LINE_RE.test(trimmed)) {
|
|
321
|
+
// Valid attr line in body → already caught by P020
|
|
322
|
+
continue;
|
|
323
|
+
}
|
|
324
|
+
if (!TRAILER_KEY_RE.test(key)) {
|
|
325
|
+
diagnostics.push({
|
|
326
|
+
code: "MSL-P022",
|
|
327
|
+
severity: "error",
|
|
328
|
+
message: `${displayId}: trailer key '${key}' contains characters ` +
|
|
329
|
+
`outside [A-Za-z][A-Za-z0-9-]* (spec section 4.1)`,
|
|
330
|
+
location: { file, line: entryLine, column: 1 },
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
else if (colonMatch[2].trim().length === 0) {
|
|
334
|
+
diagnostics.push({
|
|
335
|
+
code: "MSL-P021",
|
|
336
|
+
severity: "error",
|
|
337
|
+
message: `${displayId}: trailer line does not match 'Key: Value' ` +
|
|
338
|
+
`syntax (spec section 4.1): "${trimmed}"`,
|
|
339
|
+
location: { file, line: entryLine, column: 1 },
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
break; // one diagnostic per trailing suspect line is sufficient
|
|
343
|
+
}
|
|
344
|
+
}
|
|
150
345
|
// Detect legacy paragraph + trailing-backslash attribute form and warn.
|
|
151
346
|
if (attributes.length > 0 &&
|
|
152
347
|
attrLines.some((line) => line.trimEnd().endsWith("\\"))) {
|
|
@@ -170,45 +365,142 @@ function extractEntry(item, markdown, file, definitions, isReferencesDoc, diagno
|
|
|
170
365
|
// `Id:` is neither a ULID nor a scheme-qualified URI. Accept as an
|
|
171
366
|
// identified entry so the validator can surface MSL-R004; missing
|
|
172
367
|
// shape on a parsed entry is not useful downstream.
|
|
173
|
-
shape = "
|
|
368
|
+
shape = "Authored";
|
|
174
369
|
}
|
|
175
370
|
}
|
|
176
371
|
else {
|
|
177
372
|
// No `Id:`. Fall back on display-ID shape + document context to decide
|
|
178
373
|
// whether to admit the entry at all.
|
|
179
374
|
if (isReferencesDoc && SLUG_RE.test(displayId)) {
|
|
180
|
-
shape = "
|
|
375
|
+
shape = "Reference";
|
|
181
376
|
}
|
|
182
377
|
else {
|
|
183
378
|
// No identity attribute and no references-doc context — admit as
|
|
184
379
|
// identified so the validator can surface the missing-`Id:` error.
|
|
185
|
-
shape = "
|
|
380
|
+
shape = "Authored";
|
|
186
381
|
}
|
|
187
382
|
}
|
|
188
383
|
// Inferred type from display-ID prefix — left to the profile layer. For
|
|
189
384
|
// now the core records no type; downstream profile-aware code populates
|
|
190
385
|
// this field when a profile is loaded.
|
|
191
386
|
const type = undefined;
|
|
387
|
+
// MSL-P030: Authored entry has no body block (title + trailers only).
|
|
388
|
+
// For Reference shape, body is optional (ADR-002 section Part 3). For Authored,
|
|
389
|
+
// the body is required. We also emit P030 when the body is empty (all
|
|
390
|
+
// content was consumed as attributes).
|
|
391
|
+
if (shape === "Authored" && body.trim().length === 0) {
|
|
392
|
+
diagnostics.push({
|
|
393
|
+
code: "MSL-P030",
|
|
394
|
+
severity: "error",
|
|
395
|
+
message: `${displayId}: Authored entry has no body block -- entries must ` +
|
|
396
|
+
`have body content between title and trailers (spec section 4.1)`,
|
|
397
|
+
location: { file, line: entryLine, column: 1 },
|
|
398
|
+
});
|
|
399
|
+
}
|
|
192
400
|
// Body requirement: identified entries require a body; referenced entries
|
|
193
401
|
// may omit it. If there's only one child (the title paragraph), admit
|
|
194
402
|
// only referenced entries.
|
|
195
|
-
if (shape !== "
|
|
403
|
+
if (shape !== "Reference" && item.children.length < 2)
|
|
196
404
|
return undefined;
|
|
197
405
|
// Source location
|
|
198
406
|
const line = item.position?.start.line ?? 1;
|
|
199
407
|
const column = item.position?.start.column ?? 1;
|
|
408
|
+
const entryLocation = { file, line, column };
|
|
409
|
+
// Inline-construct tokens (ADR-016). Reuses the already-built bodyAst to
|
|
410
|
+
// avoid a redundant mdast parse.
|
|
411
|
+
//
|
|
412
|
+
// bodyStartLine: when a lineMap is present (source-file path), use the
|
|
413
|
+
// mdast position of the second child (the body paragraph) — the actual
|
|
414
|
+
// buffer line where the body starts. CommonMark loose lists have a blank
|
|
415
|
+
// line between title and body, so the body is at (entry_line + 2), not
|
|
416
|
+
// (entry_line + 1). Without a lineMap we keep the legacy (entry_line + 1)
|
|
417
|
+
// behaviour to avoid shifting existing markdown-file token locations.
|
|
418
|
+
//
|
|
419
|
+
// columnOffset: when a lineMap is present, body text has been stripped of
|
|
420
|
+
// the list-item indent (e.g., " " for column-1 items), so each token
|
|
421
|
+
// column must be bumped by that indent width for the LineMap to translate
|
|
422
|
+
// to the correct source column. Without a lineMap, no offset is applied
|
|
423
|
+
// (legacy behaviour unchanged).
|
|
424
|
+
const bodyIndent = hasLineMap
|
|
425
|
+
// + 2 = the " " continuation indent prepended by wrapAsListItem to
|
|
426
|
+
// every non-title line. Mirrors the indent computation in
|
|
427
|
+
// extractBodyContent below.
|
|
428
|
+
? (item.position?.start.column ?? 1) - 1 + 2
|
|
429
|
+
: 0;
|
|
430
|
+
const bodyStartLine = hasLineMap
|
|
431
|
+
? (item.children[1]?.position?.start.line ?? (line + 1))
|
|
432
|
+
: line + 1;
|
|
433
|
+
const bodyTokens = (0, body_tokens_js_1.extractBodyTokens)(body, bodyAst, {
|
|
434
|
+
file,
|
|
435
|
+
line: bodyStartLine,
|
|
436
|
+
column: 1,
|
|
437
|
+
}, bodyIndent, mdastTree);
|
|
438
|
+
// Extract typl declarations from all three surfaces in the body:
|
|
439
|
+
// (1) ```typl fences, (2) bullet-glossary items, (3) inline code spans.
|
|
440
|
+
// Per-surface diagnostics are bridged to file-relative positions and
|
|
441
|
+
// pushed into the parser's diagnostic stream. Cross-entry collision
|
|
442
|
+
// detection lands in a later PR; this PR aggregates all intra-entry
|
|
443
|
+
// bindings + typedefs from every surface.
|
|
444
|
+
let types;
|
|
445
|
+
const allBindings = [];
|
|
446
|
+
const allTypedefs = [];
|
|
447
|
+
for (const fence of (0, mod_js_2.extractTyplFences)(bodyAst)) {
|
|
448
|
+
const result = (0, mod_js_2.parseTyplBlock)(fence.source);
|
|
449
|
+
allBindings.push(...result.ast.bindings);
|
|
450
|
+
allTypedefs.push(...result.ast.typedefs);
|
|
451
|
+
// Fence content starts on the line AFTER the opening ```, so the
|
|
452
|
+
// bridge offset is the file line of the opening fence.
|
|
453
|
+
const fenceFileStartLine = bodyStartLine + fence.range.start.line - 1;
|
|
454
|
+
for (const td of result.diagnostics) {
|
|
455
|
+
diagnostics.push((0, mod_js_2.bridgeTyplDiagnostic)(td, file, fenceFileStartLine));
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
for (const bullet of (0, mod_js_2.extractTyplBullets)(bodyAst)) {
|
|
459
|
+
const result = (0, mod_js_2.parseTyplBlock)(bullet.source);
|
|
460
|
+
allBindings.push(...result.ast.bindings);
|
|
461
|
+
allTypedefs.push(...result.ast.typedefs);
|
|
462
|
+
// A bullet item IS the typl content (single line). The bridge
|
|
463
|
+
// computes line as `offset + diag.position.line`; we want diag
|
|
464
|
+
// position.line 1 to map to the item's file line, so offset is
|
|
465
|
+
// `itemFileLine - 1` = `bodyStartLine + bullet.range.start.line - 2`.
|
|
466
|
+
const bulletFileOffset = bodyStartLine + bullet.range.start.line - 2;
|
|
467
|
+
for (const td of result.diagnostics) {
|
|
468
|
+
diagnostics.push((0, mod_js_2.bridgeTyplDiagnostic)(td, file, bulletFileOffset));
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
for (const inline of (0, mod_js_2.extractTyplInlines)(bodyTokens)) {
|
|
472
|
+
const result = (0, mod_js_2.parseTyplBlock)(inline.source);
|
|
473
|
+
allBindings.push(...result.ast.bindings);
|
|
474
|
+
allTypedefs.push(...result.ast.typedefs);
|
|
475
|
+
// inline.location is already file-relative (translated by the
|
|
476
|
+
// bodyTokens extractor). The bridge computes file line as
|
|
477
|
+
// `offset + diag.position.line`; for inline content where
|
|
478
|
+
// diag.position.line is 1 (single-line span), offset is
|
|
479
|
+
// `inline.location.line - 1`.
|
|
480
|
+
const inlineFileOffset = inline.location.line - 1;
|
|
481
|
+
for (const td of result.diagnostics) {
|
|
482
|
+
diagnostics.push((0, mod_js_2.bridgeTyplDiagnostic)(td, inline.location.file, inlineFileOffset));
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
if (allBindings.length > 0 || allTypedefs.length > 0) {
|
|
486
|
+
types = { bindings: allBindings, typedefs: allTypedefs };
|
|
487
|
+
}
|
|
200
488
|
return {
|
|
201
|
-
displayId,
|
|
489
|
+
displayId: (0, mod_js_1.makeDisplayId)(displayId),
|
|
202
490
|
title: title ?? "",
|
|
203
491
|
body,
|
|
492
|
+
bodyAst,
|
|
204
493
|
rawAttributes: attributes,
|
|
205
494
|
typedAttributes: (0, attributes_js_1.collateAttributes)(attributes),
|
|
206
495
|
id,
|
|
207
496
|
type,
|
|
208
497
|
shape,
|
|
209
|
-
location:
|
|
210
|
-
|
|
498
|
+
location: entryLocation,
|
|
499
|
+
bodyStartLine,
|
|
500
|
+
source: { kind: "markdown" },
|
|
211
501
|
properties: { file: { path: file, line, column } },
|
|
502
|
+
bodyTokens,
|
|
503
|
+
...(types ? { types } : {}),
|
|
212
504
|
};
|
|
213
505
|
}
|
|
214
506
|
/**
|
|
@@ -216,12 +508,12 @@ function extractEntry(item, markdown, file, definitions, isReferencesDoc, diagno
|
|
|
216
508
|
* which contains the display ID and title).
|
|
217
509
|
*
|
|
218
510
|
* Reconstructs the text content from the source markdown using position info.
|
|
511
|
+
* Accepts a pre-split lines array to avoid redundant splits across entries.
|
|
219
512
|
*/
|
|
220
|
-
function extractBodyContent(item,
|
|
513
|
+
function extractBodyContent(item, lines) {
|
|
221
514
|
const children = item.children.slice(1); // Skip title paragraph
|
|
222
515
|
if (!children.length)
|
|
223
516
|
return "";
|
|
224
|
-
const lines = markdown.split("\n");
|
|
225
517
|
// Get the range from the second child's start to the last child's end
|
|
226
518
|
const startLine = children[0].position?.start.line;
|
|
227
519
|
const endLine = children[children.length - 1].position?.end.line;
|
package/script/parser/mod.d.ts
CHANGED
|
@@ -20,7 +20,12 @@ export { detectInlineRefs } from "./references.js";
|
|
|
20
20
|
export type { DetectInlineRefsOptions } from "./references.js";
|
|
21
21
|
export { parseSource } from "./source.js";
|
|
22
22
|
export type { ParseSourceOptions, ParseSourceResult } from "./source.js";
|
|
23
|
+
export { stripBlockCommentPrefix, stripLineCommentPrefix, wrapAsListItem, } from "./source.js";
|
|
23
24
|
export { isSupportedExtension, loadGrammar } from "./grammars.js";
|
|
25
|
+
export type { DocCommentBlockMeta, LineMap } from "./line_map.js";
|
|
26
|
+
export { buildBlockLineMap } from "./line_map.js";
|
|
27
|
+
export type { LanguageDocCommentSpec, SupportedLanguage, } from "./language_spec.js";
|
|
28
|
+
export { LANGUAGE_SPECS, languageIdForExtension } from "./language_spec.js";
|
|
24
29
|
/** Options for {@linkcode parse}. */
|
|
25
30
|
export interface ParseOptions {
|
|
26
31
|
/** File path used in source locations. */
|
|
@@ -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;AAU5E,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;;;;;;;GAOG;AACH,wBAAsB,SAAS,CAC7B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACjC,OAAO,CAAC,eAAe,CAAC,CA6C1B;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,11 +11,12 @@
|
|
|
11
11
|
* - source: doc comment extraction from Rust, Kotlin, C, C++, Java
|
|
12
12
|
*/
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.loadGrammar = exports.isSupportedExtension = exports.parseSource = exports.detectInlineRefs = exports.extractFrontMatter = exports.detectDirectives = void 0;
|
|
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;
|
|
15
15
|
exports.parse = parse;
|
|
16
16
|
exports.parseFile = parseFile;
|
|
17
17
|
exports.detectCaptions = detectCaptions;
|
|
18
18
|
const path_1 = require("@std/path");
|
|
19
|
+
const line_endings_js_1 = require("../util/line_endings.js");
|
|
19
20
|
const markdown_js_1 = require("./markdown.js");
|
|
20
21
|
const grammars_js_1 = require("./grammars.js");
|
|
21
22
|
const source_js_1 = require("./source.js");
|
|
@@ -29,9 +30,18 @@ var references_js_1 = require("./references.js");
|
|
|
29
30
|
Object.defineProperty(exports, "detectInlineRefs", { enumerable: true, get: function () { return references_js_1.detectInlineRefs; } });
|
|
30
31
|
var source_js_2 = require("./source.js");
|
|
31
32
|
Object.defineProperty(exports, "parseSource", { enumerable: true, get: function () { return source_js_2.parseSource; } });
|
|
33
|
+
var source_js_3 = require("./source.js");
|
|
34
|
+
Object.defineProperty(exports, "stripBlockCommentPrefix", { enumerable: true, get: function () { return source_js_3.stripBlockCommentPrefix; } });
|
|
35
|
+
Object.defineProperty(exports, "stripLineCommentPrefix", { enumerable: true, get: function () { return source_js_3.stripLineCommentPrefix; } });
|
|
36
|
+
Object.defineProperty(exports, "wrapAsListItem", { enumerable: true, get: function () { return source_js_3.wrapAsListItem; } });
|
|
32
37
|
var grammars_js_2 = require("./grammars.js");
|
|
33
38
|
Object.defineProperty(exports, "isSupportedExtension", { enumerable: true, get: function () { return grammars_js_2.isSupportedExtension; } });
|
|
34
39
|
Object.defineProperty(exports, "loadGrammar", { enumerable: true, get: function () { return grammars_js_2.loadGrammar; } });
|
|
40
|
+
var line_map_js_1 = require("./line_map.js");
|
|
41
|
+
Object.defineProperty(exports, "buildBlockLineMap", { enumerable: true, get: function () { return line_map_js_1.buildBlockLineMap; } });
|
|
42
|
+
var language_spec_js_1 = require("./language_spec.js");
|
|
43
|
+
Object.defineProperty(exports, "LANGUAGE_SPECS", { enumerable: true, get: function () { return language_spec_js_1.LANGUAGE_SPECS; } });
|
|
44
|
+
Object.defineProperty(exports, "languageIdForExtension", { enumerable: true, get: function () { return language_spec_js_1.languageIdForExtension; } });
|
|
35
45
|
/**
|
|
36
46
|
* Parse a Markdown string and return all MarkSpec entries found.
|
|
37
47
|
*
|
|
@@ -40,7 +50,12 @@ Object.defineProperty(exports, "loadGrammar", { enumerable: true, get: function
|
|
|
40
50
|
* @returns Array of parsed entries
|
|
41
51
|
*/
|
|
42
52
|
function parse(markdown, options) {
|
|
43
|
-
|
|
53
|
+
const file = options?.file;
|
|
54
|
+
const normalised = (0, line_endings_js_1.normalizeLineEndings)(markdown);
|
|
55
|
+
return (0, markdown_js_1.parseMarkdown)(normalised, {
|
|
56
|
+
...options,
|
|
57
|
+
isReferencesDoc: file !== undefined ? isReferencesDocument(file) : false,
|
|
58
|
+
}).entries;
|
|
44
59
|
}
|
|
45
60
|
/**
|
|
46
61
|
* Detect if a file is a references document.
|
|
@@ -48,8 +63,12 @@ function parse(markdown, options) {
|
|
|
48
63
|
* @param file - File path
|
|
49
64
|
*/
|
|
50
65
|
function isReferencesDocument(file) {
|
|
51
|
-
|
|
52
|
-
|
|
66
|
+
if ((0, path_1.basename)(file) === "references.md")
|
|
67
|
+
return true;
|
|
68
|
+
// Detect a `/references/` (or `\references\`) directory anywhere in the
|
|
69
|
+
// path, in a separator-agnostic way so Windows checkouts behave the
|
|
70
|
+
// same as POSIX.
|
|
71
|
+
return /[\\/]references[\\/]/.test(file);
|
|
53
72
|
}
|
|
54
73
|
/**
|
|
55
74
|
* Parse a file and return entries, annotation links, and (for Markdown
|
|
@@ -61,16 +80,26 @@ function isReferencesDocument(file) {
|
|
|
61
80
|
*/
|
|
62
81
|
async function parseFile(content, options) {
|
|
63
82
|
const ext = (0, path_1.extname)(options.file);
|
|
83
|
+
const normalised = (0, line_endings_js_1.normalizeLineEndings)(content);
|
|
64
84
|
if ((0, grammars_js_1.isSupportedExtension)(ext)) {
|
|
65
85
|
const language = await (0, grammars_js_1.loadGrammar)(ext);
|
|
66
|
-
const
|
|
86
|
+
const languageId = (0, grammars_js_1.languageIdForExtension)(ext);
|
|
87
|
+
if (!languageId) {
|
|
88
|
+
// Defensive — isSupportedExtension and languageIdForExtension are kept
|
|
89
|
+
// in sync via their shared extension lists, so this branch should be
|
|
90
|
+
// unreachable. Throwing surfaces the drift immediately rather than
|
|
91
|
+
// silently falling through to wrong grammar dispatch.
|
|
92
|
+
throw new Error(`internal: no languageId for supported extension '${ext}'`);
|
|
93
|
+
}
|
|
94
|
+
const result = (0, source_js_1.parseSource)(normalised, {
|
|
67
95
|
file: options.file,
|
|
68
96
|
language,
|
|
97
|
+
languageId,
|
|
69
98
|
});
|
|
70
99
|
return { entries: result.entries, diagnostics: [] };
|
|
71
100
|
}
|
|
72
|
-
const fm = (0, frontmatter_js_1.extractFrontMatter)(
|
|
73
|
-
const body = fm.hadFrontMatter ? fm.markdown :
|
|
101
|
+
const fm = (0, frontmatter_js_1.extractFrontMatter)(normalised, { file: options.file });
|
|
102
|
+
const body = fm.hadFrontMatter ? fm.markdown : normalised;
|
|
74
103
|
const isReferencesDoc = isReferencesDocument(options.file);
|
|
75
104
|
const { entries, diagnostics: parseDiagnostics } = (0, markdown_js_1.parseMarkdown)(body, {
|
|
76
105
|
file: options.file,
|
|
@@ -5,14 +5,23 @@
|
|
|
5
5
|
* comments in Rust, Kotlin, C, C++, and Java source files. Delegates parsed
|
|
6
6
|
* content to the markdown parser for entry extraction.
|
|
7
7
|
*/
|
|
8
|
-
import
|
|
8
|
+
import type { Node as SyntaxNode } from "web-tree-sitter";
|
|
9
|
+
import { type Language } from "web-tree-sitter";
|
|
9
10
|
import type { Entry } from "../model/mod.js";
|
|
11
|
+
import type { SupportedLanguage } from "./language_spec.js";
|
|
10
12
|
/** Options for {@linkcode parseSource}. */
|
|
11
13
|
export interface ParseSourceOptions {
|
|
12
14
|
/** File path used in source locations. */
|
|
13
15
|
readonly file?: string;
|
|
14
16
|
/** Pre-loaded tree-sitter language grammar. */
|
|
15
|
-
readonly language:
|
|
17
|
+
readonly language: Language;
|
|
18
|
+
/**
|
|
19
|
+
* Language id for the active grammar — used by the walker to look up
|
|
20
|
+
* the doc-comment dispatch row in `LANGUAGE_SPECS`. The caller maps
|
|
21
|
+
* file extension → languageId via `languageIdForExtension` before
|
|
22
|
+
* calling `parseSource`.
|
|
23
|
+
*/
|
|
24
|
+
readonly languageId: SupportedLanguage;
|
|
16
25
|
}
|
|
17
26
|
/** Result of parsing a source file. */
|
|
18
27
|
export interface ParseSourceResult {
|
|
@@ -30,4 +39,46 @@ export interface ParseSourceResult {
|
|
|
30
39
|
* @param options - Parse options (language grammar, file path)
|
|
31
40
|
*/
|
|
32
41
|
export declare function parseSource(content: string, options: ParseSourceOptions): ParseSourceResult;
|
|
42
|
+
/** Result of stripping a prefix from one source line. */
|
|
43
|
+
interface PrefixStripResult {
|
|
44
|
+
readonly text: string;
|
|
45
|
+
/** Number of source characters stripped to produce `text`. */
|
|
46
|
+
readonly prefixWidth: number;
|
|
47
|
+
/** Which rule the line-comment strip helper matched: "outer-doc-comment"
|
|
48
|
+
* for `///`, "inner-doc-comment" for `//!`. */
|
|
49
|
+
readonly rule: "outer-doc-comment" | "inner-doc-comment";
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Strip the `///` or `//!` prefix from a line comment node.
|
|
53
|
+
* Uses the `doc_comment` child if available, otherwise strips manually.
|
|
54
|
+
*/
|
|
55
|
+
export declare function stripLineCommentPrefix(node: SyntaxNode): PrefixStripResult;
|
|
56
|
+
/** Result of stripping a block comment. */
|
|
57
|
+
interface BlockStripResult {
|
|
58
|
+
readonly lines: string[];
|
|
59
|
+
/** One value per element of `lines` — chars stripped per emitted line. */
|
|
60
|
+
readonly prefixWidths: number[];
|
|
61
|
+
/**
|
|
62
|
+
* True when the block's opener line (`/**`) had no content after the
|
|
63
|
+
* marker and was therefore not emitted into `lines`. Used by the walker
|
|
64
|
+
* to advance `startLine` by 1.
|
|
65
|
+
*/
|
|
66
|
+
readonly openerSkipped: boolean;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Strip block-comment delimiters and leading ` * ` prefixes.
|
|
70
|
+
* Returns cleaned lines, per-line prefix widths, and a flag indicating
|
|
71
|
+
* whether the opener was skipped (bare `/**\n`).
|
|
72
|
+
*/
|
|
73
|
+
export declare function stripBlockCommentPrefix(text: string): BlockStripResult;
|
|
74
|
+
/**
|
|
75
|
+
* Wrap cleaned doc comment lines as a Markdown list item so the
|
|
76
|
+
* existing `parseMarkdown()` can extract entries.
|
|
77
|
+
*
|
|
78
|
+
* Doc comments use `[DISPLAY_ID] Title` without the `- ` bullet.
|
|
79
|
+
* This wraps to `- [DISPLAY_ID] Title\n\n body...` which parseMarkdown
|
|
80
|
+
* recognizes as an entry block.
|
|
81
|
+
*/
|
|
82
|
+
export declare function wrapAsListItem(lines: string[]): string;
|
|
83
|
+
export {};
|
|
33
84
|
//# sourceMappingURL=source.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../../src/parser/source.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../../src/parser/source.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,KAAK,QAAQ,EAAU,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAAE,KAAK,EAAiB,MAAM,iBAAiB,CAAC;AAG5D,OAAO,KAAK,EAEV,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAG5B,2CAA2C;AAC3C,MAAM,WAAW,kBAAkB;IACjC,0CAA0C;IAC1C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,+CAA+C;IAC/C,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B;;;;;OAKG;IACH,QAAQ,CAAC,UAAU,EAAE,iBAAiB,CAAC;CACxC;AAED,uCAAuC;AACvC,MAAM,WAAW,iBAAiB;IAChC,2CAA2C;IAC3C,QAAQ,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;CAC3B;AAsBD;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,kBAAkB,GAC1B,iBAAiB,CAgDnB;AAyHD,yDAAyD;AACzD,UAAU,iBAAiB;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,8DAA8D;IAC9D,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B;mDAC+C;IAC/C,QAAQ,CAAC,IAAI,EAAE,mBAAmB,GAAG,mBAAmB,CAAC;CAC1D;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,UAAU,GAAG,iBAAiB,CAmC1E;AAED,2CAA2C;AAC3C,UAAU,gBAAgB;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC;IACzB,0EAA0E;IAC1E,QAAQ,CAAC,YAAY,EAAE,MAAM,EAAE,CAAC;IAChC;;;;OAIG;IACH,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;CACjC;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,CAsDtE;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAKtD"}
|