From 7f2adf0709d8a34006edca8d16fc87622cab3826 Mon Sep 17 00:00:00 2001 From: Weirong Xu Date: Fri, 6 Mar 2020 20:14:23 +0800 Subject: [PATCH 1/8] fix(ruby): Fix ruby without parentheses --- autoload/doge/pattern.vim | 19 +++++++-- autoload/doge/token.vim | 5 +-- ftplugin/ruby.vim | 14 +++++-- playground/test.rb | 24 ++++++++++- test/filetypes/ruby/functions.vader | 64 ++++++++++++++++++++++++++++- 5 files changed, 115 insertions(+), 11 deletions(-) diff --git a/autoload/doge/pattern.vim b/autoload/doge/pattern.vim index 21c4096e..d1ce48ab 100644 --- a/autoload/doge/pattern.vim +++ b/autoload/doge/pattern.vim @@ -26,8 +26,21 @@ function! doge#pattern#generate(pattern) abort endif else " Skip if the current line does not match the main pattern. - let l:curr_line_raw = escape(doge#helpers#trim(join(l:lines, ' ')), '\') - if l:curr_line_raw !~# a:pattern['match'] + let l:curr_line_raw = escape(doge#helpers#trim(join(l:lines, "\n")), '\') + let l:match = v:null + if type(a:pattern['match']) == type('') + if l:curr_line_raw =~# a:pattern['match'] + let l:match = a:pattern['match'] + endif + elseif type(a:pattern['match']) == type([]) + for l:m in a:pattern['match'] + if l:curr_line_raw =~# l:m + let l:match = l:m + break + endif + endfor + endif + if l:match is v:null return 0 endif @@ -43,7 +56,7 @@ function! doge#pattern#generate(pattern) abort " Extract the primary tokens. let l:tokens = get(doge#token#extract( \ l:curr_line, - \ a:pattern['match'], + \ l:match, \ a:pattern['tokens'] \ ), 0, {}) endif diff --git a/autoload/doge/token.vim b/autoload/doge/token.vim index fa421b64..1de7a654 100644 --- a/autoload/doge/token.vim +++ b/autoload/doge/token.vim @@ -125,10 +125,9 @@ endfunction " value of that group. The regex groups in the 'regex' parameter should be " symmetrical in length to the 'regex_group_names' parameter. function! doge#token#extract(text, regex, regex_group_names) abort - let l:submatches = [] - call substitute(a:text, a:regex, '\=add(l:submatches, submatch(0))', 'g') + let l:matches = [] + call substitute(a:text, a:regex, '\=add(l:matches, submatch(0))', 'g') - let l:matches = map(l:submatches, { k, v -> doge#helpers#trim(v) }) let l:tokens = [] " We can expect a list of matches like: diff --git a/ftplugin/ruby.vim b/ftplugin/ruby.vim index b33dc0cc..62f5a8d7 100644 --- a/ftplugin/ruby.vim +++ b/ftplugin/ruby.vim @@ -20,7 +20,7 @@ let b:doge_patterns = doge#buffer#get_patterns() " ============================================================================== let s:pattern_base = { \ 'parameters': { -\ 'match': '\m\([[:alnum:]_]\+\)\%(\s*=\s*[^,]\+\)\?', +\ 'match': '\m\([[:alnum:]_]\+\)\%(\s*[=:]\s*[^,]\+\)\?', \ 'tokens': ['name'], \ 'format': '@param {name} [!type] !description', \ }, @@ -37,12 +37,20 @@ let s:pattern_base = { " Matches regular function expressions and class methods. " ------------------------------------------------------------------------------ " def myFunc(p1, p_2 = some_default_value) -" def def parameters (p1,p2=4, p3*) +" def parameters (p1,p2=4, *p3) +" def parameters p1, p2 = 4, *p3 " def where(attribute, type = nil, **options) " def each(&block) +" def self.class_method(attribute) +" def self.class_parameters p1,p2=4, *p3 " ------------------------------------------------------------------------------ +let s:parameters_matches = [ +\ '(\(.\{-}\))', +\ '\s\+\([^\n]*\)', +\ '\n', +\ ] let s:function_and_class_method_pattern = doge#helpers#deepextend(s:pattern_base, { -\ 'match': '\m^def\s\+\%([^=(!]\+\)[=!]\?\s*(\(.\{-}\))', +\ 'match': map(s:parameters_matches, { i, m -> '\m^def\s\+\%([^=(!\n ]\+\)[=!]\?\s*' . m}), \ 'tokens': ['parameters'], \}) diff --git a/playground/test.rb b/playground/test.rb index ffc95bb7..bd1eeb7d 100644 --- a/playground/test.rb +++ b/playground/test.rb @@ -11,11 +11,32 @@ def myFunc(p1, p_2 = some_default_value) def myFunc (format = :html) end +# [TODO:description] +def myFunc +end + +# [TODO:description] +# @param format [[TODO:type]] [TODO:description] +def myFunc format = :html +end + +# [TODO:description] +# @param format [[TODO:type]] [TODO:description] +def myFunc(format: :html) +end + # [TODO:description] # @param p1 [[TODO:type]] [TODO:description] # @param p2 [[TODO:type]] [TODO:description] # @param p3 [[TODO:type]] [TODO:description] -def parameters (p1,p2=4, p3*) +def parameters (p1,p2=4, *p3) +end + +# [TODO:description] +# @param p1 [[TODO:type]] [TODO:description] +# @param p2 [[TODO:type]] [TODO:description] +# @param p3 [[TODO:type]] [TODO:description] +def parameters p1,p2=4, *p3 end # [TODO:description] @@ -55,3 +76,4 @@ def [](attribute) # @param block [[TODO:type]] [TODO:description] def each(&block) end +end diff --git a/test/filetypes/ruby/functions.vader b/test/filetypes/ruby/functions.vader index cf3b3127..a203e034 100644 --- a/test/filetypes/ruby/functions.vader +++ b/test/filetypes/ruby/functions.vader @@ -13,10 +13,24 @@ Expect ruby (generated comment with nothing but the text 'TODO'): def myFunc() # inline comment end +# ------------------------------------------------------------------------------ + +Given ruby (function without parameters and parentheses): + def myFunc # inline comment + end + +Do (trigger doge): + \ + +Expect ruby (generated comment with nothing but the text 'TODO'): + # [TODO:description] + def myFunc # inline comment + end + # ============================================================================== # Functions with parameters. -Given ruby (function with parameters): # ============================================================================== +Given ruby (function with parameters): def myFunc(p1, p_2 = some_default_value) end @@ -32,6 +46,54 @@ Expect ruby (generated comment with @param tags): # ------------------------------------------------------------------------------ +Given ruby (function with parameters but without parentheses): + def myFunc p1, p_2 = some_default_value + end + +Do (trigger doge): + \ + +Expect ruby (generated comment with @param tags): + # [TODO:description] + # @param p1 [[TODO:type]] [TODO:description] + # @param p_2 [[TODO:type]] [TODO:description] + def myFunc p1, p_2 = some_default_value + end + +# ------------------------------------------------------------------------------ + +Given ruby (function with keyword parameters): + def myFunc(p1, p_2: some_default_value) + end + +Do (trigger doge): + \ + +Expect ruby (generated comment with @param tags): + # [TODO:description] + # @param p1 [[TODO:type]] [TODO:description] + # @param p_2 [[TODO:type]] [TODO:description] + def myFunc(p1, p_2: some_default_value) + end + +# ------------------------------------------------------------------------------ + +Given ruby (function with keyword parameters but without parentheses): + def myFunc p1, p_2: some_default_value + end + +Do (trigger doge): + \ + +Expect ruby (generated comment with @param tags): + # [TODO:description] + # @param p1 [[TODO:type]] [TODO:description] + # @param p_2 [[TODO:type]] [TODO:description] + def myFunc p1, p_2: some_default_value + end + +# ------------------------------------------------------------------------------ + Given ruby (function with parameters with a '&' in its name): def each(&block) end From 1342873b7142831040b381ec7e9f5968400137da Mon Sep 17 00:00:00 2001 From: Weirong Xu Date: Sat, 7 Mar 2020 01:24:41 +0800 Subject: [PATCH 2/8] use correct ruby parameter syntax --- ftplugin/ruby.vim | 7 +------ test/filetypes/ruby/functions.vader | 23 +++++++++++++++++++++-- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/ftplugin/ruby.vim b/ftplugin/ruby.vim index 62f5a8d7..b40457dc 100644 --- a/ftplugin/ruby.vim +++ b/ftplugin/ruby.vim @@ -44,13 +44,8 @@ let s:pattern_base = { " def self.class_method(attribute) " def self.class_parameters p1,p2=4, *p3 " ------------------------------------------------------------------------------ -let s:parameters_matches = [ -\ '(\(.\{-}\))', -\ '\s\+\([^\n]*\)', -\ '\n', -\ ] let s:function_and_class_method_pattern = doge#helpers#deepextend(s:pattern_base, { -\ 'match': map(s:parameters_matches, { i, m -> '\m^def\s\+\%([^=(!\n ]\+\)[=!]\?\s*' . m}), +\ 'match': '\m^def\s\+\%([^=(! ]\+\)[=!]\?\s*(\?\s*\(\(\%(\*\{0,2}&\?[[:alnum:]_]\+\%(\s*=\s*[^, ]\+\)\?\)\%(\s*,\s*\)\?\)*\)\s*)\?.\{-}', \ 'tokens': ['parameters'], \}) diff --git a/test/filetypes/ruby/functions.vader b/test/filetypes/ruby/functions.vader index a203e034..93794516 100644 --- a/test/filetypes/ruby/functions.vader +++ b/test/filetypes/ruby/functions.vader @@ -110,7 +110,7 @@ Expect ruby (generated comment with @param tags): # ------------------------------------------------------------------------------ Given ruby (function with paramters containing '*' in its name): - def parameters (p1,p2=4, p3*) + def parameters (p1,p2=4, *p3, **p4) end Do (trigger doge): @@ -121,7 +121,26 @@ Expect ruby (generated comment with @param tags): # @param p1 [[TODO:type]] [TODO:description] # @param p2 [[TODO:type]] [TODO:description] # @param p3 [[TODO:type]] [TODO:description] - def parameters (p1,p2=4, p3*) + # @param p4 [[TODO:type]] [TODO:description] + def parameters (p1,p2=4, *p3, **p4) + end + +# ------------------------------------------------------------------------------ + +Given ruby (function with paramters containing '*' in its name and without parentheses): + def parameters p1,p2=4, *p3, **p4 + end + +Do (trigger doge): + \ + +Expect ruby (generated comment with @param tags): + # [TODO:description] + # @param p1 [[TODO:type]] [TODO:description] + # @param p2 [[TODO:type]] [TODO:description] + # @param p3 [[TODO:type]] [TODO:description] + # @param p4 [[TODO:type]] [TODO:description] + def parameters p1,p2=4, *p3, **p4 end # ------------------------------------------------------------------------------ From 1d23770e52ce5b173cf7b209bb9a7e1e1689bb65 Mon Sep 17 00:00:00 2001 From: Weirong Xu Date: Sat, 7 Mar 2020 01:30:12 +0800 Subject: [PATCH 3/8] revert --- autoload/doge/pattern.vim | 19 +++---------------- autoload/doge/token.vim | 6 ++++-- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/autoload/doge/pattern.vim b/autoload/doge/pattern.vim index d1ce48ab..21c4096e 100644 --- a/autoload/doge/pattern.vim +++ b/autoload/doge/pattern.vim @@ -26,21 +26,8 @@ function! doge#pattern#generate(pattern) abort endif else " Skip if the current line does not match the main pattern. - let l:curr_line_raw = escape(doge#helpers#trim(join(l:lines, "\n")), '\') - let l:match = v:null - if type(a:pattern['match']) == type('') - if l:curr_line_raw =~# a:pattern['match'] - let l:match = a:pattern['match'] - endif - elseif type(a:pattern['match']) == type([]) - for l:m in a:pattern['match'] - if l:curr_line_raw =~# l:m - let l:match = l:m - break - endif - endfor - endif - if l:match is v:null + let l:curr_line_raw = escape(doge#helpers#trim(join(l:lines, ' ')), '\') + if l:curr_line_raw !~# a:pattern['match'] return 0 endif @@ -56,7 +43,7 @@ function! doge#pattern#generate(pattern) abort " Extract the primary tokens. let l:tokens = get(doge#token#extract( \ l:curr_line, - \ l:match, + \ a:pattern['match'], \ a:pattern['tokens'] \ ), 0, {}) endif diff --git a/autoload/doge/token.vim b/autoload/doge/token.vim index 1de7a654..06a27623 100644 --- a/autoload/doge/token.vim +++ b/autoload/doge/token.vim @@ -125,8 +125,10 @@ endfunction " value of that group. The regex groups in the 'regex' parameter should be " symmetrical in length to the 'regex_group_names' parameter. function! doge#token#extract(text, regex, regex_group_names) abort - let l:matches = [] - call substitute(a:text, a:regex, '\=add(l:matches, submatch(0))', 'g') + let l:submatches = [] + call substitute(a:text, a:regex, '\=add(l:submatches, submatch(0))', 'g') + + let l:matches = map(l:submatches, { k, v -> doge#helpers#trim(v) }) let l:tokens = [] From c7e961520a4fcf1e69733d5d64a65a96152fef69 Mon Sep 17 00:00:00 2001 From: Weirong Xu Date: Sat, 7 Mar 2020 01:30:42 +0800 Subject: [PATCH 4/8] add keyword arguments to playground --- playground/test.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/playground/test.rb b/playground/test.rb index bd1eeb7d..4a70af3c 100644 --- a/playground/test.rb +++ b/playground/test.rb @@ -29,14 +29,15 @@ def myFunc(format: :html) # @param p1 [[TODO:type]] [TODO:description] # @param p2 [[TODO:type]] [TODO:description] # @param p3 [[TODO:type]] [TODO:description] -def parameters (p1,p2=4, *p3) +# @param p4 [[TODO:type]] [TODO:description] +def parameters (p1,p2=4, *p3,**p4) end # [TODO:description] # @param p1 [[TODO:type]] [TODO:description] # @param p2 [[TODO:type]] [TODO:description] # @param p3 [[TODO:type]] [TODO:description] -def parameters p1,p2=4, *p3 +def parameters p1,p2=4, *p3,**p4 end # [TODO:description] From ddb5d4b513ce92f5879721d9cef8531c0bbf6a01 Mon Sep 17 00:00:00 2001 From: Weirong Xu Date: Sat, 7 Mar 2020 01:31:54 +0800 Subject: [PATCH 5/8] revert --- autoload/doge/token.vim | 1 - 1 file changed, 1 deletion(-) diff --git a/autoload/doge/token.vim b/autoload/doge/token.vim index 06a27623..fa421b64 100644 --- a/autoload/doge/token.vim +++ b/autoload/doge/token.vim @@ -129,7 +129,6 @@ function! doge#token#extract(text, regex, regex_group_names) abort call substitute(a:text, a:regex, '\=add(l:submatches, submatch(0))', 'g') let l:matches = map(l:submatches, { k, v -> doge#helpers#trim(v) }) - let l:tokens = [] " We can expect a list of matches like: From 3ab15f4634c2b01a28c34e9d37b264a70addc8e1 Mon Sep 17 00:00:00 2001 From: Weirong Xu Date: Sat, 7 Mar 2020 01:48:03 +0800 Subject: [PATCH 6/8] add more tests --- test/filetypes/ruby/functions.vader | 70 ++++++++++++++++++++++++----- 1 file changed, 60 insertions(+), 10 deletions(-) diff --git a/test/filetypes/ruby/functions.vader b/test/filetypes/ruby/functions.vader index 93794516..56b7d2c5 100644 --- a/test/filetypes/ruby/functions.vader +++ b/test/filetypes/ruby/functions.vader @@ -3,6 +3,7 @@ # ============================================================================== Given ruby (function without parameters): def myFunc() # inline comment + val = 1 end Do (trigger doge): @@ -11,12 +12,14 @@ Do (trigger doge): Expect ruby (generated comment with nothing but the text 'TODO'): # [TODO:description] def myFunc() # inline comment + val = 1 end # ------------------------------------------------------------------------------ Given ruby (function without parameters and parentheses): def myFunc # inline comment + val = 1 end Do (trigger doge): @@ -25,13 +28,15 @@ Do (trigger doge): Expect ruby (generated comment with nothing but the text 'TODO'): # [TODO:description] def myFunc # inline comment + val = 1 end # ============================================================================== # Functions with parameters. # ============================================================================== Given ruby (function with parameters): - def myFunc(p1, p_2 = some_default_value) + def myFunc(p1, p_2 = some_default_value) # inline comment + val = 1 end Do (trigger doge): @@ -41,13 +46,15 @@ Expect ruby (generated comment with @param tags): # [TODO:description] # @param p1 [[TODO:type]] [TODO:description] # @param p_2 [[TODO:type]] [TODO:description] - def myFunc(p1, p_2 = some_default_value) + def myFunc(p1, p_2 = some_default_value) # inline comment + val = 1 end # ------------------------------------------------------------------------------ Given ruby (function with parameters but without parentheses): - def myFunc p1, p_2 = some_default_value + def myFunc p1, p_2 = some_default_value # inline comment + val = 1 end Do (trigger doge): @@ -57,13 +64,15 @@ Expect ruby (generated comment with @param tags): # [TODO:description] # @param p1 [[TODO:type]] [TODO:description] # @param p_2 [[TODO:type]] [TODO:description] - def myFunc p1, p_2 = some_default_value + def myFunc p1, p_2 = some_default_value # inline comment + val = 1 end # ------------------------------------------------------------------------------ Given ruby (function with keyword parameters): - def myFunc(p1, p_2: some_default_value) + def myFunc(p1, p_2: some_default_value) # inline comment + val = 1 end Do (trigger doge): @@ -73,13 +82,15 @@ Expect ruby (generated comment with @param tags): # [TODO:description] # @param p1 [[TODO:type]] [TODO:description] # @param p_2 [[TODO:type]] [TODO:description] - def myFunc(p1, p_2: some_default_value) + def myFunc(p1, p_2: some_default_value) # inline comment + val = 1 end # ------------------------------------------------------------------------------ Given ruby (function with keyword parameters but without parentheses): - def myFunc p1, p_2: some_default_value + def myFunc p1, p_2: some_default_value # inline comment + val = 1 end Do (trigger doge): @@ -89,13 +100,15 @@ Expect ruby (generated comment with @param tags): # [TODO:description] # @param p1 [[TODO:type]] [TODO:description] # @param p_2 [[TODO:type]] [TODO:description] - def myFunc p1, p_2: some_default_value + def myFunc p1, p_2: some_default_value # inline comment + val = 1 end # ------------------------------------------------------------------------------ Given ruby (function with parameters with a '&' in its name): - def each(&block) + def each(&block) # inline comment + val = 1 end Do (trigger doge): @@ -104,13 +117,15 @@ Do (trigger doge): Expect ruby (generated comment with @param tags): # [TODO:description] # @param block [[TODO:type]] [TODO:description] - def each(&block) + def each(&block) # inline comment + val = 1 end # ------------------------------------------------------------------------------ Given ruby (function with paramters containing '*' in its name): def parameters (p1,p2=4, *p3, **p4) + val = 1 end Do (trigger doge): @@ -123,12 +138,44 @@ Expect ruby (generated comment with @param tags): # @param p3 [[TODO:type]] [TODO:description] # @param p4 [[TODO:type]] [TODO:description] def parameters (p1,p2=4, *p3, **p4) + val = 1 + end + +# ------------------------------------------------------------------------------ + +Given ruby (function with multiline paramters): + def parameters ( #inline comment + p1, + p2=4, + *p3, + **p4 + ) + val = 1 + end + +Do (trigger doge): + \ + +Expect ruby (generated comment with @param tags): + # [TODO:description] + # @param p1 [[TODO:type]] [TODO:description] + # @param p2 [[TODO:type]] [TODO:description] + # @param p3 [[TODO:type]] [TODO:description] + # @param p4 [[TODO:type]] [TODO:description] + def parameters ( #inline comment + p1, + p2=4, + *p3, + **p4 + ) + val = 1 end # ------------------------------------------------------------------------------ Given ruby (function with paramters containing '*' in its name and without parentheses): def parameters p1,p2=4, *p3, **p4 + val = 1 end Do (trigger doge): @@ -141,12 +188,14 @@ Expect ruby (generated comment with @param tags): # @param p3 [[TODO:type]] [TODO:description] # @param p4 [[TODO:type]] [TODO:description] def parameters p1,p2=4, *p3, **p4 + val = 1 end # ------------------------------------------------------------------------------ Given ruby (function with paramters containing ':' in its name): def myFunc (format = :html) + val = 1 end Do (trigger doge): @@ -156,6 +205,7 @@ Expect ruby (generated comment with @param tags): # [TODO:description] # @param format [[TODO:type]] [TODO:description] def myFunc (format = :html) + val = 1 end # ============================================================================== From 5915891ca7ca578d05df2354db8ccc2fef12f5b7 Mon Sep 17 00:00:00 2001 From: Kim K Date: Sat, 7 Mar 2020 10:49:34 +0800 Subject: [PATCH 7/8] feat: Allow patterns to denormalize input --- autoload/doge/pattern.vim | 4 +++- ftplugin/ruby.vim | 3 ++- playground/test.rb | 1 + test/filetypes/ruby/functions.vader | 6 +++--- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/autoload/doge/pattern.vim b/autoload/doge/pattern.vim index 21c4096e..3741a63f 100644 --- a/autoload/doge/pattern.vim +++ b/autoload/doge/pattern.vim @@ -26,7 +26,9 @@ function! doge#pattern#generate(pattern) abort endif else " Skip if the current line does not match the main pattern. - let l:curr_line_raw = escape(doge#helpers#trim(join(l:lines, ' ')), '\') + let l:glue = has_key(a:pattern, 'normalize') + \ && a:pattern['normalize'] == v:false ? "\n" : ' ' + let l:curr_line_raw = escape(doge#helpers#trim(join(l:lines, l:glue)), '\') if l:curr_line_raw !~# a:pattern['match'] return 0 endif diff --git a/ftplugin/ruby.vim b/ftplugin/ruby.vim index b40457dc..fa6ebcfa 100644 --- a/ftplugin/ruby.vim +++ b/ftplugin/ruby.vim @@ -45,7 +45,8 @@ let s:pattern_base = { " def self.class_parameters p1,p2=4, *p3 " ------------------------------------------------------------------------------ let s:function_and_class_method_pattern = doge#helpers#deepextend(s:pattern_base, { -\ 'match': '\m^def\s\+\%([^=(! ]\+\)[=!]\?\s*(\?\s*\(\(\%(\*\{0,2}&\?[[:alnum:]_]\+\%(\s*=\s*[^, ]\+\)\?\)\%(\s*,\s*\)\?\)*\)\s*)\?.\{-}', +\ 'normalize': 0, +\ 'match': '\m^def\s\+\%([^=(!\n ]\+\)[=!]\?\s*\((\_.\{-})\|[^\n]\+\)\?', \ 'tokens': ['parameters'], \}) diff --git a/playground/test.rb b/playground/test.rb index 4a70af3c..c4ccf7e3 100644 --- a/playground/test.rb +++ b/playground/test.rb @@ -37,6 +37,7 @@ def parameters (p1,p2=4, *p3,**p4) # @param p1 [[TODO:type]] [TODO:description] # @param p2 [[TODO:type]] [TODO:description] # @param p3 [[TODO:type]] [TODO:description] +# @param p4 [[TODO:type]] [TODO:description] def parameters p1,p2=4, *p3,**p4 end diff --git a/test/filetypes/ruby/functions.vader b/test/filetypes/ruby/functions.vader index 56b7d2c5..d7bb2045 100644 --- a/test/filetypes/ruby/functions.vader +++ b/test/filetypes/ruby/functions.vader @@ -1,7 +1,7 @@ # ============================================================================== # Functions without parameters. # ============================================================================== -Given ruby (function without parameters): +Given ruby (function without parameters and with parentheses): def myFunc() # inline comment val = 1 end @@ -52,7 +52,7 @@ Expect ruby (generated comment with @param tags): # ------------------------------------------------------------------------------ -Given ruby (function with parameters but without parentheses): +Given ruby (function with parameters without parentheses): def myFunc p1, p_2 = some_default_value # inline comment val = 1 end @@ -143,7 +143,7 @@ Expect ruby (generated comment with @param tags): # ------------------------------------------------------------------------------ -Given ruby (function with multiline paramters): +Given ruby (function with multiline parameters): def parameters ( #inline comment p1, p2=4, From 8de191a78bfa3045613e83af7703aacbc1c0cb9c Mon Sep 17 00:00:00 2001 From: Weirong Xu Date: Sat, 7 Mar 2020 13:45:34 +0800 Subject: [PATCH 8/8] test: Add test for keyword parameters without default value --- test/filetypes/ruby/functions.vader | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/filetypes/ruby/functions.vader b/test/filetypes/ruby/functions.vader index d7bb2045..99b33e98 100644 --- a/test/filetypes/ruby/functions.vader +++ b/test/filetypes/ruby/functions.vader @@ -93,8 +93,14 @@ Given ruby (function with keyword parameters but without parentheses): val = 1 end + def myFunc p1, p_2: # inline comment + val = 1 + end + Do (trigger doge): \ + :8\ + \ Expect ruby (generated comment with @param tags): # [TODO:description] @@ -104,6 +110,13 @@ Expect ruby (generated comment with @param tags): val = 1 end + # [TODO:description] + # @param p1 [[TODO:type]] [TODO:description] + # @param p_2 [[TODO:type]] [TODO:description] + def myFunc p1, p_2: # inline comment + val = 1 + end + # ------------------------------------------------------------------------------ Given ruby (function with parameters with a '&' in its name):