Skip to content

Commit e8115fe

Browse files
authored
Add ignore__init option (#136)
1 parent 36a0cde commit e8115fe

File tree

4 files changed

+56
-0
lines changed

4 files changed

+56
-0
lines changed

README.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,15 @@ excptions add to docstring.
135135
"""
136136
raise Exception('foo')
137137
138+
Ignore generate __init__ docstring
139+
----------------------------------
140+
141+
If you want ignore to generate `__init__` docstring, you can set like following.
142+
143+
.. code::
144+
145+
let g:pydocstring_ignore_init = 1
146+
138147
Thanks
139148
------
140149

autoload/pydocstring.vim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ let g:pydocstring_doq_path = get(
1515
\ 'pydocstring_doq_path',
1616
\ printf('%s/lib/doq', expand('<sfile>:p:h:h'))
1717
\ )
18+
let g:pydocstring_ignore_init = get(g:, 'pydocstring_ignore_init', 0)
1819

1920
let s:results = []
2021

@@ -180,6 +181,8 @@ endfunction
180181
function! pydocstring#format() abort
181182
let lines = printf("%s\n", join(getbufline(bufnr('%'), 1, '$'), "\n"))
182183
let cmd = s:create_cmd('string', '')
184+
let cmd = g:pydocstring_ignore_init ? printf('%s --ignore_init', cmd) : cmd
185+
183186
let indent = s:get_indent_width()
184187
let end_lineno = line('.')
185188
call s:execute(

doc/pydocstring.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,5 +204,10 @@ g:pydocstring_enable_mapping *g:pydocstring_enable_mapping*
204204

205205
Default value is '1'
206206

207+
g:pydocstring_ignore_init *g:pydocstring_ignore_init*
208+
Ignore to generate __init__ method docstring.
209+
This option only available at `:PydocstringFormat`
210+
Default value is '0'
211+
207212
==============================================================================
208213
vim:tw=78:ts=8:ft=help:norl:noet:fen:fdl=0:

tests/format.vader

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,42 @@ Expect python:
7676
:param arg2:
7777
"""
7878
pass
79+
80+
Given python (Ignore __init__):
81+
class Foo:
82+
def __init__(self, arg1):
83+
pass
84+
85+
def foo(arg1):
86+
pass
87+
88+
def bar(arg1, arg2):
89+
pass
90+
91+
92+
Execute:
93+
:let g:pydocstring_ignore_init = 1
94+
:PydocstringFormat
95+
:sleep 1
96+
97+
Expect python:
98+
class Foo:
99+
"""Foo."""
100+
101+
def __init__(self, arg1):
102+
pass
103+
104+
def foo(arg1):
105+
"""foo.
106+
107+
:param arg1:
108+
"""
109+
pass
110+
111+
def bar(arg1, arg2):
112+
"""bar.
113+
114+
:param arg1:
115+
:param arg2:
116+
"""
117+
pass

0 commit comments

Comments
 (0)