Skip to content

Commit c6cf34a

Browse files
committed
Add numpy tests
1 parent 0b8f593 commit c6cf34a

File tree

3 files changed

+94
-1
lines changed

3 files changed

+94
-1
lines changed

autoload/pydocstring.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ function! s:builddocstring(strs, indent, nested_indent)
195195
let template = substitute(template, '{{_lf_}}', '\n', 'g')
196196
let template = substitute(template, '{{_indent_}}', a:indent, 'g')
197197
let template = substitute(template, '{{_nested_indent_}}', a:nested_indent, 'g')
198+
let template = substitute(template, '\s$', '', '')
198199
call add(docstrings, a:indent . template)
199200
endfor
200201
if has_return_type == 1

test/numpy-template.vader

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
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/numpy/'
5+
6+
Given python (def foo):
7+
def foo():
8+
pass
9+
10+
Execute:
11+
Pydocstring
12+
13+
14+
Expect python:
15+
def foo():
16+
"""foo"""
17+
pass
18+
19+
20+
Given python (def foo with 1 params):
21+
def foo(arg1):
22+
pass
23+
24+
Execute:
25+
Pydocstring
26+
27+
Expect python:
28+
def foo(arg1):
29+
"""foo
30+
31+
Parameters
32+
----------
33+
34+
arg1 :
35+
36+
Returns
37+
-------
38+
"""
39+
pass
40+
41+
42+
Given python (def foo with 2 params):
43+
def foo(arg1, arg2):
44+
pass
45+
46+
Execute:
47+
Pydocstring
48+
49+
Expect python:
50+
def foo(arg1, arg2):
51+
"""foo
52+
53+
Parameters
54+
----------
55+
56+
arg1 :
57+
arg2 :
58+
59+
Returns
60+
-------
61+
"""
62+
pass
63+
64+
Given python (def foo with 2 params and type):
65+
def foo(arg1: str, arg2: int) -> str:
66+
pass
67+
68+
Execute:
69+
Pydocstring
70+
71+
Expect python:
72+
def foo(arg1: str, arg2: int) -> str:
73+
"""foo
74+
75+
Parameters
76+
----------
77+
78+
arg1 : str
79+
arg1 is
80+
arg2 : int
81+
arg2 is
82+
83+
Returns
84+
-------
85+
86+
returnVar : str
87+
"""
88+
pass
89+
90+
91+
Execute (Clear pydocstring_templates_dir):
92+
Restore

test/templates/numpy/comment.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
#
1+
#

0 commit comments

Comments
 (0)