🤖 An intelligent CLI tool that automatically generates comprehensive documentation for JavaScript/TypeScript projects using AI.
✨ Key Features
- 🧠 AI-Powered Documentation: Utilizes OpenAI's GPT-4 to generate intelligent and contextual documentation
- 📝 Multiple Format Support: Outputs in both Markdown and JSDoc formats
- 🔍 Smart Code Analysis: Automatically analyzes code structure, functions, classes, and relationships
- ⚡ Easy to Use: Simple CLI interface with interactive setup
- 🎨 Customizable: Flexible configuration options to match your documentation needs
- 📦 Project-Wide Support: Documents entire projects or individual files
Before you begin, ensure you have:
- Node.js (v14 or higher)
- OpenAI API key (you'll be prompted for this during setup)
- Install in your project:
npm install auto-docs
- Initialize auto-docs (this will guide you through the setup):
npx auto-docs init
- Generate documentation:
npm run docs
That's it! Your documentation will be generated in the specified output directory (default: ./docs
).
During initialization (auto-docs init
), you'll be guided through setting up your configuration. This creates a .autodocs.json
file with your preferences:
{
"openai": {
"apiKey": "YOUR_OPENAI_API_KEY",
"model": "gpt-4",
"temperature": 0.7
},
"output": {
"format": "markdown",
"directory": "./docs",
"createIndex": true
},
"parser": {
"includePrivate": false,
"includeTodos": true,
"filePatterns": ["**/*.js", "**/*.ts"],
"exclude": ["**/node_modules/**", "**/dist/**", "**/*.test.js"]
}
}
apiKey
: Your OpenAI API keymodel
: AI model to use (default: "gpt-4")temperature
: AI creativity level (0-1, default: 0.7)
format
: Documentation format ("markdown" or "jsdoc")directory
: Output directory pathcreateIndex
: Generate index file (README.md)
includePrivate
: Document private membersincludeTodos
: Include TODO commentsfilePatterns
: Files to processexclude
: Files to ignore
npx auto-docs init
- Sets up configuration file
- Adds npm scripts to package.json
- Guides you through OpenAI API key setup
# Using npm script
npm run docs
# Or directly
npx auto-docs generate
Options:
-c, --config <path>
: Custom config file path-o, --output <path>
: Custom output directory
The generator creates a docs
directory with:
- README.md (index)
- Individual markdown files for each source file
- Nested directory structure matching your project
- Complete API documentation including:
- Function descriptions and parameters
- Class documentation
- Method documentation
- Type definitions
- Code examples
- Dependencies and relationships
For a JavaScript file calculator.js
:
# Calculator
## Overview
A simple calculator module that provides basic mathematical operations.
## Functions
### add(a, b)
Adds two numbers together.
**Parameters:**
- `a` (*number*): First number
- `b` (*number*): Second number
**Returns:** (*number*) The sum of a and b
- Fork the repository
- Create your feature branch:
git checkout -b feature/amazing-feature
- Commit your changes:
git commit -m 'Add amazing feature'
- Push to the branch:
git push origin feature/amazing-feature
- Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues or have questions:
- Check existing issues
- Create a new issue with:
- Your environment details
- Steps to reproduce
- Expected vs actual behavior
- OpenAI for providing the GPT-4 API
- The open-source community for inspiration and tools
- Contributors who help improve this project