11" File: jsdoc.vim
22" Author: NAKAMURA, Hisashi <https://github.com/sunvisor>
33" Modifyed: Shinya Ohyanagi <sohyanagi@gmail.com>
4- " Version: 0.11.1
4+ " Version: 0.12.0
55" WebPage: http://github.com/heavenshell/vim-jsdoc/
66" Description: Generate JSDoc to your JavaScript file.
77" License: BSD, see LICENSE for more details.
@@ -133,15 +133,21 @@ function! s:parse_type(args)
133133
134134 let type = s: trim (args [1 ])
135135 " Split keywaord args.
136+ let default_arg = ' '
136137 if type = ~# ' ='
137- let type = s: trim (split (type , ' =' )[0 ])
138+ let values = split (type , ' =' )
139+ let type = s: trim (values [0 ])
140+ let default_arg = s: trim (values [1 ])
141+ endif
142+ if default_arg != ' '
143+ " Default keywaord should be `[keyword=default]`.
144+ let val = printf (' %s=%s' , val, default_arg)
138145 endif
139146 call add (results, {' val' : val, ' type' : type })
140147 else
141148 call add (results, {' val' : s: trim (arg), ' type' : ' ' })
142149 endif
143150 endfor
144-
145151 return results
146152endfunction
147153
@@ -199,7 +205,8 @@ function! s:hookArgs(lines, space, arg, hook, argType, argDescription) abort
199205 let l: description = a: argDescription !=# ' '
200206 \ ? g: jsdoc_param_description_separator . a: argDescription
201207 \ : ' '
202- call add (a: lines , a: space . ' * @' . g: jsdoc_tags [' param' ] . ' ' . l: type . a: arg . l: description )
208+ let arg = s: parse_keyword_arg (a: arg )
209+ call add (a: lines , a: space . ' * @' . g: jsdoc_tags [' param' ] . ' ' . l: type . arg . l: description )
203210
204211 else
205212
@@ -221,7 +228,8 @@ function! s:hookArgs(lines, space, arg, hook, argType, argDescription) abort
221228 else
222229 let l: description = g: jsdoc_param_description_separator . a: argDescription
223230 endif
224- call add (a: lines , a: space . ' * @' . g: jsdoc_tags [' param' ] . ' ' . l: type . a: arg . l: description )
231+ let arg = s: parse_keyword_arg (a: arg )
232+ call add (a: lines , a: space . ' * @' . g: jsdoc_tags [' param' ] . ' ' . l: type . arg . l: description )
225233
226234 endif
227235
@@ -309,6 +317,15 @@ function! s:extract_return_type(line)
309317 return l: return_type
310318endfunction
311319
320+ function ! s: parse_keyword_arg (arg)
321+ let result = a: arg
322+ if a: arg = ~ ' ='
323+ let result = printf (' [%s]' , a: arg )
324+ endif
325+
326+ return result
327+ endfunction
328+
312329function ! jsdoc#insert () abort
313330 let l: line = getline (' .' )
314331 let l: indentCharSpace = ' '
0 commit comments