Skip to content

Commit 91832bf

Browse files
authored
Merge pull request #18 from heavenshell/fix/lack_of_end_colon
Fix #17
2 parents 5187d52 + 6072337 commit 91832bf

File tree

6 files changed

+35
-11
lines changed

6 files changed

+35
-11
lines changed

CHANGES.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
Version 0.1.1
2+
-------------
3+
Released on Feb 12th 2017
4+
5+
- Fix bug
6+
If none typed arg, lack of last `:`.
7+
see https://github.com/heavenshell/vim-pydocstring/issues/17
8+
19
Version 0.1.0
210
-------------
311
Released on Dec 25th 2016

autoload/pydocstring.vim

Lines changed: 20 additions & 4 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.1.0
3+
" Version: 0.1.1
44
" License: This file is placed in the public domain.
55
" WebPage: http://github.com/heavenshell/vim-pydocstriong/
66
" Description: Generate Python docstring to your Python script file.
@@ -163,22 +163,38 @@ function! s:builddocstring(strs, indent, nested_indent)
163163
continue
164164
endif
165165
let template = line
166-
166+
let typed = 0
167167
if match(arg, ':') != -1
168168
let argTemplate = s:readtmpl('arg')
169169
let argTemplate = join(s:readtmpl('arg'), '')
170170
let argParts = split(arg, ':')
171171
let argTemplate = substitute(argTemplate, '{{_name_}}', argParts[0], 'g')
172172
let arg = substitute(argTemplate, '{{_type_}}', argParts[1], 'g')
173+
let typed = 1
173174
endif
174-
175175
let template = substitute(template, '{{_args_}}', arg, 'g')
176+
if typed == 1
177+
" Fix following bugs.
178+
" `def foo(arg: str):` generates like followings
179+
" ```
180+
" :param arg:
181+
" :type arg: str:
182+
" ```
183+
" Template file describes as followings
184+
" ```
185+
" '''
186+
" {{_header_}}
187+
" :param {{_args_}}:
188+
" :rtype: {{_returnType_}}
189+
" '''
190+
let template = substitute(template, ':$', '', 'g')
191+
endif
176192
let template = substitute(template, '{{_lf_}}', '\n', 'g')
177193
let template = substitute(template, '{{_indent_}}', a:indent, 'g')
178194
let template = substitute(template, '{{_nested_indent_}}', a:nested_indent, 'g')
179195
call add(docstrings, a:indent . template)
180196
endfor
181-
call add(docstrings, '' )
197+
call add(docstrings, '')
182198
endif
183199
elseif line =~ '{{_indent_}}'
184200
let arg = substitute(line, '{{_indent_}}', a:indent, 'g')

doc/pydocstring.txt

Lines changed: 1 addition & 1 deletion
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.0
3+
Version: 0.1.1
44
Author: Shinya Ohynagi <sohyanagi@gmail.com>
55
Repository: http://github.com/heavenshell/vim-pydocstring/
66
License: BSD, see LICENSE for more details.

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.1.0
3+
" Version: 0.1.1
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.

template/pydocstring/multi.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
"""{{_header_}}
2-
:param {{_args_}}
2+
:param {{_args_}}:
33
:rtype: {{_returnType_}}
44
"""

test/type-hint.vader

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Expect python:
2525
def foo(sample_var) -> str:
2626
"""foo
2727

28-
:param sample_var
28+
:param sample_var:
2929

3030
:rtype: str
3131
"""
@@ -41,8 +41,8 @@ Expect python:
4141
def foo(arg1, arg2) -> str:
4242
"""foo
4343

44-
:param arg1
45-
:param arg2
44+
:param arg1:
45+
:param arg2:
4646

4747
:rtype: str
4848
"""
@@ -100,7 +100,7 @@ Expect python:
100100

101101
:param n:
102102
:type n: int
103-
:param arg
103+
:param arg:
104104

105105
:rtype: int
106106
"""

0 commit comments

Comments
 (0)