@forge-ts/gen 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -66,6 +66,83 @@ interface ReadmeSyncOptions {
66
66
  */
67
67
  declare function syncReadme(readmePath: string, symbols: ForgeSymbol[], options?: ReadmeSyncOptions): Promise<boolean>;
68
68
 
69
+ /**
70
+ * A single generated documentation page.
71
+ * @public
72
+ */
73
+ interface DocPage {
74
+ /** Relative path from outDir (e.g., "packages/core/index.md") */
75
+ path: string;
76
+ /** Page content (Markdown or MDX) */
77
+ content: string;
78
+ /** Frontmatter fields */
79
+ frontmatter: Record<string, string | number | boolean>;
80
+ }
81
+ /**
82
+ * Options controlling the doc site generator.
83
+ * @public
84
+ */
85
+ interface SiteGeneratorOptions {
86
+ /** Output format */
87
+ format: "markdown" | "mdx";
88
+ /** SSG target for frontmatter */
89
+ ssgTarget?: "docusaurus" | "mintlify" | "nextra" | "vitepress";
90
+ /** Project name */
91
+ projectName: string;
92
+ /** Project description */
93
+ projectDescription?: string;
94
+ }
95
+ /**
96
+ * Groups symbols by their package based on file path.
97
+ *
98
+ * For monorepos (symbols under `packages/<name>/`) the package name is
99
+ * derived from the directory segment immediately after `packages/`.
100
+ * For non-monorepo projects all symbols fall under the project name.
101
+ *
102
+ * @param symbols - All extracted symbols.
103
+ * @param rootDir - Absolute path to the project root.
104
+ * @returns A map from package name to symbol list.
105
+ * @public
106
+ */
107
+ declare function groupSymbolsByPackage(symbols: ForgeSymbol[], rootDir: string): Map<string, ForgeSymbol[]>;
108
+ /**
109
+ * Generates a full multi-page documentation site from symbols grouped by package.
110
+ *
111
+ * Produces an index page, a getting-started page, and per-package pages for
112
+ * the API reference, types, functions, and examples.
113
+ *
114
+ * @param symbolsByPackage - Symbols grouped by package name.
115
+ * @param config - The resolved {@link ForgeConfig}.
116
+ * @param options - Site generation options.
117
+ * @returns An array of {@link DocPage} objects ready to be written to disk.
118
+ * @public
119
+ */
120
+ declare function generateDocSite(symbolsByPackage: Map<string, ForgeSymbol[]>, config: ForgeConfig, options: SiteGeneratorOptions): DocPage[];
121
+
122
+ /**
123
+ * A single generated SSG configuration file.
124
+ * @public
125
+ */
126
+ interface SSGConfigFile {
127
+ /** Relative path from outDir (e.g., "mint.json", "_meta.json") */
128
+ path: string;
129
+ /** File content */
130
+ content: string;
131
+ }
132
+ /**
133
+ * Generate navigation configuration file(s) for the given SSG target.
134
+ *
135
+ * Returns one file for most targets, but multiple files for Nextra (which
136
+ * uses per-directory `_meta.json` files).
137
+ *
138
+ * @param pages - The {@link DocPage} array produced by `generateDocSite`.
139
+ * @param target - The SSG target.
140
+ * @param projectName - The project name (used in config metadata).
141
+ * @returns An array of {@link SSGConfigFile} objects ready to be written to disk.
142
+ * @public
143
+ */
144
+ declare function generateSSGConfigs(pages: DocPage[], target: "docusaurus" | "mintlify" | "nextra" | "vitepress", projectName: string): SSGConfigFile[];
145
+
69
146
  /**
70
147
  * @forge-ts/gen — Markdown/MDX documentation and llms.txt generator.
71
148
  *
@@ -85,4 +162,4 @@ declare function syncReadme(readmePath: string, symbols: ForgeSymbol[], options?
85
162
  */
86
163
  declare function generate(config: ForgeConfig): Promise<ForgeResult>;
87
164
 
88
- export { type MarkdownOptions, type ReadmeSyncOptions, generate, generateLlmsFullTxt, generateLlmsTxt, generateMarkdown, syncReadme };
165
+ export { type DocPage, type MarkdownOptions, type ReadmeSyncOptions, type SSGConfigFile, type SiteGeneratorOptions, generate, generateDocSite, generateLlmsFullTxt, generateLlmsTxt, generateMarkdown, generateSSGConfigs, groupSymbolsByPackage, syncReadme };
package/dist/index.js CHANGED
@@ -407,6 +407,710 @@ ${injection}
407
407
  return true;
408
408
  }
409
409
 
