Skip to content

Commit

Permalink
docs: autogenerated typeDocs tree shaking (#1148)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yonom authored Nov 11, 2024
1 parent c2f75e5 commit 16ad6a2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions apps/docs/content/docs/reference/AssistantRuntimeProvider.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: <AssistantRuntimeProvider />
---

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.

Expand All @@ -27,4 +27,4 @@ const MyApp = () => {

#### Properties

<ParametersTable {...typeDocs.AssistantRuntimeProvider} />
<ParametersTable {...AssistantRuntimeProvider} />
4 changes: 2 additions & 2 deletions apps/docs/content/docs/reference/TextContentPartProvider.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: <AssistantRuntimeProvider />
---

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.

Expand All @@ -25,4 +25,4 @@ const MyApp = () => {

#### Properties

<ParametersTable {...typeDocs.AssistantRuntimeProvider} />
<ParametersTable {...AssistantRuntimeProvider} />
8 changes: 7 additions & 1 deletion apps/docs/scripts/generate-docs.mts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 16ad6a2

Please sign in to comment.