Failure to generate doc string on multi-line function definition in python.
Describe the bug On multiline function definitions there is an error when generating docstrings.
To Reproduce Steps to reproduce the behavior:
- Create multiline function definition.
- Run doctoring generator.
Expected behavior Generate docstrings for multiline function definitions.
Out of vim --version
VIM - Vi IMproved 8.1 (2018 May 18, compiled Jul 16 2019 03:25:28)
macOS version
Included patches: 1-1700
Compiled by Homebrew
Huge version without GUI. Features included (+) or not (-):
+acl -farsi -mouse_sysmouse -tag_any_white
+arabic +file_in_path +mouse_urxvt -tcl
+autocmd +find_in_path +mouse_xterm +termguicolors
+autochdir +float +multi_byte +terminal
-autoservername +folding +multi_lang +terminfo
-balloon_eval -footer -mzscheme +termresponse
+balloon_eval_term +fork() +netbeans_intg +textobjects
-browse +gettext +num64 +textprop
++builtin_terms -hangul_input +packages +timers
+byte_offset +iconv +path_extra +title
+channel +insert_expand +perl -toolbar
+cindent +job +persistent_undo +user_commands
-clientserver +jumplist +postscript +vartabs
+clipboard +keymap +printer +vertsplit
+cmdline_compl +lambda +profile +virtualedit
+cmdline_hist +langmap -python +visual
+cmdline_info +libcall +python3 +visualextra
+comments +linebreak +quickfix +viminfo
+conceal +lispindent +reltime +vreplace
+cryptv +listcmds +rightleft +wildignore
+cscope +localmap +ruby +wildmenu
+cursorbind +lua +scrollbind +windows
+cursorshape +menu +signs +writebackup
+dialog_con +mksession +smartindent -X11
+diff +modify_fname -sound -xfontset
+digraphs +mouse +spell -xim
-dnd -mouseshape +startuptime -xpm
-ebcdic +mouse_dec +statusline -xsmp
+emacs_tags -mouse_gpm -sun_workshop -xterm_clipboard
+eval -mouse_jsbterm +syntax -xterm_save
+ex_extra +mouse_netterm +tag_binary
+extra_search +mouse_sgr -tag_old_static
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
defaults file: "$VIMRUNTIME/defaults.vim"
fall-back for $VIM: "/usr/local/share/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H -DMACOS_X -DMACOS_X_DARWIN -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: clang -L. -fstack-protector-strong -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib -L/usr/local/lib -o vim -lncurses -liconv -lintl -framework AppKit -L/usr/local/opt/lua/lib -llua5.3 -mmacosx-version-min=10.14 -fstack-protector-strong -L/usr/local/lib -L/usr/local/Cellar/perl/5.30.0/lib/perl5/5.30.0/darwin-thread-multi-2level/CORE -lperl -lm -lutil -lc -L/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/config-3.7m-darwin -lpython3.7m -framework CoreFoundation -lruby.2.6
Hi,
Can you provide me with the scenario of the python multi-line definition? Also, if you have any custom DoGe settings, please provide them.
e.g.:
def f(a,
b,
c=1):
pass
<Plug>(doge-generate) should work at every line (L1-4).
@wookayin Having the generator to work on line 1-4 will not happen. Multi-line is supported but you should generate it from the start of your expression (which is line 1 in your case)
My plugin generates documentation based on the expression. It's not a complete parser that can determine your context and adjust to it.
Your scenario should work if you generate it from line 1.
Ah yes, the bug actually seems to be that the documentation is placed after the first line, instead of after the last. I have set
let g:doge_mapping = '<LocalLeader>d'
let g:doge_doc_standard_python = 'numpy'
On my machine:
from typing import Iterator
def test(arg_1: str, arg_2: dict,
arg_3: list, arg_4: tuple) -> Iterator[int]:
pass
results in
from typing import Iterator
def test(arg_1: str
"""
TODO
TODO
Parameters
----------
arg_1 : str
TODO
arg_2 : dict
TODO
arg_3 : list
TODO
arg_4 : tuple
TODO
Returns
-------
Iterator[int]:
TODO
"""
arg_2: dict,
arg_3: list, arg_4: tuple) -> Iterator[int]:
pass
Thank you for creating and releasing this plugin I am excited to use it.
Ah, that is indeed a mistake! This will be on the high prio list to work on.
@ColtonKinstley The issue has been fixed in v1.4.4 and I've added the multi-line scenario of you as a test as well.
Thanks for submitting your issue and providing feedback. If you experience more issues, feel free to submit new issues.