rspress-plugin-api-extractor 0.13.3 → 0.15.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/BuildEnv.js +0 -1
- package/build-program.js +5 -5
- package/build-stages.js +98 -282
- package/config-helpers.js +1 -1
- package/emit/mdx.js +311 -0
- package/emit/meta.js +62 -0
- package/index.d.ts +6 -70
- package/layers/build-metrics.js +1 -2
- package/layers/config-resolution.js +5 -8
- package/layers/type-environment.js +5 -4
- package/llms-program.js +3 -3
- package/markdown/helpers.js +10 -177
- package/observability/sinks/console-sink.js +1 -3
- package/observability/sinks/metrics-sink.js +0 -2
- package/package.json +9 -7
- package/path-derivation.js +1 -29
- package/plugin.js +3 -10
- package/prettier-formatter.js +27 -59
- package/remark-with-api.js +3 -2
- package/schemas/config.js +3 -29
- package/schemas/observability.js +8 -23
- package/schemas/performance.js +1 -7
- package/services/TwoslashCacheService.js +18 -14
- package/services/TypeRegistryService.js +4 -4
- package/shiki-transformer.js +12 -51
- package/twoslash-transformer.js +16 -49
- package/api-extracted-package.js +0 -471
- package/code-post-processor.js +0 -38
- package/frontmatter.js +0 -176
- package/llms-processing.js +0 -270
- package/markdown/page-generators/class-page.js +0 -364
- package/markdown/page-generators/enum-page.js +0 -152
- package/markdown/page-generators/function-page.js +0 -128
- package/markdown/page-generators/index-pages.js +0 -25
- package/markdown/page-generators/interface-page.js +0 -311
- package/markdown/page-generators/namespace-page.js +0 -278
- package/markdown/page-generators/type-alias-page.js +0 -111
- package/markdown/page-generators/variable-page.js +0 -111
- package/markdown/prose-linker.js +0 -22
- package/tsconfig-parser.js +0 -115
- package/twoslash-cache.js +0 -174
- package/twoslash-patterns.js +0 -87
- package/type-reference-extractor.js +0 -199
- package/typescript-config.js +0 -170
package/emit/mdx.js
ADDED
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import { Result } from "effect";
|
|
2
|
+
import { Blockquote, Code, Heading, InlineCode, Link, List, ListItem, Markdown, MdxJsxAttribute, MdxJsxAttributeValueExpression, MdxJsxFlowElement, MdxjsEsm, Paragraph, Root, Strong, Text } from "@effected/markdown";
|
|
3
|
+
|
|
4
|
+
//#region src/emit/mdx.ts
|
|
5
|
+
/** Serialize one flow node as its own document, without the trailing newline. */
|
|
6
|
+
function serialize(node) {
|
|
7
|
+
return Result.map(Markdown.stringifyResult(Root.make({ children: [node] })), (text) => text.replace(/\n$/, ""));
|
|
8
|
+
}
|
|
9
|
+
/** Serialize phrasing content to the one-line string a JSX prop or a table cell carries. */
|
|
10
|
+
function inlineText(children) {
|
|
11
|
+
if (children.length === 0) return Result.succeed("");
|
|
12
|
+
return serialize(Paragraph.make({ children: [...children] }));
|
|
13
|
+
}
|
|
14
|
+
const GENERICS = /<([A-Z][A-Za-z0-9_]*(?:\s+extends\s+[^,>\s][^,>]*)?(?:,\s*[A-Z][A-Za-z0-9_]*(?:\s+extends\s+[^,>\s][^,>]*)?)*)>/g;
|
|
15
|
+
/**
|
|
16
|
+
* {@link escapeMdxGenerics} as an mdast transform: a generic parameter list
|
|
17
|
+
* in a text run becomes an inline code node, and a raw-HTML node that IS a
|
|
18
|
+
* generic (`<T>` parses as an HTML tag) becomes one too. Code spans are
|
|
19
|
+
* already inline code and are left alone; container nodes are walked.
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* Done on the tree rather than on the serialized string because the kit
|
|
23
|
+
* escapes a bare `<` in text (`Map\<K, V\>`) as it serializes, and the
|
|
24
|
+
* string-level regex would no longer see the generic. The two spellings are
|
|
25
|
+
* the same MDX; the tree form is what lets the kit own every byte.
|
|
26
|
+
*/
|
|
27
|
+
function escapeGenericsInPhrasing(children) {
|
|
28
|
+
const out = [];
|
|
29
|
+
for (const node of children) if (node.type === "text") {
|
|
30
|
+
let last = 0;
|
|
31
|
+
for (const match of node.value.matchAll(GENERICS)) {
|
|
32
|
+
const index = match.index ?? 0;
|
|
33
|
+
if (index > last) out.push(Text.make({ value: node.value.slice(last, index) }));
|
|
34
|
+
out.push(InlineCode.make({ value: match[0] }));
|
|
35
|
+
last = index + match[0].length;
|
|
36
|
+
}
|
|
37
|
+
if (last === 0) out.push(node);
|
|
38
|
+
else if (last < node.value.length) out.push(Text.make({ value: node.value.slice(last) }));
|
|
39
|
+
} else if (node.type === "html" && new RegExp(`^${GENERICS.source}$`).test(node.value)) out.push(InlineCode.make({ value: node.value }));
|
|
40
|
+
else if (node.type === "link" || node.type === "strong" || node.type === "emphasis" || node.type === "delete") out.push({
|
|
41
|
+
...node,
|
|
42
|
+
children: [...escapeGenericsInPhrasing(node.children)]
|
|
43
|
+
});
|
|
44
|
+
else out.push(node);
|
|
45
|
+
return out;
|
|
46
|
+
}
|
|
47
|
+
/** Phrasing content with generics escaped — the tree form of {@link escapeMdxGenerics}. */
|
|
48
|
+
function escapedPhrasing(children) {
|
|
49
|
+
return Result.succeed(escapeGenericsInPhrasing(children));
|
|
50
|
+
}
|
|
51
|
+
const text = (value) => Text.make({ value });
|
|
52
|
+
const paragraph = (children) => Paragraph.make({ children: [...children] });
|
|
53
|
+
const heading = (depth, value) => Heading.make({
|
|
54
|
+
depth,
|
|
55
|
+
children: [text(value)]
|
|
56
|
+
});
|
|
57
|
+
const code = (value) => InlineCode.make({ value });
|
|
58
|
+
const expression = (name, value) => MdxJsxAttribute.make({
|
|
59
|
+
name,
|
|
60
|
+
value: MdxJsxAttributeValueExpression.make({ value: JSON.stringify(value) })
|
|
61
|
+
});
|
|
62
|
+
const literal = (name, value) => MdxJsxAttribute.make({
|
|
63
|
+
name,
|
|
64
|
+
value
|
|
65
|
+
});
|
|
66
|
+
const element = (name, attributes, children = []) => MdxJsxFlowElement.make({
|
|
67
|
+
name,
|
|
68
|
+
attributes: [...attributes],
|
|
69
|
+
children: [...children]
|
|
70
|
+
});
|
|
71
|
+
var Body = class {
|
|
72
|
+
chunks = [];
|
|
73
|
+
failure;
|
|
74
|
+
push(node, trailing = "\n\n") {
|
|
75
|
+
if (this.failure) return;
|
|
76
|
+
const result = serialize(node);
|
|
77
|
+
if (Result.isFailure(result)) {
|
|
78
|
+
this.failure = result.failure;
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
this.chunks.push({
|
|
82
|
+
text: result.success,
|
|
83
|
+
trailing
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
/** Push a heading. */
|
|
87
|
+
heading(depth, value) {
|
|
88
|
+
this.push(heading(depth, value));
|
|
89
|
+
}
|
|
90
|
+
pushResult(result, use) {
|
|
91
|
+
if (this.failure) return;
|
|
92
|
+
if (Result.isFailure(result)) {
|
|
93
|
+
this.failure = result.failure;
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
use(result.success);
|
|
97
|
+
}
|
|
98
|
+
render() {
|
|
99
|
+
if (this.failure) return Result.fail(this.failure);
|
|
100
|
+
return Result.succeed(this.chunks.map((chunk) => chunk.text + chunk.trailing).join(""));
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
const RUNTIME = "rspress-plugin-api-extractor/runtime";
|
|
104
|
+
/** The component import lines each page kind carried. */
|
|
105
|
+
function importLines(kind) {
|
|
106
|
+
const lines = [`import { SourceCode } from "@rspress/core/theme";`];
|
|
107
|
+
if (kind === "enum") lines.push(`import { EnumMembersTable } from "${RUNTIME}";`);
|
|
108
|
+
else if (kind !== "namespace") lines.push(`import { ParametersTable } from "${RUNTIME}";`);
|
|
109
|
+
const components = kind === "class" || kind === "interface" ? "ApiSignature, ApiMember, ApiExample" : "ApiSignature, ApiExample";
|
|
110
|
+
lines.push(`import { ${components} } from "${RUNTIME}";`);
|
|
111
|
+
return lines.join("\n");
|
|
112
|
+
}
|
|
113
|
+
function parameterRows(rows, escapeGenerics) {
|
|
114
|
+
return Result.all(rows.map((row) => Result.map(inlineText(escapeGenerics ? escapeGenericsInPhrasing(row.description) : row.description), (description) => ({
|
|
115
|
+
name: row.name,
|
|
116
|
+
...row.type !== void 0 ? { type: row.type } : {},
|
|
117
|
+
description
|
|
118
|
+
}))));
|
|
119
|
+
}
|
|
120
|
+
function enumRows(rows) {
|
|
121
|
+
return Result.all(rows.map((row) => Result.map(inlineText(row.description), (description) => ({
|
|
122
|
+
name: row.name,
|
|
123
|
+
...row.value !== void 0 ? { value: row.value } : {},
|
|
124
|
+
description
|
|
125
|
+
}))));
|
|
126
|
+
}
|
|
127
|
+
/** The literal `memberName` a role fixes, or none when the member's own name is spent as an expression. */
|
|
128
|
+
function fixedMemberName(member) {
|
|
129
|
+
switch (member.role) {
|
|
130
|
+
case "constructor": return "constructor";
|
|
131
|
+
case "call-signature": return "Call Signature";
|
|
132
|
+
case "construct-signature": return "Construct Signature";
|
|
133
|
+
case "index-signature": return "Index Signature";
|
|
134
|
+
default: return;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/** Whether the role carried a `hasParameters` prop — constructors and methods, never properties or signatures. */
|
|
138
|
+
function carriesHasParameters(member) {
|
|
139
|
+
return member.role === "constructor" || member.role === "method" || member.role === "getter";
|
|
140
|
+
}
|
|
141
|
+
function emitMember(body, member, apiScope) {
|
|
142
|
+
body.pushResult(member.summary ? escapedPhrasing(member.summary) : Result.succeed(void 0), (summaryNodes) => {
|
|
143
|
+
body.pushResult(summaryNodes ? inlineText(summaryNodes) : Result.succeed(""), (summary) => {
|
|
144
|
+
const fixedName = fixedMemberName(member);
|
|
145
|
+
const attributes = [
|
|
146
|
+
expression("code", member.code.display),
|
|
147
|
+
expression("source", member.code.source),
|
|
148
|
+
expression("apiScope", apiScope),
|
|
149
|
+
fixedName !== void 0 ? literal("memberName", fixedName) : expression("memberName", member.name)
|
|
150
|
+
];
|
|
151
|
+
if (summary) attributes.push(expression("summary", summary));
|
|
152
|
+
attributes.push(expression("id", member.anchor));
|
|
153
|
+
if (carriesHasParameters(member)) attributes.push(expression("hasParameters", member.parameters !== void 0));
|
|
154
|
+
body.push(element("ApiMember", attributes));
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
if (member.parameters !== void 0) body.pushResult(parameterRows(member.parameters, false), (rows) => {
|
|
158
|
+
body.push(element("ParametersTable", [expression("parameters", rows)]));
|
|
159
|
+
});
|
|
160
|
+
if (member.returns !== void 0) body.pushResult(escapedPhrasing(member.returns), (returns) => {
|
|
161
|
+
body.push(paragraph([
|
|
162
|
+
Strong.make({ children: [text("Returns:")] }),
|
|
163
|
+
text(" "),
|
|
164
|
+
...returns
|
|
165
|
+
]));
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
function emitBlock(body, block, page, options) {
|
|
169
|
+
const { apiScope } = options;
|
|
170
|
+
switch (block.kind) {
|
|
171
|
+
case "title":
|
|
172
|
+
body.heading(1, block.name);
|
|
173
|
+
if (block.deprecation !== void 0) body.pushResult(escapedPhrasing(block.deprecation), (message) => {
|
|
174
|
+
body.push(Blockquote.make({ children: [paragraph([
|
|
175
|
+
text("⚠️ "),
|
|
176
|
+
Strong.make({ children: [text("Deprecated:")] }),
|
|
177
|
+
text(" "),
|
|
178
|
+
...message
|
|
179
|
+
])] }));
|
|
180
|
+
});
|
|
181
|
+
if (block.releaseTag !== "Public") body.push(paragraph([code(block.releaseTag)]));
|
|
182
|
+
return;
|
|
183
|
+
case "prose":
|
|
184
|
+
if (block.role === "summary") {
|
|
185
|
+
for (const node of block.content) body.push(node);
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
body.heading(2, block.role === "remarks" ? "Remarks" : "Returns");
|
|
189
|
+
for (const node of block.content) if (block.role === "returns" && node.type === "paragraph") body.pushResult(escapedPhrasing(node.children), (children) => body.push(paragraph(children)));
|
|
190
|
+
else body.push(node);
|
|
191
|
+
return;
|
|
192
|
+
case "available-from": {
|
|
193
|
+
const children = [text("Available from: ")];
|
|
194
|
+
block.entryPoints.forEach((entryPoint, index) => {
|
|
195
|
+
if (index > 0) children.push(text(", "));
|
|
196
|
+
children.push(code(entryPoint === "default" ? block.packageName : `${block.packageName}/${entryPoint}`));
|
|
197
|
+
});
|
|
198
|
+
body.push(paragraph(children));
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
case "source-link": {
|
|
202
|
+
const children = [element("div", [literal("className", "api-docs-toolbar-left")], [element("SourceCode", [literal("href", block.href)])])];
|
|
203
|
+
if (options.llmsEnabled) children.push(element("div", [literal("className", "api-docs-toolbar-right")]));
|
|
204
|
+
body.push(element("div", [literal("className", "api-docs-toolbar")], children));
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
case "signature": {
|
|
208
|
+
const attributes = [
|
|
209
|
+
expression("code", block.code.display),
|
|
210
|
+
expression("source", block.code.source),
|
|
211
|
+
expression("apiScope", apiScope)
|
|
212
|
+
];
|
|
213
|
+
if (block.hasParameters !== void 0) attributes.push(expression("hasParameters", block.hasParameters));
|
|
214
|
+
if (block.hasMembers !== void 0) attributes.push(expression("hasMembers", block.hasMembers));
|
|
215
|
+
body.push(element("ApiSignature", attributes), block.hasMembers === true ? "\n" : "\n\n");
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
case "base-class":
|
|
219
|
+
body.heading(2, "Base Class");
|
|
220
|
+
body.push(paragraph([
|
|
221
|
+
code(block.className),
|
|
222
|
+
text(" extends "),
|
|
223
|
+
code(block.baseName),
|
|
224
|
+
text(", a compiler-generated declaration that is not exported from "),
|
|
225
|
+
code(block.packageName),
|
|
226
|
+
text(".")
|
|
227
|
+
]));
|
|
228
|
+
body.push(element("ApiSignature", [
|
|
229
|
+
expression("code", block.code.display),
|
|
230
|
+
expression("source", block.code.source),
|
|
231
|
+
expression("apiScope", apiScope)
|
|
232
|
+
]));
|
|
233
|
+
return;
|
|
234
|
+
case "member-group":
|
|
235
|
+
body.heading(2, block.title);
|
|
236
|
+
for (const member of block.members) emitMember(body, member, apiScope);
|
|
237
|
+
return;
|
|
238
|
+
case "parameters":
|
|
239
|
+
body.pushResult(parameterRows(block.rows, true), (rows) => {
|
|
240
|
+
body.push(element("ParametersTable", [expression("parameters", rows)]));
|
|
241
|
+
});
|
|
242
|
+
return;
|
|
243
|
+
case "enum-members":
|
|
244
|
+
body.pushResult(enumRows(block.rows), (rows) => {
|
|
245
|
+
body.push(element("EnumMembersTable", [expression("members", rows)]));
|
|
246
|
+
});
|
|
247
|
+
return;
|
|
248
|
+
case "examples":
|
|
249
|
+
body.heading(2, "Examples");
|
|
250
|
+
for (const example of block.items) if (example.typeChecked) body.push(element("ApiExample", [
|
|
251
|
+
expression("code", example.code.display),
|
|
252
|
+
expression("source", example.code.source),
|
|
253
|
+
expression("apiScope", apiScope)
|
|
254
|
+
]));
|
|
255
|
+
else body.push(Code.make({
|
|
256
|
+
value: example.code.display,
|
|
257
|
+
lang: example.language
|
|
258
|
+
}));
|
|
259
|
+
return;
|
|
260
|
+
case "see-also":
|
|
261
|
+
body.heading(2, "See Also");
|
|
262
|
+
body.pushResult(Result.all(block.references.map(escapedPhrasing)), (references) => {
|
|
263
|
+
body.push(List.make({
|
|
264
|
+
ordered: false,
|
|
265
|
+
spread: false,
|
|
266
|
+
children: references.map((reference) => ListItem.make({
|
|
267
|
+
spread: false,
|
|
268
|
+
children: [paragraph(reference)]
|
|
269
|
+
}))
|
|
270
|
+
}));
|
|
271
|
+
});
|
|
272
|
+
return;
|
|
273
|
+
case "member-index":
|
|
274
|
+
body.heading(2, block.title);
|
|
275
|
+
body.pushResult(Result.all(block.entries.map((entry) => entry.summary ? escapedPhrasing(entry.summary) : Result.succeed(void 0))), (summaries) => {
|
|
276
|
+
const items = block.entries.map((entry, index) => {
|
|
277
|
+
const children = [Link.make({
|
|
278
|
+
url: entry.route,
|
|
279
|
+
children: [text(entry.name)]
|
|
280
|
+
})];
|
|
281
|
+
const summary = summaries[index];
|
|
282
|
+
if (summary !== void 0) children.push(text(" - "), ...summary);
|
|
283
|
+
return ListItem.make({
|
|
284
|
+
spread: false,
|
|
285
|
+
children: [paragraph(children)]
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
body.push(List.make({
|
|
289
|
+
ordered: false,
|
|
290
|
+
spread: false,
|
|
291
|
+
children: items
|
|
292
|
+
}));
|
|
293
|
+
});
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Emit a page's MDX body: the component import lines followed by every
|
|
299
|
+
* block, joined as the generators joined them. No frontmatter — the adapter
|
|
300
|
+
* assembles that from the page facts, in the generate stage the snapshot
|
|
301
|
+
* hash is taken in.
|
|
302
|
+
*/
|
|
303
|
+
function emitMdxBody(page, options) {
|
|
304
|
+
const body = new Body();
|
|
305
|
+
body.push(MdxjsEsm.make({ value: importLines(page.kind) }));
|
|
306
|
+
for (const block of page.blocks) emitBlock(body, block, page, options);
|
|
307
|
+
return body.render();
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
//#endregion
|
|
311
|
+
export { emitMdxBody };
|
package/emit/meta.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { emitFrontmatterBlock } from "@tsdoctor/model";
|
|
2
|
+
|
|
3
|
+
//#region src/emit/meta.ts
|
|
4
|
+
/**
|
|
5
|
+
* The RSPress navigation and landing-page emitters: the root and
|
|
6
|
+
* per-category `_meta.json` files rendered from a `@tsdoctor/pages`
|
|
7
|
+
* {@link NavTree}, and the `index.mdx` frontmatter rendered from an
|
|
8
|
+
* {@link IndexPage}.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* Pure functions of the IR. The renderer defaults (`collapsible` and
|
|
12
|
+
* `collapsed` true, `overviewHeaders` `[2]`) are RSPress sidebar policy the
|
|
13
|
+
* tree leaves to its consumer; the tab-indented JSON is the spelling the
|
|
14
|
+
* snapshot system compares an existing file against.
|
|
15
|
+
*
|
|
16
|
+
* @packageDocumentation
|
|
17
|
+
*/
|
|
18
|
+
/** The root `_meta.json` entries, one per category group that received a page. */
|
|
19
|
+
function rootMetaEntries(tree) {
|
|
20
|
+
return tree.groups.map((group) => ({
|
|
21
|
+
type: "dir",
|
|
22
|
+
name: group.category.folderName,
|
|
23
|
+
label: group.category.displayName,
|
|
24
|
+
collapsible: group.category.collapsible ?? true,
|
|
25
|
+
collapsed: group.category.collapsed ?? true,
|
|
26
|
+
overviewHeaders: group.category.overviewHeaders ?? [2]
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
/** A category folder's `_meta.json` entries, in the tree's (label-sorted) order. */
|
|
30
|
+
function categoryMetaEntries(group) {
|
|
31
|
+
return group.pages.map((page) => ({
|
|
32
|
+
type: "file",
|
|
33
|
+
name: page.name,
|
|
34
|
+
label: page.label
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
/** Serialize `_meta.json` entries the way the plugin always has: tab-indented JSON, no trailing newline. */
|
|
38
|
+
function renderMeta(entries) {
|
|
39
|
+
return JSON.stringify(entries, null, " ");
|
|
40
|
+
}
|
|
41
|
+
/** The root `_meta.json` text for an API. */
|
|
42
|
+
function renderRootMeta(tree) {
|
|
43
|
+
return renderMeta(rootMetaEntries(tree));
|
|
44
|
+
}
|
|
45
|
+
/** A category folder's `_meta.json` text. */
|
|
46
|
+
function renderCategoryMeta(group) {
|
|
47
|
+
return renderMeta(categoryMetaEntries(group));
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The `index.mdx` text for an API: frontmatter only, with RSPress's
|
|
51
|
+
* `overview: true` so the page lists its category folders.
|
|
52
|
+
*/
|
|
53
|
+
function emitIndexPage(index) {
|
|
54
|
+
return emitFrontmatterBlock({
|
|
55
|
+
title: index.title,
|
|
56
|
+
description: index.description,
|
|
57
|
+
overview: true
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
//#endregion
|
|
62
|
+
export { categoryMetaEntries, emitIndexPage, renderCategoryMeta, renderMeta, renderRootMeta, rootMetaEntries };
|
package/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OpenGraphImageConfig, OpenGraphImageMetadata, OpenGraphMetadata } from "@tsdoctor/seo";
|
|
2
2
|
import { ApiItemKind, ApiModel } from "@microsoft/api-extractor-model";
|
|
3
3
|
import { Schema } from "effect";
|
|
4
|
-
import "
|
|
4
|
+
import "@tsdoctor/vfs";
|
|
5
5
|
import { RspressPlugin } from "@rspress/shared";
|
|
6
6
|
import "@rspress/shared/logger";
|
|
7
7
|
import "@rspress/shared/node-utils";
|
|
@@ -12,14 +12,6 @@ import "unified";
|
|
|
12
12
|
import "vfile";
|
|
13
13
|
import "react";
|
|
14
14
|
//#region src/schemas/config.d.ts
|
|
15
|
-
/**
|
|
16
|
-
* Verbosity level for plugin build output.
|
|
17
|
-
*
|
|
18
|
-
* @public
|
|
19
|
-
*/
|
|
20
|
-
declare const LogLevel: Schema.Literals<readonly ["none", "info", "verbose", "debug", "warn", "error"]>;
|
|
21
|
-
/** @public */
|
|
22
|
-
type LogLevel = typeof LogLevel.Type;
|
|
23
15
|
/**
|
|
24
16
|
* Configuration for a single documentation category (e.g. Classes, Functions).
|
|
25
17
|
*
|
|
@@ -34,8 +26,6 @@ declare const CategoryConfig: Schema.Struct<{
|
|
|
34
26
|
readonly folderName: Schema.String;
|
|
35
27
|
/** API item kinds included in this category. */
|
|
36
28
|
readonly itemKinds: Schema.optional<Schema.mutable<Schema.$Array<Schema.declare<ApiItemKind, ApiItemKind>>>>;
|
|
37
|
-
/** TSDoc modifier tag that marks items for this category. */
|
|
38
|
-
readonly tsdocModifier: Schema.optional<Schema.String>;
|
|
39
29
|
/** Whether the sidebar section is collapsible. Defaults to `true`. */
|
|
40
30
|
readonly collapsible: Schema.withDecodingDefault<Schema.Boolean, never>;
|
|
41
31
|
/** Whether the sidebar section starts collapsed. Defaults to `true`. */
|
|
@@ -90,8 +80,6 @@ declare const VersionConfig: Schema.Struct<{
|
|
|
90
80
|
readonly folderName: Schema.String;
|
|
91
81
|
/** API item kinds included in this category. */
|
|
92
82
|
readonly itemKinds: Schema.optional<Schema.mutable<Schema.$Array<Schema.declare<ApiItemKind, ApiItemKind>>>>;
|
|
93
|
-
/** TSDoc modifier tag that marks items for this category. */
|
|
94
|
-
readonly tsdocModifier: Schema.optional<Schema.String>;
|
|
95
83
|
/** Whether the sidebar section is collapsible. Defaults to `true`. */
|
|
96
84
|
readonly collapsible: Schema.withDecodingDefault<Schema.Boolean, never>;
|
|
97
85
|
/** Whether the sidebar section starts collapsed. Defaults to `true`. */
|
|
@@ -110,8 +98,6 @@ declare const VersionConfig: Schema.Struct<{
|
|
|
110
98
|
readonly externalPackages: Schema.optional<Schema.mutable<Schema.$Array<Schema.Struct<{
|
|
111
99
|
readonly name: Schema.String;
|
|
112
100
|
readonly version: Schema.String;
|
|
113
|
-
readonly tsconfig: Schema.optional<Schema.declare<string | URL | ((...args: Array<unknown>) => unknown), string | URL | ((...args: Array<unknown>) => unknown)>>;
|
|
114
|
-
readonly compilerOptions: Schema.optional<Schema.Unknown>;
|
|
115
101
|
}>>>>;
|
|
116
102
|
/** Auto-detect external packages from `package.json` dependency fields. */
|
|
117
103
|
readonly autoDetectDependencies: Schema.optional<Schema.Struct<{
|
|
@@ -139,10 +125,6 @@ declare const VersionConfig: Schema.Struct<{
|
|
|
139
125
|
readonly copyButtonText: Schema.withDecodingDefault<Schema.String, never>;
|
|
140
126
|
readonly viewOptions: Schema.withDecodingDefault<Schema.mutable<Schema.$Array<Schema.Literals<readonly ["markdownLink", "chatgpt", "claude"]>>>, never>;
|
|
141
127
|
}>>;
|
|
142
|
-
/** Path to a `tsconfig.json` for this version. */
|
|
143
|
-
readonly tsconfig: Schema.optional<Schema.declare<string | URL | ((...args: Array<unknown>) => unknown), string | URL | ((...args: Array<unknown>) => unknown)>>;
|
|
144
|
-
/** TypeScript compiler options for Twoslash. */
|
|
145
|
-
readonly compilerOptions: Schema.optional<Schema.Unknown>;
|
|
146
128
|
}>;
|
|
147
129
|
/** @public */
|
|
148
130
|
type VersionConfig = typeof VersionConfig.Encoded;
|
|
@@ -180,8 +162,6 @@ declare const SingleApiConfig: Schema.Struct<{
|
|
|
180
162
|
readonly folderName: Schema.String;
|
|
181
163
|
/** API item kinds included in this category. */
|
|
182
164
|
readonly itemKinds: Schema.optional<Schema.mutable<Schema.$Array<Schema.declare<ApiItemKind, ApiItemKind>>>>;
|
|
183
|
-
/** TSDoc modifier tag that marks items for this category. */
|
|
184
|
-
readonly tsdocModifier: Schema.optional<Schema.String>;
|
|
185
165
|
/** Whether the sidebar section is collapsible. Defaults to `true`. */
|
|
186
166
|
readonly collapsible: Schema.withDecodingDefault<Schema.Boolean, never>;
|
|
187
167
|
/** Whether the sidebar section starts collapsed. Defaults to `true`. */
|
|
@@ -200,8 +180,6 @@ declare const SingleApiConfig: Schema.Struct<{
|
|
|
200
180
|
readonly externalPackages: Schema.optional<Schema.mutable<Schema.$Array<Schema.Struct<{
|
|
201
181
|
readonly name: Schema.String;
|
|
202
182
|
readonly version: Schema.String;
|
|
203
|
-
readonly tsconfig: Schema.optional<Schema.declare<string | URL | ((...args: Array<unknown>) => unknown), string | URL | ((...args: Array<unknown>) => unknown)>>;
|
|
204
|
-
readonly compilerOptions: Schema.optional<Schema.Unknown>;
|
|
205
183
|
}>>>>;
|
|
206
184
|
/** Auto-detect external packages from `package.json` dependency fields. */
|
|
207
185
|
readonly autoDetectDependencies: Schema.optional<Schema.Struct<{
|
|
@@ -229,10 +207,6 @@ declare const SingleApiConfig: Schema.Struct<{
|
|
|
229
207
|
readonly copyButtonText: Schema.withDecodingDefault<Schema.String, never>;
|
|
230
208
|
readonly viewOptions: Schema.withDecodingDefault<Schema.mutable<Schema.$Array<Schema.Literals<readonly ["markdownLink", "chatgpt", "claude"]>>>, never>;
|
|
231
209
|
}>>;
|
|
232
|
-
/** Path to a `tsconfig.json` for this version. */
|
|
233
|
-
readonly tsconfig: Schema.optional<Schema.declare<string | URL | ((...args: Array<unknown>) => unknown), string | URL | ((...args: Array<unknown>) => unknown)>>;
|
|
234
|
-
/** TypeScript compiler options for Twoslash. */
|
|
235
|
-
readonly compilerOptions: Schema.optional<Schema.Unknown>;
|
|
236
210
|
}>]>>>;
|
|
237
211
|
/** Shiki syntax-highlighting theme. */
|
|
238
212
|
readonly theme: Schema.optional<Schema.Union<readonly [Schema.String, Schema.Struct<{
|
|
@@ -249,8 +223,6 @@ declare const SingleApiConfig: Schema.Struct<{
|
|
|
249
223
|
readonly folderName: Schema.String;
|
|
250
224
|
/** API item kinds included in this category. */
|
|
251
225
|
readonly itemKinds: Schema.optional<Schema.mutable<Schema.$Array<Schema.declare<ApiItemKind, ApiItemKind>>>>;
|
|
252
|
-
/** TSDoc modifier tag that marks items for this category. */
|
|
253
|
-
readonly tsdocModifier: Schema.optional<Schema.String>;
|
|
254
226
|
/** Whether the sidebar section is collapsible. Defaults to `true`. */
|
|
255
227
|
readonly collapsible: Schema.withDecodingDefault<Schema.Boolean, never>;
|
|
256
228
|
/** Whether the sidebar section starts collapsed. Defaults to `true`. */
|
|
@@ -269,8 +241,6 @@ declare const SingleApiConfig: Schema.Struct<{
|
|
|
269
241
|
readonly externalPackages: Schema.optional<Schema.mutable<Schema.$Array<Schema.Struct<{
|
|
270
242
|
readonly name: Schema.String;
|
|
271
243
|
readonly version: Schema.String;
|
|
272
|
-
readonly tsconfig: Schema.optional<Schema.declare<string | URL | ((...args: Array<unknown>) => unknown), string | URL | ((...args: Array<unknown>) => unknown)>>;
|
|
273
|
-
readonly compilerOptions: Schema.optional<Schema.Unknown>;
|
|
274
244
|
}>>>>;
|
|
275
245
|
/** Auto-detect external packages from `package.json` dependency fields. */
|
|
276
246
|
readonly autoDetectDependencies: Schema.optional<Schema.Struct<{
|
|
@@ -338,8 +308,6 @@ declare const MultiApiConfig: Schema.Struct<{
|
|
|
338
308
|
readonly folderName: Schema.String;
|
|
339
309
|
/** API item kinds included in this category. */
|
|
340
310
|
readonly itemKinds: Schema.optional<Schema.mutable<Schema.$Array<Schema.declare<ApiItemKind, ApiItemKind>>>>;
|
|
341
|
-
/** TSDoc modifier tag that marks items for this category. */
|
|
342
|
-
readonly tsdocModifier: Schema.optional<Schema.String>;
|
|
343
311
|
/** Whether the sidebar section is collapsible. Defaults to `true`. */
|
|
344
312
|
readonly collapsible: Schema.withDecodingDefault<Schema.Boolean, never>;
|
|
345
313
|
/** Whether the sidebar section starts collapsed. Defaults to `true`. */
|
|
@@ -358,8 +326,6 @@ declare const MultiApiConfig: Schema.Struct<{
|
|
|
358
326
|
readonly externalPackages: Schema.optional<Schema.mutable<Schema.$Array<Schema.Struct<{
|
|
359
327
|
readonly name: Schema.String;
|
|
360
328
|
readonly version: Schema.String;
|
|
361
|
-
readonly tsconfig: Schema.optional<Schema.declare<string | URL | ((...args: Array<unknown>) => unknown), string | URL | ((...args: Array<unknown>) => unknown)>>;
|
|
362
|
-
readonly compilerOptions: Schema.optional<Schema.Unknown>;
|
|
363
329
|
}>>>>;
|
|
364
330
|
/** Auto-detect external packages from `package.json` dependency fields. */
|
|
365
331
|
readonly autoDetectDependencies: Schema.optional<Schema.Struct<{
|
|
@@ -450,8 +416,6 @@ declare const PluginOptions: Schema.Struct<{
|
|
|
450
416
|
readonly folderName: Schema.String;
|
|
451
417
|
/** API item kinds included in this category. */
|
|
452
418
|
readonly itemKinds: Schema.optional<Schema.mutable<Schema.$Array<Schema.declare<ApiItemKind, ApiItemKind>>>>;
|
|
453
|
-
/** TSDoc modifier tag that marks items for this category. */
|
|
454
|
-
readonly tsdocModifier: Schema.optional<Schema.String>;
|
|
455
419
|
/** Whether the sidebar section is collapsible. Defaults to `true`. */
|
|
456
420
|
readonly collapsible: Schema.withDecodingDefault<Schema.Boolean, never>;
|
|
457
421
|
/** Whether the sidebar section starts collapsed. Defaults to `true`. */
|
|
@@ -470,8 +434,6 @@ declare const PluginOptions: Schema.Struct<{
|
|
|
470
434
|
readonly externalPackages: Schema.optional<Schema.mutable<Schema.$Array<Schema.Struct<{
|
|
471
435
|
readonly name: Schema.String;
|
|
472
436
|
readonly version: Schema.String;
|
|
473
|
-
readonly tsconfig: Schema.optional<Schema.declare<string | URL | ((...args: Array<unknown>) => unknown), string | URL | ((...args: Array<unknown>) => unknown)>>;
|
|
474
|
-
readonly compilerOptions: Schema.optional<Schema.Unknown>;
|
|
475
437
|
}>>>>;
|
|
476
438
|
/** Auto-detect external packages from `package.json` dependency fields. */
|
|
477
439
|
readonly autoDetectDependencies: Schema.optional<Schema.Struct<{
|
|
@@ -499,10 +461,6 @@ declare const PluginOptions: Schema.Struct<{
|
|
|
499
461
|
readonly copyButtonText: Schema.withDecodingDefault<Schema.String, never>;
|
|
500
462
|
readonly viewOptions: Schema.withDecodingDefault<Schema.mutable<Schema.$Array<Schema.Literals<readonly ["markdownLink", "chatgpt", "claude"]>>>, never>;
|
|
501
463
|
}>>;
|
|
502
|
-
/** Path to a `tsconfig.json` for this version. */
|
|
503
|
-
readonly tsconfig: Schema.optional<Schema.declare<string | URL | ((...args: Array<unknown>) => unknown), string | URL | ((...args: Array<unknown>) => unknown)>>;
|
|
504
|
-
/** TypeScript compiler options for Twoslash. */
|
|
505
|
-
readonly compilerOptions: Schema.optional<Schema.Unknown>;
|
|
506
464
|
}>]>>>;
|
|
507
465
|
/** Shiki syntax-highlighting theme. */
|
|
508
466
|
readonly theme: Schema.optional<Schema.Union<readonly [Schema.String, Schema.Struct<{
|
|
@@ -519,8 +477,6 @@ declare const PluginOptions: Schema.Struct<{
|
|
|
519
477
|
readonly folderName: Schema.String;
|
|
520
478
|
/** API item kinds included in this category. */
|
|
521
479
|
readonly itemKinds: Schema.optional<Schema.mutable<Schema.$Array<Schema.declare<ApiItemKind, ApiItemKind>>>>;
|
|
522
|
-
/** TSDoc modifier tag that marks items for this category. */
|
|
523
|
-
readonly tsdocModifier: Schema.optional<Schema.String>;
|
|
524
480
|
/** Whether the sidebar section is collapsible. Defaults to `true`. */
|
|
525
481
|
readonly collapsible: Schema.withDecodingDefault<Schema.Boolean, never>;
|
|
526
482
|
/** Whether the sidebar section starts collapsed. Defaults to `true`. */
|
|
@@ -539,8 +495,6 @@ declare const PluginOptions: Schema.Struct<{
|
|
|
539
495
|
readonly externalPackages: Schema.optional<Schema.mutable<Schema.$Array<Schema.Struct<{
|
|
540
496
|
readonly name: Schema.String;
|
|
541
497
|
readonly version: Schema.String;
|
|
542
|
-
readonly tsconfig: Schema.optional<Schema.declare<string | URL | ((...args: Array<unknown>) => unknown), string | URL | ((...args: Array<unknown>) => unknown)>>;
|
|
543
|
-
readonly compilerOptions: Schema.optional<Schema.Unknown>;
|
|
544
498
|
}>>>>;
|
|
545
499
|
/** Auto-detect external packages from `package.json` dependency fields. */
|
|
546
500
|
readonly autoDetectDependencies: Schema.optional<Schema.Struct<{
|
|
@@ -602,8 +556,6 @@ declare const PluginOptions: Schema.Struct<{
|
|
|
602
556
|
readonly folderName: Schema.String;
|
|
603
557
|
/** API item kinds included in this category. */
|
|
604
558
|
readonly itemKinds: Schema.optional<Schema.mutable<Schema.$Array<Schema.declare<ApiItemKind, ApiItemKind>>>>;
|
|
605
|
-
/** TSDoc modifier tag that marks items for this category. */
|
|
606
|
-
readonly tsdocModifier: Schema.optional<Schema.String>;
|
|
607
559
|
/** Whether the sidebar section is collapsible. Defaults to `true`. */
|
|
608
560
|
readonly collapsible: Schema.withDecodingDefault<Schema.Boolean, never>;
|
|
609
561
|
/** Whether the sidebar section starts collapsed. Defaults to `true`. */
|
|
@@ -622,8 +574,6 @@ declare const PluginOptions: Schema.Struct<{
|
|
|
622
574
|
readonly externalPackages: Schema.optional<Schema.mutable<Schema.$Array<Schema.Struct<{
|
|
623
575
|
readonly name: Schema.String;
|
|
624
576
|
readonly version: Schema.String;
|
|
625
|
-
readonly tsconfig: Schema.optional<Schema.declare<string | URL | ((...args: Array<unknown>) => unknown), string | URL | ((...args: Array<unknown>) => unknown)>>;
|
|
626
|
-
readonly compilerOptions: Schema.optional<Schema.Unknown>;
|
|
627
577
|
}>>>>;
|
|
628
578
|
/** Auto-detect external packages from `package.json` dependency fields. */
|
|
629
579
|
readonly autoDetectDependencies: Schema.optional<Schema.Struct<{
|
|
@@ -689,8 +639,6 @@ declare const PluginOptions: Schema.Struct<{
|
|
|
689
639
|
readonly folderName: Schema.String;
|
|
690
640
|
/** API item kinds included in this category. */
|
|
691
641
|
readonly itemKinds: Schema.optional<Schema.mutable<Schema.$Array<Schema.declare<ApiItemKind, ApiItemKind>>>>;
|
|
692
|
-
/** TSDoc modifier tag that marks items for this category. */
|
|
693
|
-
readonly tsdocModifier: Schema.optional<Schema.String>;
|
|
694
642
|
/** Whether the sidebar section is collapsible. Defaults to `true`. */
|
|
695
643
|
readonly collapsible: Schema.withDecodingDefault<Schema.Boolean, never>;
|
|
696
644
|
/** Whether the sidebar section starts collapsed. Defaults to `true`. */
|
|
@@ -712,21 +660,6 @@ declare const PluginOptions: Schema.Struct<{
|
|
|
712
660
|
readonly copyButtonText: Schema.withDecodingDefault<Schema.String, never>;
|
|
713
661
|
readonly viewOptions: Schema.withDecodingDefault<Schema.mutable<Schema.$Array<Schema.Literals<readonly ["markdownLink", "chatgpt", "claude"]>>>, never>;
|
|
714
662
|
}>]>>;
|
|
715
|
-
/** Verbosity level for plugin build output. @deprecated Use `observability.logLevel`. */
|
|
716
|
-
readonly logLevel: Schema.optional<Schema.Literals<readonly ["none", "info", "verbose", "debug", "warn", "error"]>>;
|
|
717
|
-
/** Performance tuning options. @deprecated Use `observability.thresholds`. */
|
|
718
|
-
readonly performance: Schema.optional<Schema.Struct<{
|
|
719
|
-
readonly thresholds: Schema.optional<Schema.Struct<{
|
|
720
|
-
readonly slowCodeBlock: Schema.withDecodingDefault<Schema.Number, never>;
|
|
721
|
-
readonly slowPageGeneration: Schema.withDecodingDefault<Schema.Number, never>;
|
|
722
|
-
readonly slowApiLoad: Schema.withDecodingDefault<Schema.Number, never>;
|
|
723
|
-
readonly slowFileOperation: Schema.withDecodingDefault<Schema.Number, never>;
|
|
724
|
-
readonly slowHttpRequest: Schema.withDecodingDefault<Schema.Number, never>;
|
|
725
|
-
readonly slowDbOperation: Schema.withDecodingDefault<Schema.Number, never>;
|
|
726
|
-
}>>;
|
|
727
|
-
readonly showInsights: Schema.withDecodingDefault<Schema.Boolean, never>;
|
|
728
|
-
readonly trackDetailedMetrics: Schema.withDecodingDefault<Schema.Boolean, never>;
|
|
729
|
-
}>>;
|
|
730
663
|
/** Unified observability configuration (logLevel, trace artifact, thresholds). */
|
|
731
664
|
readonly observability: Schema.optional<Schema.Struct<{
|
|
732
665
|
readonly logLevel: Schema.optional<Schema.Literals<readonly ["none", "error", "warn", "info", "debug", "trace", "verbose"]>>;
|
|
@@ -737,7 +670,6 @@ declare const PluginOptions: Schema.Struct<{
|
|
|
737
670
|
readonly slowPageGeneration: Schema.withDecodingDefault<Schema.Number, never>;
|
|
738
671
|
readonly slowApiLoad: Schema.withDecodingDefault<Schema.Number, never>;
|
|
739
672
|
readonly slowFileOperation: Schema.withDecodingDefault<Schema.Number, never>;
|
|
740
|
-
readonly slowHttpRequest: Schema.withDecodingDefault<Schema.Number, never>;
|
|
741
673
|
readonly slowDbOperation: Schema.withDecodingDefault<Schema.Number, never>;
|
|
742
674
|
}>>;
|
|
743
675
|
}>>;
|
|
@@ -821,6 +753,10 @@ declare function fromDir(dir: string, overrides?: FromDirOptions): MultiApiConfi
|
|
|
821
753
|
declare function fromParentDir(parentDir: string, options?: FromDirOptions): MultiApiConfig[];
|
|
822
754
|
//#endregion
|
|
823
755
|
//#region src/internal-types.d.ts
|
|
756
|
+
/**
|
|
757
|
+
* Compiler options relevant to type resolution.
|
|
758
|
+
* Subset of TypeScript's CompilerOptions used by the type registry and Twoslash.
|
|
759
|
+
*/
|
|
824
760
|
/**
|
|
825
761
|
* Result returned by a model loader function.
|
|
826
762
|
*
|
|
@@ -959,5 +895,5 @@ declare function resolveServeConfig(options?: ServeOptions): ResolvedServeConfig
|
|
|
959
895
|
*/
|
|
960
896
|
declare function serve(options?: ServeOptions): Promise<void>;
|
|
961
897
|
//#endregion
|
|
962
|
-
export { ApiExtractorPlugin, type PluginOptions as ApiExtractorPluginOptions, type BaseRoute, type CategoryConfig, DEFAULT_CATEGORIES, type DirInfo, type FromDirOptions, type LoadedModel, type
|
|
898
|
+
export { ApiExtractorPlugin, type PluginOptions as ApiExtractorPluginOptions, type BaseRoute, type CategoryConfig, DEFAULT_CATEGORIES, type DirInfo, type FromDirOptions, type LoadedModel, type MultiApiConfig, type OpenGraphImageConfig, type OpenGraphImageMetadata, type OpenGraphMetadata, type ResolvedServeConfig, type ServeMode, type ServeOptions, type SingleApiConfig, type SourceConfig, type VersionConfig, isServerReady, resolveServeConfig, serve };
|
|
963
899
|
//# sourceMappingURL=index.d.ts.map
|
package/layers/build-metrics.js
CHANGED
|
@@ -81,8 +81,7 @@ const BuildMetrics = {
|
|
|
81
81
|
phaseTimeMs: Metric.counter("phase.time.ms"),
|
|
82
82
|
vfsFiles: Metric.counter("vfs.files"),
|
|
83
83
|
importsPrepended: Metric.counter("imports.prepended"),
|
|
84
|
-
twoslashDiagnostics: Metric.counter("twoslash.diagnostics")
|
|
85
|
-
configDefaultsApplied: Metric.counter("config.defaults.applied")
|
|
84
|
+
twoslashDiagnostics: Metric.counter("twoslash.diagnostics")
|
|
86
85
|
};
|
|
87
86
|
|
|
88
87
|
//#endregion
|