Skip to content
프로젝트

소개

Generate Python docstring to your Python source code.

개발 도구

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
+1
in 7 days
+1
in 15 days
+1
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

vim-pydocstring

https://github.com/heavenshell/vim-pydocstring/workflows/build/badge.svg?branch=master

./assets/vim-pydocstring.gif

vim-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 and sonictemplate.vim.

Install

Since version 2, vim-pydocstring requires doq.

You can install following command.

$ make install

Note

Activated venv needs to be deactivated before install doq.

This can be automated with vim-plug.

Plug 'heavenshell/vim-pydocstring', { 'do': 'make install', 'for': 'python' }

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

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

Then set installed doq path:

$ which doq
let g:pydocstring_doq_path = path/to/doq

Note

vim-pydocstring support Vim8.

Neovim works since v2.2.0, but if something wrong, send me pull requests to fix it.

If you want use old version checkout 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 shiftwidth if smarttab is set, otherwise softtabstop. For the latter, you need to set like set softtabstop=4.

Example .vimrc

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

Or:

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

Pydocstring use ftplugin, so filetype plugin on required.

Key map

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

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

Or, if you want disable default keymapping, you can set like following.

let g:pydocstring_enable_mapping = 0

Formatter

You can set built-in formatter(Sphinx, Numpy, Google).

let g:pydocstring_formatter = 'numpy'

Custom template

You can set custom template. See example.

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

Exceptions

If you want add exceptions to docstring, create custom template and visual select source block and hit :'<,'>Pydocstring and then excptions add to docstring.

def foo():
    """Summary of foo.

    Raises:
        Exception:
    """
    raise Exception('foo')

Ignore generate __init__ docstring

If you want ignore to generate __init__ docstring, you can set like following.

let g:pydocstring_ignore_init = 1

Thanks

The idea of venv installation is from vim-lsp-settings. Highly applicate @mattn and all vim-lsp-settings contributors.

관련 프로젝트 살펴보기

불러오는 중…