• Stars
    star
    332
  • Rank 126,957 (Top 3 %)
  • Language
    Vim Script
  • License
    BSD 3-Clause "New...
  • Created almost 13 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Generate Python docstring to your Python source code.

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 insatll 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.

More Repositories

1

vim-jsdoc

Generate JSDoc to your JavaScript code.
Vim Script
441
star
2

vim-slack

Slack for Vim client
Vim Script
106
star
3

py-doq

Docstring generator
Python
44
star
4

vim-textlint

Wrapper for textlint
Vim Script
26
star
5

py-sqlalchemy_seed

Simple data seeder using SQLAlchemy.
Python
25
star
6

vim-genshijin

Genshinize your Japanese text
Vim Script
20
star
7

vim-quickrun-hook-unittest

Quickrun hook for enable to unittest by selecting method.
Vim Script
19
star
8

vim-ojosama

Vim Script
18
star
9

vim-prettier

Prettier-Eslint-Cli for Vim
Vim Script
18
star
10

vim-pokemon

Pokemon might be in your open file....
Vim Script
17
star
11

ts-lehre

Generate document block(JsDoc, EsDoc, TsDoc) from source code
TypeScript
14
star
12

py-qiita

Python wrapper for Qiita API v1.
Python
10
star
13

py-doco

Client library for docomo API written in Python.
Python
10
star
14

vim-flood

A simple Vim plugin for facebook flow
Vim Script
10
star
15

py-mackerel-client

Mackerel client implemented by Python.
Python
8
star
16

unite-sf2

A unite.vim plugin for Symfony2
Vim Script
8
star
17

php-net-kyototycoon

Client library KyotoTycoon for PHP
PHP
8
star
18

py-autodoc

Autodoc Python implementation.
Python
7
star
19

vim-tslint

Vim plugin for tslint
Vim Script
7
star
20

vim-jikoku

Convert given timestamp to local date time and utc
Vim Script
7
star
21

vim-misspell

misspell for Vim.
Vim Script
7
star
22

py-pixela

Pixela API client for Python.
Python
5
star
23

py-robo

Dead simple bot framework
Python
4
star
24

vim-shutup

Supress warnings
Vim Script
4
star
25

unite-zf

A unite.vim plugin for Zend Framework
Vim Script
4
star
26

php-silex-maintenance

Show maintenance to client.
PHP
4
star
27

php-string-filter

Porting p5-string-filter to PHP
PHP
4
star
28

py-pyltsv

Dead simple LTSV parser written in Python C extension
Python
3
star
29

php-net-url-dispatcher

PHP library for Dispatch to controller class from PATH_INFO
PHP
3
star
30

ts-react-static

My React-Static site
TypeScript
3
star
31

ts-react-redux-hooks

PoC of Typescript + [email protected] + React Hooks + react-router
TypeScript
3
star
32

unite-flask

A unite.vim plugin for Flask
Vim Script
3
star
33

vim-syntax-flowtype

Vim Script
3
star
34

cliff-samples

Cliff sample application
Python
3
star
35

gene

Glue of Zend Framework
PHP
3
star
36

vim-snowflake

An asynchronous Python source code checker for Vim.
Vim Script
3
star
37

zf-resources-lang-ja

Japanese translation of Zend Framework language resources
PHP
2
star
38

php-silex-kyototycoon

Silex Net_KyotoTycoon extension
PHP
2
star
39

vim-eslint

An asynchronous Eslint(@typescript-eslint) for Vim.
Vim Script
2
star
40

php-net-okuyama

PHP client library for Okuyama(Distributed key-value-store).
PHP
2
star
41

vim-recents

PoC of vim-prompter
Vim Script
2
star
42

vim-kotoha

vim-kotoha is useful Vim plugin that help you to quote a good phrase!
Vim Script
2
star
43

vim-flocke

Vim Script
2
star
44

php-silex-zf-validate

Silex Zend Validate extension
PHP
2
star
45

php-silex-zf-db

Silex Zend_Db extension
PHP
2
star
46

py-jokk

RESTful mock api server.
Python
2
star
47

vim-quickrun-hook-sphinx

Quickrun hook for Sphinx build
Vim Script
2
star
48

php-wozozo-zenra

PHP library of zenrize Japanese sentence.
PHP
2
star
49

vim-tslint-config

Wrapper for TSLint
Vim Script
2
star
50

py-gene-script

My Flask project generator.
JavaScript
1
star
51

fission

Python paver script stuffs
Python
1
star
52

vim-tsukasa

My extend Tsuquyomi plugin
Vim Script
1
star
53

heavenshell.github.com

My github pages
1
star
54

vim-connpass

Search interface for Connpass
Vim Script
1
star
55

vim-sudden-death

Sudden-death
Vim Script
1
star
56

go-pluginbaby

My Vim plugin updater
Go
1
star
57

rstblog-contrib-youtube

rstblog youtube module
Python
1
star
58

vim-gene-theme

My Vim colorscheme
Vim Script
1
star
59

vim-frontier

My frontend(JavaScript) Vim plugin packs.
Vim Script
1
star
60

sunzi-sudo

Wrapper for Sunzi using Python Fabric
1
star
61

vim-unitquickrun

Simple QuickRun.vim wrapper for rewrite g:quickrun_config dynamically.
Vim Script
1
star
62

tddbc-osaka

TDD Bootcamp Osaka2.0 Python repository
Python
1
star
63

vim-markuplint

Vim Script
1
star
64

p5-Net-Okuyama

Perl5 client library for Okuyama(Distributed key-value-store).
Perl
1
star
65

vim-mouko

Vim Script
1
star
66

gene-docs

Docs for Gene
1
star
67

vim-eslint-config

Wrapper for ESLint [deprecated]
Vim Script
1
star