doq (python docstring generator) extension for coc.nvim

Overview

coc-pydocstring

doq (python docstring generator) extension for coc.nvim

coc-pydocstring-demo

Install

CocInstall:

:CocInstall coc-pydocstring

vim-plug:

Plug 'yaegassy/coc-pydocstring', {'do': 'yarn install --frozen-lockfile'}

Feature

Quickly generate docstrings for python.

  • Code Action
  • Command
  • Built-in installer

Configuration options

  • pydocstring.enable: Enable coc-pydocstring extension, default: true
  • pydocstring.doqPath: The path to the doq tool (Absolute path), default: ""
  • pydocstring.builtin.pythonPath: Python 3.x path (Absolute path) to be used for built-in install, default: ""
  • pydocstring.enableInstallPrompt: Prompt the user before install, default: true
  • pydocstring.formatter: Docstring formatter (--formatter), valid options ["sphinx", "google", "numpy"], default: "sphinx"
  • pydocstring.templatePath: Path to template directory (--template_path), default: ""
  • pydocstring.ignoreException: Ignore exception statements (--ignore_exception), default: false
  • pydocstring.ignoreYield: Ignore yield statements (--ignore_yield), default: false
  • pydocstring.ignoreInit: Ignore generate docstring to init method (--ignore_init). This option only available at :CocCommand pydocstring.runFile, default: false
  • pydocstring.enableFileAction: Enable file-level code action, default: false

Code Actions

Example key mapping (Code Action related):

nmap <silent> ga <Plug>(coc-codeaction-line)
xmap <silent> ga <Plug>(coc-codeaction-selected)
nmap <silent> gA <Plug>(coc-codeaction)

Usage:

In a "line" or "selection" containing def, async def, or class, enter the mapped key (e.g. ga) and display a list of code actions that can be performed.

  • Add docstring for "Line or Selected" by pydocstring
  • Add docstring for "File" by pydocstring
    • File-level code actions are disabled (false) by default.
    • If you want to use it, set pydocstring.enableFileAction to true in "coc-settings.json".

Commands

  • pydocstring.runFile: Run doq for file
  • pydocstring.install: Install doq
    • It will be installed in this path:
      • Mac/Linux: ~/.config/coc/extensions/coc-pydocstring-data/doq/venv/bin/doq
      • Windows: ~/AppData/Local/coc/extensions/coc-pydocstring-data/doq/venv/Scripts/doq.exe

Similar plugins

Thanks

License

MIT


This extension is built with create-coc-extension

Comments
  • TypeError: document.getText is not a function

    TypeError: document.getText is not a function

    Hi, thank you for the plugin, it seems very cool.

    I have an error when I run (coc-codeaction-line) then Add docstring for "Line or Selected" by pydocstring:

    Error on request (doCodeAction): Vim(return):Error invoking 'doCodeAction' on channel 3 (coc):
    TypeError: document.getText is not a function
    

    note that CocCommand pydocstring.runFile works well.

    Config: nvim : v0.8.0-dev+448-g7b2b44bce coc-pydocstring: 0.7.3 coc is up to date

    doc is installed by CocCommand pydocstring.install

    opened by xavier-balesi 8
  • Method to install doq without prompt

    Method to install doq without prompt

    I run nvim in a container so would like to be able to get doq installed when building the image using a command like:

    RUN nvim --headless -c ":CocCommand pydocstring.install" +qa
    

    Is there a way to tell if nvim is running in headless mode and call doqInstall directly instead of installWrapper?

    opened by R-Broadley 5
  • [feature] update docstring

    [feature] update docstring

    test.py

    def f(x: int) -> int:
        """f.
    
        :param x:
        :type x: int
        :rtype: int
        """
        return x
    

    change test.py to

    def f(x: float) -> float:
        """f.
    
        :param x:
        :type x: int
        :rtype: int
        """
        return x
    

    Now use codeaction pydocstring

    def f(x: float) -> float:
        """f.
    
        :param x:
        :type x: float
        :rtype: float
        """
        """f.
    
        :param x:
        :type x: int
        :rtype: int
        """
        return x
    

    Expected behaviour:

    def f(x: float) -> float:
        """f.
    
        :param x:
        :type x: float
        :rtype: float
        """
        return x
    

    Thanks!

    opened by Freed-Wu 4
  • Wrong windows path

    Wrong windows path

    The executable in windows is not ~/AppData/Local/coc/extensions/coc-pydocstring-data/doq/venv/bin/doq, it should be ~/AppData/Local/coc/extensions/coc-pydocstring-data/doq/venv/Scripts/doq.exe.

    opened by sainnhe 2
  • Typo:

    Typo: "Add docstirng"

    See here the code action title text says "Add docstiring..." should be "docstring"

    https://github.com/yaegassy/coc-pydocstring/blob/9bb2a0a64a54351ebb15acce6ffa98fb6ef84695/src/action.ts#L83

    opened by R-Broadley 1
  • [question] Why a blank line will be generated at the end

    [question] Why a blank line will be generated at the end

    test.py

    def f(x):
        return x
    

    after coc-pydocstring:

    def f(x):
        """f.
    
        :param x:
        """
        return x
    
    

    A blank line occurs after return x.

    Can it be deleted?

    Thanks!

    opened by Freed-Wu 1
  • please put the mappings on the README.md

    please put the mappings on the README.md

    Please add some minimal mapping and remapping and usage documentation

    At the time of me writing this I have absolutely no idea whatever what the mappings are for per-line, per-selection or vim gestures to call coc-pydocstring. I've already walked through the coc-pydocstring-data which appears to contain only the virtualenv used by your plugin to wrap calls to doq. I've already walked through the node-modules/coc-pydocstring path even though I don't really know anything about coc modules and know little about the node-coc-neovim plugin stack, which makes this exploration very slow for me.

    I still haven't figured out where the vimscript command mappings are, there is no vim documentation that I can find, and absolutely no hint that these commands even exist other than the brief mention in the README.md.

    I love your plugin, you've done a better job than I could have done with implementation of a coc plugin, but I can't use anything except :CocCommand pydocstring-file to make it work. I don't even know what the hooks are in order to create my own mappings. Even the animated gif is missing any kind of OSD keypress magic to show the viewer what keys are being pressed by the author.

    Thank you for your hard work and contribution!

    opened by SkyLeach 1
  • fix: code action's range determination

    fix: code action's range determination

    opened by yaegassy 0
  • fix: Use system global python command in the built-in installer

    fix: Use system global python command in the built-in installer

    There is a problem that if the built-in installer is run while the project's virtual environment is activated, it will use the python commands of that project.

    If the python3/python command detected is a symbolic link, resolve the link and change it to use the system global absolute path.

    opened by yaegassy 0