410
+ // src/site-generator.ts
411
+ import { basename, relative as relative2 } from "path";
412
+ function toAnchor2(text) {
413
+ return text.toLowerCase().replace(/[^a-z0-9\s-]/g, "").trim().replace(/\s+/g, "-");
414
+ }
415
+ function escapePipe(text) {
416
+ return text.replace(/\|/g, "\\|");
417
+ }
418
+ function serializeFrontmatter(fields) {
419
+ if (Object.keys(fields).length === 0) return "";
420
+ const lines = ["---"];
421
+ for (const [key, value] of Object.entries(fields)) {
422
+ lines.push(`${key}: ${value}`);
423
+ }
424
+ lines.push("---");
425
+ return `${lines.join("\n")}
426
+
427
+ `;
428
+ }
429
+ function buildFrontmatterFields(title, description, ssgTarget, sidebarPosition) {
430
+ if (!ssgTarget) return {};
431
+ switch (ssgTarget) {
432
+ case "docusaurus": {
433
+ const fields = {
434
+ title,
435
+ sidebar_label: title
436
+ };
437
+ if (sidebarPosition !== void 0) {
438
+ fields.sidebar_position = sidebarPosition;
439
+ }
440
+ if (description) {
441
+ fields.description = description;
442
+ }
443
+ return fields;
444
+ }
445
+ case "mintlify": {
446
+ const fields = { title };
447
+ if (description) {
448
+ fields.description = description;
449
+ }
450
+ return fields;
451
+ }
452
+ case "nextra":
453
+ return { title };
454
+ case "vitepress": {
455
+ const fields = { title, outline: "deep" };
456
+ if (description) {
457
+ fields.description = description;
458
+ }
459
+ return fields;
460
+ }
461
+ default:
462
+ return {};
463
+ }
464
+ }
465
+ function groupSymbolsByPackage(symbols, rootDir) {
466
+ const result = /* @__PURE__ */ new Map();
467
+ for (const symbol of symbols) {
468
+ const rel = relative2(rootDir, symbol.filePath);
469
+ const monorepoMatch = /^packages[\\/]([^\\/]+)[\\/]/.exec(rel);
470
+ const packageName = monorepoMatch ? monorepoMatch[1] : basename(rootDir);
471
+ const list = result.get(packageName) ?? [];
472
+ list.push(symbol);
473
+ result.set(packageName, list);
474
+ }
475
+ return result;
476
+ }
477
+ var TYPE_KINDS = /* @__PURE__ */ new Set(["interface", "type", "enum"]);
478
+ var FUNCTION_KINDS = /* @__PURE__ */ new Set(["function", "class"]);
479
+ function renderPropertyRow(child) {
480
+ const name = `\`${child.name}\``;
481
+ const type = child.signature ? `\`${escapePipe(child.signature)}\`` : "\u2014";
482
+ const optional = child.signature?.includes("?") || child.signature?.includes("undefined") ? "No" : "Yes";
483
+ const description = escapePipe(child.documentation?.summary ?? "");
484
+ return `| ${name} | ${type} | ${optional} | ${description} |`;
485
+ }
486
+ function renderOverviewPage(packageName, symbols, _options) {
487
+ const exported = symbols.filter(
488
+ (s) => s.exported && s.kind !== "method" && s.kind !== "property"
489
+ );
490
+ const pkgDoc = symbols.map((s) => s.documentation?.tags?.packageDocumentation?.[0]).find(Boolean);
491
+ const lines = [];
492
+ lines.push(`# ${packageName}`);
493
+ lines.push("");
494
+ if (pkgDoc) {
495
+ lines.push(pkgDoc);
496
+ lines.push("");
497
+ }
498
+ if (exported.length > 0) {
499
+ lines.push("## Exported Symbols");
500
+ lines.push("");
501
+ lines.push("| Symbol | Kind | Description |");
502
+ lines.push("|--------|------|-------------|");
503
+ for (const s of exported) {
504
+ const ext = s.kind === "function" ? "()" : "";
505
+ const name = `[\`${s.name}${ext}\`](./api-reference.md#${toAnchor2(`${s.name}${ext}`)})`;
506
+ const summary = escapePipe(s.documentation?.summary ?? "");
507
+ lines.push(`| ${name} | ${s.kind} | ${summary} |`);
508
+ }
509
+ lines.push("");
510
+ }
511
+ return lines.join("\n");
512
+ }
513
+ function renderTypesPage(packageName, symbols, _options) {
514
+ const typeSymbols = symbols.filter((s) => s.exported && TYPE_KINDS.has(s.kind));
515
+ const lines = [];
516
+ lines.push(`# ${packageName} \u2014 Types`);
517
+ lines.push("");
518
+ lines.push("Type contracts exported by this package: interfaces, type aliases, and enums.");
519
+ lines.push("");
520
+ for (const s of typeSymbols) {
521
+ lines.push(`## ${s.name}`);
522
+ lines.push("");
523
+ if (s.documentation?.deprecated) {
524
+ lines.push(`> **Deprecated**: ${s.documentation.deprecated}`);
525
+ lines.push("");
526
+ }
527
+ if (s.documentation?.summary) {
528
+ lines.push(s.documentation.summary);
529
+ lines.push("");
530
+ }
531
+ if (s.signature && s.kind !== "interface") {
532
+ lines.push("```typescript");
533
+ lines.push(s.signature);
534
+ lines.push("```");
535
+ lines.push("");
536
+ }
537
+ const children = (s.children ?? []).filter((c) => c.kind === "property" || c.kind === "method");
538
+ if (children.length > 0) {
539
+ lines.push("| Property | Type | Required | Description |");
540
+ lines.push("|----------|------|----------|-------------|");
541
+ for (const child of children) {
542
+ lines.push(renderPropertyRow(child));
543
+ }
544
+ lines.push("");
545
+ }
546
+ }
547
+ return lines.join("\n");
548
+ }
549
+ function renderFunctionsPage(packageName, symbols, _options) {
550
+ const fnSymbols = symbols.filter((s) => s.exported && FUNCTION_KINDS.has(s.kind));
551
+ const lines = [];
552
+ lines.push(`# ${packageName} \u2014 Functions & Classes`);
553
+ lines.push("");
554
+ lines.push("Functions and classes exported by this package.");
555
+ lines.push("");
556
+ for (const s of fnSymbols) {
557
+ const _ext = s.kind === "function" ? "()" : "";
558
+ const paramSig = s.kind === "function" && s.documentation?.params ? s.documentation.params.map((p) => p.name).join(", ") : "";
559
+ const heading = s.kind === "function" ? `${s.name}(${paramSig})` : s.name;
560
+ lines.push(`## ${heading}`);
561
+ lines.push("");
562
+ if (s.documentation?.deprecated) {
563
+ lines.push(`> **Deprecated**: ${s.documentation.deprecated}`);
564
+ lines.push("");
565
+ }
566
+ if (s.documentation?.summary) {
567
+ lines.push(s.documentation.summary);
568
+ lines.push("");
569
+ }
570
+ if (s.signature) {
571
+ lines.push("**Signature**");
572
+ lines.push("");
573
+ lines.push("```typescript");
574
+ lines.push(s.signature);
575
+ lines.push("```");
576
+ lines.push("");
577
+ }
578
+ const params = s.documentation?.params ?? [];
579
+ if (params.length > 0) {
580
+ lines.push("**Parameters**");
581
+ lines.push("");
582
+ lines.push("| Name | Type | Description |");
583
+ lines.push("|------|------|-------------|");
584
+ for (const p of params) {
585
+ const type = p.type ? `\`${escapePipe(p.type)}\`` : "\u2014";
586
+ lines.push(`| \`${p.name}\` | ${type} | ${escapePipe(p.description)} |`);
587
+ }
588
+ lines.push("");
589
+ }
590
+ if (s.documentation?.returns) {
591
+ const retType = s.documentation.returns.type ? ` \`${s.documentation.returns.type}\`` : "";
592
+ lines.push(`**Returns**${retType} \u2014 ${s.documentation.returns.description}`);
593
+ lines.push("");
594
+ }
595
+ const throws = s.documentation?.throws ?? [];
596
+ if (throws.length > 0) {
597
+ lines.push("**Throws**");
598
+ lines.push("");
599
+ for (const t of throws) {
600
+ const typeStr = t.type ? `\`${t.type}\` \u2014 ` : "";
601
+ lines.push(`- ${typeStr}${t.description}`);
602
+ }
603
+ lines.push("");
604
+ }
605
+ const examples = s.documentation?.examples ?? [];
606
+ if (examples.length > 0) {
607
+ const ex = examples[0];
608
+ lines.push("**Example**");
609
+ lines.push("");
610
+ lines.push(`\`\`\`${ex.language}`);
611
+ lines.push(ex.code.trim());
612
+ lines.push("```");
613
+ lines.push("");
614
+ }
615
+ const methods = (s.children ?? []).filter((c) => c.kind === "method");
616
+ if (methods.length > 0) {
617
+ lines.push("**Methods**");
618
+ lines.push("");
619
+ for (const method of methods) {
620
+ lines.push(`### ${method.name}()`);
621
+ lines.push("");
622
+ if (method.documentation?.summary) {
623
+ lines.push(method.documentation.summary);
624
+ lines.push("");
625
+ }
626
+ if (method.signature) {
627
+ lines.push("```typescript");
628
+ lines.push(method.signature);
629
+ lines.push("```");
630
+ lines.push("");
631
+ }
632
+ }
633
+ }
634
+ }
635
+ return lines.join("\n");
636
+ }
637
+ function renderExamplesPage(packageName, symbols, _options) {
638
+ const exported = symbols.filter(
639
+ (s) => s.exported && s.kind !== "method" && s.kind !== "property"
640
+ );
641
+ const lines = [];
642
+ lines.push(`# ${packageName} \u2014 Examples`);
643
+ lines.push("");
644
+ lines.push("All usage examples from the package, aggregated for quick reference.");
645
+ lines.push("");
646
+ let hasExamples = false;
647
+ for (const s of exported) {
648
+ const examples = s.documentation?.examples ?? [];
649
+ if (examples.length === 0) continue;
650
+ hasExamples = true;
651
+ const ext = s.kind === "function" ? "()" : "";
652
+ lines.push(`## \`${s.name}${ext}\``);
653
+ lines.push("");
654
+ if (s.documentation?.summary) {
655
+ lines.push(`_${s.documentation.summary}_`);
656
+ lines.push("");
657
+ }
658
+ lines.push(`[View in API reference](./api-reference.md#${toAnchor2(s.name)})`);
659
+ lines.push("");
660
+ for (const ex of examples) {
661
+ lines.push(`\`\`\`${ex.language}`);
662
+ lines.push(ex.code.trim());
663
+ lines.push("```");
664
+ lines.push("");
665
+ }
666
+ }
667
+ if (!hasExamples) {
668
+ lines.push("_No examples documented yet._");
669
+ lines.push("");
670
+ }
671
+ return lines.join("\n");
672
+ }
673
+ var KIND_ORDER2 = [
674
+ "function",
675
+ "class",
676
+ "interface",
677
+ "type",
678
+ "enum",
679
+ "variable"
680
+ ];
681
+ var KIND_LABELS2 = {
682
+ function: "Functions",
683
+ class: "Classes",
684
+ interface: "Interfaces",
685
+ type: "Types",
686
+ enum: "Enums",
687
+ variable: "Variables"
688
+ };
689
+ function renderApiSymbol(symbol, depth) {
690
+ const hashes = "#".repeat(depth);
691
+ const ext = symbol.kind === "function" || symbol.kind === "method" ? "()" : "";
692
+ const lines = [];
693
+ lines.push(`${hashes} \`${symbol.name}${ext}\``);
694
+ lines.push("");
695
+ if (symbol.documentation?.deprecated) {
696
+ lines.push(`> **Deprecated**: ${symbol.documentation.deprecated}`);
697
+ lines.push("");
698
+ }
699
+ if (symbol.signature) {
700
+ lines.push("```typescript");
701
+ lines.push(symbol.signature);
702
+ lines.push("```");
703
+ lines.push("");
704
+ }
705
+ if (symbol.documentation?.summary) {
706
+ lines.push(symbol.documentation.summary);
707
+ lines.push("");
708
+ }
709
+ const params = symbol.documentation?.params ?? [];
710
+ if (params.length > 0) {
711
+ lines.push("**Parameters**");
712
+ lines.push("");
713
+ for (const p of params) {
714
+ const typeStr = p.type ? ` (\`${p.type}\`)` : "";
715
+ lines.push(`- \`${p.name}\`${typeStr} \u2014 ${p.description}`);
716
+ }
717
+ lines.push("");
718
+ }
719
+ if (symbol.documentation?.returns) {
720
+ const retType = symbol.documentation.returns.type ? ` (\`${symbol.documentation.returns.type}\`)` : "";
721
+ lines.push(`**Returns**${retType}: ${symbol.documentation.returns.description}`);
722
+ lines.push("");
723
+ }
724
+ const throws = symbol.documentation?.throws ?? [];
725
+ if (throws.length > 0) {
726
+ lines.push("**Throws**");
727
+ lines.push("");
728
+ for (const t of throws) {
729
+ const typeStr = t.type ? `\`${t.type}\` \u2014 ` : "";
730
+ lines.push(`- ${typeStr}${t.description}`);
731
+ }
732
+ lines.push("");
733
+ }
734
+ const examples = symbol.documentation?.examples ?? [];
735
+ if (examples.length > 0) {
736
+ lines.push("**Examples**");
737
+ lines.push("");
738
+ for (const ex of examples) {
739
+ lines.push(`\`\`\`${ex.language}`);
740
+ lines.push(ex.code.trim());
741
+ lines.push("```");
742
+ lines.push("");
743
+ }
744
+ }
745
+ const children = symbol.children ?? [];
746
+ if (children.length > 0 && depth < 5) {
747
+ for (const child of children) {
748
+ lines.push(renderApiSymbol(child, depth + 1));
749
+ }
750
+ }
751
+ return lines.join("\n");
752
+ }
753
+ function renderApiReferencePage(packageName, symbols) {
754
+ const exported = symbols.filter(
755
+ (s) => s.exported && s.kind !== "method" && s.kind !== "property"
756
+ );
757
+ const groups = /* @__PURE__ */ new Map();
758
+ for (const s of exported) {
759
+ const list = groups.get(s.kind) ?? [];
760
+ list.push(s);
761
+ groups.set(s.kind, list);
762
+ }
763
+ const lines = [];
764
+ lines.push(`# ${packageName} \u2014 API Reference`);
765
+ lines.push("");
766
+ for (const kind of KIND_ORDER2) {
767
+ const group = groups.get(kind);
768
+ if (!group || group.length === 0) continue;
769
+ lines.push(`## ${KIND_LABELS2[kind]}`);
770
+ lines.push("");
771
+ for (const s of group) {
772
+ lines.push(renderApiSymbol(s, 3));
773
+ lines.push("");
774
+ }
775
+ }
776
+ return lines.join("\n");
777
+ }
778
+ function renderProjectIndexPage(symbolsByPackage, options) {
779
+ const lines = [];
780
+ lines.push(`# ${options.projectName}`);
781
+ lines.push("");
782
+ if (options.projectDescription) {
783
+ lines.push(options.projectDescription);
784
+ lines.push("");
785
+ }
786
+ lines.push("## Packages");
787
+ lines.push("");
788
+ for (const [pkgName, symbols] of symbolsByPackage) {
789
+ const exported = symbols.filter(
790
+ (s) => s.exported && s.kind !== "method" && s.kind !== "property"
791
+ );
792
+ const pkgDoc = symbols.map((s) => s.documentation?.tags?.packageDocumentation?.[0]).find(Boolean);
793
+ const summary = pkgDoc ?? `${exported.length} exported symbol(s).`;
794
+ lines.push(`### [${pkgName}](./packages/${pkgName}/index.md)`);
795
+ lines.push("");
796
+ lines.push(summary);
797
+ lines.push("");
798
+ }
799
+ return lines.join("\n");
800
+ }
801
+ function renderGettingStartedPage(symbolsByPackage, options) {
802
+ let firstExample;
803
+ let firstSymbolName = "";
804
+ let firstPackageName = "";
805
+ outer: for (const [pkgName, symbols] of symbolsByPackage) {
806
+ for (const s of symbols) {
807
+ if (!s.exported || s.kind !== "function") continue;
808
+ const ex = s.documentation?.examples?.[0];
809
+ if (ex) {
810
+ firstExample = ex;
811
+ firstSymbolName = s.name;
812
+ firstPackageName = pkgName;
813
+ break outer;
814
+ }
815
+ }
816
+ }
817
+ const lines = [];
818
+ lines.push("# Getting Started");
819
+ lines.push("");
820
+ lines.push(`Welcome to **${options.projectName}**.`);
821
+ if (options.projectDescription) {
822
+ lines.push("");
823
+ lines.push(options.projectDescription);
824
+ }
825
+ lines.push("");
826
+ lines.push("## Installation");
827
+ lines.push("");
828
+ lines.push("```bash");
829
+ lines.push(`npm install ${options.projectName}`);
830
+ lines.push("```");
831
+ lines.push("");
832
+ if (firstExample) {
833
+ lines.push("## Quick Start");
834
+ lines.push("");
835
+ lines.push(
836
+ `The following example demonstrates \`${firstSymbolName}\` from the \`${firstPackageName}\` package.`
837
+ );
838
+ lines.push("");
839
+ lines.push(`\`\`\`${firstExample.language}`);
840
+ lines.push(firstExample.code.trim());
841
+ lines.push("```");
842
+ lines.push("");
843
+ }
844
+ lines.push("## Next Steps");
845
+ lines.push("");
846
+ lines.push("- Browse the [API Reference](./packages/)");
847
+ for (const pkgName of symbolsByPackage.keys()) {
848
+ lines.push(` - [${pkgName}](./packages/${pkgName}/api-reference.md)`);
849
+ }
850
+ return lines.join("\n");
851
+ }
852
+ function generateDocSite(symbolsByPackage, config, options) {
853
+ const ext = options.format === "mdx" ? "mdx" : "md";
854
+ const pages = [];
855
+ const indexContent = renderProjectIndexPage(symbolsByPackage, options);
856
+ const indexFrontmatter = buildFrontmatterFields(
857
+ options.projectName,
858
+ options.projectDescription ?? "",
859
+ options.ssgTarget,
860
+ 1
861
+ );
862
+ pages.push({
863
+ path: `index.${ext}`,
864
+ content: `${serializeFrontmatter(indexFrontmatter)}${indexContent.trimEnd()}
865
+ `,
866
+ frontmatter: indexFrontmatter
867
+ });
868
+ const gettingStartedContent = renderGettingStartedPage(symbolsByPackage, options);
869
+ const gettingStartedFrontmatter = buildFrontmatterFields(
870
+ "Getting Started",
871
+ `Quick start guide for ${options.projectName}`,
872
+ options.ssgTarget,
873
+ 2
874
+ );
875
+ pages.push({
876
+ path: `getting-started.${ext}`,
877
+ content: `${serializeFrontmatter(gettingStartedFrontmatter)}${gettingStartedContent.trimEnd()}
878
+ `,
879
+ frontmatter: gettingStartedFrontmatter
880
+ });
881
+ let pkgPosition = 1;
882
+ for (const [pkgName, symbols] of symbolsByPackage) {
883
+ const pkgBase = `packages/${pkgName}`;
884
+ const overviewContent = renderOverviewPage(pkgName, symbols, options);
885
+ const overviewFrontmatter = buildFrontmatterFields(
886
+ pkgName,
887
+ `${pkgName} package overview`,
888
+ options.ssgTarget,
889
+ pkgPosition
890
+ );
891
+ pages.push({
892
+ path: `${pkgBase}/index.${ext}`,
893
+ content: `${serializeFrontmatter(overviewFrontmatter)}${overviewContent.trimEnd()}
894
+ `,
895
+ frontmatter: overviewFrontmatter
896
+ });
897
+ const apiContent = renderApiReferencePage(pkgName, symbols);
898
+ const apiFrontmatter = buildFrontmatterFields(
899
+ `${pkgName} \u2014 API Reference`,
900
+ `Full API reference for the ${pkgName} package`,
901
+ options.ssgTarget
902
+ );
903
+ pages.push({
904
+ path: `${pkgBase}/api-reference.${ext}`,
905
+ content: `${serializeFrontmatter(apiFrontmatter)}${apiContent.trimEnd()}
906
+ `,
907
+ frontmatter: apiFrontmatter
908
+ });
909
+ const typesContent = renderTypesPage(pkgName, symbols, options);
910
+ const typesFrontmatter = buildFrontmatterFields(
911
+ `${pkgName} \u2014 Types`,
912
+ `Type contracts for the ${pkgName} package`,
913
+ options.ssgTarget
914
+ );
915
+ pages.push({
916
+ path: `${pkgBase}/types.${ext}`,
917
+ content: `${serializeFrontmatter(typesFrontmatter)}${typesContent.trimEnd()}
918
+ `,
919
+ frontmatter: typesFrontmatter
920
+ });
921
+ const functionsContent = renderFunctionsPage(pkgName, symbols, options);
922
+ const functionsFrontmatter = buildFrontmatterFields(
923
+ `${pkgName} \u2014 Functions`,
924
+ `Functions and classes for the ${pkgName} package`,
925
+ options.ssgTarget
926
+ );
927
+ pages.push({
928
+ path: `${pkgBase}/functions.${ext}`,
929
+ content: `${serializeFrontmatter(functionsFrontmatter)}${functionsContent.trimEnd()}
930
+ `,
931
+ frontmatter: functionsFrontmatter
932
+ });
933
+ const examplesContent = renderExamplesPage(pkgName, symbols, options);
934
+ const examplesFrontmatter = buildFrontmatterFields(
935
+ `${pkgName} \u2014 Examples`,
936
+ `Usage examples for the ${pkgName} package`,
937
+ options.ssgTarget
938
+ );
939
+ pages.push({
940
+ path: `${pkgBase}/examples.${ext}`,
941
+ content: `${serializeFrontmatter(examplesFrontmatter)}${examplesContent.trimEnd()}
942
+ `,
943
+ frontmatter: examplesFrontmatter
944
+ });
945
+ pkgPosition++;
946
+ }
947
+ void config;
948
+ return pages;
949
+ }
950
+
951
+ // src/ssg-config.ts
952
+ function pageSlug(pagePath) {
953
+ return pagePath.replace(/\.[^.]+$/, "");
954
+ }
955
+ function partitionPages(pages) {
956
+ const topLevel = [];
957
+ const byPackage = /* @__PURE__ */ new Map();
958
+ for (const page of pages) {
959
+ const slug = pageSlug(page.path);
960
+ const packageMatch = /^packages\/([^/]+)\/(.+)$/.exec(slug);
961
+ if (packageMatch) {
962
+ const pkgName = packageMatch[1];
963
+ const list = byPackage.get(pkgName) ?? [];
964
+ list.push(slug);
965
+ byPackage.set(pkgName, list);
966
+ } else {
967
+ topLevel.push(slug);
968
+ }
969
+ }
970
+ return { topLevel, byPackage };
971
+ }
972
+ function slugToLabel(slug) {
973
+ return slug.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
974
+ }
975
+ function generateMintlifyConfig(pages, projectName) {
976
+ const { topLevel, byPackage } = partitionPages(pages);
977
+ const navigation = [];
978
+ if (topLevel.length > 0) {
979
+ navigation.push({
980
+ group: "Getting Started",
981
+ pages: topLevel
982
+ });
983
+ }
984
+ if (byPackage.size > 0) {
985
+ const packageGroups = [];
986
+ for (const [pkgName, slugs] of byPackage) {
987
+ packageGroups.push({
988
+ group: pkgName,
989
+ pages: slugs
990
+ });
991
+ }
992
+ navigation.push({
993
+ group: "Packages",
994
+ pages: packageGroups
995
+ });
996
+ }
997
+ const config = {
998
+ $schema: "https://mintlify.com/schema.json",
999
+ name: projectName,
1000
+ navigation
1001
+ };
1002
+ return {
1003
+ path: "mint.json",
1004
+ content: `${JSON.stringify(config, null, 2)}
1005
+ `
1006
+ };
1007
+ }
1008
+ function generateDocusaurusConfig(pages, _projectName) {
1009
+ const { topLevel, byPackage } = partitionPages(pages);
1010
+ const items = [...topLevel];
1011
+ for (const [pkgName, slugs] of byPackage) {
1012
+ items.push({
1013
+ type: "category",
1014
+ label: pkgName,
1015
+ items: slugs
1016
+ });
1017
+ }
1018
+ const sidebarObj = { docs: items };
1019
+ const json = JSON.stringify(sidebarObj, null, 2);
1020
+ const content = `/** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */
1021
+ const sidebars = ${json};
1022
+ module.exports = sidebars;
1023
+ `;
1024
+ return {
1025
+ path: "sidebars.js",
1026
+ content
1027
+ };
1028
+ }
1029
+ function generateNextraConfigs(pages, _projectName) {
1030
+ const { topLevel, byPackage } = partitionPages(pages);
1031
+ const files = [];
1032
+ const rootMeta = {};
1033
+ for (const slug of topLevel) {
1034
+ const segment = slug.split("/").pop() ?? slug;
1035
+ rootMeta[segment] = slugToLabel(segment);
1036
+ }
1037
+ if (byPackage.size > 0) {
1038
+ rootMeta.packages = "Packages";
1039
+ }
1040
+ files.push({
1041
+ path: "_meta.json",
1042
+ content: `${JSON.stringify(rootMeta, null, 2)}
1043
+ `
1044
+ });
1045
+ for (const [pkgName, slugs] of byPackage) {
1046
+ const pkgMeta = {};
1047
+ for (const slug of slugs) {
1048
+ const segment = slug.split("/").pop() ?? slug;
1049
+ pkgMeta[segment] = slugToLabel(segment);
1050
+ }
1051
+ files.push({
1052
+ path: `packages/${pkgName}/_meta.json`,
1053
+ content: `${JSON.stringify(pkgMeta, null, 2)}
1054
+ `
1055
+ });
1056
+ }
1057
+ if (byPackage.size > 1) {
1058
+ const packagesMeta = {};
1059
+ for (const pkgName of byPackage.keys()) {
1060
+ packagesMeta[pkgName] = pkgName;
1061
+ }
1062
+ files.push({
1063
+ path: "packages/_meta.json",
1064
+ content: `${JSON.stringify(packagesMeta, null, 2)}
1065
+ `
1066
+ });
1067
+ }
1068
+ return files;
1069
+ }
1070
+ function generateVitePressConfig(pages, _projectName) {
1071
+ const { topLevel, byPackage } = partitionPages(pages);
1072
+ const sidebar = [];
1073
+ if (topLevel.length > 0) {
1074
+ const items = topLevel.map((slug) => {
1075
+ const segment = slug.split("/").pop() ?? slug;
1076
+ const link = slug === "index" ? "/" : `/${slug}`;
1077
+ return { text: slugToLabel(segment), link };
1078
+ });
1079
+ sidebar.push({ text: "Getting Started", items });
1080
+ }
1081
+ for (const [pkgName, slugs] of byPackage) {
1082
+ const items = slugs.map((slug) => {
1083
+ const segment = slug.split("/").pop() ?? slug;
1084
+ const isIndex = segment === "index";
1085
+ const link = isIndex ? `/packages/${pkgName}/` : `/${slug}`;
1086
+ return { text: slugToLabel(segment), link };
1087
+ });
1088
+ sidebar.push({ text: pkgName, items });
1089
+ }
1090
+ return {
1091
+ path: ".vitepress/sidebar.json",
1092
+ content: `${JSON.stringify(sidebar, null, 2)}
1093
+ `
1094
+ };
1095
+ }
1096
+ function generateSSGConfigs(pages, target, projectName) {
1097
+ switch (target) {
1098
+ case "mintlify":
1099
+ return [generateMintlifyConfig(pages, projectName)];
1100
+ case "docusaurus":
1101
+ return [generateDocusaurusConfig(pages, projectName)];
1102
+ case "nextra":
1103
+ return generateNextraConfigs(pages, projectName);
1104
+ case "vitepress":
1105
+ return [generateVitePressConfig(pages, projectName)];
1106
+ default: {
1107
+ const _exhaustive = target;
1108
+ void _exhaustive;
1109
+ return [];
1110
+ }
1111
+ }
1112
+ }
1113
+
410
1114
  // src/index.ts
411
1115
  import { mkdir, writeFile as writeFile2 } from "fs/promises";
412
1116
  import { join } from "path";
@@ -423,6 +1127,30 @@ async function generate(config) {
423
1127
  const ext = format === "mdx" ? "mdx" : "md";
424
1128
  await writeFile2(join(config.outDir, `api-reference.${ext}`), content, "utf8");
425
1129
  }
