Skip to content

Commit 45c7c7c

Browse files
committed
Fix #61
1 parent a6dfd89 commit 45c7c7c

File tree

5 files changed

+22
-6
lines changed

5 files changed

+22
-6
lines changed

autoload/jsdoc.vim

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
" File: jsdoc.vim
22
" Author: NAKAMURA, Hisashi <https://github.com/sunvisor>
33
" Modifyed: Shinya Ohyanagi <sohyanagi@gmail.com>
4-
" Version: 0.11.0
4+
" Version: 0.11.1
55
" WebPage: http://github.com/heavenshell/vim-jsdoc/
66
" Description: Generate JSDoc to your JavaScript file.
77
" License: BSD, see LICENSE for more details.
@@ -108,6 +108,7 @@ let s:regexs = {
108108
\ 'shorthand': '^.\{-}\s*\([a-zA-Z_$][a-zA-Z0-9_$]*\)\s*(\s*\([^)]*\)\s*).*$',
109109
\ 'static': '^.\{-}\s*static\s*\([a-zA-Z_$][a-zA-Z0-9_$]*\)\s*(\s*\([^)]*\)\s*).*$',
110110
\ 'arrow': '^.\{-}\s*\([a-zA-Z_$][a-zA-Z0-9_$]*\)\s*[:=]\s*(\s*\([^)]*\)\s*)\s*=>.*$',
111+
\ 'arrow_single': '^.\{-}\s*\([a-zA-Z_$][a-zA-Z0-9_$]*\)\s*[:=]\s*\([^=]*\).*$',
111112
\ 'return_type': ')\(:\|:\s\|\s*:\s*\)\([a-zA-Z]\+\).*$',
112113
\ 'interface': '^.\{-}\s*interface\s*\([a-zA-Z_$][a-zA-Z0-9_$]*\).*$',
113114
\ 'access': '^\s*\(public\|protected\|private\)',
@@ -125,7 +126,7 @@ function! s:parse_type(args)
125126
for arg in a:args
126127
if arg =~# ':'
127128
let args = split(arg, ':')
128-
let val = args[0]
129+
let val = s:trim(args[0])
129130
if val =~# s:regexs['access']
130131
let val = s:trim(split(val, s:regexs['access'])[0])
131132
endif
@@ -137,7 +138,7 @@ function! s:parse_type(args)
137138
endif
138139
call add(results, {'val': val, 'type': type})
139140
else
140-
call add(results, {'val': arg, 'type': ''})
141+
call add(results, {'val': s:trim(arg), 'type': ''})
141142
endif
142143
endfor
143144

@@ -262,6 +263,10 @@ function! s:determine_style(line)
262263
let l:is_function = 1
263264
let l:is_named = 1
264265
let l:regex = s:regexs['arrow']
266+
elseif g:jsdoc_enable_es6 == 1 && a:line =~ s:regexs['arrow_single']
267+
let l:is_function = 1
268+
let l:is_named = 1
269+
let l:regex = s:regexs['arrow_single']
265270
elseif g:jsdoc_enable_es6 == 1 && a:line =~ s:regexs['class_extend']
266271
let l:is_class = 1
267272
let l:is_named = 1

doc/jsdoc.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
*jsdoc.txt* Generate JSDoc to your JavaScript code.
22

3-
Version: 0.11.0
3+
Version: 0.11.1
44
Author: NAKAMURA, Hisashi <https://github.com/sunvisor>
55
Modifyed: Shinya Ohynagi <sohyanagi@gmail.com>
66
Repository: http://github.com/heavenshell/vim-jsdoc/
@@ -301,6 +301,11 @@ g:jsdoc_user_defined_tags *g:jsdoc_user_defined_tags*
301301
>
302302
==============================================================================
303303
CHANGELOG *jsdoc-changelog*
304+
2016-10-30
305+
- Fix missing @param around single function argument.
306+
see https://github.com/heavenshell/vim-jsdoc/issues/61 details.
307+
(thx @rpereira)
308+
304309
2016-09-11
305310
- Add g:jsdoc_user_defined_tags option for insert custom tags.
306311

ftplugin/javascript/jsdoc.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
" File: jsdoc.vim
22
" Author: NAKAMURA, Hisashi <https://github.com/sunvisor>
33
" Modifyed: Shinya Ohyanagi <sohyanagi@gmail.com>
4-
" Version: 0.11.0
4+
" Version: 0.11.1
55
" WebPage: http://github.com/heavenshell/vim-jsdoc/
66
" Description: Generate JSDoc to your JavaScript file.
77
" License: BSD, see LICENSE for more details.

ftplugin/typescript/jsdoc.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
" File: jsdoc.vim
22
" Author: NAKAMURA, Hisashi <https://github.com/sunvisor>
33
" Modifyed: Shinya Ohyanagi <sohyanagi@gmail.com>
4-
" Version: 0.11.0
4+
" Version: 0.11.1
55
" WebPage: http://github.com/heavenshell/vim-jsdoc/
66
" Description: Generate JSDoc to your JavaScript file.
77
" License: BSD, see LICENSE for more details.

test/test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ var anonymousFunctionExpression = function (arg1, arg2) {};
99

1010
var namedFunctionExpression = function namedExpression(el, $jq) {}
1111

12+
var arrowFunction = (foo, bar) => { };
13+
14+
var arrowFunctionSingle = foo => {};
15+
1216
function namedFunctionDeclaration(_a2, err) { }
1317

1418
function* namedGeneratorFunc(data) { }
@@ -25,6 +29,8 @@ namespace.x3 = function testing(e) { }; // named method
2529

2630
namespace.x4 = function* testgen(description) { }; // named method generator
2731

32+
namespace.x5 = foo => { }; // anonymous method shorthand
33+
2834
class Foo {
2935
static foo(bar, baz) { } // static method
3036

0 commit comments

Comments
 (0)