From 04247540bbdcec389aa8c5123303e16ef07d2356 Mon Sep 17 00:00:00 2001 From: Maryna Balioura Date: Thu, 12 Jun 2025 23:21:02 +0200 Subject: [PATCH 1/7] syntaxes: adds support for `PREFIX`; makes `REQ_PREFIX` deprecated. --- syntaxes/sdoc.tmLanguage.json | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/syntaxes/sdoc.tmLanguage.json b/syntaxes/sdoc.tmLanguage.json index ec30755..7773797 100644 --- a/syntaxes/sdoc.tmLanguage.json +++ b/syntaxes/sdoc.tmLanguage.json @@ -54,6 +54,9 @@ { "include": "#field_req_prefix" }, + { + "include": "#field_prefix" + }, { "include": "#document_root" }, @@ -233,7 +236,7 @@ "document_field_name_pattern": { "patterns": [{ "name": "invalid.sdoc", - "match": "^\\b(MID|UID|TITLE|VERSION|DATE|CLASSIFICATION|REQ_PREFIX|ROOT|OPTIONS|METADATA)\\b:" + "match": "^\\b(MID|UID|TITLE|VERSION|DATE|CLASSIFICATION|PREFIX|REQ_PREFIX|ROOT|OPTIONS|METADATA)\\b:" }] }, "document_from_file": { @@ -447,6 +450,9 @@ { "include": "#field_req_prefix" }, + { + "include": "#field_prefix" + }, { "include": "#section_field_names_without_values" } @@ -461,7 +467,7 @@ "patterns": [ { "comment": "reserved section fields", - "match": "^(MID|UID|LEVEL|TITLE|REQ_PREFIX):\\s", + "match": "^(MID|UID|LEVEL|TITLE|PREFIX|REQ_PREFIX):\\s", "name": "keyword.control.sdoc" } ] @@ -585,11 +591,24 @@ ] }, "field_req_prefix": { - "comment": "for document and section", + "comment": "Deprecated (legacy support): replaced by PREFIX in [DOCUMENT] and [SECTION].", "patterns": [ { "name": "keyword.control.sdoc", "match": "^\\b(REQ_PREFIX)\\b:\\s(\\S+)$", + "captures": { + "1": { "name": "invalid.deprecated.sdoc" }, + "2": { "name": "string.sdoc" } + } + } + ] + }, + "field_prefix": { + "comment": "Defines prefix for UID generation in [DOCUMENT] and [SECTION] blocks.", + "patterns": [ + { + "name": "keyword.control.sdoc", + "match": "^\\b(PREFIX)\\b:\\s(\\S+)$", "captures": { "1": { "name": "keyword.control.sdoc" }, "2": { "name": "string.sdoc" } From 071ccd67b266e3c86f29ab49a0097afd354781b1 Mon Sep 17 00:00:00 2001 From: Maryna Balioura Date: Thu, 12 Jun 2025 23:36:32 +0200 Subject: [PATCH 2/7] syntaxes: adds support for `VIEW_STYLE`; makes `REQUIREMENT_STYLE` deprecated. --- syntaxes/sdoc.tmLanguage.json | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/syntaxes/sdoc.tmLanguage.json b/syntaxes/sdoc.tmLanguage.json index 7773797..ea0678d 100644 --- a/syntaxes/sdoc.tmLanguage.json +++ b/syntaxes/sdoc.tmLanguage.json @@ -109,7 +109,10 @@ "include": "#document_options_auto_levels" }, { - "include": "#document_options_node_style" + "include": "#document_options_requirement_style_deprecated" + }, + { + "include": "#document_options_view_style" }, { "include": "#document_options_node_in_toc" @@ -142,10 +145,22 @@ } }] }, - "document_options_node_style": { + "document_options_requirement_style_deprecated": { + "comment": "Deprecated field: use VIEW_STYLE instead.", "patterns": [{ "name": "", "match": "(^\\s\\sREQUIREMENT_STYLE:)\\s\\b(Inline|Simple|Table|Zebra|Narrative)\\b$", + "captures": { + "1": { "name": "invalid.deprecated.sdoc" }, + "2": { "name": "constant.numeric.sdoc" } + } + }] + }, + "document_options_view_style": { + "comment": "Defines node view style", + "patterns": [{ + "name": "", + "match": "(^\\s\\sVIEW_STYLE:)\\s\\b(Inline|Simple|Table|Zebra|Narrative)\\b$", "captures": { "1": { "name": "keyword.control.sdoc" }, "2": { "name": "constant.numeric.sdoc" } From e9b01c4b7e3ddbd8865eda55f85a15a233372cb6 Mon Sep 17 00:00:00 2001 From: Maryna Balioura Date: Thu, 12 Jun 2025 23:44:49 +0200 Subject: [PATCH 3/7] syntaxes: adds support for `NODE_IN_TOC`; makes `REQUIREMENT_IN_TOC` deprecated. --- syntaxes/sdoc.tmLanguage.json | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/syntaxes/sdoc.tmLanguage.json b/syntaxes/sdoc.tmLanguage.json index ea0678d..144a1ec 100644 --- a/syntaxes/sdoc.tmLanguage.json +++ b/syntaxes/sdoc.tmLanguage.json @@ -114,6 +114,9 @@ { "include": "#document_options_view_style" }, + { + "include": "#document_options_requirement_in_toc_deprecated" + }, { "include": "#document_options_node_in_toc" } @@ -168,9 +171,10 @@ }] }, "document_options_node_in_toc": { + "comment": "Defines whether node appears in TOC.", "patterns": [{ "name": "", - "begin": "(^\\s\\sREQUIREMENT_IN_TOC:)", + "begin": "(^\\s\\sNODE_IN_TOC:)", "end": "$", "beginCaptures": { "0": { "name": "keyword.control.sdoc" } @@ -182,6 +186,22 @@ ] }] }, + "document_options_requirement_in_toc_deprecated": { + "comment": "Deprecated field: use NODE_IN_TOC instead.", + "patterns": [{ + "name": "", + "begin": "(^\\s\\sREQUIREMENT_IN_TOC:)", + "end": "$", + "beginCaptures": { + "0": { "name": "invalid.deprecated.sdoc" } + }, + "patterns": [ + { + "include": "#choice_boolean" + } + ] + }] + }, "document_options_auto_levels": { "patterns": [{ "name": "", From d5cf65fbee0d8f7daee04523ca868e6e3d57e5bc Mon Sep 17 00:00:00 2001 From: Maryna Balioura Date: Fri, 13 Jun 2025 00:47:56 +0200 Subject: [PATCH 4/7] syntaxes: updates UID match pattern to match symbols like (), /, :, and space --- syntaxes/sdoc.tmLanguage.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntaxes/sdoc.tmLanguage.json b/syntaxes/sdoc.tmLanguage.json index 144a1ec..1e81b72 100644 --- a/syntaxes/sdoc.tmLanguage.json +++ b/syntaxes/sdoc.tmLanguage.json @@ -591,7 +591,7 @@ "patterns": [ { "name": "keyword.control.sdoc", - "match": "(^UID:)\\s\\b(\\S+)\\b$", + "match": "(^UID:)\\s([\\w]+[\\w()\\-\\/\\.: ]*)$", "captures": { "1": { "name": "keyword.control.sdoc" }, "2": { "name": "string.unquoted.sdoc" } From 4541e6712573fc0ad9065066552617e797c2fef5 Mon Sep 17 00:00:00 2001 From: Maryna Balioura Date: Fri, 13 Jun 2025 02:36:10 +0200 Subject: [PATCH 5/7] syntaxes: prevent partial 'METADATA' from ending OPTIONS block --- syntaxes/sdoc.tmLanguage.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntaxes/sdoc.tmLanguage.json b/syntaxes/sdoc.tmLanguage.json index 1e81b72..2fbd978 100644 --- a/syntaxes/sdoc.tmLanguage.json +++ b/syntaxes/sdoc.tmLanguage.json @@ -94,7 +94,7 @@ "patterns": [{ "begin": "^OPTIONS:$", "name": "", - "end": "^(?=METADATA:|$)", + "end": "^(?=METADATA:$|$)", "beginCaptures": { "0": { "name": "keyword.control.sdoc" } }, From 0841e0c04676e8c3e42a8e8d64e398f7b5408180 Mon Sep 17 00:00:00 2001 From: Maryna Balioura Date: Fri, 13 Jun 2025 20:37:32 +0200 Subject: [PATCH 6/7] syntaxes: remove deprecated FREETEXT --- syntaxes/sdoc.tmLanguage.json | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/syntaxes/sdoc.tmLanguage.json b/syntaxes/sdoc.tmLanguage.json index 2fbd978..166bcfe 100644 --- a/syntaxes/sdoc.tmLanguage.json +++ b/syntaxes/sdoc.tmLanguage.json @@ -19,9 +19,6 @@ { "include": "#node" }, - { - "include": "#freetext" - }, { "include": "#document_from_file" }, @@ -507,25 +504,9 @@ } ] }, - "freetext": { - "begin": "^\\[FREETEXT\\]$", - "end": "^\\[\\/FREETEXT\\]$", - "contentName": "source.rst", - "patterns": [ - { - "comment": "FIXME: See 'The problem of leaking incorrect RST markup'.", - "include": "source.rst" - } - ], - "captures": { - "0": { - "name": "keyword.sdoc" - } - } - }, "node": { - "comment": "REQUIREMENT/COMPOSITE_REQUIREMENT or similar elements: use the tag pattern and exclude reserved tags", - "begin": "^\\[(?!DOCUMENT|GRAMMAR|SECTION|FREETEXT|DOCUMENT_FROM_FILE)([A-Z0-9_]+)\\]$", + "comment": "Node and Composite Node: use the tag pattern and exclude reserved tags", + "begin": "^\\[(?!DOCUMENT|GRAMMAR|SECTION|DOCUMENT_FROM_FILE)([A-Z0-9_]+)\\]$", "end": "^$", "captures": { "0": { From 2bb34bf2e6420d61cf00498a2fcf591a37d1e060 Mon Sep 17 00:00:00 2001 From: Maryna Balioura Date: Fri, 13 Jun 2025 22:50:32 +0200 Subject: [PATCH 7/7] syntaxes: add support for composite nodes with double brackets; make reserved SECTION deprecated; fix TAG regex --- syntaxes/sdoc.tmLanguage.json | 81 +++++++++++++++++++++++++++++------ 1 file changed, 68 insertions(+), 13 deletions(-) diff --git a/syntaxes/sdoc.tmLanguage.json b/syntaxes/sdoc.tmLanguage.json index 166bcfe..473c84e 100644 --- a/syntaxes/sdoc.tmLanguage.json +++ b/syntaxes/sdoc.tmLanguage.json @@ -19,6 +19,12 @@ { "include": "#node" }, + { + "include": "#forbidden_composite_tags" + }, + { + "include": "#composite_node" + }, { "include": "#document_from_file" }, @@ -215,7 +221,7 @@ }] }, "document_metadata": { - "patterns": [ + "patterns": [ { "match": "^METADATA:\\s*$", "name": "keyword.control.sdoc" @@ -331,7 +337,7 @@ "grammar_element": { "patterns": [ { - "begin": "^(-\\sTAG:)\\s\\b([A-Z0-9_]+)\\b$", + "begin": "^(-\\sTAG:)\\s\\b([A-Z]+(_[A-Z]+)*)\\b$", "name": "", "end": "$", "beginCaptures": { @@ -464,6 +470,7 @@ }] }, "section": { + "comment": "SECTION tag is deprecated: planned for removal by the end of 2025", "begin": "^\\[SECTION\\]$", "end": "^$", "patterns": [ @@ -491,11 +498,12 @@ ], "captures": { "0": { - "name": "keyword.sdoc" + "name": "invalid.deprecated.sdoc" } } }, "section_field_names_without_values": { + "comment": "SECTION tag is deprecated: planned for removal by the end of 2025", "patterns": [ { "comment": "reserved section fields", @@ -505,14 +513,45 @@ ] }, "node": { - "comment": "Node and Composite Node: use the tag pattern and exclude reserved tags", - "begin": "^\\[(?!DOCUMENT|GRAMMAR|SECTION|DOCUMENT_FROM_FILE)([A-Z0-9_]+)\\]$", + "comment": "Node: use the tag pattern and exclude reserved tags; SECTION tag is deprecated", + "begin": "^\\[(?!DOCUMENT|GRAMMAR|DOCUMENT_FROM_FILE|SECTION)([A-Z]+(_[A-Z]+)*)\\]$", "end": "^$", - "captures": { - "0": { - "name": "keyword.sdoc" + "captures": { "0": { "name": "keyword.sdoc" } }, + "patterns": [ + { + "include": "#field_mid" + }, + { + "include": "#field_uid" + }, + { + "include": "#field_title" + }, + { + "include": "#field_level_with_skipping" + }, + { + "include": "#field_prefix" + }, + { + "include": "#node_relations" + }, + { + "include": "#node_field_refs_deprecated" + }, + { + "include": "#node_field_general_except_specific" + }, + { + "include": "#node_field_names_without_values" } - }, + ] + }, + "composite_node": { + "comment": "Composite Node: use the tag pattern and exclude reserved tags; SECTION tag is deprecated", + "begin": "^\\[\\[(?!(DOCUMENT|GRAMMAR|DOCUMENT_FROM_FILE|SECTION)\\]\\])([A-Z]+(?:_[A-Z]+)*)\\]\\]$", + "end": "^$", + "captures": { "0": { "name": "keyword.sdoc" } }, "patterns": [ { "include": "#field_mid" @@ -526,6 +565,9 @@ { "include": "#field_level_with_skipping" }, + { + "include": "#field_prefix" + }, { "include": "#node_relations" }, @@ -540,19 +582,32 @@ } ] }, + "forbidden_composite_tags": { + "comment": "Catch forbidden composite node tags and highlight them as invalid", + "match": "^\\[\\[(DOCUMENT|GRAMMAR|DOCUMENT_FROM_FILE)\\]\\]$", + "name": "invalid.illegal.sdoc" + }, "closing_tag": { "patterns": [ { + "comment": "SECTION tag is deprecated: planned for removal by the end of 2025", + "name": "invalid.deprecated.sdoc", + "match": "^\\[\\/?(SECTION)\\]$" + }, + { + "comment": "Invalid closing tags for forbidden blocks", "name": "invalid.illegal.sdoc", - "match": "\\[\\/(REQUIREMENT|GRAMMAR|DOCUMENT)\\]" + "match": "^\\[\\[\\/(DOCUMENT|GRAMMAR|DOCUMENT_FROM_FILE)\\]\\]$" }, { + "comment": "Only composite nodes with double brackets have a valid closing tag", "name": "keyword.sdoc", - "match": "^\\[\\/?SECTION\\]$" + "match": "^\\[\\[\\/(?!(DOCUMENT|GRAMMAR|DOCUMENT_FROM_FILE)\\]\\])([A-Z]+(_[A-Z]+)*)\\]\\]$" }, { - "name": "keyword.sdoc", - "match": "^\\[\\/?COMPOSITE_REQUIREMENT\\]$" + "comment": "Only composite nodes with double brackets have a valid closing tag", + "name": "invalid.illegal.sdoc", + "match": "^\\[\\/(.*)\\]$" } ] },