11" File: jsdoc.vim
22" Author: NAKAMURA, Hisashi <https://github.com/sunvisor>
33" Modifyed: Shinya Ohyanagi <[email protected] >4- " Version: 0.10.0
4+ " Version: 0.10.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.
@@ -106,13 +106,13 @@ let s:regexs = {
106106 \ ' arrow' : ' ^.\{-}\s*\([a-zA-Z_$][a-zA-Z0-9_$]*\)\s*[:=]\s*(\s*\([^)]*\)\s*)\s*=>.*$' ,
107107 \ ' return_type' : ' )\(:\|:\s\|\s*:\s*\)\([a-zA-Z]\+\).*$' ,
108108 \ ' interface' : ' ^.\{-}\s*interface\s*\([a-zA-Z_$][a-zA-Z0-9_$]*\).*$' ,
109- \ ' access' : ' ^\(public\|protected\|private\)' ,
109+ \ ' access' : ' ^\s*\ (public\|protected\|private\)' ,
110110 \ ' implements' : ' ^.\{-}\s*implements\s*\(\([^{]*\)\).*$' ,
111111 \ ' extends' : ' ^.\{-}\s*extends\s*\([^\s*]\)'
112112 \ }
113113
114114function ! s: trim (value)
115- return substitute (a: value , ' \s' , ' ' , ' ' )
115+ return substitute (a: value , ' \s' , ' ' , ' g ' )
116116endfunction
117117
118118" If someday Vim support lambda use lambda.
@@ -123,15 +123,12 @@ function! s:parse_type(args)
123123 let args = split (arg, ' :' )
124124 let val = args [0 ]
125125 if val = ~# s: regexs [' access' ]
126- " let val = substitute(split(val, s:regexs['access'])[0], '\s', '', '')
127126 let val = s: trim (split (val, s: regexs [' access' ])[0 ])
128127 endif
129128
130- " let type = substitute(args[1], '\s', '', '')
131129 let type = s: trim (args [1 ])
132130 " Split keywaord args.
133131 if type = ~# ' ='
134- " let type = substitute(split(type, '=')[0], '\s', '', '')
135132 let type = s: trim (split (type , ' =' )[0 ])
136133 endif
137134 call add (results, {' val' : val, ' type' : type })
@@ -387,12 +384,16 @@ function! jsdoc#insert() abort
387384 " either @access public/private
388385 " or @public/private
389386 let l: access_tag = g: jsdoc_access_descriptions == 1
390- \ ? ' * @access '
391- \ : ' * @'
387+ \ ? ' * @access '
388+ \ : ' * @'
389+ if l: line = ~ s: regexs [' access' ]
390+ let l: access = s: trim (matchstr (l: line , s: regexs [' access' ]))
391+ else
392392
393- let l: access = g: jsdoc_underscore_private == 1 && l: funcName [0 ] == # ' _'
394- \ ? ' private'
395- \ : ' public'
393+ let l: access = g: jsdoc_underscore_private == 1 && l: funcName [0 ] == # ' _'
394+ \ ? ' private'
395+ \ : ' public'
396+ endif
396397
397398 call add (l: lines , l: space . l: access_tag . l: access )
398399 endif
0 commit comments