11"  Insert Docstring.
22"  Author:       Shinya Ohyanagi <[email protected] >3- "  Version:      0.1.5 
3+ "  Version:      0.1.6 
44"  WebPage:      http://github.com/heavenshell/vim-pydocstriong/
55"  Description:  Generate Python docstring to your Python script file.
66"  License:      BSD, see LICENSE for more details.
@@ -48,26 +48,26 @@ function! s:parseClass(line)
4848  "  do that by just delete every white spaces and the whole parenthesics if 
4949  "  existed. 
5050  let  header =  substitute (a: line' \s\|(.*\|:' ' ' ' g' 
51-   let  parse =  {' type' ' class' ' header' ' args' ' ' ' returnType ' ' ' 
51+   let  parse =  {' type' ' class' ' header' ' args' ' ' ' return_type ' ' ' 
5252  return  parse
5353endfunction 
5454
55- function !  s: parseFunc type , line )
55+ function !  s: parse_func type , line )
5656  let  header =  substitute (a: line' \s\|(.*\|:' ' ' ' g' 
5757
58-   let  argsStr  =  substitute (a: line' \s\|.*(\|).*' ' ' ' g' 
59-   let  args  =  split (argsStr , ' ,' 
58+   let  args_str  =  substitute (a: line' \s\|.*(\|).*' ' ' ' g' 
59+   let  args  =  split (args_str , ' ,' 
6060
61-   let  arrowIndex  =  match (a: line" ->" 
62-   if  arrowIndex  !=  -1 
63-     let  substring =  strpart (a: linearrowIndex  +  2 )
61+   let  arrow_index  =  match (a: line" ->" 
62+   if  arrow_index  !=  -1 
63+     let  substring =  strpart (a: linearrow_index  +  2 )
6464    "  issue #28 `\W*` would deleted `.`. 
65-     let  returnType  =  substitute (substring, ' [^0-9A-Za-z_.]*' ' ' ' g' 
65+     let  return_type  =  substitute (substring, ' [^0-9A-Za-z_.]*' ' ' ' g' 
6666  else 
67-     let  returnType  =  ' ' 
67+     let  return_type  =  ' ' 
6868  endif 
6969
70-   let  parse =  {' type' a: type' header' ' args' args , ' returnType ' returnType }
70+   let  parse =  {' type' a: type' header' ' args' args , ' return_type ' return_type }
7171  return  parse
7272endfunction 
7373
@@ -90,7 +90,7 @@ function! s:parse(line)
9090    return  0 
9191  endif 
9292
93-   return  s: parseFunc type , str)
93+   return  s: parse_func type , str)
9494endfunction 
9595
9696"  Vim Script does not support lambda function...
@@ -104,7 +104,7 @@ endfunction
104104"  Check if we should show args in the docstring. We won't do that in  case:
105105"  - There's no args.
106106"  - There's only one arg that match with g:pydocstring_ignore_args_pattern
107- function !  s: shouldIncludeArgs args )
107+ function !  s: should_include_args args )
108108  if  len (a: args==  0 
109109    return  0 
110110  endif 
@@ -124,33 +124,33 @@ endfunction
124124"    g:pydocstring_ignore_args_pattern
125125" 
126126"  Return 1 for True, and 0 for False
127- function !  s: shouldUseOneLineDocString type , args , returnType )
127+ function !  s: should_use_one_line_docstring type , args , return_type )
128128  if  a: type!=  ' def' 
129129    return  1 
130130  endif 
131131
132-   if  a: returnType !=  ' ' 
132+   if  a: return_type !=  ' ' 
133133    return  0 
134134  endif 
135135
136-   return  ! s: shouldIncludeArgs a: args
136+   return  ! s: should_include_args a: args
137137endfunction 
138138
139139function !  s: builddocstringindent , nested_indent)
140140  let  type   =  a: strs' type' 
141141  let  prefix =  a: strs' header' 
142142  let  args  =  a: strs' args' 
143-   let  returnType  =  a: strs' returnType ' 
143+   let  return_type  =  a: strs' return_type ' 
144144
145-   if  s: shouldUseOneLineDocString type , args , returnType )
145+   if  s: should_use_one_line_docstring type , args , return_type )
146146    return  s: readonelinea: indent
147147  endif 
148148
149149  let  tmpl =  ' ' 
150150  let  docstrings =  []
151151  let  lines  =  s: readtmpl' multi' 
152152  let  has_return_type =  0 
153-   if  match (lines , ' \c{{_returnType_}}' !=  -1 
153+   if  match (lines , ' \c{{_returnType_}}\|\c{{_return_type_}} ' !=  -1 
154154    let  has_return_type =  1 
155155  endif 
156156  for  line  in  lines 
@@ -186,7 +186,7 @@ function! s:builddocstring(strs, indent, nested_indent)
186186            "    ''' 
187187            "    {{_header_}} 
188188            "    :param {{_args_}}: 
189-             "    :rtype: {{_returnType_ }} 
189+             "    :rtype: {{_return_type_ }} 
190190            "    ''' 
191191            let  template =  substitute (template, ' :$' ' ' ' g' 
192192          endif 
@@ -203,9 +203,9 @@ function! s:builddocstring(strs, indent, nested_indent)
203203    elseif  line  = ~ ' {{_indent_}}' 
204204      let  arg =  substitute (line , ' {{_indent_}}' a: indent' g' 
205205      call  add (docstrings, arg)
206-     elseif  line  = ~ ' {{_returnType_}}' 
207-       if  strlen (returnType ) !=  0 
208-         let  rt =  substitute (line , ' {{_returnType_}}' returnType , ' ' 
206+     elseif  line  = ~ ' {{_returnType_}}\|{{_return_type_}} ' 
207+       if  strlen (return_type ) !=  0 
208+         let  rt =  substitute (line , ' {{_returnType_}}\|{{_return_type_}} ' return_type , ' ' 
209209        call  add (docstrings, a: indent
210210      else 
211211        call  remove (docstrings, -1 )
0 commit comments