docs: generate complete UI component reference
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import { join, resolve } from "node:path";
|
||||
import { format } from "prettier";
|
||||
|
||||
@@ -15,6 +15,28 @@ const packageNames = [...Object.keys(pkg.dependencies), ...Object.keys(pkg.devDe
|
||||
.filter((name, index, all) => all.indexOf(name) === index)
|
||||
.sort();
|
||||
const packageCount = packageNames.length;
|
||||
const uiReferencePath = join(root, "node_modules", "@wrnexus", "ui", "component-reference.json");
|
||||
const uiReference = existsSync(uiReferencePath)
|
||||
? (JSON.parse(readFileSync(uiReferencePath, "utf8")) as {
|
||||
count: number;
|
||||
components: Array<{
|
||||
name: string;
|
||||
mount: string;
|
||||
category: string;
|
||||
props: Array<{ name: string; type: string; required: boolean; default: string | null }>;
|
||||
slots: string[];
|
||||
events: string[];
|
||||
}>;
|
||||
})
|
||||
: undefined;
|
||||
const uiReferenceText = uiReference
|
||||
? uiReference.components
|
||||
.map(
|
||||
(component) =>
|
||||
`### ${component.name}\nMount: data-component="${component.mount}"\nCategory: ${component.category}\nProps: ${component.props.length ? component.props.map((prop) => `${prop.name}: ${prop.type}${prop.required ? " (required)" : ` = ${prop.default}`}`).join(", ") : "none"}\nSlots: ${component.slots.join(", ") || "none"}\nEvents: ${component.events.join(", ") || "none"}`,
|
||||
)
|
||||
.join("\n\n")
|
||||
: "UI component reference unavailable; install the release-aligned @wrnexus/ui package.";
|
||||
|
||||
async function writeFormatted(path: string, source: string) {
|
||||
writeFileSync(path, await format(source, { filepath: path }));
|
||||
@@ -487,7 +509,7 @@ await writeFormatted(
|
||||
);
|
||||
writeFileSync(
|
||||
join(pub, "llms-full.txt"),
|
||||
`# WRNexusJS ${version} comprehensive documentation index\n\nStatus: Private Developer Preview. Runtime: Bun. UI language: .wrn.\nThis is the documentation application, not the framework monorepo.\n\n${urls.map((x) => `- https://wrnexusjs.dev${x}`).join("\n")}\n\nFor exact APIs, use installed package README files followed by exported declarations.\n`,
|
||||
`# WRNexusJS ${version} comprehensive documentation index\n\nStatus: Private Developer Preview. Runtime: Bun. UI language: .wrn.\nThis is the documentation application, not the framework monorepo.\n\n${urls.map((x) => `- https://wrnexusjs.dev${x}`).join("\n")}\n\nFor exact APIs, use installed package README files followed by exported declarations.\n\n# Complete @wrnexus/ui component reference\n\n${uiReferenceText}\n`,
|
||||
);
|
||||
|
||||
const packageMarker = "# Installed package documentation";
|
||||
@@ -511,7 +533,7 @@ const installedPackageDocs = packageNames
|
||||
.join("\n\n---\n\n");
|
||||
writeFileSync(
|
||||
join(pub, "llms.txt"),
|
||||
`${frameworkGuide}\n\n${packageMarker}\n\nThe following README files and declarations come from the installed private ${version} release.\n\n${installedPackageDocs}\n`,
|
||||
`${frameworkGuide}\n\n# UI component catalog\n\nThe installed @wrnexus/ui release contains ${uiReference?.count ?? 0} documented components. Every mount name, prop type, required/default status, slot, and event is included below and in llms-full.txt.\n\n${uiReferenceText}\n\n${packageMarker}\n\nThe following README files and declarations come from the installed private ${version} release.\n\n${installedPackageDocs}\n`,
|
||||
);
|
||||
|
||||
const auditDocs: Record<string, string> = {
|
||||
|
||||
Reference in New Issue
Block a user