docs_generate_sales_docs
Generate professional sales-ready documentation for marketplace products like CodeCanyon and ThemeForest. Creates comprehensive Markdown documentation including README, installation guides, API references, and FAQs with optional PDF export.
Instructions
Generate professional sales-ready documentation for CodeCanyon, ThemeForest, and other marketplaces. Creates comprehensive Markdown documentation (README, Installation, API Reference, Configuration, Examples, FAQ, Changelog) with optional PDF export.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectPath | Yes | Path to the PHP project directory to analyze | |
| outputDir | No | Output directory for documentation files (default: ./sales-docs) | |
| productName | Yes | Product name for marketplace listing (e.g., 'Advanced User Management System') | |
| productVersion | No | Product version (default: '1.0.0') | |
| author | Yes | Author or company name (e.g., 'Your Company') | |
| description | Yes | Product description for the README (e.g., 'A comprehensive user management system with advanced features...') | |
| price | No | Product price (optional, e.g., '$49' or '€39') | |
| demoUrl | No | Live demo URL (optional) | |
| supportEmail | No | Support email address (optional) | |
| features | No | List of key product features (e.g., ['User authentication', 'Role-based access', 'API support']) |
Implementation Reference
- src/index.ts:238-288 (schema)Tool registration with input schema definition for 'docs_generate_sales_docs'{ name: "docs_generate_sales_docs", description: "Generate professional sales-ready documentation for CodeCanyon, ThemeForest, and other marketplaces. Creates comprehensive Markdown documentation (README, Installation, API Reference, Configuration, Examples, FAQ, Changelog) with optional PDF export.", inputSchema: { type: "object", properties: { projectPath: { type: "string", description: "Path to the PHP project directory to analyze", }, outputDir: { type: "string", description: "Output directory for documentation files (default: ./sales-docs)", }, productName: { type: "string", description: "Product name for marketplace listing (e.g., 'Advanced User Management System')", }, productVersion: { type: "string", description: "Product version (default: '1.0.0')", }, author: { type: "string", description: "Author or company name (e.g., 'Your Company')", }, description: { type: "string", description: "Product description for the README (e.g., 'A comprehensive user management system with advanced features...')", }, price: { type: "string", description: "Product price (optional, e.g., '$49' or '€39')", }, demoUrl: { type: "string", description: "Live demo URL (optional)", }, supportEmail: { type: "string", description: "Support email address (optional)", }, features: { type: "array", items: { type: "string" }, description: "List of key product features (e.g., ['User authentication', 'Role-based access', 'API support'])", }, }, required: ["projectPath", "productName", "author", "description"], }, },
- src/index.ts:295-328 (registration)Tool dispatch registration in CallToolRequestSchema handler switch case for 'docs_generate_sales_docs'server.setRequestHandler(CallToolRequestSchema, async (request) => { try { const { name, arguments: args } = request.params; switch (name) { case "docs_analyze_project": return await analyzeProject(args); case "docs_generate_structure": return await generateStructure(args); case "docs_create_page": return await createPage(args); case "docs_generate_api": return await generateApi(args); case "docs_build_static": return await buildStatic(args); case "docs_export_pdf": return await exportPdf(args); case "docs_preview": return await preview(args); case "docs_generate_openapi": return await generateOpenApi(args); case "docs_generate_sales_docs": return await generateSalesDocs(args); default: throw new Error(`Unknown tool: ${name}`); } } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Error: ${errorMessage}` }], isError: true, }; } });
- src/index.ts:387-489 (handler)Primary handler function 'generateSalesDocs' that executes the tool logic: analyzes project, generates OpenAPI spec, creates sales docs using helper, exports to files, and returns success messageasync function generateSalesDocs(args: any) { const projectPath = args.projectPath as string; const outputDir = (args.outputDir as string) || './sales-docs'; const productName = args.productName as string; const productVersion = (args.productVersion as string) || '1.0.0'; const author = args.author as string; const description = args.description as string; const price = args.price as string; const demoUrl = args.demoUrl as string; const supportEmail = args.supportEmail as string; const features = (args.features as string[]) || []; try { // Analyze project first const analysisResult = await analyzeProject({ projectPath, language: 'php', deep: true, }); // Extract file analysis from result const files = analysisResult.content[0].text; const analysis = JSON.parse(files); const analyzedFiles = analysis.deepAnalysis?.files || []; // Generate OpenAPI spec const openApiSpec = generateOpenApiSpec(analyzedFiles, { title: `${productName} API`, version: productVersion, description, serverUrl: demoUrl || 'https://api.example.com/v1', }) as OpenAPISpec; // Prepare sales doc options const options: SalesDocOptions = { productName, productVersion, author, description, price, demoUrl, supportEmail, features, requirements: { php: '7.4', framework: analyzedFiles[0]?.framework || 'Generic PHP', database: 'MySQL 5.7+ or PostgreSQL 10+', extensions: ['pdo', 'mbstring', 'openssl', 'curl', 'json'], }, }; // Generate all documentation const docs = generateSalesDocumentation(analyzedFiles, openApiSpec, options); // Export to files const path = await import('path'); const fullOutputDir = path.resolve(projectPath, outputDir); exportSalesDocumentation(docs, fullOutputDir); // Create combined documentation const fs = await import('fs/promises'); const combinedMd = `${docs.readme}\n\n---\n\n${docs.installation}\n\n---\n\n${docs.apiReference}\n\n---\n\n${docs.configuration}\n\n---\n\n${docs.examples}\n\n---\n\n${docs.faq}\n\n---\n\n${docs.changelog}`; const combinedPath = path.join(fullOutputDir, 'COMPLETE_DOCUMENTATION.md'); await fs.writeFile(combinedPath, combinedMd, 'utf-8'); let resultText = `✅ Sales documentation generated successfully!\n\n`; resultText += `📁 Output Directory: ${fullOutputDir}\n\n`; resultText += `📄 Files Created:\n`; resultText += ` - README.md (Main product documentation)\n`; resultText += ` - INSTALLATION.md (Step-by-step setup guide)\n`; resultText += ` - API_REFERENCE.md (${Object.keys(openApiSpec.paths).length} API endpoints)\n`; resultText += ` - CONFIGURATION.md (Configuration options)\n`; resultText += ` - EXAMPLES.md (Code examples in multiple languages)\n`; resultText += ` - FAQ.md (Frequently asked questions)\n`; resultText += ` - CHANGELOG.md (Version history)\n`; resultText += ` - COMPLETE_DOCUMENTATION.md (All-in-one combined docs)\n\n`; resultText += `📊 Documentation Stats:\n`; resultText += ` - API Endpoints: ${Object.keys(openApiSpec.paths).length}\n`; resultText += ` - Security Schemes: ${Object.keys(openApiSpec.components?.securitySchemes || {}).length}\n`; resultText += ` - Frameworks: ${analyzedFiles[0]?.framework || 'PHP'}\n`; resultText += ` - Classes Analyzed: ${analyzedFiles.length}\n\n`; resultText += `💡 Next Steps:\n`; resultText += ` 1. Review generated documentation\n`; resultText += ` 2. Customize with your branding\n`; resultText += ` 3. Generate PDF: pandoc COMPLETE_DOCUMENTATION.md -o Documentation.pdf --toc\n`; resultText += ` 4. Upload to CodeCanyon/ThemeForest\n\n`; resultText += `🎯 Perfect for marketplace sales!`; return { content: [ { type: "text", text: resultText, }, ], }; } catch (error) { throw new Error(`Failed to generate sales documentation: ${error}`); } }
- Core helper function that generates all sections of sales documentation (README, installation guide, API reference, etc.)export function generateSalesDocumentation( files: FileAnalysis[], openApiSpec: OpenAPISpec, options: SalesDocOptions ): { readme: string; installation: string; apiReference: string; configuration: string; examples: string; faq: string; changelog: string; } { return { readme: generateReadme(files, openApiSpec, options), installation: generateInstallationGuide(files, options), apiReference: generateApiReference(openApiSpec, options), configuration: generateConfigurationGuide(files, options), examples: generateExamples(files, openApiSpec, options), faq: generateFAQ(options), changelog: generateChangelog(options) }; }
- Helper function to export generated sales documentation to individual Markdown files in the output directoryexport async function exportSalesDocumentation( docs: ReturnType<typeof generateSalesDocumentation>, outputDir: string ): Promise<void> { const fs = await import('fs/promises'); const path = await import('path'); // Create output directory if it doesn't exist try { await fs.mkdir(outputDir, { recursive: true }); } catch (error) { // Directory might already exist } // Write all documentation files await Promise.all([ fs.writeFile(path.join(outputDir, 'README.md'), docs.readme), fs.writeFile(path.join(outputDir, 'INSTALLATION.md'), docs.installation), fs.writeFile(path.join(outputDir, 'API_REFERENCE.md'), docs.apiReference), fs.writeFile(path.join(outputDir, 'CONFIGURATION.md'), docs.configuration), fs.writeFile(path.join(outputDir, 'EXAMPLES.md'), docs.examples), fs.writeFile(path.join(outputDir, 'FAQ.md'), docs.faq), fs.writeFile(path.join(outputDir, 'CHANGELOG.md'), docs.changelog) ]); }