Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Visual Studio Code extension to quickly generate docstrings for python functions using AI(NLP) technology.

License

NotificationsYou must be signed in to change notification settings

graykode/ai-docstring

 
 

Repository files navigation

Build StatusInstallsRating

VSCode Python AI Docstring Generator

Visual Studio Code extension to quickly generate docstrings for python functions using AI(NLP) technology.This project is forked forNilsJPWerner/autoDocstring. Previously, the description of the function had to be written by the user, but the AI would see the code and summarize.

Auto Generate Docstrings

Features

  • AI Quickly generate a docstring snippet that can be tabbed through.
  • Choose between several different types of docstring formats.
  • Infers parameter types through pep484 type hints, default values, and var names.
  • Support for args, kwargs, decorators, errors, and parameter types

Docstring Formats

  • Google (default)
  • docBlockr
  • Numpy
  • Sphinx
  • PEP0257 (coming soon)

Usage

Usage is very simple. You just (1) run the container for the model inference server and (2) install extension in vscode and use.

(1) Run the container for the model inference server

  1. If you have GPU machine :docker run -it -d --gpus 0 -p 5000:5000 graykode/ai-docstring:gpu, after installingnvidia-docker.
  2. If you have only CPU :a. Run flask server withgoogle colab and ngrok(Recommend!)or b. use docker cpu image :docker run -it -d -p 5000:5000 graykode/ai-docstring:cpu
    • At this time, it is very likely to cause OOM problem. We need more memory limit than roughly 2GB.So add--memory 2g --memory-swap parameter in linux and change memory limit inPreferences > Advanced more than 2GB(default) in macOS.

(2) Install extension in vscode and use

Cursor must be on the line directly below the definition to generate full auto-populated docstring

  • Press enter after opening docstring with triple quotes (""" or''')
  • Keyboard shortcut:ctrl+shift+2 orcmd+shift+2 for mac
    • Can be changed in Preferences -> Keyboard Shortcuts -> extension.generateDocstring
  • Command:Generate Docstring
  • Right click menu:Generate Docstring

Extension Settings

Extension Settings are the same as themother project except forautoDocstring.ServerEndpoint :

  • ai-docstring.ServerEndpoint: endpoint address accessible to the server.

About training and dataset

For training data,github/CodeSearchNet was used, and as an initial model, we used Code2NL(Code to Natural Language) fine-tuning tasks inmicrosoft/CodeBERT. For detailed instructions, refer to the paper (CodeBERT: A Pre-Trained Model for Programming and Natural Languages) andthis section.

Inference Benchmark(mean of 100 trials)

Devicebeam_sizemax_source_lengthmax_target_lengthTime(ms)
CPU1256128470
CPU102561281332
CPU1512128511
CPU105121281954
GPU1256128165
GPU10256128381
GPU1512128205
GPU10512128545
  • CPU : Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
  • GPU : Nvidia Tesla T4

License

This project is licensed under theApache 2.0 License which is based on MIT License.

About

Visual Studio Code extension to quickly generate docstrings for python functions using AI(NLP) technology.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Jupyter Notebook52.0%
  • TypeScript38.0%
  • Python8.4%
  • HTML1.0%
  • Dockerfile0.2%
  • Starlark0.2%
  • Shell0.2%

[8]ページ先頭

©2009-2025 Movatter.jp