fumadocs-typescript 4.0.5 → 4.0.7
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/{base-CDpZg096.d.ts → base-Q18nCvFH.d.ts} +7 -2
- package/dist/{chunk-B4VUDCYC.js → chunk-HM6PM4II.js} +58 -12
- package/dist/index.d.ts +5 -3
- package/dist/index.js +178 -71
- package/dist/ui/index.d.ts +4 -2
- package/dist/ui/index.js +47 -23
- package/package.json +17 -11
|
@@ -56,10 +56,15 @@ interface DocEntry {
|
|
|
56
56
|
name: string;
|
|
57
57
|
description: string;
|
|
58
58
|
type: string;
|
|
59
|
-
|
|
59
|
+
simplifiedType: string;
|
|
60
|
+
tags: RawTag[];
|
|
60
61
|
required: boolean;
|
|
61
62
|
deprecated: boolean;
|
|
62
63
|
}
|
|
64
|
+
interface RawTag {
|
|
65
|
+
name: string;
|
|
66
|
+
text: string;
|
|
67
|
+
}
|
|
63
68
|
interface EntryContext {
|
|
64
69
|
program: Project;
|
|
65
70
|
transform?: Transformer;
|
|
@@ -109,4 +114,4 @@ declare function generateDocumentation(file: string, name: string | undefined, c
|
|
|
109
114
|
project?: Project;
|
|
110
115
|
}): GeneratedDoc[];
|
|
111
116
|
|
|
112
|
-
export { type BaseTypeTableProps as B, type DocEntry as D, type GenerateOptions as G, type GeneratedDoc as a, type Generator as b, type GenerateTypeTableOptions as c, createProject as d, type GeneratorOptions as e, createGenerator as f, generateDocumentation as g };
|
|
117
|
+
export { type BaseTypeTableProps as B, type DocEntry as D, type GenerateOptions as G, type RawTag as R, type GeneratedDoc as a, type Generator as b, type GenerateTypeTableOptions as c, createProject as d, type GeneratorOptions as e, createGenerator as f, generateDocumentation as g };
|
|
@@ -53,34 +53,80 @@ var __async = (__this, __arguments, generator) => {
|
|
|
53
53
|
// src/markdown.ts
|
|
54
54
|
import { remark } from "remark";
|
|
55
55
|
import {
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
rehypeCode,
|
|
57
|
+
remarkGfm
|
|
58
58
|
} from "fumadocs-core/mdx-plugins";
|
|
59
59
|
import remarkRehype from "remark-rehype";
|
|
60
|
-
|
|
60
|
+
import { highlightHast } from "fumadocs-core/highlight";
|
|
61
|
+
var shikiOptions = {
|
|
61
62
|
lazy: true,
|
|
62
63
|
themes: {
|
|
63
64
|
light: "github-light",
|
|
64
65
|
dark: "github-dark"
|
|
65
66
|
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
67
|
+
};
|
|
68
|
+
var processor = remark().use(remarkGfm).use(remarkRehype).use(rehypeCode, shikiOptions);
|
|
69
|
+
function renderTypeToHast(type) {
|
|
70
|
+
return __async(this, null, function* () {
|
|
71
|
+
const nodes = yield highlightHast(type, __spreadProps(__spreadValues({}, shikiOptions), {
|
|
72
|
+
lang: "ts",
|
|
73
|
+
structure: "inline"
|
|
74
|
+
}));
|
|
75
|
+
return {
|
|
76
|
+
type: "element",
|
|
77
|
+
tagName: "span",
|
|
78
|
+
properties: {
|
|
79
|
+
class: "shiki"
|
|
80
|
+
},
|
|
81
|
+
children: [
|
|
82
|
+
{
|
|
83
|
+
type: "element",
|
|
84
|
+
tagName: "code",
|
|
85
|
+
properties: {},
|
|
86
|
+
children: nodes.children
|
|
87
|
+
}
|
|
88
|
+
]
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
}
|
|
72
92
|
function renderMarkdownToHast(md) {
|
|
73
93
|
return __async(this, null, function* () {
|
|
74
94
|
md = md.replace(new RegExp("{@link (?<link>[^}]*)}", "g"), "$1");
|
|
75
|
-
|
|
76
|
-
return out.data.tree;
|
|
95
|
+
return processor.run(processor.parse(md));
|
|
77
96
|
});
|
|
78
97
|
}
|
|
79
98
|
|
|
99
|
+
// src/lib/parse-tags.ts
|
|
100
|
+
function parseTags(tags) {
|
|
101
|
+
var _a;
|
|
102
|
+
const typed = {};
|
|
103
|
+
for (const { name: key, text } of tags) {
|
|
104
|
+
if (key === "default" || key === "defaultValue") {
|
|
105
|
+
typed.default = text;
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
if (key === "param") {
|
|
109
|
+
const [param, description] = text.split("-", 2);
|
|
110
|
+
(_a = typed.params) != null ? _a : typed.params = [];
|
|
111
|
+
typed.params.push({
|
|
112
|
+
name: param.trim(),
|
|
113
|
+
description: description.trim()
|
|
114
|
+
});
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
if (key === "returns") {
|
|
118
|
+
typed.returns = text;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return typed;
|
|
122
|
+
}
|
|
123
|
+
|
|
80
124
|
export {
|
|
81
125
|
__spreadValues,
|
|
82
126
|
__spreadProps,
|
|
83
127
|
__objRest,
|
|
84
128
|
__async,
|
|
85
|
-
|
|
129
|
+
renderTypeToHast,
|
|
130
|
+
renderMarkdownToHast,
|
|
131
|
+
parseTags
|
|
86
132
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { G as GenerateOptions, a as GeneratedDoc, D as DocEntry, b as Generator, c as GenerateTypeTableOptions } from './base-
|
|
2
|
-
export { e as GeneratorOptions, f as createGenerator, d as createProject, g as generateDocumentation } from './base-
|
|
1
|
+
import { G as GenerateOptions, a as GeneratedDoc, D as DocEntry, b as Generator, c as GenerateTypeTableOptions } from './base-Q18nCvFH.js';
|
|
2
|
+
export { e as GeneratorOptions, R as RawTag, f as createGenerator, d as createProject, g as generateDocumentation } from './base-Q18nCvFH.js';
|
|
3
3
|
import { GlobOptions } from 'tinyglobby';
|
|
4
4
|
import { Nodes } from 'hast';
|
|
5
5
|
import { Root } from 'mdast';
|
|
@@ -34,6 +34,7 @@ interface GenerateFilesOptions {
|
|
|
34
34
|
}
|
|
35
35
|
declare function generateFiles(generator: Generator, options: GenerateFilesOptions): Promise<void>;
|
|
36
36
|
|
|
37
|
+
declare function renderTypeToHast(type: string): Promise<Nodes>;
|
|
37
38
|
declare function renderMarkdownToHast(md: string): Promise<Nodes>;
|
|
38
39
|
|
|
39
40
|
interface RemarkAutoTypeTableOptions {
|
|
@@ -46,6 +47,7 @@ interface RemarkAutoTypeTableOptions {
|
|
|
46
47
|
*/
|
|
47
48
|
outputName?: string;
|
|
48
49
|
renderMarkdown?: typeof renderMarkdownToHast;
|
|
50
|
+
renderType?: typeof renderTypeToHast;
|
|
49
51
|
/**
|
|
50
52
|
* Customise type table generation
|
|
51
53
|
*/
|
|
@@ -61,6 +63,6 @@ interface RemarkAutoTypeTableOptions {
|
|
|
61
63
|
*
|
|
62
64
|
* MDX is required to use this plugin.
|
|
63
65
|
*/
|
|
64
|
-
declare function remarkAutoTypeTable(
|
|
66
|
+
declare function remarkAutoTypeTable(config?: RemarkAutoTypeTableOptions): Transformer<Root, Root>;
|
|
65
67
|
|
|
66
68
|
export { DocEntry, type GenerateFilesOptions, type GenerateMDXOptions, GenerateOptions, GeneratedDoc, Generator, type RemarkAutoTypeTableOptions, generateFiles, generateMDX, remarkAutoTypeTable, renderMarkdownToHast };
|
package/dist/index.js
CHANGED
|
@@ -3,13 +3,15 @@ import {
|
|
|
3
3
|
__objRest,
|
|
4
4
|
__spreadProps,
|
|
5
5
|
__spreadValues,
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
parseTags,
|
|
7
|
+
renderMarkdownToHast,
|
|
8
|
+
renderTypeToHast
|
|
9
|
+
} from "./chunk-HM6PM4II.js";
|
|
8
10
|
|
|
9
11
|
// src/lib/base.ts
|
|
10
12
|
import {
|
|
11
13
|
Project as Project2,
|
|
12
|
-
ts
|
|
14
|
+
ts as ts2
|
|
13
15
|
} from "ts-morph";
|
|
14
16
|
|
|
15
17
|
// src/create-project.ts
|
|
@@ -86,6 +88,54 @@ function createCache() {
|
|
|
86
88
|
|
|
87
89
|
// src/lib/base.ts
|
|
88
90
|
import path2 from "path";
|
|
91
|
+
|
|
92
|
+
// src/lib/get-simple-form.ts
|
|
93
|
+
import * as ts from "ts-morph";
|
|
94
|
+
function getSimpleForm(type, checker, noUndefined = false) {
|
|
95
|
+
if (type.isUndefined() && noUndefined) return "";
|
|
96
|
+
const alias = type.getAliasSymbol();
|
|
97
|
+
if (alias && type.getAliasTypeArguments().length === 0) {
|
|
98
|
+
return alias.getEscapedName();
|
|
99
|
+
}
|
|
100
|
+
if (type.isUnion()) {
|
|
101
|
+
const types = [];
|
|
102
|
+
for (const t of type.getUnionTypes()) {
|
|
103
|
+
const str = getSimpleForm(t, checker, noUndefined);
|
|
104
|
+
if (str.length > 0 && str !== "never") types.unshift(str);
|
|
105
|
+
}
|
|
106
|
+
return types.length > 0 ? (
|
|
107
|
+
// boolean | null will become true | false | null, need to ensure it's still returned as boolean
|
|
108
|
+
types.join(" | ").replace("true | false", "boolean")
|
|
109
|
+
) : "never";
|
|
110
|
+
}
|
|
111
|
+
if (type.isIntersection()) {
|
|
112
|
+
const types = [];
|
|
113
|
+
for (const t of type.getIntersectionTypes()) {
|
|
114
|
+
const str = getSimpleForm(t, checker, noUndefined);
|
|
115
|
+
if (str.length > 0 && str !== "never") types.unshift(str);
|
|
116
|
+
}
|
|
117
|
+
return types.join(" & ");
|
|
118
|
+
}
|
|
119
|
+
if (type.isTuple()) {
|
|
120
|
+
const elements = type.getTupleElements().map((t) => getSimpleForm(t, checker)).join(", ");
|
|
121
|
+
return `[${elements}]`;
|
|
122
|
+
}
|
|
123
|
+
if (type.isArray() || type.isReadonlyArray()) {
|
|
124
|
+
return "array";
|
|
125
|
+
}
|
|
126
|
+
if (type.getCallSignatures().length > 0) {
|
|
127
|
+
return "function";
|
|
128
|
+
}
|
|
129
|
+
if (type.isClassOrInterface() || type.isObject()) {
|
|
130
|
+
return "object";
|
|
131
|
+
}
|
|
132
|
+
return type.getText(
|
|
133
|
+
void 0,
|
|
134
|
+
ts.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope | ts.TypeFormatFlags.InTypeAlias
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// src/lib/base.ts
|
|
89
139
|
function createGenerator(config) {
|
|
90
140
|
var _a;
|
|
91
141
|
const options = config instanceof Project2 ? {
|
|
@@ -146,50 +196,62 @@ function generate(program, name, declaration, { allowInternal = false, transform
|
|
|
146
196
|
);
|
|
147
197
|
return {
|
|
148
198
|
name,
|
|
149
|
-
description: comment ?
|
|
199
|
+
description: comment ? ts2.displayPartsToString(comment) : "",
|
|
150
200
|
entries: declaration.getType().getProperties().map((prop) => getDocEntry(prop, entryContext)).filter(
|
|
151
201
|
(entry) => entry && (allowInternal || !("internal" in entry.tags))
|
|
152
202
|
)
|
|
153
203
|
};
|
|
154
204
|
}
|
|
155
205
|
function getDocEntry(prop, context) {
|
|
156
|
-
var _a, _b
|
|
206
|
+
var _a, _b;
|
|
157
207
|
const { transform, program } = context;
|
|
158
208
|
if (context.type.isClass() && prop.getName().startsWith("#")) {
|
|
159
209
|
return;
|
|
160
210
|
}
|
|
161
211
|
const subType = program.getTypeChecker().getTypeOfSymbolAtLocation(prop, context.declaration);
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
212
|
+
const isOptional = prop.isOptional();
|
|
213
|
+
const tags = prop.getJsDocTags().map(
|
|
214
|
+
(tag) => ({
|
|
215
|
+
name: tag.getName(),
|
|
216
|
+
text: ts2.displayPartsToString(tag.getText())
|
|
217
|
+
})
|
|
168
218
|
);
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
typeName = typeName.slice(0, typeName.length - "| undefined".length).trimEnd();
|
|
174
|
-
}
|
|
175
|
-
if ("remarks" in tags) {
|
|
176
|
-
typeName = (_d = (_c = new RegExp("^`(?<name>.+)`").exec(tags.remarks)) == null ? void 0 : _c[1]) != null ? _d : typeName;
|
|
219
|
+
let type = getFullType(subType);
|
|
220
|
+
for (const tag of tags) {
|
|
221
|
+
if (tag.name !== "remarks") continue;
|
|
222
|
+
type = (_b = (_a = new RegExp("^`(?<name>.+)`").exec(tag.text)) == null ? void 0 : _a[1]) != null ? _b : type;
|
|
177
223
|
}
|
|
178
224
|
const entry = {
|
|
179
225
|
name: prop.getName(),
|
|
180
|
-
description:
|
|
226
|
+
description: ts2.displayPartsToString(
|
|
181
227
|
prop.compilerSymbol.getDocumentationComment(
|
|
182
228
|
program.getTypeChecker().compilerObject
|
|
183
229
|
)
|
|
184
230
|
),
|
|
185
231
|
tags,
|
|
186
|
-
type
|
|
187
|
-
|
|
188
|
-
|
|
232
|
+
type,
|
|
233
|
+
simplifiedType: getSimpleForm(
|
|
234
|
+
subType,
|
|
235
|
+
program.getTypeChecker(),
|
|
236
|
+
isOptional
|
|
237
|
+
),
|
|
238
|
+
required: !isOptional,
|
|
239
|
+
deprecated: tags.some((tag) => tag.name === "deprecated")
|
|
189
240
|
};
|
|
190
241
|
transform == null ? void 0 : transform.call(context, entry, subType, prop);
|
|
191
242
|
return entry;
|
|
192
243
|
}
|
|
244
|
+
function getFullType(type) {
|
|
245
|
+
var _a, _b;
|
|
246
|
+
let typeName = type.getText(
|
|
247
|
+
void 0,
|
|
248
|
+
ts2.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope | ts2.TypeFormatFlags.NoTruncation | ts2.TypeFormatFlags.InTypeAlias
|
|
249
|
+
);
|
|
250
|
+
if (type.getAliasSymbol() && type.getAliasTypeArguments().length === 0) {
|
|
251
|
+
typeName = (_b = (_a = type.getAliasSymbol()) == null ? void 0 : _a.getEscapedName()) != null ? _b : typeName;
|
|
252
|
+
}
|
|
253
|
+
return typeName;
|
|
254
|
+
}
|
|
193
255
|
|
|
194
256
|
// src/lib/mdx.ts
|
|
195
257
|
import * as path3 from "path";
|
|
@@ -209,8 +271,8 @@ ${doc.description}
|
|
|
209
271
|
|
|
210
272
|
${c.description || "No Description"}
|
|
211
273
|
|
|
212
|
-
${
|
|
213
|
-
${replaceJsDocLinks(
|
|
274
|
+
${c.tags.map((tag) => `- ${tag.name}:
|
|
275
|
+
${replaceJsDocLinks(tag.text)}`).join("\n")}
|
|
214
276
|
|
|
215
277
|
</div>`
|
|
216
278
|
};
|
|
@@ -267,61 +329,111 @@ function write(file, content) {
|
|
|
267
329
|
});
|
|
268
330
|
}
|
|
269
331
|
|
|
270
|
-
// src/lib/remark-auto-type-table.
|
|
332
|
+
// src/lib/remark-auto-type-table.ts
|
|
271
333
|
import { valueToEstree } from "estree-util-value-to-estree";
|
|
272
334
|
import { visit } from "unist-util-visit";
|
|
273
335
|
import { toEstree } from "hast-util-to-estree";
|
|
274
336
|
import { dirname as dirname2 } from "path";
|
|
275
|
-
function
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
const hast = toEstree(yield renderMarkdown(entry.description), {
|
|
284
|
-
elementAttributeNameCase: "react"
|
|
285
|
-
}).body[0];
|
|
286
|
-
value.properties.push({
|
|
337
|
+
function objectBuilder() {
|
|
338
|
+
const out = {
|
|
339
|
+
type: "ObjectExpression",
|
|
340
|
+
properties: []
|
|
341
|
+
};
|
|
342
|
+
return {
|
|
343
|
+
addExpressionNode(key, expression) {
|
|
344
|
+
out.properties.push({
|
|
287
345
|
type: "Property",
|
|
288
346
|
method: false,
|
|
289
347
|
shorthand: false,
|
|
290
348
|
computed: false,
|
|
291
349
|
key: {
|
|
292
350
|
type: "Identifier",
|
|
293
|
-
name:
|
|
351
|
+
name: key
|
|
294
352
|
},
|
|
295
353
|
kind: "init",
|
|
296
|
-
value:
|
|
354
|
+
value: expression
|
|
297
355
|
});
|
|
356
|
+
},
|
|
357
|
+
addJsxProperty(key, hast) {
|
|
358
|
+
const estree = toEstree(hast, {
|
|
359
|
+
elementAttributeNameCase: "react"
|
|
360
|
+
}).body[0];
|
|
361
|
+
this.addExpressionNode(key, estree.expression);
|
|
362
|
+
},
|
|
363
|
+
build() {
|
|
364
|
+
return out;
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
function buildTypeProp(_0, _1) {
|
|
369
|
+
return __async(this, arguments, function* (entries, {
|
|
370
|
+
renderMarkdown = renderMarkdownToHast,
|
|
371
|
+
renderType = renderTypeToHast
|
|
372
|
+
}) {
|
|
373
|
+
function onItem(entry) {
|
|
374
|
+
return __async(this, null, function* () {
|
|
375
|
+
const node = objectBuilder();
|
|
376
|
+
node.addJsxProperty("type", yield renderType(entry.simplifiedType));
|
|
377
|
+
node.addJsxProperty("typeDescription", yield renderType(entry.type));
|
|
378
|
+
node.addExpressionNode("required", valueToEstree(entry.required));
|
|
379
|
+
const tags = parseTags(entry.tags);
|
|
380
|
+
if (tags.default)
|
|
381
|
+
node.addJsxProperty("default", yield renderType(tags.default));
|
|
382
|
+
if (tags.returns)
|
|
383
|
+
node.addJsxProperty("returns", yield renderMarkdown(tags.returns));
|
|
384
|
+
if (tags.params) {
|
|
385
|
+
node.addExpressionNode("parameters", {
|
|
386
|
+
type: "ArrayExpression",
|
|
387
|
+
elements: yield Promise.all(tags.params.map(onParam))
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
if (entry.description) {
|
|
391
|
+
node.addJsxProperty(
|
|
392
|
+
"description",
|
|
393
|
+
yield renderMarkdown(entry.description)
|
|
394
|
+
);
|
|
395
|
+
}
|
|
396
|
+
return node.build();
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
function onParam(param) {
|
|
400
|
+
return __async(this, null, function* () {
|
|
401
|
+
const node = objectBuilder();
|
|
402
|
+
node.addExpressionNode("name", valueToEstree(param.name));
|
|
403
|
+
if (param.description)
|
|
404
|
+
node.addJsxProperty(
|
|
405
|
+
"description",
|
|
406
|
+
yield renderMarkdown(param.description)
|
|
407
|
+
);
|
|
408
|
+
return node.build();
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
const prop = objectBuilder();
|
|
412
|
+
const output = yield Promise.all(
|
|
413
|
+
entries.map((entry) => __async(null, null, function* () {
|
|
414
|
+
return {
|
|
415
|
+
name: entry.name,
|
|
416
|
+
node: yield onItem(entry)
|
|
417
|
+
};
|
|
418
|
+
}))
|
|
419
|
+
);
|
|
420
|
+
for (const node of output) {
|
|
421
|
+
prop.addExpressionNode(node.name, node.node);
|
|
298
422
|
}
|
|
299
|
-
return
|
|
300
|
-
type: "Property",
|
|
301
|
-
method: false,
|
|
302
|
-
shorthand: false,
|
|
303
|
-
computed: false,
|
|
304
|
-
key: {
|
|
305
|
-
type: "Literal",
|
|
306
|
-
value: entry.name
|
|
307
|
-
},
|
|
308
|
-
kind: "init",
|
|
309
|
-
value
|
|
310
|
-
};
|
|
423
|
+
return prop.build();
|
|
311
424
|
});
|
|
312
425
|
}
|
|
313
|
-
function remarkAutoTypeTable({
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
} =
|
|
426
|
+
function remarkAutoTypeTable(config = {}) {
|
|
427
|
+
const {
|
|
428
|
+
name = "auto-type-table",
|
|
429
|
+
outputName = "TypeTable",
|
|
430
|
+
options: generateOptions = {},
|
|
431
|
+
remarkStringify = true,
|
|
432
|
+
generator = createGenerator()
|
|
433
|
+
} = config;
|
|
321
434
|
return (tree, file) => __async(null, null, function* () {
|
|
322
435
|
const queue = [];
|
|
323
|
-
|
|
324
|
-
if (!basePath && file.path) basePath = dirname2(file.path);
|
|
436
|
+
const defaultBasePath = file.path ? dirname2(file.path) : void 0;
|
|
325
437
|
visit(tree, "mdxJsxFlowElement", (node) => {
|
|
326
438
|
if (node.name !== name) return;
|
|
327
439
|
const props = {};
|
|
@@ -334,16 +446,14 @@ function remarkAutoTypeTable({
|
|
|
334
446
|
}
|
|
335
447
|
function run() {
|
|
336
448
|
return __async(this, null, function* () {
|
|
449
|
+
var _a;
|
|
337
450
|
const output = yield generator.generateTypeTable(
|
|
338
451
|
props,
|
|
339
|
-
__spreadProps(__spreadValues({},
|
|
340
|
-
basePath
|
|
452
|
+
__spreadProps(__spreadValues({}, generateOptions), {
|
|
453
|
+
basePath: (_a = generateOptions.basePath) != null ? _a : defaultBasePath
|
|
341
454
|
})
|
|
342
455
|
);
|
|
343
456
|
const rendered = output.map((doc) => __async(null, null, function* () {
|
|
344
|
-
const properties = yield Promise.all(
|
|
345
|
-
doc.entries.map((entry) => mapProperty(entry, renderMarkdown))
|
|
346
|
-
);
|
|
347
457
|
return {
|
|
348
458
|
type: "mdxJsxFlowElement",
|
|
349
459
|
name: outputName,
|
|
@@ -361,10 +471,7 @@ function remarkAutoTypeTable({
|
|
|
361
471
|
body: [
|
|
362
472
|
{
|
|
363
473
|
type: "ExpressionStatement",
|
|
364
|
-
expression:
|
|
365
|
-
type: "ObjectExpression",
|
|
366
|
-
properties
|
|
367
|
-
}
|
|
474
|
+
expression: yield buildTypeProp(doc.entries, config)
|
|
368
475
|
}
|
|
369
476
|
]
|
|
370
477
|
}
|
package/dist/ui/index.d.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import * as runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { B as BaseTypeTableProps, b as Generator, c as GenerateTypeTableOptions } from '../base-
|
|
3
|
+
import { B as BaseTypeTableProps, b as Generator, c as GenerateTypeTableOptions } from '../base-Q18nCvFH.js';
|
|
4
4
|
import 'ts-morph';
|
|
5
5
|
|
|
6
6
|
type AutoTypeTableProps = BaseTypeTableProps;
|
|
7
|
-
declare function AutoTypeTable({ generator, options, renderMarkdown, ...props }: AutoTypeTableProps & {
|
|
7
|
+
declare function AutoTypeTable({ generator, options, renderType, renderMarkdown, ...props }: AutoTypeTableProps & {
|
|
8
8
|
generator: Generator;
|
|
9
9
|
renderMarkdown?: typeof renderMarkdownDefault;
|
|
10
|
+
renderType?: typeof renderTypeDefault;
|
|
10
11
|
options?: GenerateTypeTableOptions;
|
|
11
12
|
}): Promise<Promise<runtime.JSX.Element>[]>;
|
|
13
|
+
declare function renderTypeDefault(type: string): Promise<ReactNode>;
|
|
12
14
|
declare function renderMarkdownDefault(md: string): Promise<ReactNode>;
|
|
13
15
|
|
|
14
16
|
export { AutoTypeTable, type AutoTypeTableProps };
|
package/dist/ui/index.js
CHANGED
|
@@ -3,11 +3,15 @@ import {
|
|
|
3
3
|
__objRest,
|
|
4
4
|
__spreadProps,
|
|
5
5
|
__spreadValues,
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
parseTags,
|
|
7
|
+
renderMarkdownToHast,
|
|
8
|
+
renderTypeToHast
|
|
9
|
+
} from "../chunk-HM6PM4II.js";
|
|
8
10
|
|
|
9
11
|
// src/ui/auto-type-table.tsx
|
|
10
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
TypeTable
|
|
14
|
+
} from "fumadocs-ui/components/type-table";
|
|
11
15
|
import { toJsxRuntime } from "hast-util-to-jsx-runtime";
|
|
12
16
|
import * as runtime from "react/jsx-runtime";
|
|
13
17
|
import defaultMdxComponents from "fumadocs-ui/mdx";
|
|
@@ -18,28 +22,40 @@ function AutoTypeTable(_a) {
|
|
|
18
22
|
var _b = _a, {
|
|
19
23
|
generator,
|
|
20
24
|
options = {},
|
|
25
|
+
renderType = renderTypeDefault,
|
|
21
26
|
renderMarkdown = renderMarkdownDefault
|
|
22
27
|
} = _b, props = __objRest(_b, [
|
|
23
28
|
"generator",
|
|
24
29
|
"options",
|
|
30
|
+
"renderType",
|
|
25
31
|
"renderMarkdown"
|
|
26
32
|
]);
|
|
27
33
|
const output = yield generator.generateTypeTable(props, options);
|
|
28
34
|
return output.map((item) => __async(null, null, function* () {
|
|
29
|
-
const entries = item.entries.map(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
const entries = item.entries.map((entry) => __async(null, null, function* () {
|
|
36
|
+
var _a2;
|
|
37
|
+
const tags = parseTags(entry.tags);
|
|
38
|
+
const paramNodes = [];
|
|
39
|
+
for (const param of (_a2 = tags.params) != null ? _a2 : []) {
|
|
40
|
+
paramNodes.push({
|
|
41
|
+
name: param.name,
|
|
42
|
+
description: param.description ? yield renderMarkdown(param.description) : void 0
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return [
|
|
46
|
+
entry.name,
|
|
47
|
+
{
|
|
48
|
+
type: yield renderType(entry.simplifiedType),
|
|
49
|
+
typeDescription: yield renderType(entry.type),
|
|
50
|
+
description: yield renderMarkdown(entry.description),
|
|
51
|
+
default: tags.default ? yield renderType(tags.default) : void 0,
|
|
52
|
+
parameters: paramNodes,
|
|
53
|
+
required: entry.required,
|
|
54
|
+
deprecated: entry.deprecated,
|
|
55
|
+
returns: tags.returns ? yield renderMarkdown(tags.returns) : void 0
|
|
56
|
+
}
|
|
57
|
+
];
|
|
58
|
+
}));
|
|
43
59
|
return /* @__PURE__ */ jsx2(
|
|
44
60
|
TypeTable,
|
|
45
61
|
{
|
|
@@ -50,14 +66,22 @@ function AutoTypeTable(_a) {
|
|
|
50
66
|
}));
|
|
51
67
|
});
|
|
52
68
|
}
|
|
69
|
+
function toJsx(hast) {
|
|
70
|
+
return toJsxRuntime(hast, {
|
|
71
|
+
Fragment: runtime.Fragment,
|
|
72
|
+
jsx: runtime.jsx,
|
|
73
|
+
jsxs: runtime.jsxs,
|
|
74
|
+
components: __spreadProps(__spreadValues({}, defaultMdxComponents), { img: void 0 })
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
function renderTypeDefault(type) {
|
|
78
|
+
return __async(this, null, function* () {
|
|
79
|
+
return toJsx(yield renderTypeToHast(type));
|
|
80
|
+
});
|
|
81
|
+
}
|
|
53
82
|
function renderMarkdownDefault(md) {
|
|
54
83
|
return __async(this, null, function* () {
|
|
55
|
-
return
|
|
56
|
-
Fragment: runtime.Fragment,
|
|
57
|
-
jsx: runtime.jsx,
|
|
58
|
-
jsxs: runtime.jsxs,
|
|
59
|
-
components: __spreadProps(__spreadValues({}, defaultMdxComponents), { img: void 0 })
|
|
60
|
-
});
|
|
84
|
+
return toJsx(yield renderMarkdownToHast(md));
|
|
61
85
|
});
|
|
62
86
|
}
|
|
63
87
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-typescript",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.7",
|
|
4
4
|
"description": "Typescript Integration for Fumadocs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -33,29 +33,35 @@
|
|
|
33
33
|
"hast-util-to-jsx-runtime": "^2.3.6",
|
|
34
34
|
"remark": "^15.0.1",
|
|
35
35
|
"remark-rehype": "^11.1.2",
|
|
36
|
-
"shiki": "^3.
|
|
37
|
-
"tinyglobby": "^0.2.
|
|
36
|
+
"shiki": "^3.12.0",
|
|
37
|
+
"tinyglobby": "^0.2.14",
|
|
38
38
|
"ts-morph": "^26.0.0",
|
|
39
39
|
"unist-util-visit": "^5.0.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@mdx-js/mdx": "^3.1.
|
|
43
|
-
"@types/estree": "^1.0.
|
|
42
|
+
"@mdx-js/mdx": "^3.1.1",
|
|
43
|
+
"@types/estree": "^1.0.8",
|
|
44
44
|
"@types/hast": "^3.0.4",
|
|
45
45
|
"@types/mdast": "^4.0.3",
|
|
46
|
-
"@types/node": "
|
|
47
|
-
"@types/react": "19.1.
|
|
48
|
-
"@types/react-dom": "19.1.
|
|
49
|
-
"typescript": "^5.
|
|
46
|
+
"@types/node": "24.3.0",
|
|
47
|
+
"@types/react": "19.1.12",
|
|
48
|
+
"@types/react-dom": "19.1.9",
|
|
49
|
+
"typescript": "^5.9.2",
|
|
50
50
|
"unified": "^11.0.5",
|
|
51
51
|
"eslint-config-custom": "0.0.0",
|
|
52
|
-
"fumadocs-
|
|
53
|
-
"fumadocs-
|
|
52
|
+
"fumadocs-core": "15.7.9",
|
|
53
|
+
"fumadocs-ui": "15.7.9",
|
|
54
54
|
"tsconfig": "0.0.0"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
|
+
"@types/react": "*",
|
|
57
58
|
"typescript": "*"
|
|
58
59
|
},
|
|
60
|
+
"peerDependenciesMeta": {
|
|
61
|
+
"@types/react": {
|
|
62
|
+
"optional": true
|
|
63
|
+
}
|
|
64
|
+
},
|
|
59
65
|
"publishConfig": {
|
|
60
66
|
"access": "public"
|
|
61
67
|
},
|