# GenDocs AI

AI-powered documentation generator that automatically creates comprehensive documentation for your codebase using Google Gemini, OpenAI (ChatGPT), or Anthropic (Claude).

## Features

- **Multiple AI Providers**: Support for Google Gemini, OpenAI, and Claude
- **Automatic README Generation**: Create professional README.md files
- **API Documentation**: Generate detailed API documentation from your code
- **JSDoc Comments**: Automatically add JSDoc comments to functions
- **Code Analysis**: Parse and analyze JavaScript/TypeScript codebases
- **Fast & Easy**: Simple CLI interface with interactive setup
- **Beautiful Output**: Color-coded terminal output with progress indicators

## Installation

### Global Installation

```bash
npm install -g gendocs-ai
```

### Use with npx (No Installation Required)

```bash
npx gendocs-ai init
```

### Local Installation

```bash
npm install gendocs-ai --save-dev
```

## Quick Start

1. **Initialize Configuration**

```bash
gendocs-ai init
```

This will prompt you to:

- Select your AI provider (Gemini, OpenAI, or Claude)
- Enter your API key
- Optionally specify a model

2. **Generate Documentation**

```bash
# Generate full documentation
gendocs-ai generate

# Generate only README
gendocs-ai readme

# Add JSDoc comments
gendocs-ai jsdoc
```

## API Keys

You'll need an API key from one of these providers:

- **Google Gemini**: Get your key at [Google AI Studio](https://makersuite.google.com/app/apikey)
- **OpenAI**: Get your key at [OpenAI Platform](https://platform.openai.com/api-keys)
- **Anthropic Claude**: Get your key at [Anthropic Console](https://console.anthropic.com/)

## Usage

### Commands

#### `init`

Initialize configuration with interactive prompts:

```bash
gendocs-ai init
```

#### `generate`

Generate comprehensive documentation (README + API docs):

```bash
gendocs-ai generate [options]

Options:
  -d, --dir <directory>     Target directory to scan (default: ".")
  -o, --output <directory>  Output directory for docs (default: "./docs")
```

Example:

```bash
gendocs-ai generate --dir ./src --output ./documentation
```

#### `readme`

Generate only README.md:

```bash
gendocs-ai readme [options]

Options:
  -d, --dir <directory>  Target directory to scan (default: ".")
```

#### `jsdoc`

Add JSDoc comments to your code:

```bash
gendocs-ai jsdoc [options]

Options:
  -d, --dir <directory>  Target directory to scan (default: ".")
  -f, --file <file>      Specific file to process
```

Example:

```bash
# Process all files in src/
gendocs-ai jsdoc --dir ./src

# Process a specific file
gendocs-ai jsdoc --file ./src/utils/helper.js
```

#### `config`

Show current configuration:

```bash
gendocs-ai config
```

## Configuration

Configuration is stored in `.gendocs-ai.json` in your project root:

```json
{
  "provider": "gemini",
  "apiKey": "your-api-key",
  "model": "gemini-pro"
}
```

### Default Models

- **Gemini**: `gemini-2.5-flash`
- **OpenAI**: `gpt-4o`
- **Claude**: `claude-3-sonnet`

## Supported File Types

- `.js` - JavaScript
- `.ts` - TypeScript
- `.jsx` - React JSX
- `.tsx` - TypeScript JSX
- `.mjs` - ES Modules
- `.cjs` - CommonJS

## Ignored Directories

The following directories are automatically ignored:

- `node_modules`
- `dist`
- `build`
- `.git`
- `coverage`
- `.next`
- `out`

## Examples

### Generate Documentation for a React Project

```bash
# Navigate to your project
cd my-react-app

# Initialize
gendocs-ai init

# Generate all documentation
gendocs-ai generate --dir ./src --output ./docs
```

### Add JSDoc to a Node.js Project

```bash
# Add JSDoc comments to all files
gendocs-ai jsdoc --dir ./lib

# Add JSDoc to a specific file
gendocs-ai jsdoc --file ./lib/database.js
```

### Generate README for an Express API

```bash
gendocs-ai readme --dir ./routes
```

## Output Examples

### README.md

Generated with project overview, features, installation instructions, usage examples, and API documentation.

### API.md

Comprehensive API documentation including:

- Function signatures
- Parameters and return types
- Class methods and properties
- Import/export information

### api.json

Machine-readable JSON export of your entire codebase structure.

## License

MIT © Pratham Darji

## Acknowledgments

- Built with [Commander.js](https://github.com/tj/commander.js) for CLI
- Powered by [Babel](https://babeljs.io/) for code parsing
- AI providers: Google Gemini, OpenAI, Anthropic Claude

## Support

- 📧 Email: <pratham8355@gmail.com>
- 🐛 Issues: [GitHub Issues](https://github.com/Pratham-Prog861/gendocs-ai/issues)
- 💬 Discussions: [GitHub Discussions](https://github.com/Pratham-Prog861/gendocs-ai/discussions)

---

Made with ❤️ by Pratham Darji
