Skip to content

Commit aea9457

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents d00f69d + e3f77a5 commit aea9457

File tree

8 files changed

+98
-6
lines changed

8 files changed

+98
-6
lines changed

CHANGES.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
Version 0.6.0
2+
-------------
3+
Released on Jun 30th 2018
4+
5+
- Bug fix
6+
7+
- indent doesn't work with `{{_return_type_}}` or `{{_nested_indent_}}`
8+
9+
see https://github.com/heavenshell/vim-pydocstring/issues/51
10+
11+
Thx @JPFrancoia
12+
113
Version 0.5.0
214
-------------
315
Released on Jun 30th 2018

autoload/pydocstring.vim

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
" Insert Docstring.
22
" Author: Shinya Ohyanagi <sohyanagi@gmail.com>
3-
" Version: 0.5.0
3+
" Version: 0.6.0
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.
@@ -308,18 +308,20 @@ function! s:build_docstring(strs, indent, nested_indent)
308308
call add(docstrings, a:indent . template)
309309
endfor
310310
endif
311-
elseif line =~ '{{_indent_}}'
312-
let arg = substitute(line, '{{_indent_}}', a:indent, 'g')
313-
call add(docstrings, arg)
314-
elseif line =~ '{{_returnType_}}\|{{_return_type_}}'
311+
elseif match(line, '{{_returnType_}}\|{{_return_type_}}') != -1
315312
if strlen(return_type) != 0
313+
let line = substitute(line, '{{_indent_}}', a:indent, 'g')
314+
let line = substitute(line, '{{_nested_indent_}}', a:nested_indent, 'g')
316315
let rt = substitute(line, '{{_returnType_}}\|{{_return_type_}}', return_type, '')
317316
call add(docstrings, a:indent . rt)
318317
else
319318
if docstrings[-1] == ''
320319
call remove(docstrings, -1)
321320
endif
322321
endif
322+
elseif line =~ '{{_indent_}}'
323+
let arg = substitute(line, '{{_indent_}}', a:indent, 'g')
324+
call add(docstrings, arg)
323325
elseif line == '"""' || line == "'''"
324326
call add(docstrings, a:indent . line)
325327
else

ftplugin/python/pydocstring.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
" File: pydocstring.vim
22
" Author: Shinya Ohyanagi <sohyanagi@gmail.com>
3-
" Version: 0.5.0
3+
" Version: 0.6.0
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.

test/issue_return_type_indent.vader

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# vim:set et sw=4 ts=4 tw=79:
2+
Execute (Setup template dir):
3+
Save g:pydocstring_templates_dir
4+
let g:pydocstring_templates_dir = './templates/issue51/'
5+
6+
Given python (def foo with 1 params):
7+
def foo(arg1):
8+
pass
9+
10+
Execute:
11+
Pydocstring
12+
13+
Expect python:
14+
def foo(arg1):
15+
"""foo
16+
17+
Args:
18+
arg1:
19+
20+
Returns:
21+
"""
22+
pass
23+
24+
25+
Given python (def foo with 2 params):
26+
def foo(arg1, arg2):
27+
pass
28+
29+
Execute:
30+
Pydocstring
31+
32+
Expect python:
33+
def foo(arg1, arg2):
34+
"""foo
35+
36+
Args:
37+
arg1:
38+
arg2:
39+
40+
Returns:
41+
"""
42+
pass
43+
44+
45+
Given python (return type):
46+
def foo(arg1: str, arg2: int) -> bool:
47+
pass
48+
49+
Execute:
50+
Pydocstring
51+
52+
Expect python:
53+
def foo(arg1: str, arg2: int) -> bool:
54+
"""foo
55+
56+
Args:
57+
arg1 (str):
58+
arg2 (int):
59+
60+
Returns:
61+
bool
62+
"""
63+
pass
64+
65+
66+
Execute (Clear pydocstring_templates_dir):
67+
Restore

test/templates/issue51/arg.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{_name_}} ({{_type_}}):

test/templates/issue51/comment.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#

test/templates/issue51/multi.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""{{_header_}}
2+
3+
{{_indent_}}Args:
4+
{{_nested_indent_}}{{_args_}}:
5+
6+
{{_indent_}}Returns:
7+
{{_nested_indent_}}{{_return_type_}}
8+
"""

test/templates/issue51/oneline.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""{{_header_}}"""

0 commit comments

Comments
 (0)