vim-pydocstring


Ⅰ. 插件描述

Generate Python docstring to your Python script file.

Ⅱ. 基本信息

创建日期:  2012-01-18
使用用户:  200
Github星:  158
插件作者:  Shinya Ohyanagi

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'heavenshell/vim-pydocstring'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'heavenshell/vim-pydocstring'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'heavenshell/vim-pydocstring'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/heavenshell/vim-pydocstring

Ⅳ. 文档说明

pydocstring.vim

.. image:: https://travis-ci.org/heavenshell/vim-pydocstring.svg?branch=master
:target: https://travis-ci.org/heavenshell/vim-pydocstring

.. image:: ./assets/vim-pydocstring.gif

Pydocstring is a generator for Python docstrings and is capable of automatically

  • inserting one-line docstrings
  • inserting multi-line docstrings

This plugin is heavily inspired by phpdoc.vim <http://www.vim.org/scripts/script.php?script_id=1355>_ and sonictemplate.vim <https://github.com/mattn/sonictemplate-vim>_.

Install

Since version 2, pydocstring requires doq <https://pypi.org/project/doq/>_.

You can install following command.

.. code::

$ make install

If you want install doq manually, you can install from PyPi.

.. code::

$ python3 -m venv ./venv
$ ./venv/bin/pip3 install doq

Than set installed doq <https://pypi.org/project/doq/>_ path to g:pydocstring_doq_path.

Note


pydocstring is now support only Vim8.
If you want use old version checkout `1.0.0 <https://github.com/heavenshell/vim-pydocstring/releases/tag/1.0.0>`_

Basic usage
-----------

1. Move your cursor on a `def` or `class` keyword line,
2. type `:Pydocstring` and
3. watch a docstring template magically appear below the current line

Format all
----------

type `:PydocstringFormat` will insert all docstrings to current buffer.

Settings
--------
Pydocstring depends on ``softtabstop``.
You need to set like ``set softtabstop=4``.

Example ``.vimrc``

.. code::

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

Key map
-------

If you want change default keymapping, set following to your `.vimrc`.

.. code::

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

Custom template
---------------

You can set custom template

.. code::

  let g:pydocstring_template_path = '/path/to/custom/templates'

Thanks
------

The idea of venv installation is from `vim-lsp-settings <https://github.com/mattn/vim-lsp-settings>`_.

添加新评论