Skip to content

Commit 7087d68

Browse files
committed
feat(#31): Filter out the self parameter in Python methods
1 parent ce62c8e commit 7087d68

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

autoload/doge/preprocessors/python.vim

+8
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,13 @@ function! doge#preprocessors#python#insert_position(lnum_insert_pos) abort
1616
return a:lnum_insert_pos
1717
endfunction
1818

19+
20+
" A callback function being called after the parameter tokens have been
21+
" extracted. This function will adjust the input if needed.
22+
function! doge#preprocessors#python#parameter_tokens(tokens) abort
23+
" Filer out the 'self' variable in methods.
24+
return filter(a:tokens, {_, token -> token['name'] !=# 'self'})
25+
endfunction
26+
1927
let &cpoptions = s:save_cpo
2028
unlet s:save_cpo

test/filetypes/python/class-methods.vader

+1-4
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@ Do (trigger doge):
1111
:3\<CR>
1212
\<C-d>
1313

14-
Expect python (generated comment with :param tags):
14+
Expect python (generated comment with no :param tags):
1515
class MyClass(object):
1616

1717
def __init__(self: MyClass):
1818
"""
1919
[TODO:description]
2020

21-
:param self MyClass: [TODO:description]
2221
"""
2322
pass
2423
# ==============================================================================
@@ -41,7 +40,6 @@ Expect python (generated comment with :param tags):
4140
"""
4241
[TODO:description]
4342

44-
:param self MyClass: [TODO:description]
4543
:param p1 Sequence[T]: [TODO:description]
4644
:rtype Generator[int, float, str]: [TODO:description]
4745
"""
@@ -67,7 +65,6 @@ Expect python (generated comment with :param tags):
6765
"""
6866
[TODO:description]
6967

70-
:param self [TODO:type]: [TODO:description]
7168
:param args str: [TODO:description]
7269
:param kwargs str: [TODO:description]
7370
:rtype str: [TODO:description]

0 commit comments

Comments
 (0)