Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.

Commit fdcd271

Browse files
authored
Merge pull request #673 from graceful-potato/iss560
fix: yard syntax
2 parents 70de88e + a4f654f commit fdcd271

File tree

2 files changed

+527
-70
lines changed

2 files changed

+527
-70
lines changed

packages/vscode-ruby/syntaxes/ruby.cson.json

Lines changed: 106 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -2745,16 +2745,15 @@
27452745
]
27462746
},
27472747
"yard": {
2748-
"name": "comment.line.yard.ruby",
27492748
"patterns": [
27502749
{
27512750
"include": "#yard_comment"
27522751
},
27532752
{
2754-
"include": "#yard_name_types"
2753+
"include": "#yard_param_types"
27552754
},
27562755
{
2757-
"include": "#yard_param_types"
2756+
"include": "#yard_option"
27582757
},
27592758
{
27602759
"include": "#yard_tag"
@@ -2764,30 +2763,97 @@
27642763
},
27652764
{
27662765
"include": "#yard_directive"
2766+
},
2767+
{
2768+
"include": "#yard_see"
2769+
},
2770+
{
2771+
"include": "#yard_macro_attribute"
2772+
}
2773+
]
2774+
},
2775+
"yard_see": {
2776+
"comment": "separate rule for @see because name could contain url",
2777+
"begin": "^(\\s*)(#)(\\s*)(@)(see)(?=\\s)(\\s+(.+?))?(?=\\s|$)",
2778+
"beginCaptures": {
2779+
"2": {
2780+
"name": "punctuation.definition.comment.ruby"
2781+
},
2782+
"4": {
2783+
"name": "comment.line.keyword.punctuation.yard.ruby"
2784+
},
2785+
"5": {
2786+
"name": "comment.line.keyword.yard.ruby"
2787+
},
2788+
"7": {
2789+
"name": "comment.line.parameter.yard.ruby"
2790+
}
2791+
},
2792+
"end": "^(?!\\s*#\\3\\s{2,}|\\s*#\\s*$)",
2793+
"contentName": "comment.line.string.yard.ruby",
2794+
"name": "comment.line.number-sign.ruby",
2795+
"patterns": [
2796+
{
2797+
"include": "#yard"
2798+
},
2799+
{
2800+
"include": "#yard_continuation"
2801+
}
2802+
]
2803+
},
2804+
"yard_macro_attribute": {
2805+
"comment": "separate rule for attribute and macro tags because name goes after []",
2806+
"begin": "^(\\s*)(#)(\\s*)(@!)(attribute|macro)(\\s+((\\[).+(])))?(?=\\s)(\\s+([a-z_]\\w*:?))?",
2807+
"beginCaptures": {
2808+
"2": {
2809+
"name": "punctuation.definition.comment.ruby"
2810+
},
2811+
"4": {
2812+
"name": "comment.line.keyword.punctuation.yard.ruby"
2813+
},
2814+
"5": {
2815+
"name": "comment.line.keyword.yard.ruby"
2816+
},
2817+
"7": {
2818+
"name": "comment.line.type.yard.ruby"
2819+
},
2820+
"8": {
2821+
"name": "comment.line.punctuation.yard.ruby"
2822+
},
2823+
"9": {
2824+
"name": "comment.line.punctuation.yard.ruby"
2825+
},
2826+
"11": {
2827+
"name": "comment.line.parameter.yard.ruby"
2828+
}
2829+
},
2830+
"end": "^(?!\\s*#\\3\\s{2,}|\\s*#\\s*$)",
2831+
"contentName": "comment.line.string.yard.ruby",
2832+
"name": "comment.line.number-sign.ruby",
2833+
"patterns": [
2834+
{
2835+
"include": "#yard"
2836+
},
2837+
{
2838+
"include": "#yard_continuation"
27672839
}
27682840
]
27692841
},
27702842
"yard_comment": {
27712843
"comment": "For YARD tags that follow the tag-comment pattern",
27722844
"begin": "^(\\s*)(#)(\\s*)(@)(abstract|api|author|deprecated|example|macro|note|overload|since|todo|version)(?=\\s|$)",
27732845
"beginCaptures": {
2774-
"1": {
2775-
"name": "comment.line.yard.ruby"
2776-
},
27772846
"2": {
27782847
"name": "punctuation.definition.comment.ruby"
27792848
},
2780-
"3": {
2781-
"name": "comment.line.yard.ruby"
2782-
},
27832849
"4": {
27842850
"name": "comment.line.keyword.punctuation.yard.ruby"
27852851
},
27862852
"5": {
27872853
"name": "comment.line.keyword.yard.ruby"
27882854
}
27892855
},
2790-
"end": "^(?!\\s*#\\3\\s{2,})",
2856+
"end": "^(?!\\s*#\\3\\s{2,}|\\s*#\\s*$)",
27912857
"contentName": "comment.line.string.yard.ruby",
27922858
"name": "comment.line.number-sign.ruby",
27932859
"patterns": [
@@ -2799,45 +2865,45 @@
27992865
}
28002866
]
28012867
},
2802-
"yard_name_types": {
2803-
"comment": "For YARD tags that follow the tag-name-types-comment pattern",
2804-
"begin": "^(\\s*)(#)(\\s*)(@)(attr|attr_reader|attr_writer|see|yieldparam)(?=\\s)(\\s+([a-z_][a-zA-Z_]*))?(\\s+((\\[).+(])))?",
2868+
"yard_param_types": {
2869+
"comment": "For YARD tags that follow the tag-name-types-description or tag-types-name-description pattern",
2870+
"begin": "^(\\s*)(#)(\\s*)(@)(attr|attr_reader|attr_writer|yieldparam|param)(?=\\s)(?>\\s+(?>([a-z_]\\w*:?)|((\\[).+(]))))?(?>\\s+(?>((\\[).+(]))|([a-z_]\\w*:?)))?",
28052871
"beginCaptures": {
2806-
"1": {
2807-
"name": "comment.line.yard.ruby"
2808-
},
28092872
"2": {
28102873
"name": "punctuation.definition.comment.ruby"
28112874
},
2812-
"3": {
2813-
"name": "comment.line.yard.ruby"
2814-
},
28152875
"4": {
28162876
"name": "comment.line.keyword.punctuation.yard.ruby"
28172877
},
28182878
"5": {
28192879
"name": "comment.line.keyword.yard.ruby"
28202880
},
28212881
"6": {
2822-
"name": "comment.line.yard.ruby"
2882+
"name": "comment.line.parameter.yard.ruby"
28232883
},
28242884
"7": {
2825-
"name": "comment.line.parameter.yard.ruby"
2885+
"name": "comment.line.type.yard.ruby"
28262886
},
28272887
"8": {
2828-
"name": "comment.line.yard.ruby"
2888+
"name": "comment.line.punctuation.yard.ruby"
28292889
},
28302890
"9": {
2831-
"name": "comment.line.type.yard.ruby"
2891+
"name": "comment.line.punctuation.yard.ruby"
28322892
},
28332893
"10": {
2834-
"name": "comment.line.punctuation.yard.ruby"
2894+
"name": "comment.line.type.yard.ruby"
28352895
},
28362896
"11": {
28372897
"name": "comment.line.punctuation.yard.ruby"
2898+
},
2899+
"12": {
2900+
"name": "comment.line.punctuation.yard.ruby"
2901+
},
2902+
"13": {
2903+
"name": "comment.line.parameter.yard.ruby"
28382904
}
28392905
},
2840-
"end": "^(?!\\s*#\\3\\s{2,})",
2906+
"end": "^(?!\\s*#\\3\\s{2,}|\\s*#\\s*$)",
28412907
"contentName": "comment.line.string.yard.ruby",
28422908
"name": "comment.line.number-sign.ruby",
28432909
"patterns": [
@@ -2849,54 +2915,48 @@
28492915
}
28502916
]
28512917
},
2852-
"yard_param_types": {
2853-
"comment": "For YARD tags that follow the tag-param-types-comment pattern",
2854-
"begin": "^(\\s*)(#)(\\s*)(@)(option|param)(?=\\s)(\\s+([a-z_][a-zA-Z_]*:?))?(\\s+((\\[).+(])))?(\\s+(:[a-z_][a-zA-Z_]*))?",
2918+
"yard_option": {
2919+
"comment": "For YARD option tag that follow the tag-name-types-key-(value)-description pattern",
2920+
"begin": "^(\\s*)(#)(\\s*)(@)(option)(?=\\s)(?>\\s+([a-z_]\\w*:?))?(?>\\s+((\\[).+(])))?(?>\\s+((\\S*)))?(?>\\s+((\\().+(\\))))?",
28552921
"beginCaptures": {
2856-
"1": {
2857-
"name": "comment.line.yard.ruby"
2858-
},
28592922
"2": {
28602923
"name": "punctuation.definition.comment.ruby"
28612924
},
2862-
"3": {
2863-
"name": "comment.line.yard.ruby"
2864-
},
28652925
"4": {
28662926
"name": "comment.line.keyword.punctuation.yard.ruby"
28672927
},
28682928
"5": {
28692929
"name": "comment.line.keyword.yard.ruby"
28702930
},
28712931
"6": {
2872-
"name": "comment.line.yard.ruby"
2932+
"name": "comment.line.parameter.yard.ruby"
28732933
},
28742934
"7": {
2875-
"name": "comment.line.parameter.yard.ruby"
2935+
"name": "comment.line.type.yard.ruby"
28762936
},
28772937
"8": {
2878-
"name": "comment.line.yard.ruby"
2938+
"name": "comment.line.punctuation.yard.ruby"
28792939
},
28802940
"9": {
2881-
"name": "comment.line.type.yard.ruby"
2941+
"name": "comment.line.punctuation.yard.ruby"
28822942
},
28832943
"10": {
2884-
"name": "comment.line.punctuation.yard.ruby"
2944+
"name": "comment.line.keyword.yard.ruby"
28852945
},
28862946
"11": {
2887-
"name": "comment.line.punctuation.yard.ruby"
2947+
"name": "comment.line.hashkey.yard.ruby"
28882948
},
28892949
"12": {
2890-
"name": "comment.line.punctuation.yard.ruby"
2950+
"name": "comment.line.defaultvalue.yard.ruby"
28912951
},
28922952
"13": {
2893-
"name": "comment.line.keyword.yard.ruby"
2953+
"name": "comment.line.punctuation.yard.ruby"
28942954
},
28952955
"14": {
28962956
"name": "comment.line.punctuation.yard.ruby"
28972957
}
28982958
},
2899-
"end": "^(?!\\s*#\\3\\s{2,})",
2959+
"end": "^(?!\\s*#\\3\\s{2,}|\\s*#\\s*$)",
29002960
"contentName": "comment.line.string.yard.ruby",
29012961
"name": "comment.line.number-sign.ruby",
29022962
"patterns": [
@@ -2912,15 +2972,9 @@
29122972
"comment": "For YARD tags that are just the tag",
29132973
"match": "^(\\s*)(#)(\\s*)(@)(private)$",
29142974
"captures": {
2915-
"1": {
2916-
"name": "comment.line.yard.ruby"
2917-
},
29182975
"2": {
29192976
"name": "punctuation.definition.comment.ruby"
29202977
},
2921-
"3": {
2922-
"name": "comment.line.yard.ruby"
2923-
},
29242978
"4": {
29252979
"name": "comment.line.keyword.punctuation.yard.ruby"
29262980
},
@@ -2934,24 +2988,15 @@
29342988
"comment": "For YARD tags that follow the tag-types-comment pattern",
29352989
"begin": "^(\\s*)(#)(\\s*)(@)(raise|return|yield(?:return)?)(?=\\s)(\\s+((\\[).+(])))?",
29362990
"beginCaptures": {
2937-
"1": {
2938-
"name": "comment.line.yard.ruby"
2939-
},
29402991
"2": {
29412992
"name": "punctuation.definition.comment.ruby"
29422993
},
2943-
"3": {
2944-
"name": "comment.line.yard.ruby"
2945-
},
29462994
"4": {
29472995
"name": "comment.line.keyword.punctuation.yard.ruby"
29482996
},
29492997
"5": {
29502998
"name": "comment.line.keyword.yard.ruby"
29512999
},
2952-
"6": {
2953-
"name": "comment.line.yard.ruby"
2954-
},
29553000
"7": {
29563001
"name": "comment.line.type.yard.ruby"
29573002
},
@@ -2962,7 +3007,7 @@
29623007
"name": "comment.line.punctuation.yard.ruby"
29633008
}
29643009
},
2965-
"end": "^(?!\\s*#\\3\\s{2,})",
3010+
"end": "^(?!\\s*#\\3\\s{2,}|\\s*#\\s*$)",
29663011
"contentName": "comment.line.string.yard.ruby",
29673012
"name": "comment.line.number-sign.ruby",
29683013
"patterns": [
@@ -2976,26 +3021,17 @@
29763021
},
29773022
"yard_directive": {
29783023
"comment": "For YARD directives",
2979-
"begin": "^(\\s*)(#)(\\s*)(@!)(attribute|endgroup|group|macro|method|parse|scope|visibility)(\\s+((\\[).+(])))?(?=\\s)",
3024+
"begin": "^(\\s*)(#)(\\s*)(@!)(endgroup|group|method|parse|scope|visibility)(\\s+((\\[).+(])))?(?=\\s)",
29803025
"beginCaptures": {
2981-
"1": {
2982-
"name": "comment.line.yard.ruby"
2983-
},
29843026
"2": {
29853027
"name": "punctuation.definition.comment.ruby"
29863028
},
2987-
"3": {
2988-
"name": "comment.line.yard.ruby"
2989-
},
29903029
"4": {
29913030
"name": "comment.line.keyword.punctuation.yard.ruby"
29923031
},
29933032
"5": {
29943033
"name": "comment.line.keyword.yard.ruby"
29953034
},
2996-
"6": {
2997-
"name": "comment.line.yard.ruby"
2998-
},
29993035
"7": {
30003036
"name": "comment.line.type.yard.ruby"
30013037
},
@@ -3006,7 +3042,7 @@
30063042
"name": "comment.line.punctuation.yard.ruby"
30073043
}
30083044
},
3009-
"end": "^(?!\\s*#\\3\\s{2,})",
3045+
"end": "^(?!\\s*#\\3\\s{2,}|\\s*#\\s*$)",
30103046
"contentName": "comment.line.string.yard.ruby",
30113047
"name": "comment.line.number-sign.ruby",
30123048
"patterns": [

0 commit comments

Comments
 (0)