diff --git a/README.rst b/README.rst index 73460ae..60f40f5 100644 --- a/README.rst +++ b/README.rst @@ -135,6 +135,15 @@ excptions add to docstring. """ raise Exception('foo') +Ignore generate __init__ docstring +---------------------------------- + +If you want ignore to generate `__init__` docstring, you can set like following. + +.. code:: + + let g:pydocstring_ignore_init = 1 + Thanks ------ diff --git a/autoload/pydocstring.vim b/autoload/pydocstring.vim index 9e246f3..7675249 100644 --- a/autoload/pydocstring.vim +++ b/autoload/pydocstring.vim @@ -15,6 +15,7 @@ let g:pydocstring_doq_path = get( \ 'pydocstring_doq_path', \ printf('%s/lib/doq', expand(':p:h:h')) \ ) +let g:pydocstring_ignore_init = get(g:, 'pydocstring_ignore_init', 0) let s:results = [] @@ -180,6 +181,8 @@ endfunction function! pydocstring#format() abort let lines = printf("%s\n", join(getbufline(bufnr('%'), 1, '$'), "\n")) let cmd = s:create_cmd('string', '') + let cmd = g:pydocstring_ignore_init ? printf('%s --ignore_init', cmd) : cmd + let indent = s:get_indent_width() let end_lineno = line('.') call s:execute( diff --git a/doc/pydocstring.txt b/doc/pydocstring.txt index b014425..127fae7 100644 --- a/doc/pydocstring.txt +++ b/doc/pydocstring.txt @@ -204,5 +204,10 @@ g:pydocstring_enable_mapping *g:pydocstring_enable_mapping* Default value is '1' +g:pydocstring_ignore_init *g:pydocstring_ignore_init* + Ignore to generate __init__ method docstring. + This option only available at `:PydocstringFormat` + Default value is '0' + ============================================================================== vim:tw=78:ts=8:ft=help:norl:noet:fen:fdl=0: diff --git a/tests/format.vader b/tests/format.vader index 133a6cd..dc44dcf 100644 --- a/tests/format.vader +++ b/tests/format.vader @@ -76,3 +76,42 @@ Expect python: :param arg2: """ pass + +Given python (Ignore __init__): + class Foo: + def __init__(self, arg1): + pass + + def foo(arg1): + pass + + def bar(arg1, arg2): + pass + + +Execute: + :let g:pydocstring_ignore_init = 1 + :PydocstringFormat + :sleep 1 + +Expect python: + class Foo: + """Foo.""" + + def __init__(self, arg1): + pass + + def foo(arg1): + """foo. + + :param arg1: + """ + pass + + def bar(arg1, arg2): + """bar. + + :param arg1: + :param arg2: + """ + pass