Coder Social home page Coder Social logo

macurovc / insert-docstring Goto Github PK

View Code? Open in Web Editor NEW
12.0 1.0 4.0 66 KB

This plugin allows the automatic insertion of Google style function docstrings in Python.

License: GNU General Public License v3.0

Emacs Lisp 100.00%
emacs emacs-lisp emacs-plugin emacs-package python docstring-generator google-docstring

insert-docstring's Introduction

Python Docstring Inserter

This repository enables the automatic generation of function docstrings in Python according to the Google style guide. Here is an example:

def fetch_data(url: str, keys: List[int]) -> Mapping[int, str]:
    """This is a short description of this function and can span over multiple
    lines.

    This is a long description of the function with more details about it.

    Args:
        url: This is an argument description, which can span over multiple
            lines too.
        keys: This is a description of the second argument.

    Returns:
        This is a description of the returned data and can be detailed too.

    """

The text gets automatically indented and split on multiple lines.

Install

With MELPA

This package is available on MELPA. You can refer to this page to learn how to use the MELPA repository.

(use-package python-insert-docstring
  :ensure nil
  :quelpa (python-insert-docstring
           :fetcher github
           :repo "macurovc/insert-docstring"))

Manually

Place python-insert-docstring.el in your Emacs load-path. E.g.:

(add-to-list 'load-path (expand-file-name "~/{path/to}/insert-docstring"))
(require 'python-insert-docstring)

Usage

Set in the ~/.emacs file a keybinding such as:

(defun set-python-keybindings ()
  (local-set-key (kbd "C-c i") 'python-insert-docstring-with-google-style-at-point)
  )
(add-hook 'python-mode-hook 'set-python-keybindings)

Now, in a python file, place the cursor on a function, type C-c i and follow the instructions.

Contributing

Any contribution is welcome. The file python-insert-docstring-tests.el contains tests for the functions that don't require user inputs and don't modify a buffer. The tests can be run with the following command:

emacs -batch -l python-insert-docstring.el -l python-insert-docstring-tests.el -f ert-run-tests-batch-and-exit

Each contribution must respect the following requirements:

  • pass the validation of package-lint
  • byte-compilation without errors
  • no errors with M-x checkdoc

insert-docstring's People

Contributors

macurovc avatar mpereira avatar syohex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

insert-docstring's 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.