Skip to content

Doc Generator

j0KZ edited this page Oct 8, 2025 · 2 revisions

Doc Generator

Auto-generate JSDoc, README, and API documentation from code.

npm version Version

Overview

Doc Generator automatically creates comprehensive documentation from your code, including JSDoc comments, README files, API documentation, and changelogs from git history.

Key Features

  • JSDoc Generation - Complete function and class documentation
  • README Creation - Professional project documentation
  • API Docs - OpenAPI/Swagger specs from code
  • Changelog Generation - From git commit history
  • Markdown Tables - Clean documentation formatting
  • Full Suite - Generate all docs at once

Installation

Quick Install (All Tools)

npx @j0kz/mcp-agents@latest

Install Only Doc Generator

Claude Code:

claude mcp add doc-generator "npx @j0kz/doc-generator-mcp@latest" --scope user

Cursor/Windsurf: Add to mcp_config.json:

{
  "mcpServers": {
    "doc-generator": {
      "command": "npx",
      "args": ["-y", "@j0kz/doc-generator-mcp@latest"]
    }
  }
}

Usage Examples

Generate JSDoc Comments

You: "Add JSDoc comments to all functions in auth.ts"
AI: Generated comprehensive JSDoc with:
    - Function descriptions
    - @param tags with types
    - @returns documentation
    - @throws for error cases...

Create README

You: "Generate README for this project"
AI: Created professional README with:
    - Installation instructions
    - Usage examples
    - API reference
    - Contributing guidelines
    - Badges and TOC...

Generate API Documentation

You: "Create API docs from all TypeScript files in src/"
AI: Generated API documentation with:
    - All exported functions
    - Class documentation
    - Interface definitions
    - Type aliases
    - Examples for each API...

Create Changelog from Git

You: "Generate changelog from v1.0.0 to v1.1.0"
AI: Created changelog with:
    - 5 new features
    - 3 bug fixes
    - 2 performance improvements
    - Grouped by type and author...

API Reference

Tool: generate_jsdoc

Generate JSDoc comments for a TypeScript/JavaScript file.

Parameters:

  • filePath (required): Path to the source file
  • config (optional): JSDoc generation configuration
    • style: 'standard' | 'google' | 'typescript'
    • inferTypes: Infer types from TypeScript
    • includePrivate: Include private members
    • addTodoTags: Add @todo tags for missing documentation

Tool: generate_readme

Generate a comprehensive README.md file from project source code and package.json.

Parameters:

  • projectPath (required): Path to the project root directory
  • config (optional): README generation configuration
    • projectName: Project name
    • version: Project version
    • author: Author information
    • license: License type
    • includeTOC: Include table of contents
    • includeInstallation: Include installation section
    • includeUsage: Include usage examples
    • includeAPI: Include API reference
    • includeBadges: Include badges
    • includeContributing: Include contributing guidelines

Tool: generate_api_docs

Generate comprehensive API documentation from TypeScript/JavaScript source files.

Parameters:

  • projectPath (required): Path to the project source directory
  • config (optional): API documentation configuration
    • includeTOC: Include table of contents
    • sortAlphabetically: Sort members alphabetically
    • includeTypes: Include type definitions
    • includeInterfaces: Include interfaces
    • includeEnums: Include enums
    • includeSourceLinks: Include source code links
    • groupByCategory: Group documentation by category
    • repositoryUrl: Repository URL for source links

Tool: generate_changelog

Generate a changelog from git commit history using conventional commit format.

Parameters:

  • projectPath (required): Path to the git repository
  • config (optional): Changelog generation configuration
    • fromTag: Starting version tag
    • toTag: Ending version tag
    • conventionalCommits: Parse conventional commit format
    • groupByType: Group changes by type (feat, fix, etc.)
    • includeAuthors: Include commit authors
    • includeMerges: Include merge commits
    • linkCommits: Link to commit URLs
    • commitLimit: Number of commits to include

Tool: generate_full_docs

Generate complete documentation suite including JSDoc, README, API documentation, and changelog.

Parameters:

  • projectPath (required): Path to the project root
  • sourceFiles (optional): Array of source files for JSDoc
  • config (optional): Combined configuration for all doc types

Documentation Styles

JSDoc Standard Style

/**
 * Calculate the total price with tax
 * @param {number} price - The base price
 * @param {number} taxRate - The tax rate (0-1)
 * @returns {number} The total price including tax
 * @throws {Error} If price is negative
 */
function calculateTotal(price, taxRate) {
  if (price < 0) throw new Error('Price cannot be negative');
  return price * (1 + taxRate);
}

JSDoc Google Style

/**
 * Calculate the total price with tax
 *
 * @param {number} price The base price
 * @param {number} taxRate The tax rate (0-1)
 * @return {number} The total price including tax
 * @throws {Error} If price is negative
 */
function calculateTotal(price, taxRate) {
  if (price < 0) throw new Error('Price cannot be negative');
  return price * (1 + taxRate);
}

JSDoc TypeScript Style

/**
 * Calculate the total price with tax
 * @param price - The base price
 * @param taxRate - The tax rate (0-1)
 * @returns The total price including tax
 * @throws If price is negative
 */
function calculateTotal(price: number, taxRate: number): number {
  if (price < 0) throw new Error('Price cannot be negative');
  return price * (1 + taxRate);
}

Conventional Commits

Commit Types

  • feat: - New feature
  • fix: - Bug fix
  • docs: - Documentation changes
  • style: - Code style changes
  • refactor: - Code refactoring
  • perf: - Performance improvements
  • test: - Test changes
  • chore: - Build/tooling changes

Example Commits

feat: add user authentication
fix: resolve login timeout issue
docs: update API documentation
refactor: simplify payment processing

Best Practices

1. Document Public APIs

Generate JSDoc for all public interfaces:
"Add JSDoc comments to all exported functions"

2. Keep README Updated

Regenerate after major changes:
"Update README with new features"

3. Maintain Changelog

Generate changelog for each release:
"Create changelog from v1.0.0 to v1.1.0"

4. Use Conventional Commits

Follow commit conventions for better changelogs:
"feat: add dark mode support"

Common Use Cases

Open Source Project

Generate complete documentation suite:
"Create full docs with README, API docs, and changelog"

Internal Library

Document internal APIs:
"Generate JSDoc for all exported functions in src/"

Release Management

Track changes between versions:
"Create changelog from v2.0.0 to v2.1.0"

Onboarding Documentation

Help new developers:
"Generate comprehensive README with usage examples"

Troubleshooting

JSDoc not inferring types

  • Ensure TypeScript files have type annotations
  • Set inferTypes: true in config
  • Verify TypeScript version compatibility

README missing sections

  • Check package.json exists
  • Provide config with required sections
  • Manually add domain-specific content

Changelog has no commits

  • Verify git repository exists
  • Check commit range (fromTag/toTag)
  • Ensure commits follow conventional format

API docs incomplete

  • Verify all files are exported
  • Check file glob patterns
  • Ensure files are valid TypeScript/JavaScript

Integration with Other Tools

With Test Generator

1. Generate API documentation
2. Use test-generator to create tests matching docs
3. Keep tests and docs synchronized

With API Designer

1. Design API with api-designer
2. Generate OpenAPI spec
3. Use doc-generator for markdown docs

With Smart Reviewer

1. Review code quality
2. Add JSDoc where missing
3. Verify documentation completeness

Related Tools

See Also


Need help? Open an issue or check the Troubleshooting Guide

Clone this wiki locally