1130
+ const projectName = config.rootDir.split("/").pop() ?? "Project";
1131
+ const symbolsByPackage = groupSymbolsByPackage(symbols, config.rootDir);
1132
+ for (const format of config.gen.formats) {
1133
+ const pages = generateDocSite(symbolsByPackage, config, {
1134
+ format,
1135
+ ssgTarget: config.gen.ssgTarget,
1136
+ projectName
1137
+ });
1138
+ for (const page of pages) {
1139
+ const pagePath = join(config.outDir, page.path);
1140
+ const pageDir = pagePath.substring(0, pagePath.lastIndexOf("/"));
1141
+ await mkdir(pageDir, { recursive: true });
1142
+ await writeFile2(pagePath, page.content, "utf8");
1143
+ }
1144
+ if (config.gen.ssgTarget) {
1145
+ const configFiles = generateSSGConfigs(pages, config.gen.ssgTarget, projectName);
1146
+ for (const configFile of configFiles) {
1147
+ const configPath = join(config.outDir, configFile.path);
1148
+ const configDir = configPath.substring(0, configPath.lastIndexOf("/"));
1149
+ await mkdir(configDir, { recursive: true });
1150
+ await writeFile2(configPath, configFile.content, "utf8");
1151
+ }
1152
+ }
1153
+ }
426
1154
  if (config.gen.llmsTxt) {
427
1155
  const llms = generateLlmsTxt(symbols, config);
428
1156
  await writeFile2(join(config.outDir, "llms.txt"), llms, "utf8");
@@ -442,9 +1170,12 @@ async function generate(config) {
442
1170
  }
443
1171
  export {
444
1172
  generate,
1173
+ generateDocSite,
445
1174
  generateLlmsFullTxt,
446
1175
  generateLlmsTxt,
447
1176
  generateMarkdown,
1177
+ generateSSGConfigs,
1178
+ groupSymbolsByPackage,
448
1179
  syncReadme
449
1180
  };
450
1181
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/llms.ts","../src/markdown.ts","../src/readme-sync.ts","../src/index.ts"],"sourcesContent":["import type { ForgeConfig, ForgeSymbol } from \"@forge-ts/core\";\n\n/**\n * Derives a compact one-line signature for routing manifest entries.\n * @internal\n */\nfunction compactEntry(symbol: ForgeSymbol): string {\n\tif (symbol.signature) {\n\t\treturn symbol.signature;\n\t}\n\tconst ext = symbol.kind === \"function\" ? \"()\" : \"\";\n\treturn `${symbol.kind} ${symbol.name}${ext}`;\n}\n\n/**\n * Generates an `llms.txt` routing manifest from the extracted symbols.\n *\n * The file follows the llms.txt specification: a compact, structured overview\n * designed to help large language models navigate a project's documentation.\n *\n * @param symbols - The symbols to include.\n * @param config - The resolved {@link ForgeConfig}.\n * @returns The generated `llms.txt` content as a string.\n * @public\n */\nexport function generateLlmsTxt(symbols: ForgeSymbol[], config: ForgeConfig): string {\n\tconst exported = symbols.filter((s) => s.exported);\n\tconst projectName = config.rootDir.split(\"/\").pop() ?? \"Project\";\n\n\tconst lines: string[] = [];\n\n\tlines.push(`# ${projectName}`);\n\tlines.push(`> Auto-generated API documentation`);\n\tlines.push(\"\");\n\n\t// Sections block — link to generated files\n\tlines.push(\"## Sections\");\n\tlines.push(\"\");\n\tif (config.gen.formats.includes(\"markdown\")) {\n\t\tlines.push(\"- [API Reference](./api-reference.md): Full API documentation\");\n\t}\n\tif (config.gen.formats.includes(\"mdx\")) {\n\t\tlines.push(\"- [API Reference](./api-reference.mdx): Full API documentation (MDX)\");\n\t}\n\tif (config.gen.llmsTxt) {\n\t\tlines.push(\"- [Full Context](./llms-full.txt): Dense context for LLM consumption\");\n\t}\n\tlines.push(\"\");\n\n\t// Quick Reference block\n\tif (exported.length > 0) {\n\t\tlines.push(\"## Quick Reference\");\n\t\tlines.push(\"\");\n\t\tfor (const symbol of exported) {\n\t\t\tconst summary = symbol.documentation?.summary ?? \"\";\n\t\t\tconst entry = compactEntry(symbol);\n\t\t\tlines.push(summary ? `${entry} - ${summary}` : entry);\n\t\t}\n\t\tlines.push(\"\");\n\t}\n\n\treturn lines.join(\"\\n\");\n}\n\n/**\n * Renders a full parameter list section.\n * @internal\n */\nfunction renderParams(params: NonNullable<ForgeSymbol[\"documentation\"]>[\"params\"]): string {\n\tif (!params || params.length === 0) return \"\";\n\tconst lines: string[] = [\"\", \"Parameters:\"];\n\tfor (const p of params) {\n\t\tconst typeStr = p.type ? ` (${p.type})` : \"\";\n\t\tlines.push(`- ${p.name}${typeStr}: ${p.description}`);\n\t}\n\treturn lines.join(\"\\n\");\n}\n\n/**\n * Renders a single symbol section for llms-full.txt.\n * @internal\n */\nfunction renderFullSymbol(symbol: ForgeSymbol, depth: number): string {\n\tconst hashes = \"#\".repeat(depth);\n\tconst ext = symbol.kind === \"function\" || symbol.kind === \"method\" ? \"()\" : \"\";\n\tconst lines: string[] = [];\n\n\tlines.push(`${hashes} ${symbol.name}${ext}`);\n\n\tif (symbol.signature) {\n\t\tlines.push(\"\");\n\t\tlines.push(symbol.signature);\n\t}\n\n\tif (symbol.documentation?.deprecated) {\n\t\tlines.push(\"\");\n\t\tlines.push(`DEPRECATED: ${symbol.documentation.deprecated}`);\n\t}\n\n\tif (symbol.documentation?.summary) {\n\t\tlines.push(\"\");\n\t\tlines.push(symbol.documentation.summary);\n\t}\n\n\tconst params = symbol.documentation?.params ?? [];\n\tconst paramBlock = renderParams(params);\n\tif (paramBlock) {\n\t\tlines.push(paramBlock);\n\t}\n\n\tif (symbol.documentation?.returns) {\n\t\tconst retType = symbol.documentation.returns.type\n\t\t\t? ` (${symbol.documentation.returns.type})`\n\t\t\t: \"\";\n\t\tlines.push(\"\");\n\t\tlines.push(`Returns${retType}: ${symbol.documentation.returns.description}`);\n\t}\n\n\tconst examples = symbol.documentation?.examples ?? [];\n\tif (examples.length > 0) {\n\t\tlines.push(\"\");\n\t\tlines.push(\"Example:\");\n\t\tfor (const ex of examples) {\n\t\t\tconst exLines = ex.code.trim().split(\"\\n\");\n\t\t\tfor (const l of exLines) {\n\t\t\t\tlines.push(` ${l}`);\n\t\t\t}\n\t\t}\n\t}\n\n\t// Render children inline\n\tconst children = symbol.children ?? [];\n\tif (children.length > 0 && depth < 5) {\n\t\tlines.push(\"\");\n\t\tlines.push(\"Members:\");\n\t\tfor (const child of children) {\n\t\t\tlines.push(\"\");\n\t\t\tconst childSection = renderFullSymbol(child, depth + 1);\n\t\t\t// indent child one level\n\t\t\tfor (const cl of childSection.split(\"\\n\")) {\n\t\t\t\tlines.push(cl);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn lines.join(\"\\n\");\n}\n\n/**\n * Generates an `llms-full.txt` dense context file from the extracted symbols.\n *\n * Unlike `llms.txt`, this file contains complete documentation for every\n * exported symbol, intended for LLM ingestion that requires full context.\n *\n * @param symbols - The symbols to include.\n * @param config - The resolved {@link ForgeConfig}.\n * @returns The generated `llms-full.txt` content as a string.\n * @public\n */\nexport function generateLlmsFullTxt(symbols: ForgeSymbol[], config: ForgeConfig): string {\n\tconst exported = symbols.filter(\n\t\t(s) => s.exported && s.kind !== \"method\" && s.kind !== \"property\",\n\t);\n\tconst projectName = config.rootDir.split(\"/\").pop() ?? \"Project\";\n\n\tconst lines: string[] = [];\n\n\tlines.push(`# ${projectName} - Full Context`);\n\tlines.push(\"\");\n\tlines.push(`Root: ${config.rootDir}`);\n\tlines.push(`Generated: ${new Date().toISOString()}`);\n\tlines.push(\"\");\n\n\t// Group by kind\n\tconst kindGroups: Record<string, ForgeSymbol[]> = {};\n\tfor (const symbol of exported) {\n\t\tconst list = kindGroups[symbol.kind] ?? [];\n\t\tlist.push(symbol);\n\t\tkindGroups[symbol.kind] = list;\n\t}\n\n\tconst kindOrder: Array<ForgeSymbol[\"kind\"]> = [\n\t\t\"function\",\n\t\t\"class\",\n\t\t\"interface\",\n\t\t\"type\",\n\t\t\"enum\",\n\t\t\"variable\",\n\t];\n\n\tconst kindLabels: Record<string, string> = {\n\t\tfunction: \"Functions\",\n\t\tclass: \"Classes\",\n\t\tinterface: \"Interfaces\",\n\t\ttype: \"Types\",\n\t\tenum: \"Enums\",\n\t\tvariable: \"Variables\",\n\t};\n\n\tfor (const kind of kindOrder) {\n\t\tconst group = kindGroups[kind];\n\t\tif (!group || group.length === 0) continue;\n\n\t\tlines.push(`## ${kindLabels[kind]}`);\n\t\tlines.push(\"\");\n\n\t\tfor (const symbol of group) {\n\t\t\tlines.push(renderFullSymbol(symbol, 3));\n\t\t\tlines.push(\"\");\n\t\t}\n\t}\n\n\treturn `${lines\n\t\t.join(\"\\n\")\n\t\t.replace(/\\n{3,}/g, \"\\n\\n\")\n\t\t.trimEnd()}\\n`;\n}\n","import { relative } from \"node:path\";\nimport type { ForgeConfig, ForgeSymbol } from \"@forge-ts/core\";\n\n/**\n * Options controlling Markdown output.\n * @public\n */\nexport interface MarkdownOptions {\n\t/** Whether to use MDX syntax (default: Markdown). */\n\tmdx?: boolean;\n}\n\n/** Display labels for each symbol kind. */\nconst KIND_LABELS: Record<ForgeSymbol[\"kind\"], string> = {\n\tfunction: \"Functions\",\n\tclass: \"Classes\",\n\tinterface: \"Interfaces\",\n\ttype: \"Types\",\n\tenum: \"Enums\",\n\tvariable: \"Variables\",\n\tmethod: \"Methods\",\n\tproperty: \"Properties\",\n};\n\n/** Canonical ordering for top-level kind groups. */\nconst KIND_ORDER: Array<ForgeSymbol[\"kind\"]> = [\n\t\"function\",\n\t\"class\",\n\t\"interface\",\n\t\"type\",\n\t\"enum\",\n\t\"variable\",\n];\n\n/** Convert a label to a GitHub-compatible anchor slug. */\nfunction toAnchor(text: string): string {\n\treturn text\n\t\t.toLowerCase()\n\t\t.replace(/[^a-z0-9\\s-]/g, \"\")\n\t\t.trim()\n\t\t.replace(/\\s+/g, \"-\");\n}\n\n/** Build the frontmatter block for the configured SSG target. */\nfunction buildFrontmatter(config: ForgeConfig, mdx: boolean): string {\n\tconst target = config.gen.ssgTarget;\n\tif (!target) return \"\";\n\n\tconst lines: string[] = [\"---\"];\n\n\tswitch (target) {\n\t\tcase \"docusaurus\":\n\t\t\tlines.push(\"sidebar_position: 1\");\n\t\t\tlines.push(\"title: API Reference\");\n\t\t\tbreak;\n\t\tcase \"mintlify\":\n\t\t\tlines.push(\"title: API Reference\");\n\t\t\tbreak;\n\t\tcase \"nextra\":\n\t\t\tlines.push(\"title: API Reference\");\n\t\t\tlines.push(\"description: Auto-generated API reference\");\n\t\t\tbreak;\n\t\tcase \"vitepress\":\n\t\t\tlines.push(\"title: API Reference\");\n\t\t\tlines.push(\"outline: deep\");\n\t\t\tbreak;\n\t}\n\n\tlines.push(\"---\");\n\tif (mdx) {\n\t\tlines.push(\"\");\n\t}\n\treturn `${lines.join(\"\\n\")}\\n`;\n}\n\n/** Build MDX import block for custom components. */\nfunction buildMdxImports(): string {\n\treturn 'import { Callout } from \"@components/Callout\";\\n\\n';\n}\n\n/**\n * Render a deprecation notice banner.\n * @internal\n */\nfunction renderDeprecation(deprecated: string): string {\n\treturn `> **Deprecated**: ${deprecated}\\n`;\n}\n\n/**\n * Render source location line.\n * @internal\n */\nfunction renderSourceLink(symbol: ForgeSymbol, rootDir: string): string {\n\tconst rel = relative(rootDir, symbol.filePath);\n\treturn `_Defined in \\`${rel}:${symbol.line}\\`_\\n`;\n}\n\n/**\n * Renders a symbol at H3 level (used for both top-level and children).\n * @internal\n */\nfunction renderSymbolSection(\n\tsymbol: ForgeSymbol,\n\trootDir: string,\n\tmdx: boolean,\n\tdepth: number,\n): string {\n\tconst lines: string[] = [];\n\tconst hashes = \"#\".repeat(depth);\n\tconst ext = symbol.kind === \"function\" || symbol.kind === \"method\" ? \"()\" : \"\";\n\tlines.push(`${hashes} \\`${symbol.name}${ext}\\``);\n\tlines.push(\"\");\n\n\tif (symbol.documentation?.deprecated) {\n\t\tlines.push(renderDeprecation(symbol.documentation.deprecated));\n\t}\n\n\tlines.push(renderSourceLink(symbol, rootDir));\n\n\tif (symbol.signature) {\n\t\tlines.push(\"```typescript\");\n\t\tlines.push(symbol.signature);\n\t\tlines.push(\"```\");\n\t\tlines.push(\"\");\n\t}\n\n\tif (symbol.documentation?.summary) {\n\t\tlines.push(symbol.documentation.summary);\n\t\tlines.push(\"\");\n\t}\n\n\tconst params = symbol.documentation?.params ?? [];\n\tif (params.length > 0) {\n\t\tlines.push(\"**Parameters**\");\n\t\tlines.push(\"\");\n\t\tfor (const p of params) {\n\t\t\tconst typeStr = p.type ? ` (\\`${p.type}\\`)` : \"\";\n\t\t\tlines.push(`- \\`${p.name}\\`${typeStr} — ${p.description}`);\n\t\t}\n\t\tlines.push(\"\");\n\t}\n\n\tif (symbol.documentation?.returns) {\n\t\tconst retType = symbol.documentation.returns.type\n\t\t\t? ` (\\`${symbol.documentation.returns.type}\\`)`\n\t\t\t: \"\";\n\t\tlines.push(`**Returns**${retType}: ${symbol.documentation.returns.description}`);\n\t\tlines.push(\"\");\n\t}\n\n\tconst throws = symbol.documentation?.throws ?? [];\n\tif (throws.length > 0) {\n\t\tlines.push(\"**Throws**\");\n\t\tlines.push(\"\");\n\t\tfor (const t of throws) {\n\t\t\tconst typeStr = t.type ? `\\`${t.type}\\` — ` : \"\";\n\t\t\tlines.push(`- ${typeStr}${t.description}`);\n\t\t}\n\t\tlines.push(\"\");\n\t}\n\n\tconst examples = symbol.documentation?.examples ?? [];\n\tif (examples.length > 0) {\n\t\tlines.push(\"**Examples**\");\n\t\tlines.push(\"\");\n\t\tfor (const ex of examples) {\n\t\t\tlines.push(`\\`\\`\\`${ex.language}`);\n\t\t\tlines.push(ex.code.trim());\n\t\t\tlines.push(\"```\");\n\t\t\tlines.push(\"\");\n\t\t}\n\t}\n\n\t// Render children (class members, enum values, interface properties)\n\tconst children = symbol.children ?? [];\n\tif (children.length > 0 && depth < 5) {\n\t\tconst childDepth = depth + 1;\n\t\tfor (const child of children) {\n\t\t\tlines.push(renderSymbolSection(child, rootDir, mdx, childDepth));\n\t\t}\n\t}\n\n\treturn lines.join(\"\\n\");\n}\n\n/**\n * Build a Table of Contents from grouped symbols.\n * @internal\n */\nfunction buildToc(groups: Map<ForgeSymbol[\"kind\"], ForgeSymbol[]>): string {\n\tconst lines: string[] = [];\n\tlines.push(\"## Table of Contents\");\n\tlines.push(\"\");\n\n\tfor (const kind of KIND_ORDER) {\n\t\tconst group = groups.get(kind);\n\t\tif (!group || group.length === 0) continue;\n\n\t\tconst label = KIND_LABELS[kind];\n\t\tconst anchor = toAnchor(label);\n\t\tlines.push(`- [${label}](#${anchor})`);\n\n\t\tfor (const symbol of group) {\n\t\t\tconst ext = kind === \"function\" ? \"()\" : \"\";\n\t\t\tconst displayName = `${symbol.name}${ext}`;\n\t\t\tconst symAnchor = toAnchor(displayName);\n\t\t\tlines.push(` - [\\`${displayName}\\`](#${symAnchor})`);\n\t\t}\n\t}\n\n\tlines.push(\"\");\n\treturn lines.join(\"\\n\");\n}\n\n/**\n * Generates a Markdown (or MDX) string from a list of symbols.\n *\n * @param symbols - The symbols to document.\n * @param config - The resolved {@link ForgeConfig}.\n * @param options - Rendering options.\n * @returns The generated Markdown string.\n * @public\n */\nexport function generateMarkdown(\n\tsymbols: ForgeSymbol[],\n\tconfig: ForgeConfig,\n\toptions: MarkdownOptions = {},\n): string {\n\tconst mdx = options.mdx ?? false;\n\tconst exported = symbols.filter((s) => s.exported);\n\n\t// Group by kind (top-level only — children are nested under their parent)\n\tconst topLevel = exported.filter((s) => s.kind !== \"method\" && s.kind !== \"property\");\n\n\tconst groups = new Map<ForgeSymbol[\"kind\"], ForgeSymbol[]>();\n\tfor (const symbol of topLevel) {\n\t\tconst list = groups.get(symbol.kind) ?? [];\n\t\tlist.push(symbol);\n\t\tgroups.set(symbol.kind, list);\n\t}\n\n\tconst parts: string[] = [];\n\n\t// Frontmatter\n\tconst frontmatter = buildFrontmatter(config, mdx);\n\tif (frontmatter) {\n\t\tparts.push(frontmatter);\n\t}\n\n\t// MDX imports\n\tif (mdx) {\n\t\tparts.push(buildMdxImports());\n\t}\n\n\t// Page title + preamble\n\tparts.push(\"# API Reference\\n\");\n\tparts.push(\n\t\t`Generated by [forge-ts](https://github.com/forge-ts/forge-ts) from \\`${config.rootDir}\\`.\\n`,\n\t);\n\n\t// Table of Contents\n\tif (topLevel.length > 0) {\n\t\tparts.push(buildToc(groups));\n\t}\n\n\t// Symbol groups\n\tfor (const kind of KIND_ORDER) {\n\t\tconst group = groups.get(kind);\n\t\tif (!group || group.length === 0) continue;\n\n\t\tconst label = KIND_LABELS[kind];\n\t\tparts.push(`## ${label}\\n`);\n\n\t\tfor (const symbol of group) {\n\t\t\tparts.push(renderSymbolSection(symbol, config.rootDir, mdx, 3));\n\t\t\tparts.push(\"\");\n\t\t}\n\t}\n\n\treturn `${parts\n\t\t.join(\"\\n\")\n\t\t.replace(/\\n{3,}/g, \"\\n\\n\")\n\t\t.trimEnd()}\\n`;\n}\n","import { existsSync } from \"node:fs\";\nimport { readFile, writeFile } from \"node:fs/promises\";\nimport type { ForgeSymbol } from \"@forge-ts/core\";\n\nconst SECTION_START = \"<!-- forge-ts:start -->\";\nconst SECTION_END = \"<!-- forge-ts:end -->\";\n\n/** Options controlling README sync behaviour. */\nexport interface ReadmeSyncOptions {\n\t/** Include a \"Documented with forge-ts\" badge above the API table. */\n\tbadge?: boolean;\n\t/** Include first @example from each top-level symbol. */\n\tincludeExamples?: boolean;\n}\n\n/**\n * Derives a compact type signature string for the table.\n * @internal\n */\nfunction tableSignature(symbol: ForgeSymbol): string {\n\tif (!symbol.signature) {\n\t\tconst ext = symbol.kind === \"function\" ? \"()\" : \"\";\n\t\treturn `\\`${symbol.name}${ext}\\``;\n\t}\n\t// Keep it short: show at most 60 characters of the signature\n\tconst sig =\n\t\tsymbol.signature.length > 60 ? `${symbol.signature.slice(0, 57)}...` : symbol.signature;\n\treturn `\\`${sig}\\``;\n}\n\n/**\n * Renders the first @example block as a fenced code snippet.\n * @internal\n */\nfunction renderFirstExample(symbol: ForgeSymbol): string {\n\tconst examples = symbol.documentation?.examples ?? [];\n\tif (examples.length === 0) return \"\";\n\tconst ex = examples[0];\n\treturn [\"\", `\\`\\`\\`${ex.language}`, ex.code.trim(), \"```\"].join(\"\\n\");\n}\n\n/**\n * Builds the markdown table rows for the API overview.\n * @internal\n */\nfunction buildApiTable(symbols: ForgeSymbol[], includeExamples: boolean): string[] {\n\tconst lines: string[] = [\"| Symbol | Kind | Description |\", \"|--------|------|-------------|\"];\n\n\tfor (const s of symbols) {\n\t\tconst sig = tableSignature(s);\n\t\tconst summary = s.documentation?.summary ?? \"\";\n\t\tlines.push(`| ${sig} | ${s.kind} | ${summary} |`);\n\t}\n\n\tif (includeExamples) {\n\t\tconst withExamples = symbols.filter((s) => (s.documentation?.examples ?? []).length > 0);\n\t\tif (withExamples.length > 0) {\n\t\t\tlines.push(\"\");\n\t\t\tlines.push(\"### Examples\");\n\t\t\tfor (const s of withExamples) {\n\t\t\t\tlines.push(\"\");\n\t\t\t\tconst ext = s.kind === \"function\" ? \"()\" : \"\";\n\t\t\t\tlines.push(`#### \\`${s.name}${ext}\\``);\n\t\t\t\tlines.push(renderFirstExample(s));\n\t\t\t}\n\t\t}\n\t}\n\n\treturn lines;\n}\n\n/**\n * Injects a summary of exported symbols into a `README.md` file.\n *\n * The content is placed between `<!-- forge-ts:start -->` and\n * `<!-- forge-ts:end -->` comment markers. If neither marker exists, the\n * summary is appended to the end of the file.\n *\n * @param readmePath - Absolute path to the `README.md` to update.\n * @param symbols - Symbols to summarise in the README.\n * @param options - Options controlling sync behaviour.\n * @returns `true` if the file was modified, `false` otherwise.\n * @public\n */\nexport async function syncReadme(\n\treadmePath: string,\n\tsymbols: ForgeSymbol[],\n\toptions: ReadmeSyncOptions = {},\n): Promise<boolean> {\n\tconst exported = symbols.filter((s) => s.exported);\n\tif (exported.length === 0) return false;\n\n\tconst badge = options.badge ?? false;\n\tconst includeExamples = options.includeExamples ?? false;\n\n\tconst innerLines: string[] = [];\n\tinnerLines.push(\"## API Overview\");\n\tinnerLines.push(\"\");\n\n\tif (badge) {\n\t\tinnerLines.push(\n\t\t\t\"[![Documented with forge-ts](https://img.shields.io/badge/docs-forge--ts-blue)](https://github.com/forge-ts/forge-ts)\",\n\t\t);\n\t\tinnerLines.push(\"\");\n\t}\n\n\tinnerLines.push(...buildApiTable(exported, includeExamples));\n\n\tconst summaryLines = [SECTION_START, \"\", ...innerLines, \"\", SECTION_END];\n\tconst injection = summaryLines.join(\"\\n\");\n\n\tlet existing = existsSync(readmePath) ? await readFile(readmePath, \"utf8\") : \"\";\n\n\tconst startIdx = existing.indexOf(SECTION_START);\n\tconst endIdx = existing.indexOf(SECTION_END);\n\n\tif (startIdx !== -1 && endIdx !== -1) {\n\t\texisting =\n\t\t\texisting.slice(0, startIdx) + injection + existing.slice(endIdx + SECTION_END.length);\n\t} else {\n\t\texisting = `${existing.trimEnd()}\\n\\n${injection}\\n`;\n\t}\n\n\tawait writeFile(readmePath, existing, \"utf8\");\n\treturn true;\n}\n","/**\n * @forge-ts/gen — Markdown/MDX documentation and llms.txt generator.\n *\n * Generates human- and machine-readable documentation from the forge-ts\n * symbol graph, with optional README injection.\n *\n * @packageDocumentation\n * @public\n */\n\nexport { generateLlmsFullTxt, generateLlmsTxt } from \"./llms.js\";\nexport {\n\tgenerateMarkdown,\n\ttype MarkdownOptions,\n} from \"./markdown.js\";\nexport { type ReadmeSyncOptions, syncReadme } from \"./readme-sync.js\";\n\nimport { mkdir, writeFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { createWalker, type ForgeConfig, type ForgeResult } from \"@forge-ts/core\";\nimport { generateLlmsFullTxt, generateLlmsTxt } from \"./llms.js\";\nimport { generateMarkdown } from \"./markdown.js\";\nimport { syncReadme } from \"./readme-sync.js\";\n\n/**\n * Runs the full generation pipeline: walk → render → write.\n *\n * @param config - The resolved {@link ForgeConfig} for the project.\n * @returns A {@link ForgeResult} describing the outcome.\n * @public\n */\nexport async function generate(config: ForgeConfig): Promise<ForgeResult> {\n\tconst start = Date.now();\n\n\tconst walker = createWalker(config);\n\tconst symbols = walker.walk();\n\n\tawait mkdir(config.outDir, { recursive: true });\n\n\tfor (const format of config.gen.formats) {\n\t\tconst content = generateMarkdown(symbols, config, {\n\t\t\tmdx: format === \"mdx\",\n\t\t});\n\t\tconst ext = format === \"mdx\" ? \"mdx\" : \"md\";\n\t\tawait writeFile(join(config.outDir, `api-reference.${ext}`), content, \"utf8\");\n\t}\n\n\tif (config.gen.llmsTxt) {\n\t\tconst llms = generateLlmsTxt(symbols, config);\n\t\tawait writeFile(join(config.outDir, \"llms.txt\"), llms, \"utf8\");\n\n\t\tconst llmsFull = generateLlmsFullTxt(symbols, config);\n\t\tawait writeFile(join(config.outDir, \"llms-full.txt\"), llmsFull, \"utf8\");\n\t}\n\n\tif (config.gen.readmeSync) {\n\t\tawait syncReadme(join(config.rootDir, \"README.md\"), symbols);\n\t}\n\n\treturn {\n\t\tsuccess: true,\n\t\tsymbols,\n\t\terrors: [],\n\t\twarnings: [],\n\t\tduration: Date.now() - start,\n\t};\n}\n"],"mappings":";AAMA,SAAS,aAAa,QAA6B;AAClD,MAAI,OAAO,WAAW;AACrB,WAAO,OAAO;AAAA,EACf;AACA,QAAM,MAAM,OAAO,SAAS,aAAa,OAAO;AAChD,SAAO,GAAG,OAAO,IAAI,IAAI,OAAO,IAAI,GAAG,GAAG;AAC3C;AAaO,SAAS,gBAAgB,SAAwB,QAA6B;AACpF,QAAM,WAAW,QAAQ,OAAO,CAAC,MAAM,EAAE,QAAQ;AAC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,oBAAwD;AAYjE,eAAsB,SAAS,QAA2C;AACzE,QAAM,QAAQ,KAAK,IAAI;AAEvB,QAAM,SAAS,aAAa,MAAM;AAClC,QAAM,UAAU,OAAO,KAAK;AAE5B,QAAM,MAAM,OAAO,QAAQ,EAAE,WAAW,KAAK,CAAC;AAE9C,aAAW,UAAU,OAAO,IAAI,SAAS;AACxC,UAAM,UAAU,iBAAiB,SAAS,QAAQ;AAAA,MACjD,KAAK,WAAW;AAAA,IACjB,CAAC;AACD,UAAM,MAAM,WAAW,QAAQ,QAAQ;AACvC,UAAMC,WAAU,KAAK,OAAO,QAAQ,iBAAiB,GAAG,EAAE,GAAG,SAAS,MAAM;AAAA,EAC7E;AAEA,MAAI,OAAO,IAAI,SAAS;AACvB,UAAM,OAAO,gBAAgB,SAAS,MAAM;AAC5C,UAAMA,WAAU,KAAK,OAAO,QAAQ,UAAU,GAAG,MAAM,MAAM;AAE7D,UAAM,WAAW,oBAAoB,SAAS,MAAM;AACpD,UAAMA,WAAU,KAAK,OAAO,QAAQ,eAAe,GAAG,UAAU,MAAM;AAAA,EACvE;AAEA,MAAI,OAAO,IAAI,YAAY;AAC1B,UAAM,WAAW,KAAK,OAAO,SAAS,WAAW,GAAG,OAAO;AAAA,EAC5D;AAEA,SAAO;AAAA,IACN,SAAS;AAAA,IACT;AAAA,IACA,QAAQ,CAAC;AAAA,IACT,UAAU,CAAC;AAAA,IACX,UAAU,KAAK,IAAI,IAAI;AAAA,EACxB;AACD;","names":["writeFile","writeFile"]}
1
+ {"version":3,"sources":["../src/llms.ts","../src/markdown.ts","../src/readme-sync.ts","../src/site-generator.ts","../src/ssg-config.ts","../src/index.ts"],"sourcesContent":["import type { ForgeConfig, ForgeSymbol } from \"@forge-ts/core\";\n\n/**\n * Derives a compact one-line signature for routing manifest entries.\n * @internal\n */\nfunction compactEntry(symbol: ForgeSymbol): string {\n\tif (symbol.signature) {\n\t\treturn symbol.signature;\n\t}\n\tconst ext = symbol.kind === \"function\" ? \"()\" : \"\";\n\treturn `${symbol.kind} ${symbol.name}${ext}`;\n}\n\n/**\n * Generates an `llms.txt` routing manifest from the extracted symbols.\n *\n * The file follows the llms.txt specification: a compact, structured overview\n * designed to help large language models navigate a project's documentation.\n *\n * @param symbols - The symbols to include.\n * @param config - The resolved {@link ForgeConfig}.\n * @returns The generated `llms.txt` content as a string.\n * @public\n */\nexport function generateLlmsTxt(symbols: ForgeSymbol[], config: ForgeConfig): string {\n\tconst exported = symbols.filter((s) => s.exported);\n\tconst projectName = config.rootDir.split(\"/\").pop() ?? \"Project\";\n\n\tconst lines: string[] = [];\n\n\tlines.push(`# ${projectName}`);\n\tlines.push(`> Auto-generated API documentation`);\n\tlines.push(\"\");\n\n\t// Sections block — link to generated files\n\tlines.push(\"## Sections\");\n\tlines.push(\"\");\n\tif (config.gen.formats.includes(\"markdown\")) {\n\t\tlines.push(\"- [API Reference](./api-reference.md): Full API documentation\");\n\t}\n\tif (config.gen.formats.includes(\"mdx\")) {\n\t\tlines.push(\"- [API Reference](./api-reference.mdx): Full API documentation (MDX)\");\n\t}\n\tif (config.gen.llmsTxt) {\n\t\tlines.push(\"- [Full Context](./llms-full.txt): Dense context for LLM consumption\");\n\t}\n\tlines.push(\"\");\n\n\t// Quick Reference block\n\tif (exported.length > 0) {\n\t\tlines.push(\"## Quick Reference\");\n\t\tlines.push(\"\");\n\t\tfor (const symbol of exported) {\n\t\t\tconst summary = symbol.documentation?.summary ?? \"\";\n\t\t\tconst entry = compactEntry(symbol);\n\t\t\tlines.push(summary ? `${entry} - ${summary}` : entry);\n\t\t}\n\t\tlines.push(\"\");\n\t}\n\n\treturn lines.join(\"\\n\");\n}\n\n/**\n * Renders a full parameter list section.\n * @internal\n */\nfunction renderParams(params: NonNullable<ForgeSymbol[\"documentation\"]>[\"params\"]): string {\n\tif (!params || params.length === 0) return \"\";\n\tconst lines: string[] = [\"\", \"Parameters:\"];\n\tfor (const p of params) {\n\t\tconst typeStr = p.type ? ` (${p.type})` : \"\";\n\t\tlines.push(`- ${p.name}${typeStr}: ${p.description}`);\n\t}\n\treturn lines.join(\"\\n\");\n}\n\n/**\n * Renders a single symbol section for llms-full.txt.\n * @internal\n */\nfunction renderFullSymbol(symbol: ForgeSymbol, depth: number): string {\n\tconst hashes = \"#\".repeat(depth);\n\tconst ext = symbol.kind === \"function\" || symbol.kind === \"method\" ? \"()\" : \"\";\n\tconst lines: string[] = [];\n\n\tlines.push(`${hashes} ${symbol.name}${ext}`);\n\n\tif (symbol.signature) {\n\t\tlines.push(\"\");\n\t\tlines.push(symbol.signature);\n\t}\n\n\tif (symbol.documentation?.deprecated) {\n\t\tlines.push(\"\");\n\t\tlines.push(`DEPRECATED: ${symbol.documentation.deprecated}`);\n\t}\n\n\tif (symbol.documentation?.summary) {\n\t\tlines.push(\"\");\n\t\tlines.push(symbol.documentation.summary);\n\t}\n\n\tconst params = symbol.documentation?.params ?? [];\n\tconst paramBlock = renderParams(params);\n\tif (paramBlock) {\n\t\tlines.push(paramBlock);\n\t}\n\n\tif (symbol.documentation?.returns) {\n\t\tconst retType = symbol.documentation.returns.type\n\t\t\t? ` (${symbol.documentation.returns.type})`\n\t\t\t: \"\";\n\t\tlines.push(\"\");\n\t\tlines.push(`Returns${retType}: ${symbol.documentation.returns.description}`);\n\t}\n\n\tconst examples = symbol.documentation?.examples ?? [];\n\tif (examples.length > 0) {\n\t\tlines.push(\"\");\n\t\tlines.push(\"Example:\");\n\t\tfor (const ex of examples) {\n\t\t\tconst exLines = ex.code.trim().split(\"\\n\");\n\t\t\tfor (const l of exLines) {\n\t\t\t\tlines.push(` ${l}`);\n\t\t\t}\n\t\t}\n\t}\n\n\t// Render children inline\n\tconst children = symbol.children ?? [];\n\tif (children.length > 0 && depth < 5) {\n\t\tlines.push(\"\");\n\t\tlines.push(\"Members:\");\n\t\tfor (const child of children) {\n\t\t\tlines.push(\"\");\n\t\t\tconst childSection = renderFullSymbol(child, depth + 1);\n\t\t\t// indent child one level\n\t\t\tfor (const cl of childSection.split(\"\\n\")) {\n\t\t\t\tlines.push(cl);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn lines.join(\"\\n\");\n}\n\n/**\n * Generates an `llms-full.txt` dense context file from the extracted symbols.\n *\n * Unlike `llms.txt`, this file contains complete documentation for every\n * exported symbol, intended for LLM ingestion that requires full context.\n *\n * @param symbols - The symbols to include.\n * @param config - The resolved {@link ForgeConfig}.\n * @returns The generated `llms-full.txt` content as a string.\n * @public\n */\nexport function generateLlmsFullTxt(symbols: ForgeSymbol[], config: ForgeConfig): string {\n\tconst exported = symbols.filter(\n\t\t(s) => s.exported && s.kind !== \"method\" && s.kind !== \"property\",\n\t);\n\tconst projectName = config.rootDir.split(\"/\").pop() ?? \"Project\";\n\n\tconst lines: string[] = [];\n\n\tlines.push(`# ${projectName} - Full Context`);\n\tlines.push(\"\");\n\tlines.push(`Root: ${config.rootDir}`);\n\tlines.push(`Generated: ${new Date().toISOString()}`);\n\tlines.push(\"\");\n\n\t// Group by kind\n\tconst kindGroups: Record<string, ForgeSymbol[]> = {};\n\tfor (const symbol of exported) {\n\t\tconst list = kindGroups[symbol.kind] ?? [];\n\t\tlist.push(symbol);\n\t\tkindGroups[symbol.kind] = list;\n\t}\n\n\tconst kindOrder: Array<ForgeSymbol[\"kind\"]> = [\n\t\t\"function\",\n\t\t\"class\",\n\t\t\"interface\",\n\t\t\"type\",\n\t\t\"enum\",\n\t\t\"variable\",\n\t];\n\n\tconst kindLabels: Record<string, string> = {\n\t\tfunction: \"Functions\",\n\t\tclass: \"Classes\",\n\t\tinterface: \"Interfaces\",\n\t\ttype: \"Types\",\n\t\tenum: \"Enums\",\n\t\tvariable: \"Variables\",\n\t};\n\n\tfor (const kind of kindOrder) {\n\t\tconst group = kindGroups[kind];\n\t\tif (!group || group.length === 0) continue;\n\n\t\tlines.push(`## ${kindLabels[kind]}`);\n\t\tlines.push(\"\");\n\n\t\tfor (const symbol of group) {\n\t\t\tlines.push(renderFullSymbol(symbol, 3));\n\t\t\tlines.push(\"\");\n\t\t}\n\t}\n\n\treturn `${lines\n\t\t.join(\"\\n\")\n\t\t.replace(/\\n{3,}/g, \"\\n\\n\")\n\t\t.trimEnd()}\\n`;\n}\n","import { relative } from \"node:path\";\nimport type { ForgeConfig, ForgeSymbol } from \"@forge-ts/core\";\n\n/**\n * Options controlling Markdown output.\n * @public\n */\nexport interface MarkdownOptions {\n\t/** Whether to use MDX syntax (default: Markdown). */\n\tmdx?: boolean;\n}\n\n/** Display labels for each symbol kind. */\nconst KIND_LABELS: Record<ForgeSymbol[\"kind\"], string> = {\n\tfunction: \"Functions\",\n\tclass: \"Classes\",\n\tinterface: \"Interfaces\",\n\ttype: \"Types\",\n\tenum: \"Enums\",\n\tvariable: \"Variables\",\n\tmethod: \"Methods\",\n\tproperty: \"Properties\",\n};\n\n/** Canonical ordering for top-level kind groups. */\nconst KIND_ORDER: Array<ForgeSymbol[\"kind\"]> = [\n\t\"function\",\n\t\"class\",\n\t\"interface\",\n\t\"type\",\n\t\"enum\",\n\t\"variable\",\n];\n\n/** Convert a label to a GitHub-compatible anchor slug. */\nfunction toAnchor(text: string): string {\n\treturn text\n\t\t.toLowerCase()\n\t\t.replace(/[^a-z0-9\\s-]/g, \"\")\n\t\t.trim()\n\t\t.replace(/\\s+/g, \"-\");\n}\n\n/** Build the frontmatter block for the configured SSG target. */\nfunction buildFrontmatter(config: ForgeConfig, mdx: boolean): string {\n\tconst target = config.gen.ssgTarget;\n\tif (!target) return \"\";\n\n\tconst lines: string[] = [\"---\"];\n\n\tswitch (target) {\n\t\tcase \"docusaurus\":\n\t\t\tlines.push(\"sidebar_position: 1\");\n\t\t\tlines.push(\"title: API Reference\");\n\t\t\tbreak;\n\t\tcase \"mintlify\":\n\t\t\tlines.push(\"title: API Reference\");\n\t\t\tbreak;\n\t\tcase \"nextra\":\n\t\t\tlines.push(\"title: API Reference\");\n\t\t\tlines.push(\"description: Auto-generated API reference\");\n\t\t\tbreak;\n\t\tcase \"vitepress\":\n\t\t\tlines.push(\"title: API Reference\");\n\t\t\tlines.push(\"outline: deep\");\n\t\t\tbreak;\n\t}\n\n\tlines.push(\"---\");\n\tif (mdx) {\n\t\tlines.push(\"\");\n\t}\n\treturn `${lines.join(\"\\n\")}\\n`;\n}\n\n/** Build MDX import block for custom components. */\nfunction buildMdxImports(): string {\n\treturn 'import { Callout } from \"@components/Callout\";\\n\\n';\n}\n\n/**\n * Render a deprecation notice banner.\n * @internal\n */\nfunction renderDeprecation(deprecated: string): string {\n\treturn `> **Deprecated**: ${deprecated}\\n`;\n}\n\n/**\n * Render source location line.\n * @internal\n */\nfunction renderSourceLink(symbol: ForgeSymbol, rootDir: string): string {\n\tconst rel = relative(rootDir, symbol.filePath);\n\treturn `_Defined in \\`${rel}:${symbol.line}\\`_\\n`;\n}\n\n/**\n * Renders a symbol at H3 level (used for both top-level and children).\n * @internal\n */\nfunction renderSymbolSection(\n\tsymbol: ForgeSymbol,\n\trootDir: string,\n\tmdx: boolean,\n\tdepth: number,\n): string {\n\tconst lines: string[] = [];\n\tconst hashes = \"#\".repeat(depth);\n\tconst ext = symbol.kind === \"function\" || symbol.kind === \"method\" ? \"()\" : \"\";\n\tlines.push(`${hashes} \\`${symbol.name}${ext}\\``);\n\tlines.push(\"\");\n\n\tif (symbol.documentation?.deprecated) {\n\t\tlines.push(renderDeprecation(symbol.documentation.deprecated));\n\t}\n\n\tlines.push(renderSourceLink(symbol, rootDir));\n\n\tif (symbol.signature) {\n\t\tlines.push(\"```typescript\");\n\t\tlines.push(symbol.signature);\n\t\tlines.push(\"```\");\n\t\tlines.push(\"\");\n\t}\n\n\tif (symbol.documentation?.summary) {\n\t\tlines.push(symbol.documentation.summary);\n\t\tlines.push(\"\");\n\t}\n\n\tconst params = symbol.documentation?.params ?? [];\n\tif (params.length > 0) {\n\t\tlines.push(\"**Parameters**\");\n\t\tlines.push(\"\");\n\t\tfor (const p of params) {\n\t\t\tconst typeStr = p.type ? ` (\\`${p.type}\\`)` : \"\";\n\t\t\tlines.push(`- \\`${p.name}\\`${typeStr} — ${p.description}`);\n\t\t}\n\t\tlines.push(\"\");\n\t}\n\n\tif (symbol.documentation?.returns) {\n\t\tconst retType = symbol.documentation.returns.type\n\t\t\t? ` (\\`${symbol.documentation.returns.type}\\`)`\n\t\t\t: \"\";\n\t\tlines.push(`**Returns**${retType}: ${symbol.documentation.returns.description}`);\n\t\tlines.push(\"\");\n\t}\n\n\tconst throws = symbol.documentation?.throws ?? [];\n\tif (throws.length > 0) {\n\t\tlines.push(\"**Throws**\");\n\t\tlines.push(\"\");\n\t\tfor (const t of throws) {\n\t\t\tconst typeStr = t.type ? `\\`${t.type}\\` — ` : \"\";\n\t\t\tlines.push(`- ${typeStr}${t.description}`);\n\t\t}\n\t\tlines.push(\"\");\n\t}\n\n\tconst examples = symbol.documentation?.examples ?? [];\n\tif (examples.length > 0) {\n\t\tlines.push(\"**Examples**\");\n\t\tlines.push(\"\");\n\t\tfor (const ex of examples) {\n\t\t\tlines.push(`\\`\\`\\`${ex.language}`);\n\t\t\tlines.push(ex.code.trim());\n\t\t\tlines.push(\"```\");\n\t\t\tlines.push(\"\");\n\t\t}\n\t}\n\n\t// Render children (class members, enum values, interface properties)\n\tconst children = symbol.children ?? [];\n\tif (children.length > 0 && depth < 5) {\n\t\tconst childDepth = depth + 1;\n\t\tfor (const child of children) {\n\t\t\tlines.push(renderSymbolSection(child, rootDir, mdx, childDepth));\n\t\t}\n\t}\n\n\treturn lines.join(\"\\n\");\n}\n\n/**\n * Build a Table of Contents from grouped symbols.\n * @internal\n */\nfunction buildToc(groups: Map<ForgeSymbol[\"kind\"], ForgeSymbol[]>): string {\n\tconst lines: string[] = [];\n\tlines.push(\"## Table of Contents\");\n\tlines.push(\"\");\n\n\tfor (const kind of KIND_ORDER) {\n\t\tconst group = groups.get(kind);\n\t\tif (!group || group.length === 0) continue;\n\n\t\tconst label = KIND_LABELS[kind];\n\t\tconst anchor = toAnchor(label);\n\t\tlines.push(`- [${label}](#${anchor})`);\n\n\t\tfor (const symbol of group) {\n\t\t\tconst ext = kind === \"function\" ? \"()\" : \"\";\n\t\t\tconst displayName = `${symbol.name}${ext}`;\n\t\t\tconst symAnchor = toAnchor(displayName);\n\t\t\tlines.push(` - [\\`${displayName}\\`](#${symAnchor})`);\n\t\t}\n\t}\n\n\tlines.push(\"\");\n\treturn lines.join(\"\\n\");\n}\n\n/**\n * Generates a Markdown (or MDX) string from a list of symbols.\n *\n * @param symbols - The symbols to document.\n * @param config - The resolved {@link ForgeConfig}.\n * @param options - Rendering options.\n * @returns The generated Markdown string.\n * @public\n */\nexport function generateMarkdown(\n\tsymbols: ForgeSymbol[],\n\tconfig: ForgeConfig,\n\toptions: MarkdownOptions = {},\n): string {\n\tconst mdx = options.mdx ?? false;\n\tconst exported = symbols.filter((s) => s.exported);\n\n\t// Group by kind (top-level only — children are nested under their parent)\n\tconst topLevel = exported.filter((s) => s.kind !== \"method\" && s.kind !== \"property\");\n\n\tconst groups = new Map<ForgeSymbol[\"kind\"], ForgeSymbol[]>();\n\tfor (const symbol of topLevel) {\n\t\tconst list = groups.get(symbol.kind) ?? [];\n\t\tlist.push(symbol);\n\t\tgroups.set(symbol.kind, list);\n\t}\n\n\tconst parts: string[] = [];\n\n\t// Frontmatter\n\tconst frontmatter = buildFrontmatter(config, mdx);\n\tif (frontmatter) {\n\t\tparts.push(frontmatter);\n\t}\n\n\t// MDX imports\n\tif (mdx) {\n\t\tparts.push(buildMdxImports());\n\t}\n\n\t// Page title + preamble\n\tparts.push(\"# API Reference\\n\");\n\tparts.push(\n\t\t`Generated by [forge-ts](https://github.com/forge-ts/forge-ts) from \\`${config.rootDir}\\`.\\n`,\n\t);\n\n\t// Table of Contents\n\tif (topLevel.length > 0) {\n\t\tparts.push(buildToc(groups));\n\t}\n\n\t// Symbol groups\n\tfor (const kind of KIND_ORDER) {\n\t\tconst group = groups.get(kind);\n\t\tif (!group || group.length === 0) continue;\n\n\t\tconst label = KIND_LABELS[kind];\n\t\tparts.push(`## ${label}\\n`);\n\n\t\tfor (const symbol of group) {\n\t\t\tparts.push(renderSymbolSection(symbol, config.rootDir, mdx, 3));\n\t\t\tparts.push(\"\");\n\t\t}\n\t}\n\n\treturn `${parts\n\t\t.join(\"\\n\")\n\t\t.replace(/\\n{3,}/g, \"\\n\\n\")\n\t\t.trimEnd()}\\n`;\n}\n","import { existsSync } from \"node:fs\";\nimport { readFile, writeFile } from \"node:fs/promises\";\nimport type { ForgeSymbol } from \"@forge-ts/core\";\n\nconst SECTION_START = \"<!-- forge-ts:start -->\";\nconst SECTION_END = \"<!-- forge-ts:end -->\";\n\n/** Options controlling README sync behaviour. */\nexport interface ReadmeSyncOptions {\n\t/** Include a \"Documented with forge-ts\" badge above the API table. */\n\tbadge?: boolean;\n\t/** Include first @example from each top-level symbol. */\n\tincludeExamples?: boolean;\n}\n\n/**\n * Derives a compact type signature string for the table.\n * @internal\n */\nfunction tableSignature(symbol: ForgeSymbol): string {\n\tif (!symbol.signature) {\n\t\tconst ext = symbol.kind === \"function\" ? \"()\" : \"\";\n\t\treturn `\\`${symbol.name}${ext}\\``;\n\t}\n\t// Keep it short: show at most 60 characters of the signature\n\tconst sig =\n\t\tsymbol.signature.length > 60 ? `${symbol.signature.slice(0, 57)}...` : symbol.signature;\n\treturn `\\`${sig}\\``;\n}\n\n/**\n * Renders the first @example block as a fenced code snippet.\n * @internal\n */\nfunction renderFirstExample(symbol: ForgeSymbol): string {\n\tconst examples = symbol.documentation?.examples ?? [];\n\tif (examples.length === 0) return \"\";\n\tconst ex = examples[0];\n\treturn [\"\", `\\`\\`\\`${ex.language}`, ex.code.trim(), \"```\"].join(\"\\n\");\n}\n\n/**\n * Builds the markdown table rows for the API overview.\n * @internal\n */\nfunction buildApiTable(symbols: ForgeSymbol[], includeExamples: boolean): string[] {\n\tconst lines: string[] = [\"| Symbol | Kind | Description |\", \"|--------|------|-------------|\"];\n\n\tfor (const s of symbols) {\n\t\tconst sig = tableSignature(s);\n\t\tconst summary = s.documentation?.summary ?? \"\";\n\t\tlines.push(`| ${sig} | ${s.kind} | ${summary} |`);\n\t}\n\n\tif (includeExamples) {\n\t\tconst withExamples = symbols.filter((s) => (s.documentation?.examples ?? []).length > 0);\n\t\tif (withExamples.length > 0) {\n\t\t\tlines.push(\"\");\n\t\t\tlines.push(\"### Examples\");\n\t\t\tfor (const s of withExamples) {\n\t\t\t\tlines.push(\"\");\n\t\t\t\tconst ext = s.kind === \"function\" ? \"()\" : \"\";\n\t\t\t\tlines.push(`#### \\`${s.name}${ext}\\``);\n\t\t\t\tlines.push(renderFirstExample(s));\n\t\t\t}\n\t\t}\n\t}\n\n\treturn lines;\n}\n\n/**\n * Injects a summary of exported symbols into a `README.md` file.\n *\n * The content is placed between `<!-- forge-ts:start -->` and\n * `<!-- forge-ts:end -->` comment markers. If neither marker exists, the\n * summary is appended to the end of the file.\n *\n * @param readmePath - Absolute path to the `README.md` to update.\n * @param symbols - Symbols to summarise in the README.\n * @param options - Options controlling sync behaviour.\n * @returns `true` if the file was modified, `false` otherwise.\n * @public\n */\nexport async function syncReadme(\n\treadmePath: string,\n\tsymbols: ForgeSymbol[],\n\toptions: ReadmeSyncOptions = {},\n): Promise<boolean> {\n\tconst exported = symbols.filter((s) => s.exported);\n\tif (exported.length === 0) return false;\n\n\tconst badge = options.badge ?? false;\n\tconst includeExamples = options.includeExamples ?? false;\n\n\tconst innerLines: string[] = [];\n\tinnerLines.push(\"## API Overview\");\n\tinnerLines.push(\"\");\n\n\tif (badge) {\n\t\tinnerLines.push(\n\t\t\t\"[![Documented with forge-ts](https://img.shields.io/badge/docs-forge--ts-blue)](https://github.com/forge-ts/forge-ts)\",\n\t\t);\n\t\tinnerLines.push(\"\");\n\t}\n\n\tinnerLines.push(...buildApiTable(exported, includeExamples));\n\n\tconst summaryLines = [SECTION_START, \"\", ...innerLines, \"\", SECTION_END];\n\tconst injection = summaryLines.join(\"\\n\");\n\n\tlet existing = existsSync(readmePath) ? await readFile(readmePath, \"utf8\") : \"\";\n\n\tconst startIdx = existing.indexOf(SECTION_START);\n\tconst endIdx = existing.indexOf(SECTION_END);\n\n\tif (startIdx !== -1 && endIdx !== -1) {\n\t\texisting =\n\t\t\texisting.slice(0, startIdx) + injection + existing.slice(endIdx + SECTION_END.length);\n\t} else {\n\t\texisting = `${existing.trimEnd()}\\n\\n${injection}\\n`;\n\t}\n\n\tawait writeFile(readmePath, existing, \"utf8\");\n\treturn true;\n}\n","import { basename, relative } from \"node:path\";\nimport type { ForgeConfig, ForgeSymbol } from \"@forge-ts/core\";\n\n/**\n * A single generated documentation page.\n * @public\n */\nexport interface DocPage {\n\t/** Relative path from outDir (e.g., \"packages/core/index.md\") */\n\tpath: string;\n\t/** Page content (Markdown or MDX) */\n\tcontent: string;\n\t/** Frontmatter fields */\n\tfrontmatter: Record<string, string | number | boolean>;\n}\n\n/**\n * Options controlling the doc site generator.\n * @public\n */\nexport interface SiteGeneratorOptions {\n\t/** Output format */\n\tformat: \"markdown\" | \"mdx\";\n\t/** SSG target for frontmatter */\n\tssgTarget?: \"docusaurus\" | \"mintlify\" | \"nextra\" | \"vitepress\";\n\t/** Project name */\n\tprojectName: string;\n\t/** Project description */\n\tprojectDescription?: string;\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\n/** Convert a label to a GitHub-compatible anchor slug. */\nfunction toAnchor(text: string): string {\n\treturn text\n\t\t.toLowerCase()\n\t\t.replace(/[^a-z0-9\\s-]/g, \"\")\n\t\t.trim()\n\t\t.replace(/\\s+/g, \"-\");\n}\n\n/** Escape pipe characters for use inside Markdown table cells. */\nfunction escapePipe(text: string): string {\n\treturn text.replace(/\\|/g, \"\\\\|\");\n}\n\n/** Build a frontmatter block string from the fields map. */\nfunction serializeFrontmatter(fields: Record<string, string | number | boolean>): string {\n\tif (Object.keys(fields).length === 0) return \"\";\n\tconst lines = [\"---\"];\n\tfor (const [key, value] of Object.entries(fields)) {\n\t\tlines.push(`${key}: ${value}`);\n\t}\n\tlines.push(\"---\");\n\treturn `${lines.join(\"\\n\")}\\n\\n`;\n}\n\n/**\n * Build frontmatter fields for the given SSG target.\n * @internal\n */\nfunction buildFrontmatterFields(\n\ttitle: string,\n\tdescription: string,\n\tssgTarget: SiteGeneratorOptions[\"ssgTarget\"],\n\tsidebarPosition?: number,\n): Record<string, string | number | boolean> {\n\tif (!ssgTarget) return {};\n\n\tswitch (ssgTarget) {\n\t\tcase \"docusaurus\": {\n\t\t\tconst fields: Record<string, string | number | boolean> = {\n\t\t\t\ttitle,\n\t\t\t\tsidebar_label: title,\n\t\t\t};\n\t\t\tif (sidebarPosition !== undefined) {\n\t\t\t\tfields.sidebar_position = sidebarPosition;\n\t\t\t}\n\t\t\tif (description) {\n\t\t\t\tfields.description = description;\n\t\t\t}\n\t\t\treturn fields;\n\t\t}\n\t\tcase \"mintlify\": {\n\t\t\tconst fields: Record<string, string | number | boolean> = { title };\n\t\t\tif (description) {\n\t\t\t\tfields.description = description;\n\t\t\t}\n\t\t\treturn fields;\n\t\t}\n\t\tcase \"nextra\":\n\t\t\treturn { title };\n\t\tcase \"vitepress\": {\n\t\t\tconst fields: Record<string, string | number | boolean> = { title, outline: \"deep\" };\n\t\t\tif (description) {\n\t\t\t\tfields.description = description;\n\t\t\t}\n\t\t\treturn fields;\n\t\t}\n\t\tdefault:\n\t\t\treturn {};\n\t}\n}\n\n// ---------------------------------------------------------------------------\n// Package grouping\n// ---------------------------------------------------------------------------\n\n/**\n * Groups symbols by their package based on file path.\n *\n * For monorepos (symbols under `packages/<name>/`) the package name is\n * derived from the directory segment immediately after `packages/`.\n * For non-monorepo projects all symbols fall under the project name.\n *\n * @param symbols - All extracted symbols.\n * @param rootDir - Absolute path to the project root.\n * @returns A map from package name to symbol list.\n * @public\n */\nexport function groupSymbolsByPackage(\n\tsymbols: ForgeSymbol[],\n\trootDir: string,\n): Map<string, ForgeSymbol[]> {\n\tconst result = new Map<string, ForgeSymbol[]>();\n\n\tfor (const symbol of symbols) {\n\t\tconst rel = relative(rootDir, symbol.filePath);\n\t\t// Detect monorepo structure: packages/<name>/...\n\t\tconst monorepoMatch = /^packages[\\\\/]([^\\\\/]+)[\\\\/]/.exec(rel);\n\t\tconst packageName = monorepoMatch ? monorepoMatch[1] : basename(rootDir);\n\n\t\tconst list = result.get(packageName) ?? [];\n\t\tlist.push(symbol);\n\t\tresult.set(packageName, list);\n\t}\n\n\treturn result;\n}\n\n// ---------------------------------------------------------------------------\n// Page renderers\n// ---------------------------------------------------------------------------\n\nconst TYPE_KINDS: ReadonlySet<ForgeSymbol[\"kind\"]> = new Set([\"interface\", \"type\", \"enum\"]);\n\nconst FUNCTION_KINDS: ReadonlySet<ForgeSymbol[\"kind\"]> = new Set([\"function\", \"class\"]);\n\n/** Render a property table row. */\nfunction renderPropertyRow(child: ForgeSymbol): string {\n\tconst name = `\\`${child.name}\\``;\n\tconst type = child.signature ? `\\`${escapePipe(child.signature)}\\`` : \"—\";\n\t// Heuristic: optional if signature contains `?` or `| undefined`\n\tconst optional =\n\t\tchild.signature?.includes(\"?\") || child.signature?.includes(\"undefined\") ? \"No\" : \"Yes\";\n\tconst description = escapePipe(child.documentation?.summary ?? \"\");\n\treturn `| ${name} | ${type} | ${optional} | ${description} |`;\n}\n\n/**\n * Renders the overview (index) page for a package.\n * @internal\n */\nfunction renderOverviewPage(\n\tpackageName: string,\n\tsymbols: ForgeSymbol[],\n\t_options: SiteGeneratorOptions,\n): string {\n\tconst exported = symbols.filter(\n\t\t(s) => s.exported && s.kind !== \"method\" && s.kind !== \"property\",\n\t);\n\n\t// Find @packageDocumentation summary from tags\n\tconst pkgDoc = symbols.map((s) => s.documentation?.tags?.packageDocumentation?.[0]).find(Boolean);\n\n\tconst lines: string[] = [];\n\tlines.push(`# ${packageName}`);\n\tlines.push(\"\");\n\n\tif (pkgDoc) {\n\t\tlines.push(pkgDoc);\n\t\tlines.push(\"\");\n\t}\n\n\tif (exported.length > 0) {\n\t\tlines.push(\"## Exported Symbols\");\n\t\tlines.push(\"\");\n\t\tlines.push(\"| Symbol | Kind | Description |\");\n\t\tlines.push(\"|--------|------|-------------|\");\n\t\tfor (const s of exported) {\n\t\t\tconst ext = s.kind === \"function\" ? \"()\" : \"\";\n\t\t\tconst name = `[\\`${s.name}${ext}\\`](./api-reference.md#${toAnchor(`${s.name}${ext}`)})`;\n\t\t\tconst summary = escapePipe(s.documentation?.summary ?? \"\");\n\t\t\tlines.push(`| ${name} | ${s.kind} | ${summary} |`);\n\t\t}\n\t\tlines.push(\"\");\n\t}\n\n\treturn lines.join(\"\\n\");\n}\n\n/**\n * Renders the types page for a package (interfaces, type aliases, enums).\n * @internal\n */\nfunction renderTypesPage(\n\tpackageName: string,\n\tsymbols: ForgeSymbol[],\n\t_options: SiteGeneratorOptions,\n): string {\n\tconst typeSymbols = symbols.filter((s) => s.exported && TYPE_KINDS.has(s.kind));\n\n\tconst lines: string[] = [];\n\tlines.push(`# ${packageName} — Types`);\n\tlines.push(\"\");\n\tlines.push(\"Type contracts exported by this package: interfaces, type aliases, and enums.\");\n\tlines.push(\"\");\n\n\tfor (const s of typeSymbols) {\n\t\tlines.push(`## ${s.name}`);\n\t\tlines.push(\"\");\n\n\t\tif (s.documentation?.deprecated) {\n\t\t\tlines.push(`> **Deprecated**: ${s.documentation.deprecated}`);\n\t\t\tlines.push(\"\");\n\t\t}\n\n\t\tif (s.documentation?.summary) {\n\t\t\tlines.push(s.documentation.summary);\n\t\t\tlines.push(\"\");\n\t\t}\n\n\t\tif (s.signature && s.kind !== \"interface\") {\n\t\t\tlines.push(\"```typescript\");\n\t\t\tlines.push(s.signature);\n\t\t\tlines.push(\"```\");\n\t\t\tlines.push(\"\");\n\t\t}\n\n\t\tconst children = (s.children ?? []).filter((c) => c.kind === \"property\" || c.kind === \"method\");\n\n\t\tif (children.length > 0) {\n\t\t\tlines.push(\"| Property | Type | Required | Description |\");\n\t\t\tlines.push(\"|----------|------|----------|-------------|\");\n\t\t\tfor (const child of children) {\n\t\t\t\tlines.push(renderPropertyRow(child));\n\t\t\t}\n\t\t\tlines.push(\"\");\n\t\t}\n\t}\n\n\treturn lines.join(\"\\n\");\n}\n\n/**\n * Renders the functions page for a package (functions and classes).\n * @internal\n */\nfunction renderFunctionsPage(\n\tpackageName: string,\n\tsymbols: ForgeSymbol[],\n\t_options: SiteGeneratorOptions,\n): string {\n\tconst fnSymbols = symbols.filter((s) => s.exported && FUNCTION_KINDS.has(s.kind));\n\n\tconst lines: string[] = [];\n\tlines.push(`# ${packageName} — Functions & Classes`);\n\tlines.push(\"\");\n\tlines.push(\"Functions and classes exported by this package.\");\n\tlines.push(\"\");\n\n\tfor (const s of fnSymbols) {\n\t\tconst _ext = s.kind === \"function\" ? \"()\" : \"\";\n\t\tconst paramSig =\n\t\t\ts.kind === \"function\" && s.documentation?.params\n\t\t\t\t? s.documentation.params.map((p) => p.name).join(\", \")\n\t\t\t\t: \"\";\n\t\tconst heading = s.kind === \"function\" ? `${s.name}(${paramSig})` : s.name;\n\n\t\tlines.push(`## ${heading}`);\n\t\tlines.push(\"\");\n\n\t\tif (s.documentation?.deprecated) {\n\t\t\tlines.push(`> **Deprecated**: ${s.documentation.deprecated}`);\n\t\t\tlines.push(\"\");\n\t\t}\n\n\t\tif (s.documentation?.summary) {\n\t\t\tlines.push(s.documentation.summary);\n\t\t\tlines.push(\"\");\n\t\t}\n\n\t\tif (s.signature) {\n\t\t\tlines.push(\"**Signature**\");\n\t\t\tlines.push(\"\");\n\t\t\tlines.push(\"```typescript\");\n\t\t\tlines.push(s.signature);\n\t\t\tlines.push(\"```\");\n\t\t\tlines.push(\"\");\n\t\t}\n\n\t\tconst params = s.documentation?.params ?? [];\n\t\tif (params.length > 0) {\n\t\t\tlines.push(\"**Parameters**\");\n\t\t\tlines.push(\"\");\n\t\t\tlines.push(\"| Name | Type | Description |\");\n\t\t\tlines.push(\"|------|------|-------------|\");\n\t\t\tfor (const p of params) {\n\t\t\t\tconst type = p.type ? `\\`${escapePipe(p.type)}\\`` : \"—\";\n\t\t\t\tlines.push(`| \\`${p.name}\\` | ${type} | ${escapePipe(p.description)} |`);\n\t\t\t}\n\t\t\tlines.push(\"\");\n\t\t}\n\n\t\tif (s.documentation?.returns) {\n\t\t\tconst retType = s.documentation.returns.type ? ` \\`${s.documentation.returns.type}\\`` : \"\";\n\t\t\tlines.push(`**Returns**${retType} — ${s.documentation.returns.description}`);\n\t\t\tlines.push(\"\");\n\t\t}\n\n\t\tconst throws = s.documentation?.throws ?? [];\n\t\tif (throws.length > 0) {\n\t\t\tlines.push(\"**Throws**\");\n\t\t\tlines.push(\"\");\n\t\t\tfor (const t of throws) {\n\t\t\t\tconst typeStr = t.type ? `\\`${t.type}\\` — ` : \"\";\n\t\t\t\tlines.push(`- ${typeStr}${t.description}`);\n\t\t\t}\n\t\t\tlines.push(\"\");\n\t\t}\n\n\t\tconst examples = s.documentation?.examples ?? [];\n\t\tif (examples.length > 0) {\n\t\t\tconst ex = examples[0];\n\t\t\tlines.push(\"**Example**\");\n\t\t\tlines.push(\"\");\n\t\t\tlines.push(`\\`\\`\\`${ex.language}`);\n\t\t\tlines.push(ex.code.trim());\n\t\t\tlines.push(\"```\");\n\t\t\tlines.push(\"\");\n\t\t}\n\n\t\t// Render class methods\n\t\tconst methods = (s.children ?? []).filter((c) => c.kind === \"method\");\n\t\tif (methods.length > 0) {\n\t\t\tlines.push(\"**Methods**\");\n\t\t\tlines.push(\"\");\n\t\t\tfor (const method of methods) {\n\t\t\t\tlines.push(`### ${method.name}()`);\n\t\t\t\tlines.push(\"\");\n\t\t\t\tif (method.documentation?.summary) {\n\t\t\t\t\tlines.push(method.documentation.summary);\n\t\t\t\t\tlines.push(\"\");\n\t\t\t\t}\n\t\t\t\tif (method.signature) {\n\t\t\t\t\tlines.push(\"```typescript\");\n\t\t\t\t\tlines.push(method.signature);\n\t\t\t\t\tlines.push(\"```\");\n\t\t\t\t\tlines.push(\"\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn lines.join(\"\\n\");\n}\n\n/**\n * Renders the examples page for a package — aggregates all @example blocks.\n * @internal\n */\nfunction renderExamplesPage(\n\tpackageName: string,\n\tsymbols: ForgeSymbol[],\n\t_options: SiteGeneratorOptions,\n): string {\n\tconst exported = symbols.filter(\n\t\t(s) => s.exported && s.kind !== \"method\" && s.kind !== \"property\",\n\t);\n\n\tconst lines: string[] = [];\n\tlines.push(`# ${packageName} — Examples`);\n\tlines.push(\"\");\n\tlines.push(\"All usage examples from the package, aggregated for quick reference.\");\n\tlines.push(\"\");\n\n\tlet hasExamples = false;\n\n\tfor (const s of exported) {\n\t\tconst examples = s.documentation?.examples ?? [];\n\t\tif (examples.length === 0) continue;\n\n\t\thasExamples = true;\n\t\tconst ext = s.kind === \"function\" ? \"()\" : \"\";\n\t\tlines.push(`## \\`${s.name}${ext}\\``);\n\t\tlines.push(\"\");\n\n\t\tif (s.documentation?.summary) {\n\t\t\tlines.push(`_${s.documentation.summary}_`);\n\t\t\tlines.push(\"\");\n\t\t}\n\n\t\tlines.push(`[View in API reference](./api-reference.md#${toAnchor(s.name)})`);\n\t\tlines.push(\"\");\n\n\t\tfor (const ex of examples) {\n\t\t\tlines.push(`\\`\\`\\`${ex.language}`);\n\t\t\tlines.push(ex.code.trim());\n\t\t\tlines.push(\"```\");\n\t\t\tlines.push(\"\");\n\t\t}\n\t}\n\n\tif (!hasExamples) {\n\t\tlines.push(\"_No examples documented yet._\");\n\t\tlines.push(\"\");\n\t}\n\n\treturn lines.join(\"\\n\");\n}\n\n// ---------------------------------------------------------------------------\n// API reference renderer (full, scoped to one package)\n// ---------------------------------------------------------------------------\n\nconst KIND_ORDER: ReadonlyArray<ForgeSymbol[\"kind\"]> = [\n\t\"function\",\n\t\"class\",\n\t\"interface\",\n\t\"type\",\n\t\"enum\",\n\t\"variable\",\n];\n\nconst KIND_LABELS: Record<string, string> = {\n\tfunction: \"Functions\",\n\tclass: \"Classes\",\n\tinterface: \"Interfaces\",\n\ttype: \"Types\",\n\tenum: \"Enums\",\n\tvariable: \"Variables\",\n};\n\n/** Render a single symbol section at the given heading depth. */\nfunction renderApiSymbol(symbol: ForgeSymbol, depth: number): string {\n\tconst hashes = \"#\".repeat(depth);\n\tconst ext = symbol.kind === \"function\" || symbol.kind === \"method\" ? \"()\" : \"\";\n\tconst lines: string[] = [];\n\n\tlines.push(`${hashes} \\`${symbol.name}${ext}\\``);\n\tlines.push(\"\");\n\n\tif (symbol.documentation?.deprecated) {\n\t\tlines.push(`> **Deprecated**: ${symbol.documentation.deprecated}`);\n\t\tlines.push(\"\");\n\t}\n\n\tif (symbol.signature) {\n\t\tlines.push(\"```typescript\");\n\t\tlines.push(symbol.signature);\n\t\tlines.push(\"```\");\n\t\tlines.push(\"\");\n\t}\n\n\tif (symbol.documentation?.summary) {\n\t\tlines.push(symbol.documentation.summary);\n\t\tlines.push(\"\");\n\t}\n\n\tconst params = symbol.documentation?.params ?? [];\n\tif (params.length > 0) {\n\t\tlines.push(\"**Parameters**\");\n\t\tlines.push(\"\");\n\t\tfor (const p of params) {\n\t\t\tconst typeStr = p.type ? ` (\\`${p.type}\\`)` : \"\";\n\t\t\tlines.push(`- \\`${p.name}\\`${typeStr} — ${p.description}`);\n\t\t}\n\t\tlines.push(\"\");\n\t}\n\n\tif (symbol.documentation?.returns) {\n\t\tconst retType = symbol.documentation.returns.type\n\t\t\t? ` (\\`${symbol.documentation.returns.type}\\`)`\n\t\t\t: \"\";\n\t\tlines.push(`**Returns**${retType}: ${symbol.documentation.returns.description}`);\n\t\tlines.push(\"\");\n\t}\n\n\tconst throws = symbol.documentation?.throws ?? [];\n\tif (throws.length > 0) {\n\t\tlines.push(\"**Throws**\");\n\t\tlines.push(\"\");\n\t\tfor (const t of throws) {\n\t\t\tconst typeStr = t.type ? `\\`${t.type}\\` — ` : \"\";\n\t\t\tlines.push(`- ${typeStr}${t.description}`);\n\t\t}\n\t\tlines.push(\"\");\n\t}\n\n\tconst examples = symbol.documentation?.examples ?? [];\n\tif (examples.length > 0) {\n\t\tlines.push(\"**Examples**\");\n\t\tlines.push(\"\");\n\t\tfor (const ex of examples) {\n\t\t\tlines.push(`\\`\\`\\`${ex.language}`);\n\t\t\tlines.push(ex.code.trim());\n\t\t\tlines.push(\"```\");\n\t\t\tlines.push(\"\");\n\t\t}\n\t}\n\n\tconst children = symbol.children ?? [];\n\tif (children.length > 0 && depth < 5) {\n\t\tfor (const child of children) {\n\t\t\tlines.push(renderApiSymbol(child, depth + 1));\n\t\t}\n\t}\n\n\treturn lines.join(\"\\n\");\n}\n\n/** Render a full API reference page for one package. */\nfunction renderApiReferencePage(packageName: string, symbols: ForgeSymbol[]): string {\n\tconst exported = symbols.filter(\n\t\t(s) => s.exported && s.kind !== \"method\" && s.kind !== \"property\",\n\t);\n\n\tconst groups = new Map<ForgeSymbol[\"kind\"], ForgeSymbol[]>();\n\tfor (const s of exported) {\n\t\tconst list = groups.get(s.kind) ?? [];\n\t\tlist.push(s);\n\t\tgroups.set(s.kind, list);\n\t}\n\n\tconst lines: string[] = [];\n\tlines.push(`# ${packageName} — API Reference`);\n\tlines.push(\"\");\n\n\tfor (const kind of KIND_ORDER) {\n\t\tconst group = groups.get(kind);\n\t\tif (!group || group.length === 0) continue;\n\n\t\tlines.push(`## ${KIND_LABELS[kind]}`);\n\t\tlines.push(\"\");\n\n\t\tfor (const s of group) {\n\t\t\tlines.push(renderApiSymbol(s, 3));\n\t\t\tlines.push(\"\");\n\t\t}\n\t}\n\n\treturn lines.join(\"\\n\");\n}\n\n// ---------------------------------------------------------------------------\n// Project-level pages\n// ---------------------------------------------------------------------------\n\n/** Render the root index page listing all packages. */\nfunction renderProjectIndexPage(\n\tsymbolsByPackage: Map<string, ForgeSymbol[]>,\n\toptions: SiteGeneratorOptions,\n): string {\n\tconst lines: string[] = [];\n\tlines.push(`# ${options.projectName}`);\n\tlines.push(\"\");\n\n\tif (options.projectDescription) {\n\t\tlines.push(options.projectDescription);\n\t\tlines.push(\"\");\n\t}\n\n\tlines.push(\"## Packages\");\n\tlines.push(\"\");\n\n\tfor (const [pkgName, symbols] of symbolsByPackage) {\n\t\tconst exported = symbols.filter(\n\t\t\t(s) => s.exported && s.kind !== \"method\" && s.kind !== \"property\",\n\t\t);\n\t\tconst pkgDoc = symbols\n\t\t\t.map((s) => s.documentation?.tags?.packageDocumentation?.[0])\n\t\t\t.find(Boolean);\n\t\tconst summary = pkgDoc ?? `${exported.length} exported symbol(s).`;\n\t\tlines.push(`### [${pkgName}](./packages/${pkgName}/index.md)`);\n\t\tlines.push(\"\");\n\t\tlines.push(summary);\n\t\tlines.push(\"\");\n\t}\n\n\treturn lines.join(\"\\n\");\n}\n\n/** Render a getting-started page using the first @example from any exported function. */\nfunction renderGettingStartedPage(\n\tsymbolsByPackage: Map<string, ForgeSymbol[]>,\n\toptions: SiteGeneratorOptions,\n): string {\n\t// Find the first exported function with an example\n\tlet firstExample: { code: string; language: string } | undefined;\n\tlet firstSymbolName = \"\";\n\tlet firstPackageName = \"\";\n\n\touter: for (const [pkgName, symbols] of symbolsByPackage) {\n\t\tfor (const s of symbols) {\n\t\t\tif (!s.exported || s.kind !== \"function\") continue;\n\t\t\tconst ex = s.documentation?.examples?.[0];\n\t\t\tif (ex) {\n\t\t\t\tfirstExample = ex;\n\t\t\t\tfirstSymbolName = s.name;\n\t\t\t\tfirstPackageName = pkgName;\n\t\t\t\tbreak outer;\n\t\t\t}\n\t\t}\n\t}\n\n\tconst lines: string[] = [];\n\tlines.push(\"# Getting Started\");\n\tlines.push(\"\");\n\tlines.push(`Welcome to **${options.projectName}**.`);\n\n\tif (options.projectDescription) {\n\t\tlines.push(\"\");\n\t\tlines.push(options.projectDescription);\n\t}\n\n\tlines.push(\"\");\n\tlines.push(\"## Installation\");\n\tlines.push(\"\");\n\tlines.push(\"```bash\");\n\tlines.push(`npm install ${options.projectName}`);\n\tlines.push(\"```\");\n\tlines.push(\"\");\n\n\tif (firstExample) {\n\t\tlines.push(\"## Quick Start\");\n\t\tlines.push(\"\");\n\t\tlines.push(\n\t\t\t`The following example demonstrates \\`${firstSymbolName}\\` from the \\`${firstPackageName}\\` package.`,\n\t\t);\n\t\tlines.push(\"\");\n\t\tlines.push(`\\`\\`\\`${firstExample.language}`);\n\t\tlines.push(firstExample.code.trim());\n\t\tlines.push(\"```\");\n\t\tlines.push(\"\");\n\t}\n\n\tlines.push(\"## Next Steps\");\n\tlines.push(\"\");\n\tlines.push(\"- Browse the [API Reference](./packages/)\");\n\tfor (const pkgName of symbolsByPackage.keys()) {\n\t\tlines.push(` - [${pkgName}](./packages/${pkgName}/api-reference.md)`);\n\t}\n\n\treturn lines.join(\"\\n\");\n}\n\n// ---------------------------------------------------------------------------\n// Main entry point\n// ---------------------------------------------------------------------------\n\n/**\n * Generates a full multi-page documentation site from symbols grouped by package.\n *\n * Produces an index page, a getting-started page, and per-package pages for\n * the API reference, types, functions, and examples.\n *\n * @param symbolsByPackage - Symbols grouped by package name.\n * @param config - The resolved {@link ForgeConfig}.\n * @param options - Site generation options.\n * @returns An array of {@link DocPage} objects ready to be written to disk.\n * @public\n */\nexport function generateDocSite(\n\tsymbolsByPackage: Map<string, ForgeSymbol[]>,\n\tconfig: ForgeConfig,\n\toptions: SiteGeneratorOptions,\n): DocPage[] {\n\tconst ext = options.format === \"mdx\" ? \"mdx\" : \"md\";\n\tconst pages: DocPage[] = [];\n\n\t// Project index\n\tconst indexContent = renderProjectIndexPage(symbolsByPackage, options);\n\tconst indexFrontmatter = buildFrontmatterFields(\n\t\toptions.projectName,\n\t\toptions.projectDescription ?? \"\",\n\t\toptions.ssgTarget,\n\t\t1,\n\t);\n\tpages.push({\n\t\tpath: `index.${ext}`,\n\t\tcontent: `${serializeFrontmatter(indexFrontmatter)}${indexContent.trimEnd()}\\n`,\n\t\tfrontmatter: indexFrontmatter,\n\t});\n\n\t// Getting started\n\tconst gettingStartedContent = renderGettingStartedPage(symbolsByPackage, options);\n\tconst gettingStartedFrontmatter = buildFrontmatterFields(\n\t\t\"Getting Started\",\n\t\t`Quick start guide for ${options.projectName}`,\n\t\toptions.ssgTarget,\n\t\t2,\n\t);\n\tpages.push({\n\t\tpath: `getting-started.${ext}`,\n\t\tcontent: `${serializeFrontmatter(gettingStartedFrontmatter)}${gettingStartedContent.trimEnd()}\\n`,\n\t\tfrontmatter: gettingStartedFrontmatter,\n\t});\n\n\t// Per-package pages\n\tlet pkgPosition = 1;\n\tfor (const [pkgName, symbols] of symbolsByPackage) {\n\t\tconst pkgBase = `packages/${pkgName}`;\n\n\t\t// Package index\n\t\tconst overviewContent = renderOverviewPage(pkgName, symbols, options);\n\t\tconst overviewFrontmatter = buildFrontmatterFields(\n\t\t\tpkgName,\n\t\t\t`${pkgName} package overview`,\n\t\t\toptions.ssgTarget,\n\t\t\tpkgPosition,\n\t\t);\n\t\tpages.push({\n\t\t\tpath: `${pkgBase}/index.${ext}`,\n\t\t\tcontent: `${serializeFrontmatter(overviewFrontmatter)}${overviewContent.trimEnd()}\\n`,\n\t\t\tfrontmatter: overviewFrontmatter,\n\t\t});\n\n\t\t// API reference\n\t\tconst apiContent = renderApiReferencePage(pkgName, symbols);\n\t\tconst apiFrontmatter = buildFrontmatterFields(\n\t\t\t`${pkgName} — API Reference`,\n\t\t\t`Full API reference for the ${pkgName} package`,\n\t\t\toptions.ssgTarget,\n\t\t);\n\t\tpages.push({\n\t\t\tpath: `${pkgBase}/api-reference.${ext}`,\n\t\t\tcontent: `${serializeFrontmatter(apiFrontmatter)}${apiContent.trimEnd()}\\n`,\n\t\t\tfrontmatter: apiFrontmatter,\n\t\t});\n\n\t\t// Types page\n\t\tconst typesContent = renderTypesPage(pkgName, symbols, options);\n\t\tconst typesFrontmatter = buildFrontmatterFields(\n\t\t\t`${pkgName} — Types`,\n\t\t\t`Type contracts for the ${pkgName} package`,\n\t\t\toptions.ssgTarget,\n\t\t);\n\t\tpages.push({\n\t\t\tpath: `${pkgBase}/types.${ext}`,\n\t\t\tcontent: `${serializeFrontmatter(typesFrontmatter)}${typesContent.trimEnd()}\\n`,\n\t\t\tfrontmatter: typesFrontmatter,\n\t\t});\n\n\t\t// Functions page\n\t\tconst functionsContent = renderFunctionsPage(pkgName, symbols, options);\n\t\tconst functionsFrontmatter = buildFrontmatterFields(\n\t\t\t`${pkgName} — Functions`,\n\t\t\t`Functions and classes for the ${pkgName} package`,\n\t\t\toptions.ssgTarget,\n\t\t);\n\t\tpages.push({\n\t\t\tpath: `${pkgBase}/functions.${ext}`,\n\t\t\tcontent: `${serializeFrontmatter(functionsFrontmatter)}${functionsContent.trimEnd()}\\n`,\n\t\t\tfrontmatter: functionsFrontmatter,\n\t\t});\n\n\t\t// Examples page\n\t\tconst examplesContent = renderExamplesPage(pkgName, symbols, options);\n\t\tconst examplesFrontmatter = buildFrontmatterFields(\n\t\t\t`${pkgName} — Examples`,\n\t\t\t`Usage examples for the ${pkgName} package`,\n\t\t\toptions.ssgTarget,\n\t\t);\n\t\tpages.push({\n\t\t\tpath: `${pkgBase}/examples.${ext}`,\n\t\t\tcontent: `${serializeFrontmatter(examplesFrontmatter)}${examplesContent.trimEnd()}\\n`,\n\t\t\tfrontmatter: examplesFrontmatter,\n\t\t});\n\n\t\tpkgPosition++;\n\t}\n\n\t// Suppress unused variable warning — config is available for future use\n\tvoid config;\n\n\treturn pages;\n}\n","import type { DocPage } from \"./site-generator.js\";\n\n/**\n * A single generated SSG configuration file.\n * @public\n */\nexport interface SSGConfigFile {\n\t/** Relative path from outDir (e.g., \"mint.json\", \"_meta.json\") */\n\tpath: string;\n\t/** File content */\n\tcontent: string;\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\n/** Strip the file extension from a page path, returning the slug. */\nfunction pageSlug(pagePath: string): string {\n\treturn pagePath.replace(/\\.[^.]+$/, \"\");\n}\n\n/**\n * Partition pages into top-level pages and package pages.\n *\n * Top-level pages are those not nested under `packages/`.\n * Package pages are grouped by their package directory segment.\n */\nfunction partitionPages(pages: DocPage[]): {\n\ttopLevel: string[];\n\tbyPackage: Map<string, string[]>;\n} {\n\tconst topLevel: string[] = [];\n\tconst byPackage = new Map<string, string[]>();\n\n\tfor (const page of pages) {\n\t\tconst slug = pageSlug(page.path);\n\t\tconst packageMatch = /^packages\\/([^/]+)\\/(.+)$/.exec(slug);\n\t\tif (packageMatch) {\n\t\t\tconst pkgName = packageMatch[1];\n\t\t\tconst list = byPackage.get(pkgName) ?? [];\n\t\t\tlist.push(slug);\n\t\t\tbyPackage.set(pkgName, list);\n\t\t} else {\n\t\t\ttopLevel.push(slug);\n\t\t}\n\t}\n\n\treturn { topLevel, byPackage };\n}\n\n/** Convert a slug segment to a human-readable label. */\nfunction slugToLabel(slug: string): string {\n\treturn slug\n\t\t.split(\"-\")\n\t\t.map((w) => w.charAt(0).toUpperCase() + w.slice(1))\n\t\t.join(\" \");\n}\n\n// ---------------------------------------------------------------------------\n// Mintlify\n// ---------------------------------------------------------------------------\n\ninterface MintlifyNavigationPage {\n\tgroup: string;\n\tpages: Array<string | MintlifyNavigationPage>;\n}\n\ninterface MintlifyConfig {\n\t$schema: string;\n\tname: string;\n\tnavigation: MintlifyNavigationPage[];\n}\n\nfunction generateMintlifyConfig(pages: DocPage[], projectName: string): SSGConfigFile {\n\tconst { topLevel, byPackage } = partitionPages(pages);\n\n\tconst navigation: MintlifyNavigationPage[] = [];\n\n\tif (topLevel.length > 0) {\n\t\tnavigation.push({\n\t\t\tgroup: \"Getting Started\",\n\t\t\tpages: topLevel,\n\t\t});\n\t}\n\n\tif (byPackage.size > 0) {\n\t\tconst packageGroups: MintlifyNavigationPage[] = [];\n\t\tfor (const [pkgName, slugs] of byPackage) {\n\t\t\tpackageGroups.push({\n\t\t\t\tgroup: pkgName,\n\t\t\t\tpages: slugs,\n\t\t\t});\n\t\t}\n\t\tnavigation.push({\n\t\t\tgroup: \"Packages\",\n\t\t\tpages: packageGroups as unknown as Array<string | MintlifyNavigationPage>,\n\t\t});\n\t}\n\n\tconst config: MintlifyConfig = {\n\t\t$schema: \"https://mintlify.com/schema.json\",\n\t\tname: projectName,\n\t\tnavigation,\n\t};\n\n\treturn {\n\t\tpath: \"mint.json\",\n\t\tcontent: `${JSON.stringify(config, null, 2)}\\n`,\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// Docusaurus\n// ---------------------------------------------------------------------------\n\ninterface DocusaurusCategory {\n\ttype: \"category\";\n\tlabel: string;\n\titems: Array<string | DocusaurusCategory>;\n}\n\ntype DocusaurusSidebarItem = string | DocusaurusCategory;\n\nfunction generateDocusaurusConfig(pages: DocPage[], _projectName: string): SSGConfigFile {\n\tconst { topLevel, byPackage } = partitionPages(pages);\n\n\tconst items: DocusaurusSidebarItem[] = [...topLevel];\n\n\tfor (const [pkgName, slugs] of byPackage) {\n\t\titems.push({\n\t\t\ttype: \"category\",\n\t\t\tlabel: pkgName,\n\t\t\titems: slugs,\n\t\t});\n\t}\n\n\tconst sidebarObj = { docs: items };\n\tconst json = JSON.stringify(sidebarObj, null, 2);\n\tconst content =\n\t\t`/** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */\\n` +\n\t\t`const sidebars = ${json};\\n` +\n\t\t`module.exports = sidebars;\\n`;\n\n\treturn {\n\t\tpath: \"sidebars.js\",\n\t\tcontent,\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// Nextra\n// ---------------------------------------------------------------------------\n\nfunction generateNextraConfigs(pages: DocPage[], _projectName: string): SSGConfigFile[] {\n\tconst { topLevel, byPackage } = partitionPages(pages);\n\tconst files: SSGConfigFile[] = [];\n\n\t// Root _meta.json\n\tconst rootMeta: Record<string, string> = {};\n\tfor (const slug of topLevel) {\n\t\tconst segment = slug.split(\"/\").pop() ?? slug;\n\t\trootMeta[segment] = slugToLabel(segment);\n\t}\n\tif (byPackage.size > 0) {\n\t\trootMeta.packages = \"Packages\";\n\t}\n\n\tfiles.push({\n\t\tpath: \"_meta.json\",\n\t\tcontent: `${JSON.stringify(rootMeta, null, 2)}\\n`,\n\t});\n\n\t// Per-package _meta.json files\n\tfor (const [pkgName, slugs] of byPackage) {\n\t\tconst pkgMeta: Record<string, string> = {};\n\t\tfor (const slug of slugs) {\n\t\t\t// slug is e.g. \"packages/core/api-reference\"\n\t\t\tconst segment = slug.split(\"/\").pop() ?? slug;\n\t\t\tpkgMeta[segment] = slugToLabel(segment);\n\t\t}\n\n\t\t// packages/<pkgName>/_meta.json\n\t\tfiles.push({\n\t\t\tpath: `packages/${pkgName}/_meta.json`,\n\t\t\tcontent: `${JSON.stringify(pkgMeta, null, 2)}\\n`,\n\t\t});\n\t}\n\n\t// If there are multiple packages, also write a packages/_meta.json\n\tif (byPackage.size > 1) {\n\t\tconst packagesMeta: Record<string, string> = {};\n\t\tfor (const pkgName of byPackage.keys()) {\n\t\t\tpackagesMeta[pkgName] = pkgName;\n\t\t}\n\t\tfiles.push({\n\t\t\tpath: \"packages/_meta.json\",\n\t\t\tcontent: `${JSON.stringify(packagesMeta, null, 2)}\\n`,\n\t\t});\n\t}\n\n\treturn files;\n}\n\n// ---------------------------------------------------------------------------\n// VitePress\n// ---------------------------------------------------------------------------\n\ninterface VitePressItem {\n\ttext: string;\n\tlink: string;\n}\n\ninterface VitePressGroup {\n\ttext: string;\n\titems: VitePressItem[];\n}\n\nfunction generateVitePressConfig(pages: DocPage[], _projectName: string): SSGConfigFile {\n\tconst { topLevel, byPackage } = partitionPages(pages);\n\tconst sidebar: VitePressGroup[] = [];\n\n\tif (topLevel.length > 0) {\n\t\tconst items: VitePressItem[] = topLevel.map((slug) => {\n\t\t\tconst segment = slug.split(\"/\").pop() ?? slug;\n\t\t\tconst link = slug === \"index\" ? \"/\" : `/${slug}`;\n\t\t\treturn { text: slugToLabel(segment), link };\n\t\t});\n\t\tsidebar.push({ text: \"Getting Started\", items });\n\t}\n\n\tfor (const [pkgName, slugs] of byPackage) {\n\t\tconst items: VitePressItem[] = slugs.map((slug) => {\n\t\t\tconst segment = slug.split(\"/\").pop() ?? slug;\n\t\t\tconst isIndex = segment === \"index\";\n\t\t\tconst link = isIndex ? `/packages/${pkgName}/` : `/${slug}`;\n\t\t\treturn { text: slugToLabel(segment), link };\n\t\t});\n\t\tsidebar.push({ text: pkgName, items });\n\t}\n\n\treturn {\n\t\tpath: \".vitepress/sidebar.json\",\n\t\tcontent: `${JSON.stringify(sidebar, null, 2)}\\n`,\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// Public entry point\n// ---------------------------------------------------------------------------\n\n/**\n * Generate navigation configuration file(s) for the given SSG target.\n *\n * Returns one file for most targets, but multiple files for Nextra (which\n * uses per-directory `_meta.json` files).\n *\n * @param pages - The {@link DocPage} array produced by `generateDocSite`.\n * @param target - The SSG target.\n * @param projectName - The project name (used in config metadata).\n * @returns An array of {@link SSGConfigFile} objects ready to be written to disk.\n * @public\n */\nexport function generateSSGConfigs(\n\tpages: DocPage[],\n\ttarget: \"docusaurus\" | \"mintlify\" | \"nextra\" | \"vitepress\",\n\tprojectName: string,\n): SSGConfigFile[] {\n\tswitch (target) {\n\t\tcase \"mintlify\":\n\t\t\treturn [generateMintlifyConfig(pages, projectName)];\n\t\tcase \"docusaurus\":\n\t\t\treturn [generateDocusaurusConfig(pages, projectName)];\n\t\tcase \"nextra\":\n\t\t\treturn generateNextraConfigs(pages, projectName);\n\t\tcase \"vitepress\":\n\t\t\treturn [generateVitePressConfig(pages, projectName)];\n\t\tdefault: {\n\t\t\t// Exhaustiveness guard — TypeScript will catch unhandled variants at\n\t\t\t// compile time, but we want a safe runtime fallback too.\n\t\t\tconst _exhaustive: never = target;\n\t\t\tvoid _exhaustive;\n\t\t\treturn [];\n\t\t}\n\t}\n}\n","/**\n * @forge-ts/gen — Markdown/MDX documentation and llms.txt generator.\n *\n * Generates human- and machine-readable documentation from the forge-ts\n * symbol graph, with optional README injection.\n *\n * @packageDocumentation\n * @public\n */\n\nexport { generateLlmsFullTxt, generateLlmsTxt } from \"./llms.js\";\nexport {\n\tgenerateMarkdown,\n\ttype MarkdownOptions,\n} from \"./markdown.js\";\nexport { type ReadmeSyncOptions, syncReadme } from \"./readme-sync.js\";\nexport {\n\ttype DocPage,\n\tgenerateDocSite,\n\tgroupSymbolsByPackage,\n\ttype SiteGeneratorOptions,\n} from \"./site-generator.js\";\nexport { generateSSGConfigs, type SSGConfigFile } from \"./ssg-config.js\";\n\nimport { mkdir, writeFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { createWalker, type ForgeConfig, type ForgeResult } from \"@forge-ts/core\";\nimport { generateLlmsFullTxt, generateLlmsTxt } from \"./llms.js\";\nimport { generateMarkdown } from \"./markdown.js\";\nimport { syncReadme } from \"./readme-sync.js\";\nimport { generateDocSite, groupSymbolsByPackage } from \"./site-generator.js\";\nimport { generateSSGConfigs } from \"./ssg-config.js\";\n\n/**\n * Runs the full generation pipeline: walk → render → write.\n *\n * @param config - The resolved {@link ForgeConfig} for the project.\n * @returns A {@link ForgeResult} describing the outcome.\n * @public\n */\nexport async function generate(config: ForgeConfig): Promise<ForgeResult> {\n\tconst start = Date.now();\n\n\tconst walker = createWalker(config);\n\tconst symbols = walker.walk();\n\n\tawait mkdir(config.outDir, { recursive: true });\n\n\t// Legacy flat output — kept for backward compatibility\n\tfor (const format of config.gen.formats) {\n\t\tconst content = generateMarkdown(symbols, config, {\n\t\t\tmdx: format === \"mdx\",\n\t\t});\n\t\tconst ext = format === \"mdx\" ? \"mdx\" : \"md\";\n\t\tawait writeFile(join(config.outDir, `api-reference.${ext}`), content, \"utf8\");\n\t}\n\n\t// Multi-page site output — writes directly to outDir\n\tconst projectName = config.rootDir.split(\"/\").pop() ?? \"Project\";\n\tconst symbolsByPackage = groupSymbolsByPackage(symbols, config.rootDir);\n\n\tfor (const format of config.gen.formats) {\n\t\tconst pages = generateDocSite(symbolsByPackage, config, {\n\t\t\tformat,\n\t\t\tssgTarget: config.gen.ssgTarget,\n\t\t\tprojectName,\n\t\t});\n\n\t\tfor (const page of pages) {\n\t\t\tconst pagePath = join(config.outDir, page.path);\n\t\t\tconst pageDir = pagePath.substring(0, pagePath.lastIndexOf(\"/\"));\n\t\t\tawait mkdir(pageDir, { recursive: true });\n\t\t\tawait writeFile(pagePath, page.content, \"utf8\");\n\t\t}\n\n\t\tif (config.gen.ssgTarget) {\n\t\t\tconst configFiles = generateSSGConfigs(pages, config.gen.ssgTarget, projectName);\n\t\t\tfor (const configFile of configFiles) {\n\t\t\t\tconst configPath = join(config.outDir, configFile.path);\n\t\t\t\tconst configDir = configPath.substring(0, configPath.lastIndexOf(\"/\"));\n\t\t\t\tawait mkdir(configDir, { recursive: true });\n\t\t\t\tawait writeFile(configPath, configFile.content, \"utf8\");\n\t\t\t}\n\t\t}\n\t}\n\n\tif (config.gen.llmsTxt) {\n\t\tconst llms = generateLlmsTxt(symbols, config);\n\t\tawait writeFile(join(config.outDir, \"llms.txt\"), llms, \"utf8\");\n\n\t\tconst llmsFull = generateLlmsFullTxt(symbols, config);\n\t\tawait writeFile(join(config.outDir, \"llms-full.txt\"), llmsFull, \"utf8\");\n\t}\n\n\tif (config.gen.readmeSync) {\n\t\tawait syncReadme(join(config.rootDir, \"README.md\"), symbols);\n\t}\n\n\treturn {\n\t\tsuccess: true,\n\t\tsymbols,\n\t\terrors: [],\n\t\twarnings: [],\n\t\tduration: Date.now() - start,\n\t};\n}\n"],"mappings":";AAMA,SAAS,aAAa,QAA6B;AAClD,MAAI,OAAO,WAAW;AACrB,WAAO,OAAO;AAAA,EACf;AACA,QAAM,MAAM,OAAO,SAAS,aAAa,OAAO;AAChD,SAAO,GAAG,OAAO,IAAI,IAAI,OAAO,IAAI,GAAG,GAAG;AAC3C;AAaO,SAAS,gBAAgB,SAAwB,QAA6B;AACpF,QAAM,WAAW,QAAQ,OAAO,CAAC,MAAM,EAAE,QAAQ;AACjD,QAAM,cAAc,OAAO,QAAQ,MAAM,GAAG,EAAE,IAAI,KAAK;AAEvD,QAAM,QAAkB,CAAC;AAEzB,QAAM,KAAK,KAAK,WAAW,EAAE;AAC7B,QAAM,KAAK,oCAAoC;AAC/C,QAAM,KAAK,EAAE;AAGb,QAAM,KAAK,aAAa;AAC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 +1,6 @@
1
1
  {
2
2
  "name": "@forge-ts/gen",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "description": "Markdown/MDX and llms.txt generator for forge-ts",
6
6
  "license": "MIT",
@@ -24,7 +24,7 @@
24
24
  }
25
25
  },
26
26
  "dependencies": {
27
- "@forge-ts/core": "0.2.1"
27
+ "@forge-ts/core": "0.3.0"
28
28
  },
29
29
  "devDependencies": {
30
30
  "tsup": "^8.3.5",