ardo 3.1.0 → 3.2.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/README.md +9 -19
- package/dist/DocPage-BVibJR9O.js +997 -0
- package/dist/DocPage-BVibJR9O.js.map +1 -0
- package/dist/assets/src/ui/Breadcrumb.css.ts.vanilla-Dpgq-C_p.css +20 -0
- package/dist/assets/src/ui/DocPage.css.ts.vanilla-CXKuz4U-.css +34 -0
- package/dist/assets/src/ui/Footer.css.ts.vanilla-BSzPIPt4.css +100 -0
- package/dist/assets/src/ui/Header.css.ts.vanilla-8QL0Jzgk.css +156 -0
- package/dist/assets/src/ui/Layout.css.ts.vanilla-Bpx_-gJt.css +67 -0
- package/dist/assets/src/ui/Nav.css.ts.vanilla-CsAQjogy.css +51 -0
- package/dist/assets/src/ui/Sidebar.css.ts.vanilla-D70qXTEr.css +115 -0
- package/dist/assets/src/ui/TOC.css.ts.vanilla-435FKDcl.css +52 -0
- package/dist/assets/src/ui/components/ApiItem.css.ts.vanilla-B_DW-1iJ.css +218 -0
- package/dist/assets/src/ui/components/CodeBlock.css.ts.vanilla-lNKqskjQ.css +182 -0
- package/dist/assets/src/ui/components/Container.css.ts.vanilla-CUhRUA9t.css +80 -0
- package/dist/assets/src/ui/components/CopyButton.css.ts.vanilla-DZZ5jgTM.css +24 -0
- package/dist/assets/src/ui/components/Features.css.ts.vanilla-D-pNXM9Q.css +129 -0
- package/dist/assets/src/ui/components/Hero.css.ts.vanilla-DHJVZ6GX.css +134 -0
- package/dist/assets/src/ui/components/Search.css.ts.vanilla-BYpWHzky.css +135 -0
- package/dist/assets/src/ui/components/Steps.css.ts.vanilla-CisaxeNj.css +59 -0
- package/dist/assets/src/ui/components/Tabs.css.ts.vanilla-C4-vJSnf.css +30 -0
- package/dist/assets/src/ui/components/ThemeToggle.css.ts.vanilla---sSUELC.css +22 -0
- package/dist/assets/src/ui/content.css.ts.vanilla-O_RaSPXm.css +106 -0
- package/dist/assets/src/ui/theme/animations.css.ts.vanilla-D6ImVUKy.css +10 -0
- package/dist/assets/src/ui/theme/dark.css.ts.vanilla-2iJgcpbU.css +87 -0
- package/dist/assets/src/ui/theme/light.css.ts.vanilla-CwinfWSf.css +87 -0
- package/dist/assets/src/ui/theme/reset.css.ts.vanilla-0Q3pLjfC.css +34 -0
- package/dist/config/index.d.ts +5 -5
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +54 -11
- package/dist/config/index.js.map +1 -1
- package/dist/contract.css-QS0y3-CM.d.ts +105 -0
- package/dist/contract.css-QS0y3-CM.d.ts.map +1 -0
- package/dist/generator-DcUomVnD.js +1193 -0
- package/dist/generator-DcUomVnD.js.map +1 -0
- package/dist/icons/index.d.ts +1 -1
- package/dist/icons/index.js +1 -2
- package/dist/index-DNKCjxv5.d.ts +78 -0
- package/dist/index-DNKCjxv5.d.ts.map +1 -0
- package/dist/index-DSeJoaxz.d.ts +938 -0
- package/dist/index-DSeJoaxz.d.ts.map +1 -0
- package/dist/index.d.ts +5 -8
- package/dist/index.js +6 -100
- package/dist/mdx/provider.d.ts +61 -4
- package/dist/mdx/provider.d.ts.map +1 -0
- package/dist/mdx/provider.js +89 -117
- package/dist/mdx/provider.js.map +1 -1
- package/dist/runtime/index.d.ts +2 -41
- package/dist/runtime/index.js +2 -28
- package/dist/sidebar-utils-1Skqle1Q.js +109 -0
- package/dist/sidebar-utils-1Skqle1Q.js.map +1 -0
- package/dist/theme/index.d.ts +201 -182
- package/dist/theme/index.d.ts.map +1 -0
- package/dist/theme/index.js +288 -128
- package/dist/theme/index.js.map +1 -1
- package/dist/typedoc/components/index.d.ts +55 -0
- package/dist/typedoc/components/index.d.ts.map +1 -0
- package/dist/typedoc/components/index.js +328 -0
- package/dist/typedoc/components/index.js.map +1 -0
- package/dist/typedoc/index.d.ts +34 -303
- package/dist/typedoc/index.d.ts.map +1 -0
- package/dist/typedoc/index.js +97 -268
- package/dist/typedoc/index.js.map +1 -1
- package/dist/types-DAZHcySL.d.ts +182 -0
- package/dist/types-DAZHcySL.d.ts.map +1 -0
- package/dist/types-DVodb4lK.d.ts +198 -0
- package/dist/types-DVodb4lK.d.ts.map +1 -0
- package/dist/ui/index.d.ts +2 -178
- package/dist/ui/index.js +3 -95
- package/dist/ui/styles.css +1401 -1335
- package/dist/ui/styles.d.ts +1 -2
- package/dist/ui/styles.js +23 -4
- package/dist/ui-NhRDIFUN.js +1301 -0
- package/dist/ui-NhRDIFUN.js.map +1 -0
- package/dist/vite/index.d.ts +72 -78
- package/dist/vite/index.d.ts.map +1 -0
- package/dist/vite/index.js +2918 -1282
- package/dist/vite/index.js.map +1 -1
- package/package.json +25 -17
- package/dist/Features-D_Pt7zpA.d.ts +0 -615
- package/dist/Search-DOJMNI2T.css +0 -193
- package/dist/Search-DOJMNI2T.css.map +0 -1
- package/dist/Search-VYYG3D43.js +0 -10
- package/dist/Search-VYYG3D43.js.map +0 -1
- package/dist/chunk-4YQE3TNM.js +0 -1
- package/dist/chunk-4YQE3TNM.js.map +0 -1
- package/dist/chunk-AXLJDGQL.js +0 -1
- package/dist/chunk-AXLJDGQL.js.map +0 -1
- package/dist/chunk-CZM5NX27.js +0 -909
- package/dist/chunk-CZM5NX27.js.map +0 -1
- package/dist/chunk-FZP2AVJL.js +0 -43
- package/dist/chunk-FZP2AVJL.js.map +0 -1
- package/dist/chunk-IEPSORG5.js +0 -444
- package/dist/chunk-IEPSORG5.js.map +0 -1
- package/dist/chunk-KUWEUO37.js +0 -1
- package/dist/chunk-KUWEUO37.js.map +0 -1
- package/dist/chunk-NBRHGTR2.js +0 -79
- package/dist/chunk-NBRHGTR2.js.map +0 -1
- package/dist/chunk-PGHUPTGL.js +0 -1035
- package/dist/chunk-PGHUPTGL.js.map +0 -1
- package/dist/chunk-PMS3P4MA.js +0 -43
- package/dist/chunk-PMS3P4MA.js.map +0 -1
- package/dist/chunk-QELSOHIY.js +0 -46
- package/dist/chunk-QELSOHIY.js.map +0 -1
- package/dist/chunk-R2QKY6G3.js +0 -1
- package/dist/chunk-R2QKY6G3.js.map +0 -1
- package/dist/chunk-ZPYQQZ7J.js +0 -210
- package/dist/chunk-ZPYQQZ7J.js.map +0 -1
- package/dist/icons/index.js.map +0 -1
- package/dist/index.css +0 -1290
- package/dist/index.css.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/mdx/provider.css +0 -403
- package/dist/mdx/provider.css.map +0 -1
- package/dist/runtime/index.js.map +0 -1
- package/dist/types-CLkHwCch.d.ts +0 -248
- package/dist/ui/index.css +0 -1290
- package/dist/ui/index.css.map +0 -1
- package/dist/ui/index.js.map +0 -1
- package/dist/ui/styles.css.map +0 -1
- package/dist/ui/styles.js.map +0 -1
package/dist/chunk-PGHUPTGL.js
DELETED
|
@@ -1,1035 +0,0 @@
|
|
|
1
|
-
// src/typedoc/generator.ts
|
|
2
|
-
import {
|
|
3
|
-
Application,
|
|
4
|
-
TSConfigReader,
|
|
5
|
-
TypeDocReader,
|
|
6
|
-
ReflectionKind
|
|
7
|
-
} from "typedoc";
|
|
8
|
-
import path from "path";
|
|
9
|
-
import fs from "fs/promises";
|
|
10
|
-
import { readPackageUp } from "read-package-up";
|
|
11
|
-
var TypeDocGenerator = class {
|
|
12
|
-
config;
|
|
13
|
-
app;
|
|
14
|
-
project;
|
|
15
|
-
basePath;
|
|
16
|
-
packageNameCache = /* @__PURE__ */ new Map();
|
|
17
|
-
constructor(config) {
|
|
18
|
-
this.config = {
|
|
19
|
-
out: "api",
|
|
20
|
-
excludeExternals: true,
|
|
21
|
-
excludePrivate: true,
|
|
22
|
-
excludeProtected: false,
|
|
23
|
-
excludeInternal: true,
|
|
24
|
-
sort: ["source-order"],
|
|
25
|
-
sidebar: {
|
|
26
|
-
title: "API Reference",
|
|
27
|
-
position: 100,
|
|
28
|
-
collapsed: false
|
|
29
|
-
},
|
|
30
|
-
markdown: {
|
|
31
|
-
breadcrumbs: true,
|
|
32
|
-
hierarchy: true,
|
|
33
|
-
sourceLinks: true,
|
|
34
|
-
codeBlocks: true
|
|
35
|
-
},
|
|
36
|
-
...config
|
|
37
|
-
};
|
|
38
|
-
this.basePath = "/" + this.config.out;
|
|
39
|
-
}
|
|
40
|
-
async generate(outputDir) {
|
|
41
|
-
await Promise.all(this.config.entryPoints.map((ep) => this.resolvePackageName(ep)));
|
|
42
|
-
const typedocOptions = {
|
|
43
|
-
entryPoints: this.config.entryPoints,
|
|
44
|
-
tsconfig: this.config.tsconfig,
|
|
45
|
-
excludeExternals: this.config.excludeExternals,
|
|
46
|
-
excludePrivate: this.config.excludePrivate,
|
|
47
|
-
excludeProtected: this.config.excludeProtected,
|
|
48
|
-
excludeInternal: this.config.excludeInternal,
|
|
49
|
-
sort: this.config.sort
|
|
50
|
-
};
|
|
51
|
-
if (this.config.exclude) typedocOptions.exclude = this.config.exclude;
|
|
52
|
-
if (this.config.categoryOrder) typedocOptions.categoryOrder = this.config.categoryOrder;
|
|
53
|
-
if (this.config.groupOrder) typedocOptions.groupOrder = this.config.groupOrder;
|
|
54
|
-
if (this.config.plugin) typedocOptions.plugin = this.config.plugin;
|
|
55
|
-
if (this.config.readme) typedocOptions.readme = this.config.readme;
|
|
56
|
-
this.app = await Application.bootstrapWithPlugins(typedocOptions, [
|
|
57
|
-
new TSConfigReader(),
|
|
58
|
-
new TypeDocReader()
|
|
59
|
-
]);
|
|
60
|
-
this.project = await this.app.convert();
|
|
61
|
-
if (!this.project) {
|
|
62
|
-
throw new Error("TypeDoc conversion failed");
|
|
63
|
-
}
|
|
64
|
-
const docs = this.generateMarkdownDocs();
|
|
65
|
-
const apiDir = path.join(outputDir, this.config.out);
|
|
66
|
-
await fs.mkdir(apiDir, { recursive: true });
|
|
67
|
-
for (const doc of docs) {
|
|
68
|
-
const filePath = path.join(apiDir, doc.path);
|
|
69
|
-
const dir = path.dirname(filePath);
|
|
70
|
-
await fs.mkdir(dir, { recursive: true });
|
|
71
|
-
const frontmatterLines = [
|
|
72
|
-
"---",
|
|
73
|
-
`title: ${doc.frontmatter.title}`,
|
|
74
|
-
doc.frontmatter.description ? `description: ${doc.frontmatter.description}` : null,
|
|
75
|
-
doc.frontmatter.sidebar_position !== void 0 ? `sidebar_position: ${doc.frontmatter.sidebar_position}` : null,
|
|
76
|
-
doc.frontmatter.sidebar === false ? `sidebar: false` : null,
|
|
77
|
-
"---"
|
|
78
|
-
].filter((line) => line !== null);
|
|
79
|
-
const frontmatter = frontmatterLines.join("\n") + "\n\n";
|
|
80
|
-
await fs.writeFile(filePath, frontmatter + doc.content);
|
|
81
|
-
}
|
|
82
|
-
return docs;
|
|
83
|
-
}
|
|
84
|
-
generateMarkdownDocs() {
|
|
85
|
-
if (!this.project) return [];
|
|
86
|
-
const docs = [];
|
|
87
|
-
docs.push(this.generateIndexPage());
|
|
88
|
-
const children = this.project.children || [];
|
|
89
|
-
const functionsByFile = /* @__PURE__ */ new Map();
|
|
90
|
-
const typesByFile = /* @__PURE__ */ new Map();
|
|
91
|
-
const componentItems = [];
|
|
92
|
-
const standaloneItems = [];
|
|
93
|
-
for (const child of children) {
|
|
94
|
-
const sourceFile = child.sources?.[0]?.fileName;
|
|
95
|
-
if (child.kind === ReflectionKind.Function && sourceFile) {
|
|
96
|
-
if (this.isReactComponent(child.name)) {
|
|
97
|
-
componentItems.push(child);
|
|
98
|
-
} else {
|
|
99
|
-
const existing = functionsByFile.get(sourceFile) || [];
|
|
100
|
-
existing.push(child);
|
|
101
|
-
functionsByFile.set(sourceFile, existing);
|
|
102
|
-
}
|
|
103
|
-
} else if (child.kind === ReflectionKind.TypeAlias && sourceFile) {
|
|
104
|
-
const existing = typesByFile.get(sourceFile) || [];
|
|
105
|
-
existing.push(child);
|
|
106
|
-
typesByFile.set(sourceFile, existing);
|
|
107
|
-
} else {
|
|
108
|
-
standaloneItems.push(child);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
for (const [sourceFile, functions] of functionsByFile) {
|
|
112
|
-
docs.push(this.generateGroupedFunctionsPage(sourceFile, functions));
|
|
113
|
-
}
|
|
114
|
-
for (const [sourceFile, types] of typesByFile) {
|
|
115
|
-
docs.push(this.generateGroupedTypesPage(sourceFile, types));
|
|
116
|
-
}
|
|
117
|
-
const sortedComponents = [...componentItems].sort((a, b) => a.name.localeCompare(b.name));
|
|
118
|
-
for (let i = 0; i < sortedComponents.length; i++) {
|
|
119
|
-
const prev = i > 0 ? sortedComponents[i - 1] : null;
|
|
120
|
-
const next = i < sortedComponents.length - 1 ? sortedComponents[i + 1] : null;
|
|
121
|
-
docs.push(this.generateComponentPage(sortedComponents[i], prev, next));
|
|
122
|
-
}
|
|
123
|
-
const itemsByKind = /* @__PURE__ */ new Map();
|
|
124
|
-
for (const child of standaloneItems) {
|
|
125
|
-
const kind = child.kind;
|
|
126
|
-
const existing = itemsByKind.get(kind) || [];
|
|
127
|
-
existing.push(child);
|
|
128
|
-
itemsByKind.set(kind, existing);
|
|
129
|
-
}
|
|
130
|
-
for (const [, items] of itemsByKind) {
|
|
131
|
-
const sortedItems = [...items].sort((a, b) => a.name.localeCompare(b.name));
|
|
132
|
-
for (let i = 0; i < sortedItems.length; i++) {
|
|
133
|
-
const prev = i > 0 ? sortedItems[i - 1] : null;
|
|
134
|
-
const next = i < sortedItems.length - 1 ? sortedItems[i + 1] : null;
|
|
135
|
-
docs.push(...this.generateReflectionDocs(sortedItems[i], "", prev, next));
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
docs.push(
|
|
139
|
-
...this.generateCategoryIndexPages(
|
|
140
|
-
docs,
|
|
141
|
-
componentItems,
|
|
142
|
-
functionsByFile,
|
|
143
|
-
typesByFile,
|
|
144
|
-
standaloneItems
|
|
145
|
-
)
|
|
146
|
-
);
|
|
147
|
-
return docs;
|
|
148
|
-
}
|
|
149
|
-
generateCategoryIndexPages(docs, componentItems, functionsByFile, typesByFile, standaloneItems) {
|
|
150
|
-
const indexPages = [];
|
|
151
|
-
if (componentItems.length > 0) {
|
|
152
|
-
const sorted = [...componentItems].sort((a, b) => a.name.localeCompare(b.name));
|
|
153
|
-
const content = [
|
|
154
|
-
`# Components`,
|
|
155
|
-
"",
|
|
156
|
-
...sorted.map((c) => {
|
|
157
|
-
const desc = c.comment?.summary ? ` - ${this.renderCommentShort(c.comment.summary)}` : "";
|
|
158
|
-
return `- [${c.name}](${this.buildLink("components", this.getSlug(c.name))})${desc}`;
|
|
159
|
-
}),
|
|
160
|
-
""
|
|
161
|
-
];
|
|
162
|
-
indexPages.push({
|
|
163
|
-
path: "components/index.md",
|
|
164
|
-
content: content.join("\n"),
|
|
165
|
-
frontmatter: { title: "Components", sidebar: false }
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
if (functionsByFile.size > 0) {
|
|
169
|
-
const sortedModules = [...functionsByFile.entries()].sort(
|
|
170
|
-
(a, b) => this.getModuleNameFromPath(a[0]).localeCompare(this.getModuleNameFromPath(b[0]))
|
|
171
|
-
);
|
|
172
|
-
const content = [
|
|
173
|
-
`# Functions`,
|
|
174
|
-
"",
|
|
175
|
-
...sortedModules.map(([sourceFile, functions]) => {
|
|
176
|
-
const moduleName = this.getModuleNameFromPath(sourceFile);
|
|
177
|
-
const slug = this.getSlug(moduleName);
|
|
178
|
-
const funcNames = functions.map((f) => f.name).sort().join(", ");
|
|
179
|
-
return `- [${moduleName}](${this.buildLink("functions", slug)}) - ${funcNames}`;
|
|
180
|
-
}),
|
|
181
|
-
""
|
|
182
|
-
];
|
|
183
|
-
indexPages.push({
|
|
184
|
-
path: "functions/index.md",
|
|
185
|
-
content: content.join("\n"),
|
|
186
|
-
frontmatter: { title: "Functions", sidebar: false }
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
const interfaces = standaloneItems.filter((c) => c.kind === ReflectionKind.Interface);
|
|
190
|
-
const classes = standaloneItems.filter((c) => c.kind === ReflectionKind.Class);
|
|
191
|
-
if (interfaces.length > 0) {
|
|
192
|
-
const sorted = [...interfaces].sort((a, b) => a.name.localeCompare(b.name));
|
|
193
|
-
const content = [
|
|
194
|
-
`# Interfaces`,
|
|
195
|
-
"",
|
|
196
|
-
...sorted.map((item) => {
|
|
197
|
-
const desc = item.comment?.summary ? ` - ${this.renderCommentShort(item.comment.summary)}` : "";
|
|
198
|
-
return `- [${item.name}](${this.buildLink("interfaces", this.getSlug(item.name))})${desc}`;
|
|
199
|
-
}),
|
|
200
|
-
""
|
|
201
|
-
];
|
|
202
|
-
indexPages.push({
|
|
203
|
-
path: "interfaces/index.md",
|
|
204
|
-
content: content.join("\n"),
|
|
205
|
-
frontmatter: { title: "Interfaces", sidebar: false }
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
if (typesByFile.size > 0) {
|
|
209
|
-
const sortedModules = [...typesByFile.entries()].sort(
|
|
210
|
-
(a, b) => this.getModuleNameFromPath(a[0]).localeCompare(this.getModuleNameFromPath(b[0]))
|
|
211
|
-
);
|
|
212
|
-
const content = [
|
|
213
|
-
`# Types`,
|
|
214
|
-
"",
|
|
215
|
-
...sortedModules.map(([sourceFile, types]) => {
|
|
216
|
-
const moduleName = this.getModuleNameFromPath(sourceFile);
|
|
217
|
-
const slug = this.getSlug(moduleName);
|
|
218
|
-
const typeNames = types.map((t) => t.name).sort().join(", ");
|
|
219
|
-
return `- [${moduleName}](${this.buildLink("types", slug)}) - ${typeNames}`;
|
|
220
|
-
}),
|
|
221
|
-
""
|
|
222
|
-
];
|
|
223
|
-
indexPages.push({
|
|
224
|
-
path: "types/index.md",
|
|
225
|
-
content: content.join("\n"),
|
|
226
|
-
frontmatter: { title: "Types", sidebar: false }
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
if (classes.length > 0) {
|
|
230
|
-
const sorted = [...classes].sort((a, b) => a.name.localeCompare(b.name));
|
|
231
|
-
const content = [
|
|
232
|
-
`# Classes`,
|
|
233
|
-
"",
|
|
234
|
-
...sorted.map((item) => {
|
|
235
|
-
const desc = item.comment?.summary ? ` - ${this.renderCommentShort(item.comment.summary)}` : "";
|
|
236
|
-
return `- [${item.name}](${this.buildLink("classes", this.getSlug(item.name))})${desc}`;
|
|
237
|
-
}),
|
|
238
|
-
""
|
|
239
|
-
];
|
|
240
|
-
indexPages.push({
|
|
241
|
-
path: "classes/index.md",
|
|
242
|
-
content: content.join("\n"),
|
|
243
|
-
frontmatter: { title: "Classes", sidebar: false }
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
return indexPages;
|
|
247
|
-
}
|
|
248
|
-
generateGroupedFunctionsPage(sourceFile, functions) {
|
|
249
|
-
const moduleName = this.getModuleNameFromPath(sourceFile);
|
|
250
|
-
const slug = this.getSlug(moduleName);
|
|
251
|
-
const content = [];
|
|
252
|
-
content.push(`# ${moduleName} Functions`);
|
|
253
|
-
content.push("");
|
|
254
|
-
content.push(`Functions exported from \`${sourceFile}\``);
|
|
255
|
-
content.push("");
|
|
256
|
-
const sortedFunctions = [...functions].sort((a, b) => a.name.localeCompare(b.name));
|
|
257
|
-
for (const func of sortedFunctions) {
|
|
258
|
-
content.push(`## ${func.name}`);
|
|
259
|
-
content.push("");
|
|
260
|
-
if (func.comment?.summary) {
|
|
261
|
-
content.push(this.renderComment(func.comment.summary));
|
|
262
|
-
content.push("");
|
|
263
|
-
}
|
|
264
|
-
if (func.signatures) {
|
|
265
|
-
for (const sig of func.signatures) {
|
|
266
|
-
content.push(this.renderSignature(sig));
|
|
267
|
-
content.push("");
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
if (func.comment?.blockTags) {
|
|
271
|
-
const examples = func.comment.blockTags.filter((t) => t.tag === "@example");
|
|
272
|
-
if (examples.length > 0) {
|
|
273
|
-
content.push("### Example");
|
|
274
|
-
content.push("");
|
|
275
|
-
for (const example of examples) {
|
|
276
|
-
content.push(this.renderComment(example.content));
|
|
277
|
-
content.push("");
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
if (this.config.markdown?.sourceLinks && func.sources?.[0]) {
|
|
282
|
-
const source = func.sources[0];
|
|
283
|
-
const sourceUrl = this.getSourceUrl(source.fileName, source.line);
|
|
284
|
-
if (sourceUrl) {
|
|
285
|
-
content.push(`[Source](${sourceUrl})`);
|
|
286
|
-
content.push("");
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
content.push("---");
|
|
290
|
-
content.push("");
|
|
291
|
-
}
|
|
292
|
-
return {
|
|
293
|
-
path: `functions/${slug}.md`,
|
|
294
|
-
content: content.join("\n"),
|
|
295
|
-
frontmatter: {
|
|
296
|
-
title: `${moduleName} Functions`,
|
|
297
|
-
description: `Functions from ${sourceFile}`
|
|
298
|
-
}
|
|
299
|
-
};
|
|
300
|
-
}
|
|
301
|
-
generateGroupedTypesPage(sourceFile, types) {
|
|
302
|
-
const moduleName = this.getModuleNameFromPath(sourceFile);
|
|
303
|
-
const slug = this.getSlug(moduleName);
|
|
304
|
-
const content = [];
|
|
305
|
-
content.push(`# ${moduleName} Types`);
|
|
306
|
-
content.push("");
|
|
307
|
-
content.push(`Type definitions from \`${sourceFile}\``);
|
|
308
|
-
content.push("");
|
|
309
|
-
const sortedTypes = [...types].sort((a, b) => a.name.localeCompare(b.name));
|
|
310
|
-
for (const typeAlias of sortedTypes) {
|
|
311
|
-
content.push(`## ${typeAlias.name}`);
|
|
312
|
-
content.push("");
|
|
313
|
-
if (typeAlias.comment?.summary) {
|
|
314
|
-
content.push(this.renderComment(typeAlias.comment.summary));
|
|
315
|
-
content.push("");
|
|
316
|
-
}
|
|
317
|
-
if (typeAlias.type) {
|
|
318
|
-
content.push("```typescript");
|
|
319
|
-
content.push(`type ${typeAlias.name} = ${typeAlias.type.toString()}`);
|
|
320
|
-
content.push("```");
|
|
321
|
-
content.push("");
|
|
322
|
-
}
|
|
323
|
-
if (this.config.markdown?.sourceLinks && typeAlias.sources?.[0]) {
|
|
324
|
-
const source = typeAlias.sources[0];
|
|
325
|
-
const sourceUrl = this.getSourceUrl(source.fileName, source.line);
|
|
326
|
-
if (sourceUrl) {
|
|
327
|
-
content.push(`[Source](${sourceUrl})`);
|
|
328
|
-
content.push("");
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
content.push("---");
|
|
332
|
-
content.push("");
|
|
333
|
-
}
|
|
334
|
-
return {
|
|
335
|
-
path: `types/${slug}.md`,
|
|
336
|
-
content: content.join("\n"),
|
|
337
|
-
frontmatter: {
|
|
338
|
-
title: `${moduleName} Types`,
|
|
339
|
-
description: `Type definitions from ${sourceFile}`
|
|
340
|
-
}
|
|
341
|
-
};
|
|
342
|
-
}
|
|
343
|
-
async resolvePackageName(filePath) {
|
|
344
|
-
const dir = path.dirname(path.resolve(filePath));
|
|
345
|
-
if (this.packageNameCache.has(dir)) {
|
|
346
|
-
return this.packageNameCache.get(dir);
|
|
347
|
-
}
|
|
348
|
-
const result = await readPackageUp({ cwd: dir });
|
|
349
|
-
const name = result?.packageJson.name;
|
|
350
|
-
const resolved = name ? name.replace(/^@[^/]+\//, "") : void 0;
|
|
351
|
-
this.packageNameCache.set(dir, resolved);
|
|
352
|
-
return resolved;
|
|
353
|
-
}
|
|
354
|
-
getModuleNameFromPath(filePath) {
|
|
355
|
-
const parts = filePath.split("/");
|
|
356
|
-
const basename = (parts.pop() || filePath).replace(/\.(ts|tsx|js|jsx)$/, "");
|
|
357
|
-
const parent = parts.pop();
|
|
358
|
-
if (parent && parent !== "src") {
|
|
359
|
-
return `${parent}/${basename}`;
|
|
360
|
-
}
|
|
361
|
-
if (basename === "index") {
|
|
362
|
-
for (const packageName of this.packageNameCache.values()) {
|
|
363
|
-
if (packageName) return packageName;
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
return basename;
|
|
367
|
-
}
|
|
368
|
-
generateIndexPage() {
|
|
369
|
-
const content = [
|
|
370
|
-
`# ${this.config.sidebar?.title || "API Reference"}`,
|
|
371
|
-
"",
|
|
372
|
-
this.project?.comment?.summary ? this.renderComment(this.project.comment.summary) : "Auto-generated API documentation.",
|
|
373
|
-
""
|
|
374
|
-
];
|
|
375
|
-
const children = this.project?.children || [];
|
|
376
|
-
const functionsByFile = /* @__PURE__ */ new Map();
|
|
377
|
-
const typesByFile = /* @__PURE__ */ new Map();
|
|
378
|
-
const componentItems = [];
|
|
379
|
-
const standaloneItems = [];
|
|
380
|
-
for (const child of children) {
|
|
381
|
-
const sourceFile = child.sources?.[0]?.fileName;
|
|
382
|
-
if (child.kind === ReflectionKind.Function && sourceFile) {
|
|
383
|
-
if (this.isReactComponent(child.name)) {
|
|
384
|
-
componentItems.push(child);
|
|
385
|
-
} else {
|
|
386
|
-
const existing = functionsByFile.get(sourceFile) || [];
|
|
387
|
-
existing.push(child);
|
|
388
|
-
functionsByFile.set(sourceFile, existing);
|
|
389
|
-
}
|
|
390
|
-
} else if (child.kind === ReflectionKind.TypeAlias && sourceFile) {
|
|
391
|
-
const existing = typesByFile.get(sourceFile) || [];
|
|
392
|
-
existing.push(child);
|
|
393
|
-
typesByFile.set(sourceFile, existing);
|
|
394
|
-
} else {
|
|
395
|
-
standaloneItems.push(child);
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
if (componentItems.length > 0) {
|
|
399
|
-
content.push("## Components");
|
|
400
|
-
content.push("");
|
|
401
|
-
const sortedComponents = [...componentItems].sort((a, b) => a.name.localeCompare(b.name));
|
|
402
|
-
for (const component of sortedComponents) {
|
|
403
|
-
const description = component.comment?.summary ? this.renderCommentShort(component.comment.summary) : "";
|
|
404
|
-
const descSuffix = description ? ` - ${description}` : "";
|
|
405
|
-
content.push(
|
|
406
|
-
`- [${component.name}](${this.buildLink("components", this.getSlug(component.name))})${descSuffix}`
|
|
407
|
-
);
|
|
408
|
-
}
|
|
409
|
-
content.push("");
|
|
410
|
-
}
|
|
411
|
-
if (functionsByFile.size > 0) {
|
|
412
|
-
content.push("## Functions");
|
|
413
|
-
content.push("");
|
|
414
|
-
const sortedModules = [...functionsByFile.entries()].sort(
|
|
415
|
-
(a, b) => this.getModuleNameFromPath(a[0]).localeCompare(this.getModuleNameFromPath(b[0]))
|
|
416
|
-
);
|
|
417
|
-
for (const [sourceFile, functions] of sortedModules) {
|
|
418
|
-
const moduleName = this.getModuleNameFromPath(sourceFile);
|
|
419
|
-
const slug = this.getSlug(moduleName);
|
|
420
|
-
const funcNames = functions.map((f) => f.name).sort().join(", ");
|
|
421
|
-
content.push(`- [${moduleName}](${this.buildLink("functions", slug)}) - ${funcNames}`);
|
|
422
|
-
}
|
|
423
|
-
content.push("");
|
|
424
|
-
}
|
|
425
|
-
if (typesByFile.size > 0) {
|
|
426
|
-
content.push("## Type Aliases");
|
|
427
|
-
content.push("");
|
|
428
|
-
const sortedModules = [...typesByFile.entries()].sort(
|
|
429
|
-
(a, b) => this.getModuleNameFromPath(a[0]).localeCompare(this.getModuleNameFromPath(b[0]))
|
|
430
|
-
);
|
|
431
|
-
for (const [sourceFile, types] of sortedModules) {
|
|
432
|
-
const moduleName = this.getModuleNameFromPath(sourceFile);
|
|
433
|
-
const slug = this.getSlug(moduleName);
|
|
434
|
-
const typeNames = types.map((t) => t.name).sort().join(", ");
|
|
435
|
-
content.push(`- [${moduleName}](${this.buildLink("types", slug)}) - ${typeNames}`);
|
|
436
|
-
}
|
|
437
|
-
content.push("");
|
|
438
|
-
}
|
|
439
|
-
const groups = {};
|
|
440
|
-
for (const child of standaloneItems) {
|
|
441
|
-
const kindName = this.getKindGroupName(child.kind, child.name);
|
|
442
|
-
if (!groups[kindName]) {
|
|
443
|
-
groups[kindName] = [];
|
|
444
|
-
}
|
|
445
|
-
groups[kindName].push(child);
|
|
446
|
-
}
|
|
447
|
-
for (const group of Object.values(groups)) {
|
|
448
|
-
group.sort((a, b) => a.name.localeCompare(b.name));
|
|
449
|
-
}
|
|
450
|
-
const groupOrder = ["Interfaces", "Classes", "Variables", "Enums", "Other"];
|
|
451
|
-
for (const groupName of groupOrder) {
|
|
452
|
-
const group = groups[groupName];
|
|
453
|
-
if (!group || group.length === 0) continue;
|
|
454
|
-
content.push(`## ${groupName}`);
|
|
455
|
-
content.push("");
|
|
456
|
-
for (const child of group) {
|
|
457
|
-
const description = child.comment?.summary ? this.renderCommentShort(child.comment.summary) : "";
|
|
458
|
-
const descSuffix = description ? ` - ${description}` : "";
|
|
459
|
-
const groupUrlPrefix = this.getGroupUrlPrefix(child.kind);
|
|
460
|
-
content.push(
|
|
461
|
-
`- [${child.name}](${this.buildLink(groupUrlPrefix, this.getSlug(child.name))})${descSuffix}`
|
|
462
|
-
);
|
|
463
|
-
}
|
|
464
|
-
content.push("");
|
|
465
|
-
}
|
|
466
|
-
return {
|
|
467
|
-
path: "index.md",
|
|
468
|
-
content: content.join("\n"),
|
|
469
|
-
frontmatter: {
|
|
470
|
-
title: this.config.sidebar?.title || "API Reference",
|
|
471
|
-
description: "Auto-generated API documentation",
|
|
472
|
-
sidebar_position: 0
|
|
473
|
-
}
|
|
474
|
-
};
|
|
475
|
-
}
|
|
476
|
-
getKindGroupName(kind, name) {
|
|
477
|
-
if (kind === ReflectionKind.Function) {
|
|
478
|
-
if (name.startsWith("use")) {
|
|
479
|
-
return "React Hooks";
|
|
480
|
-
}
|
|
481
|
-
if (name[0] === name[0].toUpperCase() && !name.includes("_")) {
|
|
482
|
-
return "React Components";
|
|
483
|
-
}
|
|
484
|
-
return "Functions";
|
|
485
|
-
}
|
|
486
|
-
switch (kind) {
|
|
487
|
-
case ReflectionKind.Interface:
|
|
488
|
-
return "Interfaces";
|
|
489
|
-
case ReflectionKind.TypeAlias:
|
|
490
|
-
return "Types";
|
|
491
|
-
case ReflectionKind.Class:
|
|
492
|
-
return "Classes";
|
|
493
|
-
case ReflectionKind.Variable:
|
|
494
|
-
return "Variables";
|
|
495
|
-
case ReflectionKind.Enum:
|
|
496
|
-
return "Enums";
|
|
497
|
-
default:
|
|
498
|
-
return "Other";
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
generateReflectionDocs(reflection, parentPath, prev = null, next = null) {
|
|
502
|
-
const docs = [];
|
|
503
|
-
const slug = this.getSlug(reflection.name);
|
|
504
|
-
const groupPrefix = parentPath ? "" : this.getGroupUrlPrefix(reflection.kind);
|
|
505
|
-
const currentPath = parentPath ? `${parentPath}/${slug}` : groupPrefix ? `${groupPrefix}/${slug}` : slug;
|
|
506
|
-
docs.push(this.generateReflectionPage(reflection, currentPath, prev, next));
|
|
507
|
-
const children = reflection.children || [];
|
|
508
|
-
const hasOwnPage = [
|
|
509
|
-
ReflectionKind.Class,
|
|
510
|
-
ReflectionKind.Interface,
|
|
511
|
-
ReflectionKind.Enum,
|
|
512
|
-
ReflectionKind.Namespace,
|
|
513
|
-
ReflectionKind.Module
|
|
514
|
-
];
|
|
515
|
-
for (const child of children) {
|
|
516
|
-
if (hasOwnPage.includes(child.kind)) {
|
|
517
|
-
docs.push(...this.generateReflectionDocs(child, currentPath));
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
return docs;
|
|
521
|
-
}
|
|
522
|
-
generateReflectionPage(reflection, pagePath, prev = null, next = null) {
|
|
523
|
-
const kind = this.getKindName(reflection.kind);
|
|
524
|
-
const content = [];
|
|
525
|
-
if (this.config.markdown?.breadcrumbs) {
|
|
526
|
-
content.push(this.generateBreadcrumbs(pagePath));
|
|
527
|
-
content.push("");
|
|
528
|
-
}
|
|
529
|
-
content.push(`# ${kind}: ${reflection.name}`);
|
|
530
|
-
content.push("");
|
|
531
|
-
if (reflection.comment?.summary) {
|
|
532
|
-
content.push(this.renderComment(reflection.comment.summary));
|
|
533
|
-
content.push("");
|
|
534
|
-
}
|
|
535
|
-
if (reflection.typeParameters && reflection.typeParameters.length > 0) {
|
|
536
|
-
content.push("## Type Parameters");
|
|
537
|
-
content.push("");
|
|
538
|
-
content.push(this.renderTypeParameters(reflection.typeParameters));
|
|
539
|
-
content.push("");
|
|
540
|
-
}
|
|
541
|
-
if (this.config.markdown?.hierarchy) {
|
|
542
|
-
const hierarchy = this.renderHierarchy(reflection);
|
|
543
|
-
if (hierarchy) {
|
|
544
|
-
content.push("## Hierarchy");
|
|
545
|
-
content.push("");
|
|
546
|
-
content.push(hierarchy);
|
|
547
|
-
content.push("");
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
if (reflection.signatures) {
|
|
551
|
-
content.push("## Signature");
|
|
552
|
-
content.push("");
|
|
553
|
-
for (const sig of reflection.signatures) {
|
|
554
|
-
content.push(this.renderSignature(sig));
|
|
555
|
-
content.push("");
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
const properties = (reflection.children || []).filter((c) => c.kind === ReflectionKind.Property);
|
|
559
|
-
if (properties.length > 0) {
|
|
560
|
-
content.push("## Properties");
|
|
561
|
-
content.push("");
|
|
562
|
-
for (const prop of properties) {
|
|
563
|
-
content.push(this.renderProperty(prop));
|
|
564
|
-
content.push("");
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
const methods = (reflection.children || []).filter((c) => c.kind === ReflectionKind.Method);
|
|
568
|
-
if (methods.length > 0) {
|
|
569
|
-
content.push("## Methods");
|
|
570
|
-
content.push("");
|
|
571
|
-
for (const method of methods) {
|
|
572
|
-
content.push(this.renderMethod(method));
|
|
573
|
-
content.push("");
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
const enumMembers = (reflection.children || []).filter(
|
|
577
|
-
(c) => c.kind === ReflectionKind.EnumMember
|
|
578
|
-
);
|
|
579
|
-
if (enumMembers.length > 0) {
|
|
580
|
-
content.push("## Members");
|
|
581
|
-
content.push("");
|
|
582
|
-
content.push("| Member | Value | Description |");
|
|
583
|
-
content.push("|--------|-------|-------------|");
|
|
584
|
-
for (const member of enumMembers) {
|
|
585
|
-
const value = member.defaultValue || "";
|
|
586
|
-
const desc = member.comment?.summary ? this.renderCommentShort(member.comment.summary) : "";
|
|
587
|
-
content.push(`| \`${member.name}\` | \`${value}\` | ${desc} |`);
|
|
588
|
-
}
|
|
589
|
-
content.push("");
|
|
590
|
-
}
|
|
591
|
-
if (reflection.kind === ReflectionKind.TypeAlias && reflection.type) {
|
|
592
|
-
content.push("## Type");
|
|
593
|
-
content.push("");
|
|
594
|
-
content.push("```typescript");
|
|
595
|
-
content.push(`type ${reflection.name} = ${reflection.type.toString()}`);
|
|
596
|
-
content.push("```");
|
|
597
|
-
content.push("");
|
|
598
|
-
}
|
|
599
|
-
if (this.config.markdown?.sourceLinks && reflection.sources?.[0]) {
|
|
600
|
-
const source = reflection.sources[0];
|
|
601
|
-
const sourceUrl = this.getSourceUrl(source.fileName, source.line);
|
|
602
|
-
content.push("## Source");
|
|
603
|
-
content.push("");
|
|
604
|
-
if (sourceUrl) {
|
|
605
|
-
content.push(`[${source.fileName}:${source.line}](${sourceUrl})`);
|
|
606
|
-
} else {
|
|
607
|
-
content.push(`${source.fileName}:${source.line}`);
|
|
608
|
-
}
|
|
609
|
-
content.push("");
|
|
610
|
-
}
|
|
611
|
-
if (reflection.comment?.blockTags) {
|
|
612
|
-
const examples = reflection.comment.blockTags.filter((t) => t.tag === "@example");
|
|
613
|
-
if (examples.length > 0) {
|
|
614
|
-
content.push("## Examples");
|
|
615
|
-
content.push("");
|
|
616
|
-
for (const example of examples) {
|
|
617
|
-
content.push(this.renderComment(example.content));
|
|
618
|
-
content.push("");
|
|
619
|
-
}
|
|
620
|
-
}
|
|
621
|
-
const deprecated = reflection.comment.blockTags.find((t) => t.tag === "@deprecated");
|
|
622
|
-
if (deprecated) {
|
|
623
|
-
content.push('<Warning title="Deprecated">');
|
|
624
|
-
content.push(this.renderComment(deprecated.content));
|
|
625
|
-
content.push("</Warning>");
|
|
626
|
-
content.push("");
|
|
627
|
-
}
|
|
628
|
-
const see = reflection.comment.blockTags.filter((t) => t.tag === "@see");
|
|
629
|
-
if (see.length > 0) {
|
|
630
|
-
content.push("## See Also");
|
|
631
|
-
content.push("");
|
|
632
|
-
for (const s of see) {
|
|
633
|
-
content.push(`- ${this.renderComment(s.content)}`);
|
|
634
|
-
}
|
|
635
|
-
content.push("");
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
if (prev || next) {
|
|
639
|
-
content.push("---");
|
|
640
|
-
content.push("");
|
|
641
|
-
const groupPrefix = this.getGroupUrlPrefix(reflection.kind);
|
|
642
|
-
const prevLink = prev ? `[\u2190 ${prev.name}](${this.buildLink(groupPrefix, this.getSlug(prev.name))})` : "";
|
|
643
|
-
const nextLink = next ? `[${next.name} \u2192](${this.buildLink(groupPrefix, this.getSlug(next.name))})` : "";
|
|
644
|
-
if (prev && next) {
|
|
645
|
-
content.push(`${prevLink} | ${nextLink}`);
|
|
646
|
-
} else {
|
|
647
|
-
content.push(prevLink || nextLink);
|
|
648
|
-
}
|
|
649
|
-
content.push("");
|
|
650
|
-
}
|
|
651
|
-
return {
|
|
652
|
-
path: `${pagePath}.md`,
|
|
653
|
-
content: content.join("\n"),
|
|
654
|
-
frontmatter: {
|
|
655
|
-
title: reflection.name,
|
|
656
|
-
description: reflection.comment?.summary ? this.renderCommentShort(reflection.comment.summary) : `${kind} ${reflection.name}`
|
|
657
|
-
}
|
|
658
|
-
};
|
|
659
|
-
}
|
|
660
|
-
renderSignature(sig) {
|
|
661
|
-
const lines = [];
|
|
662
|
-
if (this.config.markdown?.codeBlocks) {
|
|
663
|
-
lines.push("```typescript");
|
|
664
|
-
}
|
|
665
|
-
const typeParams = sig.typeParameters ? `<${sig.typeParameters.map((tp) => tp.name).join(", ")}>` : "";
|
|
666
|
-
const params = (sig.parameters || []).map((p) => {
|
|
667
|
-
const optional = p.flags.isOptional ? "?" : "";
|
|
668
|
-
const type = p.type ? `: ${p.type.toString()}` : "";
|
|
669
|
-
return `${p.name}${optional}${type}`;
|
|
670
|
-
}).join(", ");
|
|
671
|
-
const returnType = sig.type ? `: ${sig.type.toString()}` : "";
|
|
672
|
-
lines.push(`function ${sig.name}${typeParams}(${params})${returnType}`);
|
|
673
|
-
if (this.config.markdown?.codeBlocks) {
|
|
674
|
-
lines.push("```");
|
|
675
|
-
}
|
|
676
|
-
if (sig.parameters && sig.parameters.length > 0) {
|
|
677
|
-
lines.push("");
|
|
678
|
-
lines.push("### Parameters");
|
|
679
|
-
lines.push("");
|
|
680
|
-
lines.push("| Name | Type | Description |");
|
|
681
|
-
lines.push("|------|------|-------------|");
|
|
682
|
-
for (const param of sig.parameters) {
|
|
683
|
-
const type = param.type ? `\`${param.type.toString()}\`` : "-";
|
|
684
|
-
const desc = param.comment?.summary ? this.renderCommentShort(param.comment.summary) : "-";
|
|
685
|
-
const optional = param.flags.isOptional ? " (optional)" : "";
|
|
686
|
-
lines.push(`| ${param.name}${optional} | ${type} | ${desc} |`);
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
if (sig.type && sig.type.toString() !== "void") {
|
|
690
|
-
lines.push("");
|
|
691
|
-
lines.push("### Returns");
|
|
692
|
-
lines.push("");
|
|
693
|
-
lines.push(`\`${sig.type.toString()}\``);
|
|
694
|
-
if (sig.comment?.blockTags) {
|
|
695
|
-
const returns = sig.comment.blockTags.find((t) => t.tag === "@returns");
|
|
696
|
-
if (returns) {
|
|
697
|
-
lines.push("");
|
|
698
|
-
lines.push(this.renderComment(returns.content));
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
return lines.join("\n");
|
|
703
|
-
}
|
|
704
|
-
renderProperty(prop) {
|
|
705
|
-
const lines = [];
|
|
706
|
-
const flags = [];
|
|
707
|
-
if (prop.flags.isOptional) flags.push("optional");
|
|
708
|
-
if (prop.flags.isReadonly) flags.push("readonly");
|
|
709
|
-
if (prop.flags.isStatic) flags.push("static");
|
|
710
|
-
lines.push(`### ${prop.name}`);
|
|
711
|
-
if (flags.length > 0) {
|
|
712
|
-
lines.push(`*${flags.join(", ")}*`);
|
|
713
|
-
}
|
|
714
|
-
lines.push("");
|
|
715
|
-
if (prop.type) {
|
|
716
|
-
lines.push("```typescript");
|
|
717
|
-
lines.push(`${prop.name}: ${prop.type.toString()}`);
|
|
718
|
-
lines.push("```");
|
|
719
|
-
lines.push("");
|
|
720
|
-
}
|
|
721
|
-
if (prop.comment?.summary) {
|
|
722
|
-
lines.push(this.renderComment(prop.comment.summary));
|
|
723
|
-
}
|
|
724
|
-
if (prop.defaultValue) {
|
|
725
|
-
lines.push("");
|
|
726
|
-
lines.push(`**Default:** \`${prop.defaultValue}\``);
|
|
727
|
-
}
|
|
728
|
-
return lines.join("\n");
|
|
729
|
-
}
|
|
730
|
-
renderMethod(method) {
|
|
731
|
-
const lines = [];
|
|
732
|
-
lines.push(`### ${method.name}()`);
|
|
733
|
-
lines.push("");
|
|
734
|
-
if (method.signatures) {
|
|
735
|
-
for (const sig of method.signatures) {
|
|
736
|
-
if (sig.comment?.summary) {
|
|
737
|
-
lines.push(this.renderComment(sig.comment.summary));
|
|
738
|
-
lines.push("");
|
|
739
|
-
}
|
|
740
|
-
lines.push(this.renderSignature(sig));
|
|
741
|
-
lines.push("");
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
return lines.join("\n");
|
|
745
|
-
}
|
|
746
|
-
renderTypeParameters(typeParams) {
|
|
747
|
-
const lines = [];
|
|
748
|
-
lines.push("| Name | Constraint | Default | Description |");
|
|
749
|
-
lines.push("|------|------------|---------|-------------|");
|
|
750
|
-
for (const tp of typeParams) {
|
|
751
|
-
const constraint = tp.type ? `\`${tp.type.toString()}\`` : "-";
|
|
752
|
-
const defaultVal = tp.default ? `\`${tp.default.toString()}\`` : "-";
|
|
753
|
-
const desc = tp.comment?.summary ? this.renderCommentShort(tp.comment.summary) : "-";
|
|
754
|
-
lines.push(`| ${tp.name} | ${constraint} | ${defaultVal} | ${desc} |`);
|
|
755
|
-
}
|
|
756
|
-
return lines.join("\n");
|
|
757
|
-
}
|
|
758
|
-
renderHierarchy(reflection) {
|
|
759
|
-
const lines = [];
|
|
760
|
-
if (reflection.extendedTypes && reflection.extendedTypes.length > 0) {
|
|
761
|
-
lines.push("**Extends:**");
|
|
762
|
-
for (const t of reflection.extendedTypes) {
|
|
763
|
-
lines.push(`- \`${t.toString()}\``);
|
|
764
|
-
}
|
|
765
|
-
}
|
|
766
|
-
if (reflection.implementedTypes && reflection.implementedTypes.length > 0) {
|
|
767
|
-
lines.push("**Implements:**");
|
|
768
|
-
for (const t of reflection.implementedTypes) {
|
|
769
|
-
lines.push(`- \`${t.toString()}\``);
|
|
770
|
-
}
|
|
771
|
-
}
|
|
772
|
-
if (reflection.extendedBy && reflection.extendedBy.length > 0) {
|
|
773
|
-
lines.push("**Extended by:**");
|
|
774
|
-
for (const t of reflection.extendedBy) {
|
|
775
|
-
lines.push(`- \`${t.toString()}\``);
|
|
776
|
-
}
|
|
777
|
-
}
|
|
778
|
-
if (reflection.implementedBy && reflection.implementedBy.length > 0) {
|
|
779
|
-
lines.push("**Implemented by:**");
|
|
780
|
-
for (const t of reflection.implementedBy) {
|
|
781
|
-
lines.push(`- \`${t.toString()}\``);
|
|
782
|
-
}
|
|
783
|
-
}
|
|
784
|
-
return lines.length > 0 ? lines.join("\n") : null;
|
|
785
|
-
}
|
|
786
|
-
renderComment(parts) {
|
|
787
|
-
return parts.map((p) => p.text).join("");
|
|
788
|
-
}
|
|
789
|
-
renderCommentShort(parts) {
|
|
790
|
-
const text = this.renderComment(parts);
|
|
791
|
-
const firstSentence = text.split(/[.!?]\s/)[0];
|
|
792
|
-
return firstSentence.length < text.length ? firstSentence + "." : text;
|
|
793
|
-
}
|
|
794
|
-
generateBreadcrumbs(pagePath) {
|
|
795
|
-
const parts = pagePath.split("/");
|
|
796
|
-
const breadcrumbs = [`[API](${this.basePath})`];
|
|
797
|
-
let currentPath = "";
|
|
798
|
-
for (let i = 0; i < parts.length - 1; i++) {
|
|
799
|
-
currentPath += (currentPath ? "/" : "") + parts[i];
|
|
800
|
-
breadcrumbs.push(`[${parts[i]}](${this.basePath}/${currentPath})`);
|
|
801
|
-
}
|
|
802
|
-
breadcrumbs.push(parts[parts.length - 1]);
|
|
803
|
-
return breadcrumbs.join(" / ");
|
|
804
|
-
}
|
|
805
|
-
getKindName(kind) {
|
|
806
|
-
const kindNames = {
|
|
807
|
-
[ReflectionKind.Class]: "Class",
|
|
808
|
-
[ReflectionKind.Interface]: "Interface",
|
|
809
|
-
[ReflectionKind.Enum]: "Enum",
|
|
810
|
-
[ReflectionKind.TypeAlias]: "Type",
|
|
811
|
-
[ReflectionKind.Function]: "Function",
|
|
812
|
-
[ReflectionKind.Variable]: "Variable",
|
|
813
|
-
[ReflectionKind.Namespace]: "Namespace",
|
|
814
|
-
[ReflectionKind.Module]: "Module",
|
|
815
|
-
[ReflectionKind.Property]: "Property",
|
|
816
|
-
[ReflectionKind.Method]: "Method"
|
|
817
|
-
};
|
|
818
|
-
return kindNames[kind] || "Unknown";
|
|
819
|
-
}
|
|
820
|
-
getGroupUrlPrefix(kind) {
|
|
821
|
-
const prefixes = {
|
|
822
|
-
[ReflectionKind.Class]: "classes",
|
|
823
|
-
[ReflectionKind.Interface]: "interfaces",
|
|
824
|
-
[ReflectionKind.Enum]: "enums",
|
|
825
|
-
[ReflectionKind.Variable]: "variables",
|
|
826
|
-
[ReflectionKind.Namespace]: "namespaces",
|
|
827
|
-
[ReflectionKind.Module]: "modules"
|
|
828
|
-
};
|
|
829
|
-
return prefixes[kind] || "other";
|
|
830
|
-
}
|
|
831
|
-
getSlug(name) {
|
|
832
|
-
return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
833
|
-
}
|
|
834
|
-
/**
|
|
835
|
-
* Build a route-compatible link path for a category/slug pair.
|
|
836
|
-
* React Router maps "category/index.md" to the "/category" route,
|
|
837
|
-
* so links must not include a trailing "/index".
|
|
838
|
-
*/
|
|
839
|
-
buildLink(category, slug) {
|
|
840
|
-
if (slug === "index") {
|
|
841
|
-
return `${this.basePath}/${category}`;
|
|
842
|
-
}
|
|
843
|
-
return `${this.basePath}/${category}/${slug}`;
|
|
844
|
-
}
|
|
845
|
-
getSourceUrl(fileName, line) {
|
|
846
|
-
if (!this.config.markdown?.sourceBaseUrl) return null;
|
|
847
|
-
const baseUrl = this.config.markdown.sourceBaseUrl.replace(/\/$/, "");
|
|
848
|
-
return `${baseUrl}/${fileName}#L${line}`;
|
|
849
|
-
}
|
|
850
|
-
/**
|
|
851
|
-
* Check if a function name looks like a React component (PascalCase)
|
|
852
|
-
*/
|
|
853
|
-
isReactComponent(name) {
|
|
854
|
-
if (name[0] !== name[0].toUpperCase()) return false;
|
|
855
|
-
if (name.includes("_")) return false;
|
|
856
|
-
if (name.startsWith("use")) return false;
|
|
857
|
-
if (name.endsWith("Props") || name.endsWith("Options") || name.endsWith("Config")) return false;
|
|
858
|
-
return true;
|
|
859
|
-
}
|
|
860
|
-
/**
|
|
861
|
-
* Generate a page for a React component
|
|
862
|
-
*/
|
|
863
|
-
generateComponentPage(component, prev, next) {
|
|
864
|
-
const slug = this.getSlug(component.name);
|
|
865
|
-
const groupPrefix = "components";
|
|
866
|
-
const content = [];
|
|
867
|
-
content.push(`# ${component.name}`);
|
|
868
|
-
content.push("");
|
|
869
|
-
if (component.comment?.summary) {
|
|
870
|
-
content.push(this.renderComment(component.comment.summary));
|
|
871
|
-
content.push("");
|
|
872
|
-
}
|
|
873
|
-
if (component.signatures) {
|
|
874
|
-
content.push("## Usage");
|
|
875
|
-
content.push("");
|
|
876
|
-
for (const sig of component.signatures) {
|
|
877
|
-
content.push(this.renderComponentSignature(sig, component.name));
|
|
878
|
-
content.push("");
|
|
879
|
-
}
|
|
880
|
-
}
|
|
881
|
-
if (component.comment?.blockTags) {
|
|
882
|
-
const examples = component.comment.blockTags.filter((t) => t.tag === "@example");
|
|
883
|
-
if (examples.length > 0) {
|
|
884
|
-
content.push("## Example");
|
|
885
|
-
content.push("");
|
|
886
|
-
for (const example of examples) {
|
|
887
|
-
content.push(this.renderComment(example.content));
|
|
888
|
-
content.push("");
|
|
889
|
-
}
|
|
890
|
-
}
|
|
891
|
-
}
|
|
892
|
-
if (this.config.markdown?.sourceLinks && component.sources?.[0]) {
|
|
893
|
-
const source = component.sources[0];
|
|
894
|
-
const sourceUrl = this.getSourceUrl(source.fileName, source.line);
|
|
895
|
-
if (sourceUrl) {
|
|
896
|
-
content.push(`[Source](${sourceUrl})`);
|
|
897
|
-
content.push("");
|
|
898
|
-
}
|
|
899
|
-
}
|
|
900
|
-
if (prev || next) {
|
|
901
|
-
content.push("---");
|
|
902
|
-
content.push("");
|
|
903
|
-
const prevLink = prev ? `[\u2190 ${prev.name}](${this.buildLink(groupPrefix, this.getSlug(prev.name))})` : "";
|
|
904
|
-
const nextLink = next ? `[${next.name} \u2192](${this.buildLink(groupPrefix, this.getSlug(next.name))})` : "";
|
|
905
|
-
if (prev && next) {
|
|
906
|
-
content.push(`${prevLink} | ${nextLink}`);
|
|
907
|
-
} else {
|
|
908
|
-
content.push(prevLink || nextLink);
|
|
909
|
-
}
|
|
910
|
-
content.push("");
|
|
911
|
-
}
|
|
912
|
-
return {
|
|
913
|
-
path: `${groupPrefix}/${slug}.md`,
|
|
914
|
-
content: content.join("\n"),
|
|
915
|
-
frontmatter: {
|
|
916
|
-
title: component.name,
|
|
917
|
-
description: component.comment?.summary ? this.renderCommentShort(component.comment.summary) : `${component.name} component`
|
|
918
|
-
}
|
|
919
|
-
};
|
|
920
|
-
}
|
|
921
|
-
/**
|
|
922
|
-
* Get the name of a TypeDoc type (handles reference types, etc.)
|
|
923
|
-
*/
|
|
924
|
-
getTypeName(paramType) {
|
|
925
|
-
if (!paramType || typeof paramType !== "object") return null;
|
|
926
|
-
if ("name" in paramType && typeof paramType.name === "string") {
|
|
927
|
-
return paramType.name;
|
|
928
|
-
}
|
|
929
|
-
if ("type" in paramType && paramType.type === "reference") {
|
|
930
|
-
const refType = paramType;
|
|
931
|
-
return refType.name || refType.qualifiedName || null;
|
|
932
|
-
}
|
|
933
|
-
return null;
|
|
934
|
-
}
|
|
935
|
-
/**
|
|
936
|
-
* Get props from a component's parameter type
|
|
937
|
-
*/
|
|
938
|
-
getPropsFromType(paramType) {
|
|
939
|
-
const props = [];
|
|
940
|
-
if (paramType && typeof paramType === "object" && "declaration" in paramType) {
|
|
941
|
-
const declaration = paramType.declaration;
|
|
942
|
-
const children = declaration.children || [];
|
|
943
|
-
for (const child of children) {
|
|
944
|
-
props.push({
|
|
945
|
-
name: child.name,
|
|
946
|
-
type: child.type ? child.type.toString() : "unknown",
|
|
947
|
-
optional: child.flags.isOptional,
|
|
948
|
-
description: child.comment?.summary ? this.renderCommentShort(child.comment.summary) : ""
|
|
949
|
-
});
|
|
950
|
-
}
|
|
951
|
-
} else {
|
|
952
|
-
const typeName = this.getTypeName(paramType);
|
|
953
|
-
if (typeName) {
|
|
954
|
-
let propsInterface = this.project?.getChildByName(typeName);
|
|
955
|
-
if (!propsInterface && this.project?.children) {
|
|
956
|
-
for (const child of this.project.children) {
|
|
957
|
-
if (child.name === typeName) {
|
|
958
|
-
propsInterface = child;
|
|
959
|
-
break;
|
|
960
|
-
}
|
|
961
|
-
}
|
|
962
|
-
}
|
|
963
|
-
if (propsInterface && "children" in propsInterface) {
|
|
964
|
-
const children = propsInterface.children || [];
|
|
965
|
-
for (const child of children) {
|
|
966
|
-
props.push({
|
|
967
|
-
name: child.name,
|
|
968
|
-
type: child.type ? child.type.toString() : "unknown",
|
|
969
|
-
optional: child.flags.isOptional,
|
|
970
|
-
description: child.comment?.summary ? this.renderCommentShort(child.comment.summary) : ""
|
|
971
|
-
});
|
|
972
|
-
}
|
|
973
|
-
}
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
|
-
return props;
|
|
977
|
-
}
|
|
978
|
-
/**
|
|
979
|
-
* Render a component signature in a more readable format
|
|
980
|
-
*/
|
|
981
|
-
renderComponentSignature(sig, componentName) {
|
|
982
|
-
const lines = [];
|
|
983
|
-
const propsParam = sig.parameters?.[0];
|
|
984
|
-
const props = propsParam ? this.getPropsFromType(propsParam.type) : [];
|
|
985
|
-
const propsTypeName = propsParam?.type ? this.getTypeName(propsParam.type) : null;
|
|
986
|
-
const hasChildren = props.some((p) => p.name === "children");
|
|
987
|
-
const displayProps = props.filter((p) => p.name !== "children");
|
|
988
|
-
lines.push("```tsx");
|
|
989
|
-
lines.push(`<${componentName}`);
|
|
990
|
-
if (displayProps.length > 0) {
|
|
991
|
-
for (const prop of displayProps) {
|
|
992
|
-
const optMark = prop.optional ? "?" : "";
|
|
993
|
-
lines.push(` ${prop.name}${optMark}={${prop.type}}`);
|
|
994
|
-
}
|
|
995
|
-
} else if (!hasChildren) {
|
|
996
|
-
lines.push(` {...props}`);
|
|
997
|
-
}
|
|
998
|
-
if (hasChildren) {
|
|
999
|
-
lines.push(`>`);
|
|
1000
|
-
lines.push(` {children}`);
|
|
1001
|
-
lines.push(`</${componentName}>`);
|
|
1002
|
-
} else {
|
|
1003
|
-
lines.push(`/>`);
|
|
1004
|
-
}
|
|
1005
|
-
lines.push("```");
|
|
1006
|
-
if (props.length > 0) {
|
|
1007
|
-
lines.push("");
|
|
1008
|
-
if (propsTypeName) {
|
|
1009
|
-
lines.push(`## [Props](${this.basePath}/interfaces/${this.getSlug(propsTypeName)})`);
|
|
1010
|
-
} else {
|
|
1011
|
-
lines.push("## Props");
|
|
1012
|
-
}
|
|
1013
|
-
lines.push("");
|
|
1014
|
-
lines.push("| Prop | Type | Required | Description |");
|
|
1015
|
-
lines.push("|------|------|----------|-------------|");
|
|
1016
|
-
for (const prop of props) {
|
|
1017
|
-
const type = `\`${prop.type}\``;
|
|
1018
|
-
const required = prop.optional ? "No" : "Yes";
|
|
1019
|
-
const desc = prop.description || "-";
|
|
1020
|
-
lines.push(`| ${prop.name} | ${type} | ${required} | ${desc} |`);
|
|
1021
|
-
}
|
|
1022
|
-
}
|
|
1023
|
-
return lines.join("\n");
|
|
1024
|
-
}
|
|
1025
|
-
};
|
|
1026
|
-
async function generateApiDocs(config, outputDir) {
|
|
1027
|
-
const generator = new TypeDocGenerator(config);
|
|
1028
|
-
return generator.generate(outputDir);
|
|
1029
|
-
}
|
|
1030
|
-
|
|
1031
|
-
export {
|
|
1032
|
-
TypeDocGenerator,
|
|
1033
|
-
generateApiDocs
|
|
1034
|
-
};
|
|
1035
|
-
//# sourceMappingURL=chunk-PGHUPTGL.js.map
|