From abc71f61a740fcb60bed3a0ff889ae0149f3fd4c Mon Sep 17 00:00:00 2001 From: yuhei mukoyama Date: Sat, 21 Jul 2018 14:38:24 +0900 Subject: [PATCH 1/2] Support multiline YARD comments --- syntaxes/ruby.cson.json | 174 +++++++++++++++++++++++++++++----------- 1 file changed, 127 insertions(+), 47 deletions(-) diff --git a/syntaxes/ruby.cson.json b/syntaxes/ruby.cson.json index 1421de993..db47afeba 100644 --- a/syntaxes/ruby.cson.json +++ b/syntaxes/ruby.cson.json @@ -1499,6 +1499,9 @@ "end": "^=end", "name": "comment.block.documentation.ruby" }, + { + "include": "#yard" + }, { "begin": "(^[ \\t]+)?(?=#)", "beginCaptures": { @@ -1516,12 +1519,7 @@ } }, "end": "\\n", - "name": "comment.line.number-sign.ruby", - "patterns": [ - { - "include": "#yard" - } - ] + "name": "comment.line.number-sign.ruby" } ] }, @@ -2610,117 +2608,199 @@ }, "yard_comment": { "comment": "For YARD tags that follow the tag-comment pattern", - "match": "(@)(abstract|api|author|deprecated|example|note|overload|since|todo|version)(?=\\s)(.*)$", - "captures": { + "begin": "^(\\s*)(#)(\\s*)(@)(abstract|api|author|deprecated|example|macro|note|overload|since|todo|version)(?=\\s|$)", + "beginCaptures": { "1": { - "name": "comment.line.keyword.punctuation.yard.ruby" + "name": "comment.line.yard.ruby" }, "2": { - "name": "comment.line.keyword.yard.ruby" + "name": "punctuation.definition.comment.ruby" }, "3": { - "name": "comment.line.string.yard.ruby" + "name": "comment.line.yard.ruby" + }, + "4": { + "name": "comment.line.keyword.punctuation.yard.ruby" + }, + "5": { + "name": "comment.line.keyword.yard.ruby" } - } + }, + "end": "^(?!\\s*#\\3\\s{2,})", + "contentName": "comment.line.string.yard.ruby", + "name": "comment.line.number-sign.ruby", + "patterns": [ + { + "include": "#yard" + }, + { + "include": "#yard_continuation" + } + ] }, "yard_name_types": { "comment": "For YARD tags that follow the tag-name-types-comment pattern", - "match": "(@)(attr|attr_reader|attr_writer|option|param|see|yieldparam)(?=\\s)(\\s+([a-z_][a-zA-Z_]*))?(\\s+((\\[).+(])))?(.*)$", - "captures": { + "begin": "^(\\s*)(#)(\\s*)(@)(attr|attr_reader|option|param|attr_writer|see|yieldparam)(?=\\s)(\\s+([a-z_][a-zA-Z_]*))?(\\s+((\\[).+(])))?", + "beginCaptures":{ "1": { - "name": "comment.line.keyword.punctuation.yard.ruby" + "name": "comment.line.yard.ruby" }, "2": { - "name": "comment.line.keyword.yard.ruby" + "name": "punctuation.definition.comment.ruby" }, "3": { "name": "comment.line.yard.ruby" }, "4": { - "name": "comment.line.parameter.yard.ruby" + "name": "comment.line.keyword.punctuation.yard.ruby" }, "5": { - "name": "comment.line.yard.ruby" + "name": "comment.line.keyword.yard.ruby" }, "6": { - "name": "comment.line.type.yard.ruby" + "name": "comment.line.yard.ruby" }, "7": { - "name": "comment.line.punctuation.yard.ruby" + "name": "comment.line.parameter.yard.ruby" }, "8": { - "name": "comment.line.punctuation.yard.ruby" + "name": "comment.line.yard.ruby" }, "9": { - "name": "comment.line.string.yard.ruby" + "name": "comment.line.type.yard.ruby" + }, + "10": { + "name": "comment.line.punctuation.yard.ruby" + }, + "11": { + "name": "comment.line.punctuation.yard.ruby" } - } + }, + "end": "^(?!\\s*#\\3\\s{2,})", + "contentName": "comment.line.string.yard.ruby", + "name": "comment.line.number-sign.ruby", + "patterns": [ + { + "include": "#yard" + }, + { + "include": "#yard_continuation" + } + ] }, "yard_tag": { "comment": "For YARD tags that are just the tag", - "match": "(@)(private)$", - "captures": { + "match": "^(\\s*)(#)(\\s*)(@)(private)$", + "captures":{ "1": { - "name": "comment.line.keyword.punctuation.yard.ruby" + "name": "comment.line.yard.ruby" }, "2": { + "name": "punctuation.definition.comment.ruby" + }, + "3": { + "name": "comment.line.yard.ruby" + }, + "4": { + "name": "comment.line.keyword.punctuation.yard.ruby" + }, + "5": { "name": "comment.line.keyword.yard.ruby" } - } + }, + "name": "comment.line.number-sign.ruby" }, - "yard_types": { + "yard_types":{ "comment": "For YARD tags that follow the tag-types-comment pattern", - "match": "(@)(raise|return|yield(?:return)?)(?=\\s)(\\s+((\\[).+(])))?(.*)$", - "captures": { + "begin": "^(\\s*)(#)(\\s*)(@)(raise|return|yield(?:return)?)(?=\\s)(\\s+((\\[).+(])))?", + "beginCaptures": { "1": { - "name": "comment.line.keyword.punctuation.yard.ruby" + "name": "comment.line.yard.ruby" }, "2": { - "name": "comment.line.keyword.yard.ruby" + "name": "punctuation.definition.comment.ruby" }, "3": { "name": "comment.line.yard.ruby" }, "4": { - "name": "comment.line.type.yard.ruby" + "name": "comment.line.keyword.punctuation.yard.ruby" }, "5": { - "name": "comment.line.punctuation.yard.ruby" + "name": "comment.line.keyword.yard.ruby" }, "6": { - "name": "comment.line.punctuation.yard.ruby" + "name": "comment.line.yard.ruby" }, "7": { - "name": "comment.line.string.yard.ruby" + "name": "comment.line.type.yard.ruby" + }, + "8": { + "name": "comment.line.punctuation.yard.ruby" + }, + "9": { + "name": "comment.line.punctuation.yard.ruby" } - } + }, + "end": "^(?!\\s*#\\3\\s{2,})", + "contentName": "comment.line.string.yard.ruby", + "name": "comment.line.number-sign.ruby", + "patterns": [ + { + "include": "#yard" + }, + { + "include": "#yard_continuation" + } + ] }, "yard_directive": { "comment": "For YARD directives", - "match": "(@!)(attribute|endgroup|group|macro|method|parse|scope|visibility)(\\s+((\\[).+(])))?(?=\\s)(.*)$", - "captures": { + "begin": "^(\\s*)(#)(\\s*)(@!)(attribute|endgroup|group|macro|method|parse|scope|visibility)(\\s+((\\[).+(])))?(?=\\s)", + "beginCaptures":{ "1": { - "name": "comment.line.keyword.punctuation.yard.ruby" + "name": "comment.line.yard.ruby" }, "2": { - "name": "comment.line.keyword.yard.ruby" + "name": "punctuation.definition.comment.ruby" }, "3": { "name": "comment.line.yard.ruby" }, "4": { - "name": "comment.line.type.yard.ruby" + "name": "comment.line.keyword.punctuation.yard.ruby" }, "5": { - "name": "comment.line.punctuation.yard.ruby" + "name": "comment.line.keyword.yard.ruby" }, "6": { - "name": "comment.line.punctuation.yard.ruby" + "name": "comment.line.yard.ruby" }, "7": { - "name": "comment.line.string.yard.ruby" + "name": "comment.line.type.yard.ruby" + }, + "8": { + "name": "comment.line.punctuation.yard.ruby" + }, + "9": { + "name": "comment.line.punctuation.yard.ruby" } - } + }, + "end": "^(?!\\s*#\\3\\s{2,})", + "contentName": "comment.line.string.yard.ruby", + "name": "comment.line.number-sign.ruby", + "patterns": [ + { + "include": "#yard" + }, + { + "include": "#yard_continuation" + } + ] + }, + "yard_continuation": { + "match": "^\\s*#", + "name": "punctuation.definition.comment.ruby" } } -} \ No newline at end of file +} From 097191e1aee6b30ade350f90764e2bfbf030f8b6 Mon Sep 17 00:00:00 2001 From: yuhei mukoyama Date: Sat, 21 Jul 2018 14:42:49 +0900 Subject: [PATCH 2/2] Support keyword param and option_key YARD comments --- syntaxes/ruby.cson.json | 64 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/syntaxes/ruby.cson.json b/syntaxes/ruby.cson.json index db47afeba..07c86688b 100644 --- a/syntaxes/ruby.cson.json +++ b/syntaxes/ruby.cson.json @@ -2595,6 +2595,9 @@ { "include": "#yard_name_types" }, + { + "include": "#yard_param_types" + }, { "include": "#yard_tag" }, @@ -2640,7 +2643,7 @@ }, "yard_name_types": { "comment": "For YARD tags that follow the tag-name-types-comment pattern", - "begin": "^(\\s*)(#)(\\s*)(@)(attr|attr_reader|option|param|attr_writer|see|yieldparam)(?=\\s)(\\s+([a-z_][a-zA-Z_]*))?(\\s+((\\[).+(])))?", + "begin": "^(\\s*)(#)(\\s*)(@)(attr|attr_reader|attr_writer|see|yieldparam)(?=\\s)(\\s+([a-z_][a-zA-Z_]*))?(\\s+((\\[).+(])))?", "beginCaptures":{ "1": { "name": "comment.line.yard.ruby" @@ -2688,6 +2691,65 @@ } ] }, + "yard_param_types": { + "comment": "For YARD tags that follow the tag-param-types-comment pattern", + "begin": "^(\\s*)(#)(\\s*)(@)(option|param)(?=\\s)(\\s+([a-z_][a-zA-Z_]*:?))?(\\s+((\\[).+(])))?(\\s+(:[a-z_][a-zA-Z_]*))?", + "beginCaptures":{ + "1": { + "name": "comment.line.yard.ruby" + }, + "2": { + "name": "punctuation.definition.comment.ruby" + }, + "3": { + "name": "comment.line.yard.ruby" + }, + "4": { + "name": "comment.line.keyword.punctuation.yard.ruby" + }, + "5": { + "name": "comment.line.keyword.yard.ruby" + }, + "6": { + "name": "comment.line.yard.ruby" + }, + "7": { + "name": "comment.line.parameter.yard.ruby" + }, + "8": { + "name": "comment.line.yard.ruby" + }, + "9": { + "name": "comment.line.type.yard.ruby" + }, + "10": { + "name": "comment.line.punctuation.yard.ruby" + }, + "11": { + "name": "comment.line.punctuation.yard.ruby" + }, + "12": { + "name": "comment.line.punctuation.yard.ruby" + }, + "13": { + "name": "comment.line.keyword.yard.ruby" + }, + "14": { + "name": "comment.line.punctuation.yard.ruby" + } + }, + "end": "^(?!\\s*#\\3\\s{2,})", + "contentName": "comment.line.string.yard.ruby", + "name": "comment.line.number-sign.ruby", + "patterns": [ + { + "include": "#yard" + }, + { + "include": "#yard_continuation" + } + ] + }, "yard_tag": { "comment": "For YARD tags that are just the tag", "match": "^(\\s*)(#)(\\s*)(@)(private)$",