From 16ad6a2380b4ef9d8ebbf35f20a78cce1c8a827a Mon Sep 17 00:00:00 2001 From: Simon Farshid Date: Sun, 10 Nov 2024 17:34:55 -0800 Subject: [PATCH] docs: autogenerated typeDocs tree shaking (#1148) --- .../content/docs/reference/AssistantRuntimeProvider.mdx | 4 ++-- .../content/docs/reference/TextContentPartProvider.mdx | 4 ++-- apps/docs/scripts/generate-docs.mts | 8 +++++++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/apps/docs/content/docs/reference/AssistantRuntimeProvider.mdx b/apps/docs/content/docs/reference/AssistantRuntimeProvider.mdx index 3b43f6d10..d0669bc97 100644 --- a/apps/docs/content/docs/reference/AssistantRuntimeProvider.mdx +++ b/apps/docs/content/docs/reference/AssistantRuntimeProvider.mdx @@ -3,7 +3,7 @@ title: --- import { ParametersTable } from "@/components/docs"; -import typeDocs from "@/generated/typeDocs.json"; +import { AssistantRuntimeProvider } from "@/generated/typeDocs"; The `AssistantRuntimeProvider` provides data and APIs used by assistant-ui components. @@ -27,4 +27,4 @@ const MyApp = () => { #### Properties - + diff --git a/apps/docs/content/docs/reference/TextContentPartProvider.mdx b/apps/docs/content/docs/reference/TextContentPartProvider.mdx index b07a062c3..648b70cc8 100644 --- a/apps/docs/content/docs/reference/TextContentPartProvider.mdx +++ b/apps/docs/content/docs/reference/TextContentPartProvider.mdx @@ -3,7 +3,7 @@ title: --- import { ParametersTable } from "@/components/docs"; -import typeDocs from "@/generated/typeDocs.json"; +import { AssistantRuntimeProvider } from "@/generated/typeDocs"; The `TextContentPartProvider` provides data and APIs for `TextContentPart` components. @@ -25,4 +25,4 @@ const MyApp = () => { #### Properties - + diff --git a/apps/docs/scripts/generate-docs.mts b/apps/docs/scripts/generate-docs.mts index a5362c93a..409d9a5c2 100644 --- a/apps/docs/scripts/generate-docs.mts +++ b/apps/docs/scripts/generate-docs.mts @@ -32,8 +32,14 @@ sourceFile.getExportedDeclarations().forEach((declarations, name) => { }); }); +const typesSrc = Object.entries(types) + .map(([name, type]) => { + return `export const ${name} = ${JSON.stringify(type, null, 2)};\n`; + }) + .join("\n"); + fs.mkdirSync("./generated", { recursive: true }); -fs.writeFileSync("./generated/typeDocs.json", JSON.stringify(types, null, 2)); +fs.writeFileSync("./generated/typeDocs.ts", typesSrc); // Function to resolve aliased declarations function resolveAliasedDeclaration(declaration: any) {