@@ -24,10 +24,10 @@ if !exists('g:pydocstring_ignore_args_pattern')
2424endif
2525
2626let s: regexs = {
27- \ ' def' : ' ^def\s\|^\s*def\s' ,
28- \ ' class' : ' ^class\s\|^\s*class\s' ,
29- \ ' async' : ' ^async\s*def\s\|^\s*async\sdef\s'
30- \ }
27+ \ ' def' : ' ^def\s\|^\s*def\s' ,
28+ \ ' class' : ' ^class\s\|^\s*class\s' ,
29+ \ ' async' : ' ^async\s*def\s\|^\s*async\sdef\s'
30+ \ }
3131
3232function ! s: readtmpl (type )
3333 let tmpldir = g: pydocstring_templates_dir
@@ -45,9 +45,9 @@ function! s:readtmpl(type)
4545endfunction
4646
4747function ! s: parseClass (line )
48- " For class definition, we just simply need to extract the class name. We can
49- " do that by just delete every white spaces and the whole parenthesics if
50- " existed.
48+ " For class definition, we just simply need to extract the class name. We can
49+ " do that by just delete every white spaces and the whole parenthesics if
50+ " existed.
5151 let header = substitute (a: line , ' \s\|(.*\|:' , ' ' , ' g' )
5252 let parse = {' type' : ' class' , ' header' : header, ' args' : ' ' , ' returnType' : ' ' }
5353 return parse
@@ -153,21 +153,24 @@ function! s:builddocstring(strs, indent, nested_indent)
153153 for line in lines
154154 if line = ~ ' {{_header_}}'
155155 let header = substitute (line , ' {{_header_}}' , prefix, ' ' )
156- let header = substitute (header, ' {{_lf_}}' , ' \n' , ' ' )
157156 call add (docstrings, a: indent . header)
157+ call add (docstrings, ' ' )
158158 elseif line = ~ ' {{_args_}}'
159- for arg in args
160- let arg = substitute (arg, ' =.*$' , ' ' , ' ' )
161- if arg = ~ g: pydocstring_ignore_args_pattern
162- continue
163- endif
164- let template = line
165- let template = substitute (template, ' {{_args_}}' , arg, ' g' )
166- let template = substitute (template, ' {{_lf_}}' , ' \n' , ' ' )
167- let template = substitute (template, ' {{_indent_}}' , a: indent , ' g' )
168- let template = substitute (template, ' {{_nested_indent_}}' , a: nested_indent , ' g' )
169- call add (docstrings, a: indent . template)
170- endfor
159+ if len (args ) != 0
160+ for arg in args
161+ let arg = substitute (arg, ' =.*$' , ' ' , ' ' )
162+ if arg = ~ g: pydocstring_ignore_args_pattern
163+ continue
164+ endif
165+ let template = line
166+ let template = substitute (template, ' {{_args_}}' , arg, ' g' )
167+ let template = substitute (template, ' {{_lf_}}' , ' \n' , ' ' )
168+ let template = substitute (template, ' {{_indent_}}' , a: indent , ' g' )
169+ let template = substitute (template, ' {{_nested_indent_}}' , a: nested_indent , ' g' )
170+ call add (docstrings, a: indent . template)
171+ endfor
172+ call add (docstrings, ' ' )
173+ endif
171174 elseif line = ~ ' {{_indent_}}'
172175 let arg = substitute (line , ' {{_indent_}}' , a: indent , ' g' )
173176 call add (docstrings, arg)
@@ -176,20 +179,16 @@ function! s:builddocstring(strs, indent, nested_indent)
176179 let rt = substitute (line , ' {{_returnType_}}' , returnType, ' ' )
177180 call add (docstrings, a: indent . rt)
178181 else
179- " call remove(docstrings, -1)
182+ call remove (docstrings, -1 )
180183 endif
181184 elseif line == ' """'
182185 call add (docstrings, a: indent . line )
183186 else
184187 call add (docstrings, line )
185188 endif
186-
187- echo string (docstrings)
188-
189189 endfor
190190 let tmpl = substitute (join (docstrings, " \n " ), " \n $" , ' ' , ' ' )
191191
192- echom string (tmpl)
193192 return tmpl
194193endfunction
195194
0 commit comments