Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>docstring-generator-extNew to Visual Studio Code? Get it now.
docstring-generator-ext

docstring-generator-ext

Shanthosh S

|
37 installs
| (0) | Free
Generate PEP-257 compliant docstrings for Python functions using Gemini AI
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

🧠 Python Docstring Generator

A VSCode extension that automatically generates high-quality, PEP-257 compliant docstrings for your Python functions and methods using Google's Gemini AI — all within your editor.


🚀 Features

  • ✨ One-click Docstring Generation: Instantly create docstrings via context menu or shortcut
  • 🧠 AI-powered Understanding: Uses Gemini AI to infer function purpose, parameters, returns, and exceptions
  • 📚 PEP-257 Compliant: Generates standardized docstrings in Google-style format
  • 💻 Local Execution: No external server — works entirely within VSCode using Gemini API
  • 🔧 Configurable Model: Choose between different Gemini models (gemini-1.5-flash or gemini-2.0-flash)

🛠 Requirements

  • VSCode with Python extension installed
  • A Google Gemini API Key from Google AI Studio
  • Internet access (for model calls)

📥 Installation

Option 1: Install from Marketplace (Coming soon)

Search for Python Docstring Generator in the VSCode Extensions marketplace.

✅ Option 2: Install from .vsix

1. Download the latest `.vsix` file from the [Releases](https://github.com/aijurist/python-docstring-generator/blob/HEAD/releases) section  
2. In VSCode, press `Ctrl+Shift+P` → type `Extensions: Install from VSIX...`  
3. Select the downloaded `.vsix` file  
4. Reload window if prompted

⚙️ Extension Settings

Access settings via: `File → Preferences → Settings` → search `docstringGenerator`.

| Setting                           | Description                                                                 | Default              |
|-----------------------------------|-----------------------------------------------------------------------------|----------------------|
| `docstringGenerator.geminiApiKey` | Your API key from [Google AI Studio](https://aistudio.google.com/app/apikey) | `""`                 |
| `docstringGenerator.modelName`    | Gemini model to use (`gemini-1.5-flash` or `gemini-2.0-flash`)              | `"gemini-2.0-flash"` |

🔐 Get Your API Key

1. Go to [Google AI Studio](https://aistudio.google.com/app/apikey)  
2. Sign in with your Google account  
3. Click **Create API Key**  
4. Copy the key  
5. Open VSCode → Settings → Search "docstringGenerator"  
6. Paste the key into `docstringGenerator.geminiApiKey`

🧪 How to Use

1. Open any Python file in VSCode  
2. Place your cursor inside a function (or select the function code)  
3. **Right-click** → select **"Generate Docstring"**  
or press `Ctrl+Shift+P` → run the **"Generate Docstring"** command  
4. A properly formatted docstring will be inserted above the function body

📝 Example Output

Before

def calculate_total_price(items, tax_rate=0.1, discount=0):
    total = sum(item['price'] for item in items)
    return total * (1 + tax_rate) - discount

After

def calculate_total_price(items, tax_rate=0.1, discount=0):
    """
    Calculate the total price for a list of items including tax and discount.
    
    Args:
        items (list): List of dictionaries containing item information with 'price' key
        tax_rate (float): The tax rate as a decimal (default: 0.1)
        discount (float): Discount amount to subtract from total (default: 0)
    
    Returns:
        float: The calculated total price after tax and discount
        
    Raises:
        ValueError: If tax_rate is negative or items list is empty
    """
    if tax_rate < 0:
        raise ValueError("Tax rate cannot be negative")
    if not items:
        raise ValueError("Items list cannot be empty")
        
    subtotal = sum(item['price'] for item in items)
    total = subtotal * (1 + tax_rate) - discount
    return total

🤖 Supported Gemini Models

You can configure the extension to use one of the following Gemini models:

  • gemini-1.5-flash – lightweight and optimized for speed
  • gemini-2.0-flash – more advanced reasoning and better quality (default)

Change this via the docstringGenerator.modelName setting.


🧑‍💻 Development

Clone & Build

git clone https://github.com/aijurist/python-docstring-generator.git
cd python-docstring-generator
npm install
npm run compile

Launch in VSCode

  • Press F5 to open a new Extension Development Host window with the extension loaded

📦 Package as .vsix

npm install -g vsce
vsce package

This will generate a .vsix file which you or others can install using:

code --install-extension python-docstring-generator-x.x.x.vsix

🗒 Release Notes

0.1.0

  • 🎉 Initial release
  • Generate Google-style docstrings
  • Supports Gemini 1.5 and 2.0 Flash models
  • Manual API key setup via settings
  • Works from both context menu and command palette

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft