美文网首页
Pydocstring - Python

Pydocstring - Python

作者: 溪风205 | 来源:发表于2020-01-31 09:54 被阅读0次

能够自动生成函数文档注释、类文档注释,包含以下功能。

插入一行文档字符串

插入多行文档字符串

原仓库地址:https://github.com/heavenshell/vim-pydocstring

效果图:https://github.com/heavenshell/vim-pydocstring/blob/master/assets/vim-pydocstring.gif

用法

将光标移动到 def 或 class 关键字所在行,按下 ctrl + l 或在命令行输入Pydocstring, 就可以看到文档字符串模板神奇地出现在当前行下方。

设置

Pydocstring 的缩进取决于 softtabstop 值。你需要给 vim 配置这样的语句 set softtabstop=4。

例 .vimrc 中输入

autocmd FileType python setlocal tabstop = 4 shiftwidth = 4 softtabstop = 4 expandtab

关键映射

如果要更改默认键映射,请在.vimrc中设置以下内容。

nmap <silent> <C-_> <Plug>(pydocstring)

函数文档效果图

生成效果图

指定参数和返回值的类型

相关文档:https://python3-cookbook.readthedocs.io/zh_CN/latest/c07/p03_attach_informatinal_matadata_to_function_arguments.html

相关文章

网友评论

      本文标题:Pydocstring - Python

      本文链接:https://www.haomeiwen.com/subject/vpfgthtx.html