fumadocs-typescript 3.1.0 → 4.0.1
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/{chunk-LRCT2FYJ.js → chunk-2WGVCLFC.js} +4 -98
- package/dist/index.d.ts +14 -9
- package/dist/index.js +143 -63
- package/dist/{type-table-DyymKQK8.d.ts → type-table-Duzly_SK.d.ts} +21 -14
- package/dist/ui/index.d.ts +8 -16
- package/dist/ui/index.js +7 -16
- package/package.json +10 -10
|
@@ -50,88 +50,6 @@ var __async = (__this, __arguments, generator) => {
|
|
|
50
50
|
});
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
-
// src/get-project.ts
|
|
54
|
-
import { Project } from "ts-morph";
|
|
55
|
-
function getProject(options = {}) {
|
|
56
|
-
var _a;
|
|
57
|
-
return new Project({
|
|
58
|
-
tsConfigFilePath: (_a = options.tsconfigPath) != null ? _a : "./tsconfig.json",
|
|
59
|
-
skipAddingFilesFromTsConfig: true
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// src/lib/base.ts
|
|
64
|
-
import {
|
|
65
|
-
ts
|
|
66
|
-
} from "ts-morph";
|
|
67
|
-
function generateDocumentation(file, name, content, options = {}) {
|
|
68
|
-
var _a;
|
|
69
|
-
const project = (_a = options.project) != null ? _a : getProject(options.config);
|
|
70
|
-
const sourceFile = project.createSourceFile(file, content, {
|
|
71
|
-
overwrite: true
|
|
72
|
-
});
|
|
73
|
-
const out = [];
|
|
74
|
-
for (const [k, d] of sourceFile.getExportedDeclarations()) {
|
|
75
|
-
if (name && name !== k) continue;
|
|
76
|
-
if (d.length > 1)
|
|
77
|
-
console.warn(
|
|
78
|
-
`export ${k} should not have more than one type declaration.`
|
|
79
|
-
);
|
|
80
|
-
out.push(generate(project, k, d[0], options));
|
|
81
|
-
}
|
|
82
|
-
return out;
|
|
83
|
-
}
|
|
84
|
-
function generate(program, name, declaration, { allowInternal = false, transform }) {
|
|
85
|
-
var _a;
|
|
86
|
-
const entryContext = {
|
|
87
|
-
transform,
|
|
88
|
-
program,
|
|
89
|
-
type: declaration.getType(),
|
|
90
|
-
declaration
|
|
91
|
-
};
|
|
92
|
-
const comment = (_a = declaration.getSymbol()) == null ? void 0 : _a.compilerSymbol.getDocumentationComment(
|
|
93
|
-
program.getTypeChecker().compilerObject
|
|
94
|
-
);
|
|
95
|
-
return {
|
|
96
|
-
name,
|
|
97
|
-
description: comment ? ts.displayPartsToString(comment) : "",
|
|
98
|
-
entries: declaration.getType().getProperties().map((prop) => getDocEntry(prop, entryContext)).filter(
|
|
99
|
-
(entry) => entry && (allowInternal || !("internal" in entry.tags))
|
|
100
|
-
)
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
function getDocEntry(prop, context) {
|
|
104
|
-
var _a, _b, _c, _d;
|
|
105
|
-
const { transform, program } = context;
|
|
106
|
-
if (context.type.isClass() && prop.getName().startsWith("#")) {
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
const subType = program.getTypeChecker().getTypeOfSymbolAtLocation(prop, context.declaration);
|
|
110
|
-
const tags = Object.fromEntries(
|
|
111
|
-
prop.getJsDocTags().map((tag) => [tag.getName(), ts.displayPartsToString(tag.getText())])
|
|
112
|
-
);
|
|
113
|
-
let typeName = subType.getNonNullableType().getText(void 0, ts.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope);
|
|
114
|
-
if (subType.getAliasSymbol() && subType.getAliasTypeArguments().length === 0) {
|
|
115
|
-
typeName = (_b = (_a = subType.getAliasSymbol()) == null ? void 0 : _a.getEscapedName()) != null ? _b : typeName;
|
|
116
|
-
}
|
|
117
|
-
if ("remarks" in tags) {
|
|
118
|
-
typeName = (_d = (_c = new RegExp("^`(?<name>.+)`").exec(tags.remarks)) == null ? void 0 : _c[1]) != null ? _d : typeName;
|
|
119
|
-
}
|
|
120
|
-
const entry = {
|
|
121
|
-
name: prop.getName(),
|
|
122
|
-
description: ts.displayPartsToString(
|
|
123
|
-
prop.compilerSymbol.getDocumentationComment(
|
|
124
|
-
program.getTypeChecker().compilerObject
|
|
125
|
-
)
|
|
126
|
-
),
|
|
127
|
-
tags,
|
|
128
|
-
type: typeName,
|
|
129
|
-
required: !prop.isOptional()
|
|
130
|
-
};
|
|
131
|
-
transform == null ? void 0 : transform.call(context, entry, subType, prop);
|
|
132
|
-
return entry;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
53
|
// src/markdown.ts
|
|
136
54
|
import { remark } from "remark";
|
|
137
55
|
import {
|
|
@@ -162,17 +80,9 @@ function renderMarkdownToHast(md) {
|
|
|
162
80
|
// src/utils/type-table.ts
|
|
163
81
|
import * as fs from "node:fs/promises";
|
|
164
82
|
import { join } from "node:path";
|
|
165
|
-
function getTypeTableOutput(_a) {
|
|
83
|
+
function getTypeTableOutput(gen, _a, options) {
|
|
166
84
|
return __async(this, null, function* () {
|
|
167
|
-
var _b = _a, {
|
|
168
|
-
name,
|
|
169
|
-
type,
|
|
170
|
-
options
|
|
171
|
-
} = _b, props = __objRest(_b, [
|
|
172
|
-
"name",
|
|
173
|
-
"type",
|
|
174
|
-
"options"
|
|
175
|
-
]);
|
|
85
|
+
var _b = _a, { name, type } = _b, props = __objRest(_b, ["name", "type"]);
|
|
176
86
|
const file = props.path && (options == null ? void 0 : options.basePath) ? join(options.basePath, props.path) : props.path;
|
|
177
87
|
let typeName = name;
|
|
178
88
|
let content = "";
|
|
@@ -187,10 +97,9 @@ ${type}`;
|
|
|
187
97
|
content += `
|
|
188
98
|
export type ${typeName} = ${type}`;
|
|
189
99
|
}
|
|
190
|
-
const output = generateDocumentation(
|
|
191
|
-
file != null ? file : "temp.ts",
|
|
100
|
+
const output = gen.generateDocumentation(
|
|
101
|
+
{ path: file != null ? file : "temp.ts", content },
|
|
192
102
|
typeName,
|
|
193
|
-
content,
|
|
194
103
|
options
|
|
195
104
|
);
|
|
196
105
|
if (name && output.length === 0)
|
|
@@ -204,9 +113,6 @@ export {
|
|
|
204
113
|
__spreadProps,
|
|
205
114
|
__objRest,
|
|
206
115
|
__async,
|
|
207
|
-
getProject,
|
|
208
|
-
generateDocumentation,
|
|
209
|
-
generate,
|
|
210
116
|
renderMarkdownToHast,
|
|
211
117
|
getTypeTableOutput
|
|
212
118
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { G as
|
|
2
|
-
export {
|
|
1
|
+
import { G as GenerateOptions, a as GeneratedDoc, D as DocEntry, b as Generator, c as GenerateTypeTableOptions } from './type-table-Duzly_SK.js';
|
|
2
|
+
export { d as createGenerator, e as generateDocumentation, g as getProject } from './type-table-Duzly_SK.js';
|
|
3
3
|
import fg from 'fast-glob';
|
|
4
4
|
import { Nodes } from 'hast';
|
|
5
5
|
import { Root } from 'mdast';
|
|
@@ -10,14 +10,14 @@ interface Templates {
|
|
|
10
10
|
block: (doc: GeneratedDoc, children: string) => string;
|
|
11
11
|
property: (entry: DocEntry) => string;
|
|
12
12
|
}
|
|
13
|
-
interface GenerateMDXOptions extends
|
|
13
|
+
interface GenerateMDXOptions extends GenerateOptions {
|
|
14
14
|
/**
|
|
15
15
|
* a root directory to resolve relative file paths
|
|
16
16
|
*/
|
|
17
17
|
basePath?: string;
|
|
18
18
|
templates?: Partial<Templates>;
|
|
19
19
|
}
|
|
20
|
-
declare function generateMDX(source: string, { basePath, templates: overrides, ...rest }?: GenerateMDXOptions): string;
|
|
20
|
+
declare function generateMDX(generator: Generator, source: string, { basePath, templates: overrides, ...rest }?: GenerateMDXOptions): string;
|
|
21
21
|
|
|
22
22
|
interface GenerateFilesOptions {
|
|
23
23
|
input: string | string[];
|
|
@@ -32,7 +32,7 @@ interface GenerateFilesOptions {
|
|
|
32
32
|
*/
|
|
33
33
|
transformOutput?: (path: string, content: string) => string;
|
|
34
34
|
}
|
|
35
|
-
declare function generateFiles(options: GenerateFilesOptions): Promise<void>;
|
|
35
|
+
declare function generateFiles(generator: Generator, options: GenerateFilesOptions): Promise<void>;
|
|
36
36
|
|
|
37
37
|
declare function renderMarkdownToHast(md: string): Promise<Nodes>;
|
|
38
38
|
|
|
@@ -47,15 +47,20 @@ interface RemarkAutoTypeTableOptions {
|
|
|
47
47
|
outputName?: string;
|
|
48
48
|
renderMarkdown?: typeof renderMarkdownToHast;
|
|
49
49
|
/**
|
|
50
|
-
*
|
|
50
|
+
* Customise type table generation
|
|
51
51
|
*/
|
|
52
|
-
options?:
|
|
52
|
+
options?: GenerateTypeTableOptions;
|
|
53
|
+
/**
|
|
54
|
+
* generate required `value` property for `remark-stringify`
|
|
55
|
+
*/
|
|
56
|
+
remarkStringify?: boolean;
|
|
57
|
+
generator?: Generator;
|
|
53
58
|
}
|
|
54
59
|
/**
|
|
55
60
|
* Compile `auto-type-table` into Fumadocs UI compatible TypeTable
|
|
56
61
|
*
|
|
57
62
|
* MDX is required to use this plugin.
|
|
58
63
|
*/
|
|
59
|
-
declare function remarkAutoTypeTable({ name, outputName, renderMarkdown, options, }?: RemarkAutoTypeTableOptions): Transformer<Root, Root>;
|
|
64
|
+
declare function remarkAutoTypeTable({ name, outputName, renderMarkdown, options, remarkStringify, generator, }?: RemarkAutoTypeTableOptions): Transformer<Root, Root>;
|
|
60
65
|
|
|
61
|
-
export { DocEntry,
|
|
66
|
+
export { DocEntry, type GenerateFilesOptions, type GenerateMDXOptions, GenerateOptions, GeneratedDoc, Generator, type RemarkAutoTypeTableOptions, generateFiles, generateMDX, remarkAutoTypeTable, renderMarkdownToHast };
|
package/dist/index.js
CHANGED
|
@@ -3,16 +3,111 @@ import {
|
|
|
3
3
|
__objRest,
|
|
4
4
|
__spreadProps,
|
|
5
5
|
__spreadValues,
|
|
6
|
-
generate,
|
|
7
|
-
generateDocumentation,
|
|
8
|
-
getProject,
|
|
9
6
|
getTypeTableOutput,
|
|
10
7
|
renderMarkdownToHast
|
|
11
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-2WGVCLFC.js";
|
|
9
|
+
|
|
10
|
+
// src/lib/base.ts
|
|
11
|
+
import {
|
|
12
|
+
Project as Project2,
|
|
13
|
+
ts
|
|
14
|
+
} from "ts-morph";
|
|
15
|
+
|
|
16
|
+
// src/get-project.ts
|
|
17
|
+
import { Project } from "ts-morph";
|
|
18
|
+
function getProject(options = {}) {
|
|
19
|
+
var _a;
|
|
20
|
+
return new Project({
|
|
21
|
+
tsConfigFilePath: (_a = options.tsconfigPath) != null ? _a : "./tsconfig.json",
|
|
22
|
+
skipAddingFilesFromTsConfig: true
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// src/lib/base.ts
|
|
27
|
+
import fs from "node:fs";
|
|
28
|
+
function createGenerator(config) {
|
|
29
|
+
const project = config instanceof Project2 ? config : getProject(config);
|
|
30
|
+
return {
|
|
31
|
+
generateDocumentation(file, name, options = {}) {
|
|
32
|
+
var _a;
|
|
33
|
+
const sourceFile = project.createSourceFile(
|
|
34
|
+
file.path,
|
|
35
|
+
(_a = file.content) != null ? _a : fs.readFileSync(file.path).toString(),
|
|
36
|
+
{
|
|
37
|
+
overwrite: true
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
const out = [];
|
|
41
|
+
for (const [k, d] of sourceFile.getExportedDeclarations()) {
|
|
42
|
+
if (name && name !== k) continue;
|
|
43
|
+
if (d.length > 1)
|
|
44
|
+
console.warn(
|
|
45
|
+
`export ${k} should not have more than one type declaration.`
|
|
46
|
+
);
|
|
47
|
+
out.push(generate(project, k, d[0], options));
|
|
48
|
+
}
|
|
49
|
+
return out;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function generateDocumentation(file, name, content, options = {}) {
|
|
54
|
+
var _a;
|
|
55
|
+
const gen = createGenerator((_a = options.project) != null ? _a : options.config);
|
|
56
|
+
return gen.generateDocumentation({ path: file, content }, name, options);
|
|
57
|
+
}
|
|
58
|
+
function generate(program, name, declaration, { allowInternal = false, transform }) {
|
|
59
|
+
var _a;
|
|
60
|
+
const entryContext = {
|
|
61
|
+
transform,
|
|
62
|
+
program,
|
|
63
|
+
type: declaration.getType(),
|
|
64
|
+
declaration
|
|
65
|
+
};
|
|
66
|
+
const comment = (_a = declaration.getSymbol()) == null ? void 0 : _a.compilerSymbol.getDocumentationComment(
|
|
67
|
+
program.getTypeChecker().compilerObject
|
|
68
|
+
);
|
|
69
|
+
return {
|
|
70
|
+
name,
|
|
71
|
+
description: comment ? ts.displayPartsToString(comment) : "",
|
|
72
|
+
entries: declaration.getType().getProperties().map((prop) => getDocEntry(prop, entryContext)).filter(
|
|
73
|
+
(entry) => entry && (allowInternal || !("internal" in entry.tags))
|
|
74
|
+
)
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function getDocEntry(prop, context) {
|
|
78
|
+
var _a, _b, _c, _d;
|
|
79
|
+
const { transform, program } = context;
|
|
80
|
+
if (context.type.isClass() && prop.getName().startsWith("#")) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const subType = program.getTypeChecker().getTypeOfSymbolAtLocation(prop, context.declaration);
|
|
84
|
+
const tags = Object.fromEntries(
|
|
85
|
+
prop.getJsDocTags().map((tag) => [tag.getName(), ts.displayPartsToString(tag.getText())])
|
|
86
|
+
);
|
|
87
|
+
let typeName = subType.getNonNullableType().getText(void 0, ts.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope);
|
|
88
|
+
if (subType.getAliasSymbol() && subType.getAliasTypeArguments().length === 0) {
|
|
89
|
+
typeName = (_b = (_a = subType.getAliasSymbol()) == null ? void 0 : _a.getEscapedName()) != null ? _b : typeName;
|
|
90
|
+
}
|
|
91
|
+
if ("remarks" in tags) {
|
|
92
|
+
typeName = (_d = (_c = new RegExp("^`(?<name>.+)`").exec(tags.remarks)) == null ? void 0 : _c[1]) != null ? _d : typeName;
|
|
93
|
+
}
|
|
94
|
+
const entry = {
|
|
95
|
+
name: prop.getName(),
|
|
96
|
+
description: ts.displayPartsToString(
|
|
97
|
+
prop.compilerSymbol.getDocumentationComment(
|
|
98
|
+
program.getTypeChecker().compilerObject
|
|
99
|
+
)
|
|
100
|
+
),
|
|
101
|
+
tags,
|
|
102
|
+
type: typeName,
|
|
103
|
+
required: !prop.isOptional()
|
|
104
|
+
};
|
|
105
|
+
transform == null ? void 0 : transform.call(context, entry, subType, prop);
|
|
106
|
+
return entry;
|
|
107
|
+
}
|
|
12
108
|
|
|
13
109
|
// src/lib/mdx.ts
|
|
14
110
|
import * as path from "node:path";
|
|
15
|
-
import fs from "node:fs";
|
|
16
111
|
var regex = new RegExp("^---type-table---\\r?\\n(?<file>.+?)(?:#(?<name>.+))?\\r?\\n---end---$", "gm");
|
|
17
112
|
var defaultTemplates = {
|
|
18
113
|
block: (doc, c) => `### ${doc.name}
|
|
@@ -34,18 +129,17 @@ ${replaceJsDocLinks(value)}`).join("\n")}
|
|
|
34
129
|
|
|
35
130
|
</div>`
|
|
36
131
|
};
|
|
37
|
-
function generateMDX(source, _a = {}) {
|
|
132
|
+
function generateMDX(generator, source, _a = {}) {
|
|
38
133
|
var _b = _a, { basePath = "./", templates: overrides } = _b, rest = __objRest(_b, ["basePath", "templates"]);
|
|
39
|
-
var _a2;
|
|
40
134
|
const templates = __spreadValues(__spreadValues({}, defaultTemplates), overrides);
|
|
41
|
-
const project = (_a2 = rest.project) != null ? _a2 : getProject(rest.config);
|
|
42
135
|
return source.replace(regex, (...args) => {
|
|
43
136
|
const groups = args[args.length - 1];
|
|
44
137
|
const file = path.resolve(basePath, groups.file);
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
138
|
+
const docs = generator.generateDocumentation(
|
|
139
|
+
{ path: file },
|
|
140
|
+
groups.name,
|
|
141
|
+
rest
|
|
142
|
+
);
|
|
49
143
|
return docs.map(
|
|
50
144
|
(doc) => templates.block(doc, doc.entries.map(templates.property).join("\n"))
|
|
51
145
|
).join("\n\n");
|
|
@@ -59,11 +153,9 @@ function replaceJsDocLinks(md) {
|
|
|
59
153
|
import * as path2 from "node:path";
|
|
60
154
|
import { mkdir, writeFile, readFile } from "node:fs/promises";
|
|
61
155
|
import fg from "fast-glob";
|
|
62
|
-
function generateFiles(options) {
|
|
156
|
+
function generateFiles(generator, options) {
|
|
63
157
|
return __async(this, null, function* () {
|
|
64
|
-
var _a, _b, _c;
|
|
65
158
|
const files = yield fg(options.input, options.globOptions);
|
|
66
|
-
const project = (_c = (_a = options.options) == null ? void 0 : _a.project) != null ? _c : getProject((_b = options.options) == null ? void 0 : _b.config);
|
|
67
159
|
const produce = files.map((file) => __async(this, null, function* () {
|
|
68
160
|
const absolutePath = path2.resolve(file);
|
|
69
161
|
const outputPath = typeof options.output === "function" ? options.output(file) : path2.resolve(
|
|
@@ -71,11 +163,9 @@ function generateFiles(options) {
|
|
|
71
163
|
`${path2.basename(file, path2.extname(file))}.mdx`
|
|
72
164
|
);
|
|
73
165
|
const content = (yield readFile(absolutePath)).toString();
|
|
74
|
-
let result = generateMDX(content,
|
|
166
|
+
let result = generateMDX(generator, content, __spreadValues({
|
|
75
167
|
basePath: path2.dirname(absolutePath)
|
|
76
|
-
}, options.options)
|
|
77
|
-
project
|
|
78
|
-
}));
|
|
168
|
+
}, options.options));
|
|
79
169
|
if (options.transformOutput) {
|
|
80
170
|
result = options.transformOutput(outputPath, result);
|
|
81
171
|
}
|
|
@@ -97,31 +187,12 @@ import { valueToEstree } from "estree-util-value-to-estree";
|
|
|
97
187
|
import { visit } from "unist-util-visit";
|
|
98
188
|
import { toEstree } from "hast-util-to-estree";
|
|
99
189
|
import { dirname as dirname2 } from "node:path";
|
|
100
|
-
function expressionToAttribute(key, value) {
|
|
101
|
-
return {
|
|
102
|
-
type: "mdxJsxAttribute",
|
|
103
|
-
name: key,
|
|
104
|
-
value: {
|
|
105
|
-
type: "mdxJsxAttributeValueExpression",
|
|
106
|
-
data: {
|
|
107
|
-
estree: {
|
|
108
|
-
type: "Program",
|
|
109
|
-
body: [
|
|
110
|
-
{
|
|
111
|
-
type: "ExpressionStatement",
|
|
112
|
-
expression: value
|
|
113
|
-
}
|
|
114
|
-
]
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
190
|
function mapProperty(entry, renderMarkdown) {
|
|
121
191
|
return __async(this, null, function* () {
|
|
122
192
|
const value = valueToEstree({
|
|
123
193
|
type: entry.type,
|
|
124
|
-
default: entry.tags.default || entry.tags.defaultValue
|
|
194
|
+
default: entry.tags.default || entry.tags.defaultValue,
|
|
195
|
+
required: entry.required
|
|
125
196
|
});
|
|
126
197
|
if (entry.description) {
|
|
127
198
|
const hast = toEstree(yield renderMarkdown(entry.description), {
|
|
@@ -158,10 +229,10 @@ function remarkAutoTypeTable({
|
|
|
158
229
|
name = "auto-type-table",
|
|
159
230
|
outputName = "TypeTable",
|
|
160
231
|
renderMarkdown = renderMarkdownToHast,
|
|
161
|
-
options = {}
|
|
232
|
+
options = {},
|
|
233
|
+
remarkStringify = true,
|
|
234
|
+
generator = createGenerator()
|
|
162
235
|
} = {}) {
|
|
163
|
-
var _a;
|
|
164
|
-
const project = (_a = options.project) != null ? _a : getProject(options.config);
|
|
165
236
|
return (tree, file) => __async(this, null, function* () {
|
|
166
237
|
const queue = [];
|
|
167
238
|
let basePath = options == null ? void 0 : options.basePath;
|
|
@@ -178,12 +249,13 @@ function remarkAutoTypeTable({
|
|
|
178
249
|
}
|
|
179
250
|
function run() {
|
|
180
251
|
return __async(this, null, function* () {
|
|
181
|
-
const output = yield getTypeTableOutput(
|
|
182
|
-
|
|
183
|
-
|
|
252
|
+
const output = yield getTypeTableOutput(
|
|
253
|
+
generator,
|
|
254
|
+
props,
|
|
255
|
+
__spreadProps(__spreadValues({}, options), {
|
|
184
256
|
basePath
|
|
185
257
|
})
|
|
186
|
-
|
|
258
|
+
);
|
|
187
259
|
const rendered = output.map((doc) => __async(this, null, function* () {
|
|
188
260
|
const properties = yield Promise.all(
|
|
189
261
|
doc.entries.map((entry) => mapProperty(entry, renderMarkdown))
|
|
@@ -192,22 +264,30 @@ function remarkAutoTypeTable({
|
|
|
192
264
|
type: "mdxJsxFlowElement",
|
|
193
265
|
name: outputName,
|
|
194
266
|
attributes: [
|
|
195
|
-
|
|
196
|
-
type: "
|
|
197
|
-
|
|
198
|
-
|
|
267
|
+
{
|
|
268
|
+
type: "mdxJsxAttribute",
|
|
269
|
+
name: "type",
|
|
270
|
+
value: {
|
|
271
|
+
type: "mdxJsxAttributeValueExpression",
|
|
272
|
+
value: remarkStringify ? JSON.stringify(doc, null, 2) : "",
|
|
273
|
+
data: {
|
|
274
|
+
estree: {
|
|
275
|
+
type: "Program",
|
|
276
|
+
sourceType: "module",
|
|
277
|
+
body: [
|
|
278
|
+
{
|
|
279
|
+
type: "ExpressionStatement",
|
|
280
|
+
expression: {
|
|
281
|
+
type: "ObjectExpression",
|
|
282
|
+
properties
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
]
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
199
290
|
],
|
|
200
|
-
data: {
|
|
201
|
-
// for Fumadocs `remarkStructure`
|
|
202
|
-
_string: [
|
|
203
|
-
doc.name,
|
|
204
|
-
doc.description,
|
|
205
|
-
...doc.entries.flatMap((entry) => [
|
|
206
|
-
`${entry.name}: ${entry.type}`,
|
|
207
|
-
entry.description
|
|
208
|
-
])
|
|
209
|
-
]
|
|
210
|
-
},
|
|
211
291
|
children: []
|
|
212
292
|
};
|
|
213
293
|
}));
|
|
@@ -225,7 +305,7 @@ function remarkAutoTypeTable({
|
|
|
225
305
|
});
|
|
226
306
|
}
|
|
227
307
|
export {
|
|
228
|
-
|
|
308
|
+
createGenerator,
|
|
229
309
|
generateDocumentation,
|
|
230
310
|
generateFiles,
|
|
231
311
|
generateMDX,
|
|
@@ -39,18 +39,25 @@ interface GenerateOptions {
|
|
|
39
39
|
*/
|
|
40
40
|
transform?: Transformer;
|
|
41
41
|
}
|
|
42
|
-
|
|
42
|
+
type Generator = ReturnType<typeof createGenerator>;
|
|
43
|
+
declare function createGenerator(config?: TypescriptConfig | Project): {
|
|
44
|
+
generateDocumentation(file: {
|
|
45
|
+
path: string;
|
|
46
|
+
content?: string;
|
|
47
|
+
}, name: string | undefined, options?: GenerateOptions): GeneratedDoc[];
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Generate documentation for properties in an exported type/interface
|
|
51
|
+
*
|
|
52
|
+
* @deprecated use `createGenerator` instead
|
|
53
|
+
*/
|
|
54
|
+
declare function generateDocumentation(file: string, name: string | undefined, content: string, options?: GenerateOptions & {
|
|
43
55
|
/**
|
|
44
56
|
* Typescript configurations
|
|
45
57
|
*/
|
|
46
58
|
config?: TypescriptConfig;
|
|
47
59
|
project?: Project;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Generate documentation for properties in an exported type/interface
|
|
51
|
-
*/
|
|
52
|
-
declare function generateDocumentation(file: string, name: string | undefined, content: string, options?: GenerateDocumentationOptions): GeneratedDoc[];
|
|
53
|
-
declare function generate(program: Project, name: string, declaration: ExportedDeclarations, { allowInternal, transform }: GenerateOptions): GeneratedDoc;
|
|
60
|
+
}): GeneratedDoc[];
|
|
54
61
|
|
|
55
62
|
interface BaseTypeTableProps {
|
|
56
63
|
/**
|
|
@@ -83,12 +90,12 @@ interface BaseTypeTableProps {
|
|
|
83
90
|
* ```
|
|
84
91
|
*/
|
|
85
92
|
type?: string;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
93
|
+
}
|
|
94
|
+
interface GenerateTypeTableOptions extends GenerateOptions {
|
|
95
|
+
/**
|
|
96
|
+
* base path to resolve `path` prop
|
|
97
|
+
*/
|
|
98
|
+
basePath?: string;
|
|
92
99
|
}
|
|
93
100
|
|
|
94
|
-
export { type BaseTypeTableProps as B, type DocEntry as D, type
|
|
101
|
+
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, createGenerator as d, generateDocumentation as e, getProject as g };
|
package/dist/ui/index.d.ts
CHANGED
|
@@ -1,22 +1,14 @@
|
|
|
1
|
-
import
|
|
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 '../type-table-Duzly_SK.js';
|
|
3
4
|
import 'ts-morph';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*/
|
|
6
|
+
type AutoTypeTableProps = BaseTypeTableProps;
|
|
7
|
+
declare function AutoTypeTable({ generator, options, renderMarkdown, ...props }: AutoTypeTableProps & {
|
|
8
|
+
generator: Generator;
|
|
9
9
|
renderMarkdown?: typeof renderMarkdownDefault;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
AutoTypeTable: (props: Omit<AutoTypeTableProps, 'options'>) => ReactNode;
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* **Server Component Only**
|
|
16
|
-
*
|
|
17
|
-
* Display properties in an exported interface via Type Table
|
|
18
|
-
*/
|
|
19
|
-
declare function AutoTypeTable({ renderMarkdown, ...props }: AutoTypeTableProps): Promise<ReactNode>;
|
|
10
|
+
options?: GenerateTypeTableOptions;
|
|
11
|
+
}): Promise<Promise<runtime.JSX.Element>[]>;
|
|
20
12
|
declare function renderMarkdownDefault(md: string): Promise<ReactNode>;
|
|
21
13
|
|
|
22
|
-
export { AutoTypeTable, type AutoTypeTableProps
|
|
14
|
+
export { AutoTypeTable, type AutoTypeTableProps };
|
package/dist/ui/index.js
CHANGED
|
@@ -3,10 +3,9 @@ import {
|
|
|
3
3
|
__objRest,
|
|
4
4
|
__spreadProps,
|
|
5
5
|
__spreadValues,
|
|
6
|
-
getProject,
|
|
7
6
|
getTypeTableOutput,
|
|
8
7
|
renderMarkdownToHast
|
|
9
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-2WGVCLFC.js";
|
|
10
9
|
|
|
11
10
|
// src/ui/auto-type-table.tsx
|
|
12
11
|
import { TypeTable } from "fumadocs-ui/components/type-table";
|
|
@@ -15,25 +14,18 @@ import * as runtime from "react/jsx-runtime";
|
|
|
15
14
|
import defaultMdxComponents from "fumadocs-ui/mdx";
|
|
16
15
|
import "server-only";
|
|
17
16
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
18
|
-
function createTypeTable(options = {}) {
|
|
19
|
-
var _a;
|
|
20
|
-
const overrideOptions = __spreadProps(__spreadValues({}, options), {
|
|
21
|
-
project: (_a = options.project) != null ? _a : getProject(options.config)
|
|
22
|
-
});
|
|
23
|
-
return {
|
|
24
|
-
AutoTypeTable(props) {
|
|
25
|
-
return /* @__PURE__ */ jsx2(AutoTypeTable, __spreadProps(__spreadValues({}, props), { options: overrideOptions }));
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
17
|
function AutoTypeTable(_a) {
|
|
30
18
|
return __async(this, null, function* () {
|
|
31
19
|
var _b = _a, {
|
|
20
|
+
generator,
|
|
21
|
+
options = {},
|
|
32
22
|
renderMarkdown = renderMarkdownDefault
|
|
33
23
|
} = _b, props = __objRest(_b, [
|
|
24
|
+
"generator",
|
|
25
|
+
"options",
|
|
34
26
|
"renderMarkdown"
|
|
35
27
|
]);
|
|
36
|
-
const output = yield getTypeTableOutput(props);
|
|
28
|
+
const output = yield getTypeTableOutput(generator, props, options);
|
|
37
29
|
return output.map((item) => __async(this, null, function* () {
|
|
38
30
|
const entries = item.entries.map(
|
|
39
31
|
(entry) => __async(this, null, function* () {
|
|
@@ -69,6 +61,5 @@ function renderMarkdownDefault(md) {
|
|
|
69
61
|
});
|
|
70
62
|
}
|
|
71
63
|
export {
|
|
72
|
-
AutoTypeTable
|
|
73
|
-
createTypeTable
|
|
64
|
+
AutoTypeTable
|
|
74
65
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-typescript",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "Typescript Integration for Fumadocs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -30,28 +30,28 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"estree-util-value-to-estree": "^3.3.2",
|
|
32
32
|
"fast-glob": "^3.3.3",
|
|
33
|
-
"hast-util-to-estree": "^3.1.
|
|
34
|
-
"hast-util-to-jsx-runtime": "^2.3.
|
|
33
|
+
"hast-util-to-estree": "^3.1.3",
|
|
34
|
+
"hast-util-to-jsx-runtime": "^2.3.6",
|
|
35
35
|
"remark": "^15.0.1",
|
|
36
36
|
"remark-rehype": "^11.1.1",
|
|
37
|
-
"shiki": "^3.1
|
|
37
|
+
"shiki": "^3.2.1",
|
|
38
38
|
"ts-morph": "^25.0.1",
|
|
39
39
|
"unist-util-visit": "^5.0.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@mdx-js/mdx": "^3.1.0",
|
|
43
|
-
"@types/estree": "^1.0.
|
|
43
|
+
"@types/estree": "^1.0.7",
|
|
44
44
|
"@types/hast": "^3.0.4",
|
|
45
45
|
"@types/mdast": "^4.0.3",
|
|
46
|
-
"@types/node": "22.13.
|
|
47
|
-
"@types/react": "19.0.
|
|
46
|
+
"@types/node": "22.13.14",
|
|
47
|
+
"@types/react": "19.0.12",
|
|
48
48
|
"@types/react-dom": "19.0.4",
|
|
49
49
|
"typescript": "^5.8.2",
|
|
50
50
|
"unified": "^11.0.5",
|
|
51
51
|
"eslint-config-custom": "0.0.0",
|
|
52
|
-
"fumadocs-
|
|
53
|
-
"
|
|
54
|
-
"
|
|
52
|
+
"fumadocs-ui": "15.2.1",
|
|
53
|
+
"tsconfig": "0.0.0",
|
|
54
|
+
"fumadocs-core": "15.2.1"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"typescript": "*"
|