docs_generate_api
Generate API documentation from code comments like JSDoc and docstrings by providing project path, output path, and language. Supports TypeScript, JavaScript, Python, Go, Rust, Java, and C#.
Instructions
Generate API documentation from code (JSDoc, Docstrings, etc.)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectPath | Yes | Path to the project source code | |
| outputPath | Yes | Output path for API documentation | |
| language | Yes | Programming language |
Implementation Reference
- src/index.ts:13-13 (registration)Imports the generateApi handler function from the tools module
import { generateApi } from "./tools/generateApi.js"; - src/index.ts:111-132 (schema)Tool registration with name 'docs_generate_api' and inputSchema (projectPath, outputPath, language)
name: "docs_generate_api", description: "Generate API documentation from code (JSDoc, Docstrings, etc.)", inputSchema: { type: "object", properties: { projectPath: { type: "string", description: "Path to the project source code", }, outputPath: { type: "string", description: "Output path for API documentation", }, language: { type: "string", description: "Programming language", enum: ["typescript", "javascript", "python", "go", "rust", "java", "csharp"], }, }, required: ["projectPath", "outputPath", "language"], }, }, - src/tools/generateApi.ts:7-81 (handler)Main handler function that generates API documentation instructions based on language
export async function generateApi(args: any) { const { projectPath, outputPath, language } = args as GenerateApiArgs; const instructions: Record<string, string> = { typescript: `📖 TypeScript API Documentation: 1. Install TypeDoc: npm install --save-dev typedoc 2. Generate API docs: npx typedoc --out ${outputPath} ${projectPath} 3. For integration with Docusaurus: npm install --save-dev docusaurus-plugin-typedoc`, javascript: `📖 JavaScript API Documentation: 1. Install JSDoc: npm install --save-dev jsdoc 2. Generate API docs: npx jsdoc -c jsdoc.json -d ${outputPath} ${projectPath} 3. Use JSDoc comments: /** * Description * @param {string} param - Parameter description * @returns {Promise<void>} */`, python: `📖 Python API Documentation: 1. For Sphinx: pip install sphinx sphinx-autodoc 2. Generate API docs: sphinx-apidoc -o ${outputPath} ${projectPath} 3. For MkDocs: pip install mkdocstrings mkdocstrings-python Add to mkdocs.yml: plugins: - mkdocstrings: handlers: python: options: docstring_style: google`, go: `📖 Go API Documentation: 1. Use godoc: godoc -http=:6060 2. Or generate static docs: go doc -all > ${outputPath}/api.md`, rust: `📖 Rust API Documentation: 1. Generate docs: cargo doc --no-deps 2. Open in browser: cargo doc --no-deps --open 3. Output is in target/doc`, }; const instruction = instructions[language] || "Language not supported for API generation"; return { content: [ { type: "text", text: instruction, }, ], }; } - src/tools/generateApi.ts:1-5 (schema)TypeScript interface defining the arguments (projectPath, outputPath, language)
interface GenerateApiArgs { projectPath: string; outputPath: string; language: string; } - src/index.ts:306-307 (registration)Routes the 'docs_generate_api' tool name to the generateApi handler
case "docs_generate_api": return await generateApi(args);