Skip to content

A Visual Studio Code extension designed to effortlessly generate informative comments for your code files. Leveraging a code summarization model via API, this extension streamlines the documentation process, improving code clarity and saving developers time.

Notifications You must be signed in to change notification settings

Sheel-ui/code-to-text

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Code-to-text

Code-to-Text is a Visual Studio Code extension designed to streamline the process of generating comments for your code files. With this extension, you can effortlessly generate informative comments that summarize the functionality and purpose of your code. This repository combines a comment generation modeI with a user-friendly Visual Studio Code extension through an API, providing a seamless experience for developers.

Features

  • Code Summarization Model: The repository hosts code summarization models from SEBIS as an API. This model is specifically trained to analyze code and generate comments.

  • Effortless Comment Generation: The Visual Studio Code extension simplifies the comment generation process. It parses your code file and sends a request to the API, allowing you to quickly generate comments without the need for extensive manual writing.

  • Improved Documentation: By automatically generating comments, Code-to-Text helps improve the overall documentation of your codebase. The tree-sitter implementation also seperate out method arguments in the comments. It saves you time and ensures that your code is well-documented, making it easier for other developers to understand and collaborate.

  • Customization Options: The extension offers various customization options, allowing you to change models as per your preferences. You can adjust the number of models loaded at run time based on the codebase you are working on.

Table of Contents

Getting Started

To get started with Code-to-Text, follow these steps:

API Setup

  1. Make sure you have Python installed on your system.
  2. Navigate to the api directory and create a new environment. Install the required dependencies by running the following commands:
$ cd api
$ conda create -n env <env_name>
$ conda activate <env_name>
$ pip install -r requirements.txt
  1. Start the API service by running the app.py file:
$ python app.py

VS-Extension Setup

  1. Ensure you have Node.js and npm installed on your system.

  2. Navigate to the extension directory and install the required dependencies:

$ cd extension
$ npm i
  1. Launch the extension by running the extension.js file or by pressing F5 in Visual Studio Code.

  2. A new window will open. Open any code file Ctrl + O on which you want to generate comments. Use the command palette F1 or Ctrl + Shift + P and type "generate" to trigger the comment generation.

Changing env variables and Models

API

  1. You can find a .env file in the api directory. Open the file using the following command
$ vi api/.env
  1. You can change HOST, PORT or the ENDPOINT of the flask service here.

Language Support

The current API supports the following languages: Java, Python, JavaScript, Go, Ruby, and PHP. The api/build directory contains Python-usable compiled libraries for these languages. Please note that generating comments for other languages may not produce the desired results.

Changing Models

The .env file in the api directory contains variables that point to the Hugging Face repositories of SEBIS language models. By modifying these repository links, you can switch to different models. For example, you can change the Java model from its current this to a larger model by using a link like this this for improved results.

Specifying Models to Load at Runtime

The MODELS variable in the .env file defines the models to load when starting the Flask app. To reduce memory usage, it is recommended to load models only for the languages for which you want to generate comments.

Extension

  1. You can find a .env file in the extension directory. Open the file using the following command
$ vi extension/.env
  1. You can define HOST, PORT or the ENDPOINT of the flask service here.

Demo

The following demo uses the SEBIS Java large model, which is different from the model specified in the configuration file. To achieve similar results, it is recommended to use the same model.

Alt Text

Happy coding with Code-to-Text!

About

A Visual Studio Code extension designed to effortlessly generate informative comments for your code files. Leveraging a code summarization model via API, this extension streamlines the documentation process, improving code clarity and saving developers time.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages