Skip to content

Commit 7a80244

Browse files
authored
Add exceptions to docstring (#79)
1 parent a046e4a commit 7a80244

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

README.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,23 @@ You can set custom template
8181
8282
let g:pydocstring_template_path = '/path/to/custom/templates'
8383
84+
Exceptions
85+
----------
86+
87+
If you want add exceptions to docstring, create custom template
88+
and visual select source block and hit `:'<,'>Pydocstring` and then
89+
excptions add to docstring.
90+
91+
.. code::
92+
93+
def foo():
94+
"""Summary of foo.
95+
96+
Raises:
97+
Exception:
98+
"""
99+
raise Exception('foo')
100+
84101
Thanks
85102
------
86103

autoload/pydocstring.vim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,13 @@ function! pydocstring#insert(...) abort
168168
endif
169169
call setpos('.', pos)
170170

171+
let cmd = s:create_cmd('json', 'self,cls')
171172
let lines = join(getline(start_lineno, end_lineno), "\n")
172173
if is_not_range
173174
let lines = printf("%s\n%s%s", lines, indent, 'pass')
175+
let cmd = printf('%s --ignore_exception', cmd)
174176
endif
175177

176-
let cmd = s:create_cmd('json', 'self,cls')
177178
call s:execute(
178179
\ cmd,
179180
\ lines,

0 commit comments

Comments
 (0)