AI-powered TypeScript docstring generator. Add JSDoc comments to your TypeScript files using local AI or manual input.
- Scans all
.tsand.tsxfiles recursively from your current directory - Interactive selection with arrow key navigation and fuzzy search
- AI-powered generation using local Ollama, or manual input as fallback
- Multiple templates for different documentation styles
- Safe operations with automatic backups before any changes
npm install -g dockidocki- Node.js 16+
- TypeScript files (.ts, .tsx)
- Ollama (optional, for AI generation)
Docki now includes 7 specialized templates designed for different types of TypeScript files, with intelligent auto-detection based on file content and location.
| Template | Best For | Tokens Used |
|---|---|---|
default |
General purpose files | description, emoji, author |
ai-function |
π€ AI/ML utilities, model functions | description, emoji, params, returns, example, author |
api-endpoint |
π REST API handlers, route functions | description, emoji, method, route, params, returns, throws, author |
react-component |
βοΈ React components | description, emoji, props, returns, example, author |
react-hook |
πͺ Custom React hooks (use*) |
description, emoji, params, returns, example, author |
utility |
π§ Helper functions, utilities | description, emoji, params, returns, author |
comprehensive |
π Complex functions needing all docs | All available tokens |
The ai-function template is specifically designed for AI/ML code:
/**
* @description Generates embeddings for text using OpenAI API
*
* @param {string} text - The input text to embed
* @param {string} model - OpenAI model to use (default: text-embedding-ada-002)
* @returns {Promise<number[]>} Array of embedding vectors
*
* @example
* const embeddings = await generateEmbeddings("Hello world", "text-embedding-ada-002")
* console.log(embeddings.length) // 1536
*
* @author AI Team
*/Docki automatically suggests the best template based on:
- File location:
/api/βapi-endpoint,/ai/βai-function,/components/βreact-component - File naming:
useAuth.tsβreact-hook,aiModel.tsβai-function - Content analysis: Detects React components, API handlers, AI/ML keywords
All templates support these tokens (unused tokens are automatically removed):
| Token | Purpose | Example |
|---|---|---|
{{description}} |
Required - Main function description | Processes user authentication |
{{emoji}} |
Optional emoji for visual context | :lock:, :rocket:, :chart: |
{{author}} |
Author attribution | @author John Doe |
{{params}} |
Function parameters | {string} username - User identifier |
{{returns}} |
Return value description | {Promise<User>} Authenticated user object |
{{example}} |
Usage example code | const user = await login('john') |
{{method}} |
HTTP method for API endpoints | POST, GET, DELETE |
{{route}} |
API route path | /api/auth/login |
{{throws}} |
Possible exceptions | {AuthError} When credentials invalid |
{{props}} |
React component props | {ButtonProps} Component properties |
{{generics}} |
Generic type parameters | <T, K extends keyof T> |
You can create custom templates by adding .txt files to the templates/ directory:
my-custom.txt:
/**
* @description {{description}}
*
* @version 1.0.0
* @since {{date}}
* @param {{params}}
* @returns {{returns}}
*
* {{author}}
*/Configuration with template mapping:
{
"templateMap": {
"api-endpoint": "my-custom",
"react-component": "comprehensive"
}
}This maps specific file types to your preferred templates.
Docki supports multiple AI providers for automatic documentation generation:
Use Google's Gemini AI for cloud-based documentation generation:
# Set your API key (get one free at https://makersuite.google.com/app/apikey)
export GEMINI_API_KEY="your-api-key-here"
# Run Docki - it will automatically detect and use Gemini
dockiUse Ollama for completely offline, private documentation generation:
# Install Ollama from https://ollama.ai
# Pull a model
ollama pull codellama:7b
# Run Docki
dockiDocki automatically detects available AI providers in this order:
- Gemini - If
GEMINI_API_KEYis set - Ollama - If installed locally
- Manual - Falls back to manual input if no AI is available
Create a .docstring-cli.json file in your project root:
{
"extensions": [".ts", ".tsx", ".js", ".jsx"],
"excludeDirectories": ["node_modules", "dist", ".git"],
"defaultTemplate": "jsdoc",
"defaultAuthor": "Your Name",
"aiProvider": "gemini",
"geminiModel": "gemini-1.5-flash",
"ollamaModel": "codellama:7b",
"maxDescriptionLength": 80
}- extensions: File extensions to scan for (default: TypeScript files)
- excludeDirectories: Directories to ignore during scanning
- defaultTemplate: Template to use by default
- defaultAuthor: Your name to include in docstrings
- aiProvider: Preferred AI provider:
"gemini","ollama", or"none"(auto-detect if not set) - geminiModel: Gemini model to use (default:
"gemini-1.5-flash") - geminiApiKey: Your Gemini API key. Strongly recommended to use the
GEMINI_API_KEYenvironment variable instead of storing it directly in this file. - ollamaModel: Ollama model to use (default:
"codellama:7b") - maxDescriptionLength: Maximum line length for AI-generated descriptions (default: 80)
MIT Β© Remco Stoeten