Skip to content

Commit ae9b634

Browse files
committed
Tiny refactoring.
1 parent e93ae9b commit ae9b634

File tree

4 files changed

+21
-9
lines changed

4 files changed

+21
-9
lines changed

CHANGES.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Version 0.0.5
2+
-------------
3+
Released on September 28th 2015
4+
5+
- Tiny refactoring.
6+
17
Version 0.0.4
28
-------------
39
Released on September 14th 2015

autoload/pydocstring.vim

Lines changed: 13 additions & 7 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.0.4
3+
" Version: 0.0.5
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.
@@ -24,6 +24,12 @@ if !exists('g:pydocstring_ignore_args_pattern')
2424
let g:pydocstring_ignore_args_pattern = 'self\|cls'
2525
endif
2626

27+
let s:regexs = {
28+
\ 'def': '^def\s\|^\s*def\s',
29+
\ 'class': '^class\s\|^\s*class\s',
30+
\ 'async': '^async\s*def\s\|^\s*async\sdef\s'
31+
\ }
32+
2733
function! s:readtmpl(type)
2834
let path = s:tmpldir . a:type . '.txt'
2935
if !filereadable(path)
@@ -36,14 +42,14 @@ endfunction
3642
function! s:parse(line)
3743
let str = substitute(a:line, '\\', '', 'g')
3844
let type = ''
39-
if str =~ '^def\s\|^\s*def\s'
40-
let str = substitute(str, '^def\s\|^\s*def\s', '', '')
45+
if str =~ s:regexs['def']
46+
let str = substitute(str, s:regexs['def'], '', '')
4147
let type = 'def'
42-
elseif str =~ '^async\s*def\s\|^\s*async\sdef\s'
43-
let str = substitute(str, '^async\sdef\s\|^\s*async\sdef\s', '', '')
48+
elseif str =~ s:regexs['async']
49+
let str = substitute(str, s:regexs['async'], '', '')
4450
let type = 'def'
45-
elseif str =~ '^class\s\|^\s*class\s'
46-
let str = substitute(str, '^class\s\|^\s*class\s', '', '')
51+
elseif str =~ s:regexs['class']
52+
let str = substitute(str, s:regexs['class'], '', '')
4753
let type = 'class'
4854
else
4955
return 0

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.0.4
3+
Version: 0.0.5
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.0.4
3+
" Version: 0.0.5
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.

0 commit comments

Comments
 (0)