// Planu — Documentation Generator Engine
// Public API: generateDocs, generateDocument, generateDiagram
// All implementation lives in src/engine/doc-generator/
import { generateReadme, generateSetupGuide, generateArchitectureDoc, generateApiReference, generateUserGuide, generateDeploymentGuide, } from './doc-generator/guide-generators.js';
import { generateChangelog, generateOnboarding, generateFaq, generateHelpArticles, } from './doc-generator/support-generators.js';
import { generateReleaseNotes, generateRunbook, generateSecurityDoc, generateDatabaseDoc, } from './doc-generator/ops-generators.js';
import { generateArchitectureDecisionLog, generateContributing, } from './doc-generator/team-generators.js';
import { generateMobileDistributionGuide } from './doc-generator/mobile-distribution-guide.js';
import { generateExecutiveSummary } from './doc-generator/executive-summary/index.js';
import { generatePerSpecExecutiveReport, generatePerSpecTechnicalReport, } from './doc-generator/per-spec-report/index.js';
import { generateArchitectureDiagram, generateComponentDiagram, generateDataFlowDiagram, generateSequenceDiagram, generateErDiagram, generateStateMachineDiagram, generateDependencyDiagram, generateDeploymentDiagram, } from './doc-generator/diagrams.js';
function fallbackDoc(type, message) {
    return {
        type,
        title: `Error: ${type}`,
        path: `docs/${type}.html`,
        content: message,
        audience: 'developer',
        sections: [],
        diagrams: [],
        relatedSpecs: [],
    };
}
// === Public API ===
/**
 * Generate documentation for a project.
 * Supports multiple document types and audiences.
 */
export function generateDocs(types, knowledge, specs = [], audience = 'developer', language = 'en') {
    const documents = [];
    for (const docType of types) {
        const doc = generateDocument(docType, knowledge, specs, audience, language);
        documents.push(doc);
    }
    const typeNames = types.join(', ');
    return {
        documents,
        message: `Generated ${documents.length} document(s): ${typeNames}`,
    };
}
/**
 * Generate a single document of a specific type.
 */
export function generateDocument(type, knowledge, specs, audience, language) {
    const generators = {
        'user-guide': () => generateUserGuide(knowledge, specs, language),
        'api-reference': () => generateApiReference(knowledge, specs, language),
        readme: () => generateReadme(knowledge, specs, language),
        'setup-guide': () => generateSetupGuide(knowledge, language),
        changelog: () => generateChangelog(specs, language),
        onboarding: () => generateOnboarding(knowledge, language),
        faq: () => generateFaq(knowledge, specs, language),
        'architecture-doc': () => generateArchitectureDoc(knowledge, language),
        'deployment-guide': () => generateDeploymentGuide(knowledge, language),
        'database-doc': () => generateDatabaseDoc(knowledge, language),
        'help-articles': () => generateHelpArticles(knowledge, specs, language),
        'release-notes': () => generateReleaseNotes(specs, language),
        runbook: () => generateRunbook(knowledge, language),
        'security-doc': () => generateSecurityDoc(knowledge, language),
        'architecture-decision-log': () => generateArchitectureDecisionLog(specs, language),
        contributing: () => generateContributing(knowledge, language),
        'mobile-distribution-guide': () => generateMobileDistributionGuide(knowledge, specs, language),
        'executive-summary': () => generateExecutiveSummary(knowledge, specs, language),
        'per-spec-executive': () => {
            const spec = specs[0];
            return spec
                ? generatePerSpecExecutiveReport(spec, [], [])
                : fallbackDoc('per-spec-executive', 'No spec provided for per-spec-executive report.');
        },
        'per-spec-technical': () => {
            const spec = specs[0];
            return spec
                ? generatePerSpecTechnicalReport(spec, [], [], [])
                : fallbackDoc('per-spec-technical', 'No spec provided for per-spec-technical report.');
        },
    };
    const generator = generators[type];
    if (!generator) {
        return {
            type,
            title: `Unsupported: ${type}`,
            path: `docs/${type}.md`,
            content: `Documentation type "${type}" is not yet supported.`,
            audience,
            sections: [],
            diagrams: [],
            relatedSpecs: [],
        };
    }
    const doc = generator();
    doc.audience = audience;
    return doc;
}
/**
 * Generate a Mermaid diagram for a spec or architecture.
 */
export function generateDiagram(type, knowledge, spec) {
    const generators = {
        'data-flow': () => generateDataFlowDiagram(knowledge),
        sequence: () => generateSequenceDiagram(spec),
        er: () => generateErDiagram(knowledge),
        component: () => generateComponentDiagram(knowledge),
        architecture: () => generateArchitectureDiagram(knowledge),
        'state-machine': () => generateStateMachineDiagram(spec),
        dependency: () => generateDependencyDiagram(knowledge),
        deployment: () => generateDeploymentDiagram(knowledge),
    };
    return (generators[type]?.() ?? {
        type,
        title: `${type} diagram`,
        format: 'mermaid',
        content: `graph LR\n  A[Not yet implemented] --> B[${type}]`,
        description: `${type} diagram placeholder`,
    });
}
//# sourceMappingURL=doc-generator.js.map