Giter Site home page Giter Site logo

vim-python-docstring's Introduction

vim-python-docstring

This is a plugin to Vim and NeoVim for the creation of Python docstrings.

What it does

Docstrings for methods will contain a list of parameters and their type hints, list of raised exceptions and whether the method yields or raises.

Class docstring will have a list of atributes.

usage

It uses Python's ast library for parsing code. This makes it quite robust solution, which can handle function signature such as

def foo(a='foo(c,d)',
    b,
    z):
        pass

Installation

If you use for example Vundle, add Plugin 'pixelneo/vim-python-docstring' to your .vimrc file.

Alternatively if you have Vim 8 and newer, you can clone this repository into ~/.vim/pack/<whatever>/start/ where <whatever> is whatever you want it to be.

If you have neovim, install python provider first: pip3 install pynvim.

Usage

The plugin has only commands which you can map however you like (i use <leader>ss for :Docstring).

  1. Place cursor at the first line of the object (def ... of class ...) for which you want to create a docstring
  2. Then type :Docstring or different command

The plugin uses these commands:

Command Description
Docstring Create full docstring
DocstringTypes Just like :Docstring but includes type hints
DocstringLine Create empty one-line docstring

Options:

There are things you can set.

The g:vpd_indent option

String which you use to indent your code.

Default: ' ' (4 spaces).

let g:vpd_indent = '    '

The g:python_style option

Which docstring style you wish to use.

Default: 'google'

Possible values = ['google', 'numpy', 'rest', 'epytext']

let g:python_style = 'google'

Development

Pull requests are welcome as are feature request and issue reports.

You can encounter some situations in which the plugin may not work as expected. Most notably there may be issues if your keyword for refering to instance is not self -- in such case it may be added to the list of arguments.

There are more unsolved issues.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.