Skip to content

Commit eb9c354

Browse files
authored
Fix remove blank line above {{_return_type_}} (#39)
* Fix remove blank line above {{_return_type_}} * Fix travis settings * Fix configure settings * Fix disable gui
1 parent feecc37 commit eb9c354

File tree

10 files changed

+25
-28
lines changed

10 files changed

+25
-28
lines changed

.travis.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
sudo: false
2+
dist: trusty
13
language: vim
24

35
install:
@@ -7,7 +9,7 @@ install:
79
- mkdir ~/tmp
810
- cd /tmp/vim
911
- sudo apt-get install -y gettext libncurses5-dev libacl1-dev libgpm-dev
10-
- ./configure --with-features=huge --enable-fail-if-missing --enable-pythoninterp --prefix=$HOME/tmp/vim
12+
- ./configure --with-features=huge --enable-fail-if-missing --enable-pythoninterp --prefix=$HOME/tmp/vim --disable-gui
1113
- make && make install
1214
- git clone https://github.com/junegunn/vader.vim.git
1315
- export VIM_EXE=$HOME/tmp/vim/bin/vim

CHANGES.rst

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1-
Version 0.1.6
1+
Version 0.2.0
22
-------------
33
Released on Nov 19th 2017
44

5+
- Minor changes
6+
7+
- Notice template `{{_return_type_}}` does not add extra blank
8+
- Now template shows as is
9+
10+
Version 0.1.6
11+
-------------
12+
Released on Nov 18th 2017
13+
514
- Minor changes
615

716
- Change function name camelCase to snake_case

autoload/pydocstring.vim

+8-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
" Insert Docstring.
22
" Author: Shinya Ohyanagi <[email protected]>
3-
" Version: 0.1.6
3+
" Version: 0.2.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.
@@ -149,10 +149,6 @@ function! s:builddocstring(strs, indent, nested_indent)
149149
let tmpl = ''
150150
let docstrings = []
151151
let lines = s:readtmpl('multi')
152-
let has_return_type = 0
153-
if match(lines, '\c{{_returnType_}}\|\c{{_return_type_}}') != -1
154-
let has_return_type = 1
155-
endif
156152
for line in lines
157153
if line =~ '{{_header_}}'
158154
let header = substitute(line, '{{_header_}}', prefix, '')
@@ -167,10 +163,10 @@ function! s:builddocstring(strs, indent, nested_indent)
167163
let template = line
168164
let typed = 0
169165
if match(arg, ':') != -1
170-
let argTemplate = join(s:readtmpl('arg'), '')
171-
let argParts = split(arg, ':')
172-
let argTemplate = substitute(argTemplate, '{{_name_}}', argParts[0], 'g')
173-
let arg = substitute(argTemplate, '{{_type_}}', argParts[1], 'g')
166+
let arg_template = join(s:readtmpl('arg'), '')
167+
let arg_parts = split(arg, ':')
168+
let arg_template = substitute(arg_template, '{{_name_}}', arg_parts[0], 'g')
169+
let arg = substitute(arg_template, '{{_type_}}', arg_parts[1], 'g')
174170
let typed = 1
175171
endif
176172
let template = substitute(template, '{{_args_}}', arg, 'g')
@@ -196,9 +192,6 @@ function! s:builddocstring(strs, indent, nested_indent)
196192
let template = substitute(template, '\s$', '', '')
197193
call add(docstrings, a:indent . template)
198194
endfor
199-
if has_return_type == 1
200-
call add(docstrings, '')
201-
endif
202195
endif
203196
elseif line =~ '{{_indent_}}'
204197
let arg = substitute(line, '{{_indent_}}', a:indent, 'g')
@@ -208,7 +201,9 @@ function! s:builddocstring(strs, indent, nested_indent)
208201
let rt = substitute(line, '{{_returnType_}}\|{{_return_type_}}', return_type, '')
209202
call add(docstrings, a:indent . rt)
210203
else
211-
call remove(docstrings, -1)
204+
if docstrings[-1] == ''
205+
call remove(docstrings, -1)
206+
endif
212207
endif
213208
elseif line == '"""' || line == "'''"
214209
call add(docstrings, a:indent . line)

doc/pydocstring.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
*pydocstring.txt* Generate Python docstring to your Python code.
22

3-
Version: 0.1.6
3+
Version: 0.2.0
44
Author: Shinya Ohynagi <[email protected]>
55
Repository: http://github.com/heavenshell/vim-pydocstring/
66
License: BSD, see LICENSE for more details.

ftplugin/python/pydocstring.vim

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
" File: pydocstring.vim
22
" Author: Shinya Ohyanagi <[email protected]>
3-
" Version: 0.1.6
3+
" Version: 0.2.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/basic.vader

-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ Expect python:
208208
:type weights: tuple
209209
:param coords:
210210
:type coords: numpy.ndarray
211-
212211
:rtype: numpy.ndarray
213212
"""
214213
pass

test/issue_return_type.vader

-5
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ Expect python:
3030
"""foo
3131

3232
:param sample_var:
33-
3433
:rtype: str
3534
"""
3635
pass
@@ -47,7 +46,6 @@ Expect python:
4746

4847
:param arg1:
4948
:param arg2:
50-
5149
:rtype: str
5250
"""
5351
pass
@@ -65,7 +63,6 @@ Expect python:
6563

6664
:param n:
6765
:type n: int
68-
6966
:rtype: int
7067
"""
7168
pass
@@ -85,7 +82,6 @@ Expect python:
8582
:type n: int
8683
:param m:
8784
:type m: str
88-
8985
:rtype: int
9086
"""
9187
pass
@@ -105,7 +101,6 @@ Expect python:
105101
:param n:
106102
:type n: int
107103
:param arg:
108-
109104
:rtype: int
110105
"""
111106
pass
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""{{_header_}}
22

33
{{_args_}}:{{_lf_}}{{_indent_}} the ...
4+
45
return ({{_return_type_}}):
56
"""

test/templates/numpy/multi.txt

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
{{_indent_}}----------
55

66
{{_args_}} :
7+
78
{{_indent_}}Returns
89
{{_indent_}}-------
910

test/type-hint.vader

-5
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ Expect python:
2626
"""foo
2727

2828
:param sample_var:
29-
3029
:rtype: str
3130
"""
3231
pass
@@ -43,7 +42,6 @@ Expect python:
4342

4443
:param arg1:
4544
:param arg2:
46-
4745
:rtype: str
4846
"""
4947
pass
@@ -61,7 +59,6 @@ Expect python:
6159

6260
:param n:
6361
:type n: int
64-
6562
:rtype: int
6663
"""
6764
pass
@@ -81,7 +78,6 @@ Expect python:
8178
:type n: int
8279
:param m:
8380
:type m: str
84-
8581
:rtype: int
8682
"""
8783
pass
@@ -101,7 +97,6 @@ Expect python:
10197
:param n:
10298
:type n: int
10399
:param arg:
104-
105100
:rtype: int
106101
"""
107102
pass

0 commit comments

Comments
 (0)