docs_generate_structure
Generate a documentation scaffold by analyzing your project. Creates the initial directory structure and configuration files for Docusaurus, MkDocs, or Sphinx frameworks.
Instructions
Generate documentation scaffold/structure based on project analysis. Creates initial directory structure and configuration files.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectPath | Yes | Path to the project directory | |
| framework | Yes | Documentation framework to use | |
| template | No | Template to use (for Docusaurus: classic, facebook, etc.) | |
| outputPath | No | Output path for documentation (default: ./docs) |
Implementation Reference
- src/index.ts:57-83 (registration)Tool registration and schema definition for docs_generate_structure in the tools array
{ name: "docs_generate_structure", description: "Generate documentation scaffold/structure based on project analysis. Creates initial directory structure and configuration files.", inputSchema: { type: "object", properties: { projectPath: { type: "string", description: "Path to the project directory", }, framework: { type: "string", description: "Documentation framework to use", enum: ["docusaurus", "mkdocs", "sphinx"], }, template: { type: "string", description: "Template to use (for Docusaurus: classic, facebook, etc.)", }, outputPath: { type: "string", description: "Output path for documentation (default: ./docs)", }, }, required: ["projectPath", "framework"], }, }, - src/index.ts:302-303 (registration)Handler dispatch case mapping docs_generate_structure to generateStructure function
case "docs_generate_structure": return await generateStructure(args); - src/tools/generateStructure.ts:10-29 (handler)Main handler function that dispatches to framework-specific generators (Docusaurus, MkDocs, Sphinx)
export async function generateStructure(args: any) { const { projectPath, framework, template, outputPath = "docs" } = args as GenerateStructureArgs; try { const fullOutputPath = path.resolve(projectPath, outputPath); switch (framework) { case "docusaurus": return await generateDocusaurus(projectPath, fullOutputPath, template); case "mkdocs": return await generateMkDocs(projectPath, fullOutputPath); case "sphinx": return await generateSphinx(projectPath, fullOutputPath); default: throw new Error(`Unsupported framework: ${framework}`); } } catch (error) { throw new Error(`Failed to generate structure: ${error}`); } } - src/tools/generateStructure.ts:3-8 (schema)TypeScript interface for the tool's input arguments, matching the inputSchema in registration
interface GenerateStructureArgs { projectPath: string; framework: "docusaurus" | "mkdocs" | "sphinx"; template?: string; outputPath?: string; } - src/tools/generateStructure.ts:31-66 (helper)Helper generating Docusaurus setup instructions and returning them as text content
async function generateDocusaurus(projectPath: string, outputPath: string, template?: string) { const availableTemplates = [ "classic", "facebook", "meta", ]; const selectedTemplate = template && availableTemplates.includes(template) ? template : "classic"; const message = `📦 Docusaurus Setup Instructions: 1. Install Docusaurus: cd ${projectPath} npx create-docusaurus@latest ${path.basename(outputPath)} ${selectedTemplate} --typescript 2. Available templates: ${availableTemplates.map(t => `- ${t}`).join("\n ")} 3. Start the development server: cd ${path.basename(outputPath)} npm start 4. Build for production: npm run build The static files will be in the 'build' directory, ready for hosting!`; return { content: [ { type: "text", text: message, }, ], }; } - Helper generating MkDocs setup instructions with mkdocs.yml config and structure
async function generateMkDocs(projectPath: string, outputPath: string) { const configContent = `site_name: My Documentation site_url: https://example.com theme: name: material features: - navigation.tabs - navigation.sections - toc.integrate - search.suggest - search.highlight palette: - scheme: default primary: indigo accent: indigo toggle: icon: material/brightness-7 name: Switch to dark mode - scheme: slate primary: indigo accent: indigo toggle: icon: material/brightness-4 name: Switch to light mode nav: - Home: index.md - Getting Started: getting-started.md - API Reference: api/index.md markdown_extensions: - pymdownx.highlight - pymdownx.superfences - pymdownx.tabbed - admonition - codehilite`; const message = `📦 MkDocs Setup Instructions: 1. Install MkDocs with Material theme: pip install mkdocs mkdocs-material 2. Create the following structure in '${outputPath}': ${outputPath}/ ├── mkdocs.yml └── docs/ ├── index.md ├── getting-started.md └── api/ └── index.md 3. Configuration file (mkdocs.yml): ${configContent} 4. Start the development server: cd ${projectPath} mkdocs serve 5. Build for production: mkdocs build The static files will be in the 'site' directory!`; return { content: [ { type: "text", text: message, }, ], }; } - Helper generating Sphinx setup instructions
async function generateSphinx(projectPath: string, outputPath: string) { const message = `📦 Sphinx Setup Instructions: 1. Install Sphinx: pip install sphinx sphinx-rtd-theme 2. Initialize Sphinx: cd ${projectPath} sphinx-quickstart ${path.basename(outputPath)} 3. Edit conf.py to use the Read the Docs theme: html_theme = 'sphinx_rtd_theme' 4. Build documentation: cd ${path.basename(outputPath)} make html 5. The HTML output will be in '_build/html' For API documentation from Python code: pip install sphinx-autodoc`; return { content: [ { type: "text", text: message, }, ], }; }