Example of a CLI with python - know the extension of your files.

extensionCLI Example of a CLI with python - know the extension of your files. Usage: Install the CLI: pip3 install -e . Run the command with "ext" + t

ItanuRomero 5 Dec 29, 2022
Albert launcher extension for converting units of length, mass, speed, temperature, time, current, luminosity, printing measurements, molecular substance, and more

unit-converter-albert-ext Extension for converting units of length, mass, speed, temperature, time, current, luminosity, printing measurements, molecu

Jonah Lawrence 2 Jan 13, 2022
Message commands extension for discord-py-interactions

interactions-message-commands Message commands extension for discord-py-interactions README IS NOT FINISHED YET BUT IT IS A GOOD START Installation pi

null 2 Aug 4, 2022
topalias - Linux alias generator from bash/zsh command history with statistics, written on Python.

topalias topalias - Linux alias generator from bash/zsh command history with statistics, written on Python. Features Generate short alias for popular

Sergey Chudakov 38 May 26, 2022
ghfetch is ai customizable CLI GitHub personal README generator.

ghfetch is ai customizable CLI GitHub personal README generator. Inspired by famous fetch such as screenfetch, neofetch and ufetch, the purpose of this tool is to introduce yourself as if you were a machine.

Alessio Celentano 3 Sep 10, 2021
f90nml - A Fortran namelist parser, generator, and editor

f90nml - A Fortran namelist parser, generator, and editor A Python module and command line tool for parsing Fortran namelist files Documentation The c

Marshall Ward 110 Dec 14, 2022
A CLI password generator

passgen - A CLI password generator Usage python3 main.py <arguments> Arguments Argument Short Description --length -l The length of the password to ge

null 1 Nov 13, 2021
๐ŸThe nx-python plugin allows users to create a basic python application using nx commands.

?? NxPy: Nx Python plugin This project was generated using Nx. The nx-python plugin allows users to create a basic python application using nx command

StandUP Communications 74 Aug 31, 2022
Simple Python Library to display text with color in Python Terminal

pyTextColor v1.0 Introduction pyTextColor is a simple Python Library to display colorful outputs in Terminal, etc. Note: Your Terminal or any software

Siddhesh Chavan 1 Jan 23, 2022
cli simple python script to interact with iphone afc api based on python library( tidevice )

afcclient cli simple python script to interact with iphone afc api based on python library( tidevice ) installation pip3 install -U tidevice cp afccli

fyst_14 2 Jul 15, 2022
Zecwallet-Python is a simple wrapper around the Zecwallet Command Line LightClient written in Python

A wrapper around Zecwallet Command Line LightClient, written in Python Table of Contents About Installation Usage Examples About Zecw

Priveasy 2 Sep 6, 2022
Python command line tool and python engine to label table fields and fields in data files.

Python command line tool and python engine to label table fields and fields in data files. It could help to find meaningful data in your tables and data files or to find Personal identifable information (PII).

APICrafter 22 Dec 5, 2022
xonsh is a Python-powered, cross-platform, Unix-gazing shell

xonsh is a Python-powered, cross-platform, Unix-gazing shell language and command prompt.

xonsh 6.7k Dec 31, 2022
A command-line utility that creates projects from cookiecutters (project templates), e.g. Python package projects, VueJS projects.

Cookiecutter A command-line utility that creates projects from cookiecutters (project templates), e.g. creating a Python package project from a Python

null 18.6k Dec 30, 2022
Dead simple CLI tool to try Python packages - It's never been easier! :package:

try - It's never been easier to try Python packages try is an easy-to-use cli tool to try out Python packages. Features Install specific package versi

Timo Furrer 659 Dec 28, 2022
Python commandline tool for remembering linux/terminal commands

ehh Remember linux commands Commandline tool for remembering linux/terminal commands. It stores your favorite commands in ~/ehh.json in your homedir a

null 56 Nov 10, 2022
A Telegram Bot Written In Python To Upload Medias To telegra.ph

Telegraph-Uploader A Telegram Bot Written In Python To Upload Medias To telegra.ph DEPLOY YOU CAN SIMPLY DEPLOY ON HEROKU BY CLICKING THE BUTTON BELOW

Rithunand 31 Dec 3, 2022
Rich is a Python library for rich text and beautiful formatting in the terminal.

The Rich API makes it easy to add color and style to terminal output. Rich can also render pretty tables, progress bars, markdown, syntax highlighted source code, tracebacks, and more โ€” out of the box.

Will McGugan 41.4k Jan 3, 2023