rspress-plugin-api-extractor 0.3.1 → 0.3.3
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/api-extracted-package.js +48 -16
- package/index.d.ts +30 -30
- package/package.json +3 -3
- package/type-reference-extractor.js +2 -4
package/api-extracted-package.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApiItemKind, ApiModel } from "@microsoft/api-extractor-model";
|
|
1
|
+
import { ApiItemKind, ApiModel, ExcerptTokenKind } from "@microsoft/api-extractor-model";
|
|
2
2
|
import { VirtualPackage } from "type-registry-effect";
|
|
3
3
|
|
|
4
4
|
//#region src/api-extracted-package.ts
|
|
@@ -82,10 +82,10 @@ var ApiExtractedPackage = class ApiExtractedPackage extends VirtualPackageClass
|
|
|
82
82
|
if (jsDoc) lines.push(jsDoc);
|
|
83
83
|
let name = apiClass.displayName;
|
|
84
84
|
if (apiClass.typeParameters?.length) name += this.formatTypeParameters(apiClass.typeParameters);
|
|
85
|
-
const headerParts = ["export declare class", name];
|
|
86
|
-
if (apiClass.extendsType) headerParts.push(`extends ${apiClass.extendsType.excerpt
|
|
85
|
+
const headerParts = apiClass.isAbstract ? ["export declare abstract class", name] : ["export declare class", name];
|
|
86
|
+
if (apiClass.extendsType) headerParts.push(`extends ${this.renderExcerpt(apiClass.extendsType.excerpt)}`);
|
|
87
87
|
if (apiClass.implementsTypes?.length) {
|
|
88
|
-
const impl = apiClass.implementsTypes.map((t) => t.excerpt
|
|
88
|
+
const impl = apiClass.implementsTypes.map((t) => this.renderExcerpt(t.excerpt)).join(", ");
|
|
89
89
|
headerParts.push(`implements ${impl}`);
|
|
90
90
|
}
|
|
91
91
|
lines.push(`${headerParts.join(" ")} {`);
|
|
@@ -104,7 +104,7 @@ var ApiExtractedPackage = class ApiExtractedPackage extends VirtualPackageClass
|
|
|
104
104
|
if (apiInterface.typeParameters?.length) name += this.formatTypeParameters(apiInterface.typeParameters);
|
|
105
105
|
const headerParts = ["export declare interface", name];
|
|
106
106
|
if (apiInterface.extendsTypes?.length) {
|
|
107
|
-
const ext = apiInterface.extendsTypes.map((t) => t.excerpt
|
|
107
|
+
const ext = apiInterface.extendsTypes.map((t) => this.renderExcerpt(t.excerpt)).join(", ");
|
|
108
108
|
headerParts.push(`extends ${ext}`);
|
|
109
109
|
}
|
|
110
110
|
lines.push(`${headerParts.join(" ")} {`);
|
|
@@ -121,14 +121,14 @@ var ApiExtractedPackage = class ApiExtractedPackage extends VirtualPackageClass
|
|
|
121
121
|
if (jsDoc) lines.push(jsDoc);
|
|
122
122
|
let name = typeAlias.displayName;
|
|
123
123
|
if (typeAlias.typeParameters?.length) name += this.formatTypeParameters(typeAlias.typeParameters);
|
|
124
|
-
lines.push(`export declare type ${name} = ${typeAlias.typeExcerpt
|
|
124
|
+
lines.push(`export declare type ${name} = ${this.renderExcerpt(typeAlias.typeExcerpt)};`);
|
|
125
125
|
return lines.join("\n");
|
|
126
126
|
}
|
|
127
127
|
generateFunctionDeclaration(apiFunction) {
|
|
128
128
|
const lines = [];
|
|
129
129
|
const jsDoc = this.formatJSDoc(apiFunction);
|
|
130
130
|
if (jsDoc) lines.push(jsDoc);
|
|
131
|
-
const cleaned = this.cleanExcerpt(apiFunction.excerpt
|
|
131
|
+
const cleaned = this.cleanExcerpt(this.renderExcerpt(apiFunction.excerpt));
|
|
132
132
|
const decl = cleaned.startsWith("function ") ? cleaned : `const ${cleaned}`;
|
|
133
133
|
lines.push(`export declare ${decl};`);
|
|
134
134
|
return lines.join("\n");
|
|
@@ -155,7 +155,7 @@ var ApiExtractedPackage = class ApiExtractedPackage extends VirtualPackageClass
|
|
|
155
155
|
const lines = [];
|
|
156
156
|
const jsDoc = this.formatJSDoc(apiVariable);
|
|
157
157
|
if (jsDoc) lines.push(jsDoc);
|
|
158
|
-
let cleaned = this.cleanExcerpt(apiVariable.excerpt
|
|
158
|
+
let cleaned = this.cleanExcerpt(this.renderExcerpt(apiVariable.excerpt));
|
|
159
159
|
if (!cleaned.startsWith("const ") && !cleaned.startsWith("let ") && !cleaned.startsWith("var ")) cleaned = `const ${cleaned}`;
|
|
160
160
|
lines.push(`export declare ${cleaned};`);
|
|
161
161
|
return lines.join("\n");
|
|
@@ -187,7 +187,7 @@ var ApiExtractedPackage = class ApiExtractedPackage extends VirtualPackageClass
|
|
|
187
187
|
const lines = [];
|
|
188
188
|
const jsDoc = this.formatJSDoc(apiFunction, " ");
|
|
189
189
|
if (jsDoc) lines.push(jsDoc);
|
|
190
|
-
const cleaned = this.cleanExcerpt(apiFunction.excerpt
|
|
190
|
+
const cleaned = this.cleanExcerpt(this.renderExcerpt(apiFunction.excerpt));
|
|
191
191
|
lines.push(` export ${cleaned};`);
|
|
192
192
|
return lines.join("\n");
|
|
193
193
|
}
|
|
@@ -199,7 +199,7 @@ var ApiExtractedPackage = class ApiExtractedPackage extends VirtualPackageClass
|
|
|
199
199
|
if (apiInterface.typeParameters?.length) name += this.formatTypeParameters(apiInterface.typeParameters);
|
|
200
200
|
const headerParts = ["export interface", name];
|
|
201
201
|
if (apiInterface.extendsTypes?.length) {
|
|
202
|
-
const ext = apiInterface.extendsTypes.map((t) => t.excerpt
|
|
202
|
+
const ext = apiInterface.extendsTypes.map((t) => this.renderExcerpt(t.excerpt)).join(", ");
|
|
203
203
|
headerParts.push(`extends ${ext}`);
|
|
204
204
|
}
|
|
205
205
|
lines.push(` ${headerParts.join(" ")} {`);
|
|
@@ -234,14 +234,14 @@ var ApiExtractedPackage = class ApiExtractedPackage extends VirtualPackageClass
|
|
|
234
234
|
if (jsDoc) lines.push(jsDoc);
|
|
235
235
|
let name = typeAlias.displayName;
|
|
236
236
|
if (typeAlias.typeParameters?.length) name += this.formatTypeParameters(typeAlias.typeParameters);
|
|
237
|
-
lines.push(` export type ${name} = ${typeAlias.typeExcerpt
|
|
237
|
+
lines.push(` export type ${name} = ${this.renderExcerpt(typeAlias.typeExcerpt)};`);
|
|
238
238
|
return lines.join("\n");
|
|
239
239
|
}
|
|
240
240
|
generateNamespaceVariable(apiVariable) {
|
|
241
241
|
const lines = [];
|
|
242
242
|
const jsDoc = this.formatJSDoc(apiVariable, " ");
|
|
243
243
|
if (jsDoc) lines.push(jsDoc);
|
|
244
|
-
let cleaned = this.cleanExcerpt(apiVariable.excerpt
|
|
244
|
+
let cleaned = this.cleanExcerpt(this.renderExcerpt(apiVariable.excerpt));
|
|
245
245
|
if (!cleaned.startsWith("const ") && !cleaned.startsWith("let ") && !cleaned.startsWith("var ")) cleaned = `const ${cleaned}`;
|
|
246
246
|
lines.push(` export ${cleaned};`);
|
|
247
247
|
return lines.join("\n");
|
|
@@ -249,7 +249,7 @@ var ApiExtractedPackage = class ApiExtractedPackage extends VirtualPackageClass
|
|
|
249
249
|
generateNamespaceClass(apiClass) {
|
|
250
250
|
const decl = this.generateClassDeclaration(apiClass);
|
|
251
251
|
if (!decl) return "";
|
|
252
|
-
return decl.replace(/\bexport declare class\b/, "export
|
|
252
|
+
return decl.replace(/\bexport declare (abstract )?class\b/, "export $1class").split("\n").map((line) => line.trim() ? ` ${line}` : line).join("\n");
|
|
253
253
|
}
|
|
254
254
|
generateClassMember(member, indent = " ") {
|
|
255
255
|
switch (member.kind) {
|
|
@@ -273,11 +273,43 @@ var ApiExtractedPackage = class ApiExtractedPackage extends VirtualPackageClass
|
|
|
273
273
|
const lines = [];
|
|
274
274
|
const jsDoc = this.formatJSDoc(member, indent);
|
|
275
275
|
if (jsDoc) lines.push(jsDoc);
|
|
276
|
-
const cleaned = this.cleanExcerpt(member.excerpt
|
|
276
|
+
const cleaned = this.cleanExcerpt(this.renderExcerpt(member.excerpt));
|
|
277
277
|
lines.push(`${indent}${cleaned};`);
|
|
278
278
|
return lines.join("\n");
|
|
279
279
|
}
|
|
280
280
|
/**
|
|
281
|
+
* Render an excerpt to source text, normalizing dts-rollup disambiguation
|
|
282
|
+
* aliases. The dts rollup renames a re-imported symbol as `Name$1`, but its
|
|
283
|
+
* canonical reference is the un-suffixed `Name` (the same symbol). The import
|
|
284
|
+
* prepender ({@link TypeReferenceExtractor}) imports the canonical name, so
|
|
285
|
+
* emitting the suffixed text would leave `Name$1` undefined (TS2304). Emit the
|
|
286
|
+
* canonical name so the body and the prepended import agree.
|
|
287
|
+
*
|
|
288
|
+
* Equivalent to `excerpt.text` for excerpts without rollup aliases (the text
|
|
289
|
+
* is the concatenation of the spanned tokens), so unaliased output is unchanged.
|
|
290
|
+
*/
|
|
291
|
+
renderExcerpt(excerpt) {
|
|
292
|
+
return excerpt.spannedTokens.map((token) => this.normalizeTokenText(token)).join("");
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Strip a dts-rollup `$N` suffix from a reference token when the de-suffixed
|
|
296
|
+
* text matches the token's canonical symbol. Never touches a non-reference
|
|
297
|
+
* token or a legitimate identifier that genuinely ends in `$N` (its canonical
|
|
298
|
+
* name would carry the suffix too).
|
|
299
|
+
*/
|
|
300
|
+
normalizeTokenText(token) {
|
|
301
|
+
if (token.kind !== ExcerptTokenKind.Reference) return token.text;
|
|
302
|
+
const match = /^(.+)\$\d+$/.exec(token.text);
|
|
303
|
+
if (!match) return token.text;
|
|
304
|
+
const canonical = token.canonicalReference?.toString();
|
|
305
|
+
if (!canonical) return token.text;
|
|
306
|
+
const afterBang = canonical.slice(canonical.indexOf("!") + 1);
|
|
307
|
+
const colon = afterBang.indexOf(":");
|
|
308
|
+
const symbol = colon === -1 ? afterBang : afterBang.slice(0, colon);
|
|
309
|
+
const leaf = symbol.includes(".") ? symbol.slice(symbol.lastIndexOf(".") + 1) : symbol;
|
|
310
|
+
return match[1] === symbol || match[1] === leaf ? match[1] : token.text;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
281
313
|
* Clean an excerpt text: strip export/declare keywords and trailing semicolons/whitespace.
|
|
282
314
|
*/
|
|
283
315
|
cleanExcerpt(text) {
|
|
@@ -287,8 +319,8 @@ var ApiExtractedPackage = class ApiExtractedPackage extends VirtualPackageClass
|
|
|
287
319
|
if (!typeParameters.length) return "";
|
|
288
320
|
return `<${typeParameters.map((tp) => {
|
|
289
321
|
const parts = [tp.name];
|
|
290
|
-
if (tp.constraintExcerpt
|
|
291
|
-
if (tp.defaultTypeExcerpt
|
|
322
|
+
if (tp.constraintExcerpt && this.renderExcerpt(tp.constraintExcerpt).trim()) parts.push(`extends ${this.renderExcerpt(tp.constraintExcerpt).trim()}`);
|
|
323
|
+
if (tp.defaultTypeExcerpt && this.renderExcerpt(tp.defaultTypeExcerpt).trim()) parts.push(`= ${this.renderExcerpt(tp.defaultTypeExcerpt).trim()}`);
|
|
292
324
|
return parts.join(" ");
|
|
293
325
|
}).join(", ")}>`;
|
|
294
326
|
}
|
package/index.d.ts
CHANGED
|
@@ -63,8 +63,8 @@ declare const DEFAULT_CATEGORIES: Record<string, CategoryConfig>;
|
|
|
63
63
|
* @public
|
|
64
64
|
*/
|
|
65
65
|
declare const VersionConfig: Schema.mutable<Schema.Struct<{
|
|
66
|
-
/** Path or loader for the `.api.json` model file for this version. */model: Schema.declare<string | ((...args: Array<unknown>) => unknown) | URL
|
|
67
|
-
packageJson: Schema.optional<Schema.declare<string | ((...args: Array<unknown>) => unknown) | URL
|
|
66
|
+
/** Path or loader for the `.api.json` model file for this version. */model: Schema.declare<string | URL | ((...args: Array<unknown>) => unknown), string | URL | ((...args: Array<unknown>) => unknown), readonly [], never>; /** Path or loader for the `package.json` for this version. */
|
|
67
|
+
packageJson: Schema.optional<Schema.declare<string | URL | ((...args: Array<unknown>) => unknown), string | URL | ((...args: Array<unknown>) => unknown), readonly [], never>>; /** Category overrides for this version. */
|
|
68
68
|
categories: Schema.optional<Schema.mutable<Schema.Record$<typeof Schema.String, Schema.mutable<Schema.Struct<{
|
|
69
69
|
/** Human-readable plural display name shown in the sidebar. */displayName: typeof Schema.String; /** Human-readable singular name used in page titles. */
|
|
70
70
|
singularName: typeof Schema.String; /** Folder name under the API base route (URL segment). */
|
|
@@ -88,7 +88,7 @@ declare const VersionConfig: Schema.mutable<Schema.Struct<{
|
|
|
88
88
|
externalPackages: Schema.optional<Schema.mutable<Schema.Array$<Schema.mutable<Schema.Struct<{
|
|
89
89
|
name: typeof Schema.String;
|
|
90
90
|
version: typeof Schema.String;
|
|
91
|
-
tsconfig: Schema.optional<Schema.declare<string | ((...args: Array<unknown>) => unknown) | URL
|
|
91
|
+
tsconfig: Schema.optional<Schema.declare<string | URL | ((...args: Array<unknown>) => unknown), string | URL | ((...args: Array<unknown>) => unknown), readonly [], never>>;
|
|
92
92
|
compilerOptions: Schema.optional<typeof Schema.Unknown>;
|
|
93
93
|
}>>>>>; /** Auto-detect external packages from `package.json` dependency fields. */
|
|
94
94
|
autoDetectDependencies: Schema.optional<Schema.mutable<Schema.Struct<{
|
|
@@ -136,7 +136,7 @@ declare const VersionConfig: Schema.mutable<Schema.Struct<{
|
|
|
136
136
|
default: () => ["markdownLink", "chatgpt", "claude"];
|
|
137
137
|
}>;
|
|
138
138
|
}>>>; /** Path to a `tsconfig.json` for this version. */
|
|
139
|
-
tsconfig: Schema.optional<Schema.declare<string | ((...args: Array<unknown>) => unknown) | URL
|
|
139
|
+
tsconfig: Schema.optional<Schema.declare<string | URL | ((...args: Array<unknown>) => unknown), string | URL | ((...args: Array<unknown>) => unknown), readonly [], never>>; /** TypeScript compiler options for Twoslash. */
|
|
140
140
|
compilerOptions: Schema.optional<typeof Schema.Unknown>;
|
|
141
141
|
}>>;
|
|
142
142
|
/** @public */
|
|
@@ -151,11 +151,11 @@ declare const SingleApiConfig: Schema.mutable<Schema.Struct<{
|
|
|
151
151
|
name: Schema.optional<typeof Schema.String>; /** Base URL route for API pages (defaults to `/api`). */
|
|
152
152
|
baseRoute: Schema.optional<typeof Schema.String>; /** Subfolder name under `baseRoute` for API pages, or `null` to omit. */
|
|
153
153
|
apiFolder: Schema.optional<Schema.Union<[typeof Schema.String, typeof Schema.Null]>>; /** Path or loader for the `.api.json` model file. */
|
|
154
|
-
model: Schema.optional<Schema.declare<string | ((...args: Array<unknown>) => unknown) | URL
|
|
155
|
-
packageJson: Schema.optional<Schema.declare<string | ((...args: Array<unknown>) => unknown) | URL
|
|
156
|
-
versions: Schema.optional<Schema.mutable<Schema.Record$<typeof Schema.String, Schema.Union<[Schema.declare<string | ((...args: Array<unknown>) => unknown) | URL
|
|
157
|
-
/** Path or loader for the `.api.json` model file for this version. */model: Schema.declare<string | ((...args: Array<unknown>) => unknown) | URL
|
|
158
|
-
packageJson: Schema.optional<Schema.declare<string | ((...args: Array<unknown>) => unknown) | URL
|
|
154
|
+
model: Schema.optional<Schema.declare<string | URL | ((...args: Array<unknown>) => unknown), string | URL | ((...args: Array<unknown>) => unknown), readonly [], never>>; /** Path or loader for the `package.json`. */
|
|
155
|
+
packageJson: Schema.optional<Schema.declare<string | URL | ((...args: Array<unknown>) => unknown), string | URL | ((...args: Array<unknown>) => unknown), readonly [], never>>; /** Versioned models keyed by version label. */
|
|
156
|
+
versions: Schema.optional<Schema.mutable<Schema.Record$<typeof Schema.String, Schema.Union<[Schema.declare<string | URL | ((...args: Array<unknown>) => unknown), string | URL | ((...args: Array<unknown>) => unknown), readonly [], never>, Schema.mutable<Schema.Struct<{
|
|
157
|
+
/** Path or loader for the `.api.json` model file for this version. */model: Schema.declare<string | URL | ((...args: Array<unknown>) => unknown), string | URL | ((...args: Array<unknown>) => unknown), readonly [], never>; /** Path or loader for the `package.json` for this version. */
|
|
158
|
+
packageJson: Schema.optional<Schema.declare<string | URL | ((...args: Array<unknown>) => unknown), string | URL | ((...args: Array<unknown>) => unknown), readonly [], never>>; /** Category overrides for this version. */
|
|
159
159
|
categories: Schema.optional<Schema.mutable<Schema.Record$<typeof Schema.String, Schema.mutable<Schema.Struct<{
|
|
160
160
|
/** Human-readable plural display name shown in the sidebar. */displayName: typeof Schema.String; /** Human-readable singular name used in page titles. */
|
|
161
161
|
singularName: typeof Schema.String; /** Folder name under the API base route (URL segment). */
|
|
@@ -179,7 +179,7 @@ declare const SingleApiConfig: Schema.mutable<Schema.Struct<{
|
|
|
179
179
|
externalPackages: Schema.optional<Schema.mutable<Schema.Array$<Schema.mutable<Schema.Struct<{
|
|
180
180
|
name: typeof Schema.String;
|
|
181
181
|
version: typeof Schema.String;
|
|
182
|
-
tsconfig: Schema.optional<Schema.declare<string | ((...args: Array<unknown>) => unknown) | URL
|
|
182
|
+
tsconfig: Schema.optional<Schema.declare<string | URL | ((...args: Array<unknown>) => unknown), string | URL | ((...args: Array<unknown>) => unknown), readonly [], never>>;
|
|
183
183
|
compilerOptions: Schema.optional<typeof Schema.Unknown>;
|
|
184
184
|
}>>>>>; /** Auto-detect external packages from `package.json` dependency fields. */
|
|
185
185
|
autoDetectDependencies: Schema.optional<Schema.mutable<Schema.Struct<{
|
|
@@ -227,7 +227,7 @@ declare const SingleApiConfig: Schema.mutable<Schema.Struct<{
|
|
|
227
227
|
default: () => ["markdownLink", "chatgpt", "claude"];
|
|
228
228
|
}>;
|
|
229
229
|
}>>>; /** Path to a `tsconfig.json` for this version. */
|
|
230
|
-
tsconfig: Schema.optional<Schema.declare<string | ((...args: Array<unknown>) => unknown) | URL
|
|
230
|
+
tsconfig: Schema.optional<Schema.declare<string | URL | ((...args: Array<unknown>) => unknown), string | URL | ((...args: Array<unknown>) => unknown), readonly [], never>>; /** TypeScript compiler options for Twoslash. */
|
|
231
231
|
compilerOptions: Schema.optional<typeof Schema.Unknown>;
|
|
232
232
|
}>>]>>>>; /** Shiki syntax-highlighting theme. */
|
|
233
233
|
theme: Schema.optional<Schema.Union<[typeof Schema.String, Schema.mutable<Schema.Struct<{
|
|
@@ -257,7 +257,7 @@ declare const SingleApiConfig: Schema.mutable<Schema.Struct<{
|
|
|
257
257
|
externalPackages: Schema.optional<Schema.mutable<Schema.Array$<Schema.mutable<Schema.Struct<{
|
|
258
258
|
name: typeof Schema.String;
|
|
259
259
|
version: typeof Schema.String;
|
|
260
|
-
tsconfig: Schema.optional<Schema.declare<string | ((...args: Array<unknown>) => unknown) | URL
|
|
260
|
+
tsconfig: Schema.optional<Schema.declare<string | URL | ((...args: Array<unknown>) => unknown), string | URL | ((...args: Array<unknown>) => unknown), readonly [], never>>;
|
|
261
261
|
compilerOptions: Schema.optional<typeof Schema.Unknown>;
|
|
262
262
|
}>>>>>; /** Auto-detect external packages from `package.json` dependency fields. */
|
|
263
263
|
autoDetectDependencies: Schema.optional<Schema.mutable<Schema.Struct<{
|
|
@@ -305,7 +305,7 @@ declare const SingleApiConfig: Schema.mutable<Schema.Struct<{
|
|
|
305
305
|
default: () => ["markdownLink", "chatgpt", "claude"];
|
|
306
306
|
}>;
|
|
307
307
|
}>>>; /** Path to a `tsconfig.json` for Twoslash. */
|
|
308
|
-
tsconfig: Schema.optional<Schema.declare<string | ((...args: Array<unknown>) => unknown) | URL
|
|
308
|
+
tsconfig: Schema.optional<Schema.declare<string | URL | ((...args: Array<unknown>) => unknown), string | URL | ((...args: Array<unknown>) => unknown), readonly [], never>>; /** TypeScript compiler options for Twoslash. */
|
|
309
309
|
compilerOptions: Schema.optional<typeof Schema.Unknown>;
|
|
310
310
|
}>>;
|
|
311
311
|
/** @public */
|
|
@@ -320,8 +320,8 @@ declare const MultiApiConfig: Schema.mutable<Schema.Struct<{
|
|
|
320
320
|
name: Schema.optional<typeof Schema.String>; /** Base URL route for this package's API pages. */
|
|
321
321
|
baseRoute: Schema.optional<typeof Schema.String>; /** Subfolder name under `baseRoute` for API pages, or `null` to omit. */
|
|
322
322
|
apiFolder: Schema.optional<Schema.Union<[typeof Schema.String, typeof Schema.Null]>>; /** Path or loader for the `.api.json` model file (required). */
|
|
323
|
-
model: Schema.declare<string | ((...args: Array<unknown>) => unknown) | URL
|
|
324
|
-
packageJson: Schema.optional<Schema.declare<string | ((...args: Array<unknown>) => unknown) | URL
|
|
323
|
+
model: Schema.declare<string | URL | ((...args: Array<unknown>) => unknown), string | URL | ((...args: Array<unknown>) => unknown), readonly [], never>; /** Path or loader for the `package.json`. */
|
|
324
|
+
packageJson: Schema.optional<Schema.declare<string | URL | ((...args: Array<unknown>) => unknown), string | URL | ((...args: Array<unknown>) => unknown), readonly [], never>>; /** Shiki syntax-highlighting theme. */
|
|
325
325
|
theme: Schema.optional<Schema.Union<[typeof Schema.String, Schema.mutable<Schema.Struct<{
|
|
326
326
|
light: typeof Schema.String;
|
|
327
327
|
dark: typeof Schema.String;
|
|
@@ -349,7 +349,7 @@ declare const MultiApiConfig: Schema.mutable<Schema.Struct<{
|
|
|
349
349
|
externalPackages: Schema.optional<Schema.mutable<Schema.Array$<Schema.mutable<Schema.Struct<{
|
|
350
350
|
name: typeof Schema.String;
|
|
351
351
|
version: typeof Schema.String;
|
|
352
|
-
tsconfig: Schema.optional<Schema.declare<string | ((...args: Array<unknown>) => unknown) | URL
|
|
352
|
+
tsconfig: Schema.optional<Schema.declare<string | URL | ((...args: Array<unknown>) => unknown), string | URL | ((...args: Array<unknown>) => unknown), readonly [], never>>;
|
|
353
353
|
compilerOptions: Schema.optional<typeof Schema.Unknown>;
|
|
354
354
|
}>>>>>; /** Auto-detect external packages from `package.json` dependency fields. */
|
|
355
355
|
autoDetectDependencies: Schema.optional<Schema.mutable<Schema.Struct<{
|
|
@@ -397,7 +397,7 @@ declare const MultiApiConfig: Schema.mutable<Schema.Struct<{
|
|
|
397
397
|
default: () => ["markdownLink", "chatgpt", "claude"];
|
|
398
398
|
}>;
|
|
399
399
|
}>>>; /** Path to a `tsconfig.json` for Twoslash. */
|
|
400
|
-
tsconfig: Schema.optional<Schema.declare<string | ((...args: Array<unknown>) => unknown) | URL
|
|
400
|
+
tsconfig: Schema.optional<Schema.declare<string | URL | ((...args: Array<unknown>) => unknown), string | URL | ((...args: Array<unknown>) => unknown), readonly [], never>>; /** TypeScript compiler options for Twoslash. */
|
|
401
401
|
compilerOptions: Schema.optional<typeof Schema.Unknown>;
|
|
402
402
|
}>>;
|
|
403
403
|
/** @public */
|
|
@@ -413,11 +413,11 @@ declare const PluginOptions: Schema.mutable<Schema.Struct<{
|
|
|
413
413
|
name: Schema.optional<typeof Schema.String>; /** Base URL route for API pages (defaults to `/api`). */
|
|
414
414
|
baseRoute: Schema.optional<typeof Schema.String>; /** Subfolder name under `baseRoute` for API pages, or `null` to omit. */
|
|
415
415
|
apiFolder: Schema.optional<Schema.Union<[typeof Schema.String, typeof Schema.Null]>>; /** Path or loader for the `.api.json` model file. */
|
|
416
|
-
model: Schema.optional<Schema.declare<string | ((...args: Array<unknown>) => unknown) | URL
|
|
417
|
-
packageJson: Schema.optional<Schema.declare<string | ((...args: Array<unknown>) => unknown) | URL
|
|
418
|
-
versions: Schema.optional<Schema.mutable<Schema.Record$<typeof Schema.String, Schema.Union<[Schema.declare<string | ((...args: Array<unknown>) => unknown) | URL
|
|
419
|
-
/** Path or loader for the `.api.json` model file for this version. */model: Schema.declare<string | ((...args: Array<unknown>) => unknown) | URL
|
|
420
|
-
packageJson: Schema.optional<Schema.declare<string | ((...args: Array<unknown>) => unknown) | URL
|
|
416
|
+
model: Schema.optional<Schema.declare<string | URL | ((...args: Array<unknown>) => unknown), string | URL | ((...args: Array<unknown>) => unknown), readonly [], never>>; /** Path or loader for the `package.json`. */
|
|
417
|
+
packageJson: Schema.optional<Schema.declare<string | URL | ((...args: Array<unknown>) => unknown), string | URL | ((...args: Array<unknown>) => unknown), readonly [], never>>; /** Versioned models keyed by version label. */
|
|
418
|
+
versions: Schema.optional<Schema.mutable<Schema.Record$<typeof Schema.String, Schema.Union<[Schema.declare<string | URL | ((...args: Array<unknown>) => unknown), string | URL | ((...args: Array<unknown>) => unknown), readonly [], never>, Schema.mutable<Schema.Struct<{
|
|
419
|
+
/** Path or loader for the `.api.json` model file for this version. */model: Schema.declare<string | URL | ((...args: Array<unknown>) => unknown), string | URL | ((...args: Array<unknown>) => unknown), readonly [], never>; /** Path or loader for the `package.json` for this version. */
|
|
420
|
+
packageJson: Schema.optional<Schema.declare<string | URL | ((...args: Array<unknown>) => unknown), string | URL | ((...args: Array<unknown>) => unknown), readonly [], never>>; /** Category overrides for this version. */
|
|
421
421
|
categories: Schema.optional<Schema.mutable<Schema.Record$<typeof Schema.String, Schema.mutable<Schema.Struct<{
|
|
422
422
|
/** Human-readable plural display name shown in the sidebar. */displayName: typeof Schema.String; /** Human-readable singular name used in page titles. */
|
|
423
423
|
singularName: typeof Schema.String; /** Folder name under the API base route (URL segment). */
|
|
@@ -441,7 +441,7 @@ declare const PluginOptions: Schema.mutable<Schema.Struct<{
|
|
|
441
441
|
externalPackages: Schema.optional<Schema.mutable<Schema.Array$<Schema.mutable<Schema.Struct<{
|
|
442
442
|
name: typeof Schema.String;
|
|
443
443
|
version: typeof Schema.String;
|
|
444
|
-
tsconfig: Schema.optional<Schema.declare<string | ((...args: Array<unknown>) => unknown) | URL
|
|
444
|
+
tsconfig: Schema.optional<Schema.declare<string | URL | ((...args: Array<unknown>) => unknown), string | URL | ((...args: Array<unknown>) => unknown), readonly [], never>>;
|
|
445
445
|
compilerOptions: Schema.optional<typeof Schema.Unknown>;
|
|
446
446
|
}>>>>>; /** Auto-detect external packages from `package.json` dependency fields. */
|
|
447
447
|
autoDetectDependencies: Schema.optional<Schema.mutable<Schema.Struct<{
|
|
@@ -489,7 +489,7 @@ declare const PluginOptions: Schema.mutable<Schema.Struct<{
|
|
|
489
489
|
default: () => ["markdownLink", "chatgpt", "claude"];
|
|
490
490
|
}>;
|
|
491
491
|
}>>>; /** Path to a `tsconfig.json` for this version. */
|
|
492
|
-
tsconfig: Schema.optional<Schema.declare<string | ((...args: Array<unknown>) => unknown) | URL
|
|
492
|
+
tsconfig: Schema.optional<Schema.declare<string | URL | ((...args: Array<unknown>) => unknown), string | URL | ((...args: Array<unknown>) => unknown), readonly [], never>>; /** TypeScript compiler options for Twoslash. */
|
|
493
493
|
compilerOptions: Schema.optional<typeof Schema.Unknown>;
|
|
494
494
|
}>>]>>>>; /** Shiki syntax-highlighting theme. */
|
|
495
495
|
theme: Schema.optional<Schema.Union<[typeof Schema.String, Schema.mutable<Schema.Struct<{
|
|
@@ -519,7 +519,7 @@ declare const PluginOptions: Schema.mutable<Schema.Struct<{
|
|
|
519
519
|
externalPackages: Schema.optional<Schema.mutable<Schema.Array$<Schema.mutable<Schema.Struct<{
|
|
520
520
|
name: typeof Schema.String;
|
|
521
521
|
version: typeof Schema.String;
|
|
522
|
-
tsconfig: Schema.optional<Schema.declare<string | ((...args: Array<unknown>) => unknown) | URL
|
|
522
|
+
tsconfig: Schema.optional<Schema.declare<string | URL | ((...args: Array<unknown>) => unknown), string | URL | ((...args: Array<unknown>) => unknown), readonly [], never>>;
|
|
523
523
|
compilerOptions: Schema.optional<typeof Schema.Unknown>;
|
|
524
524
|
}>>>>>; /** Auto-detect external packages from `package.json` dependency fields. */
|
|
525
525
|
autoDetectDependencies: Schema.optional<Schema.mutable<Schema.Struct<{
|
|
@@ -567,7 +567,7 @@ declare const PluginOptions: Schema.mutable<Schema.Struct<{
|
|
|
567
567
|
default: () => ["markdownLink", "chatgpt", "claude"];
|
|
568
568
|
}>;
|
|
569
569
|
}>>>; /** Path to a `tsconfig.json` for Twoslash. */
|
|
570
|
-
tsconfig: Schema.optional<Schema.declare<string | ((...args: Array<unknown>) => unknown) | URL
|
|
570
|
+
tsconfig: Schema.optional<Schema.declare<string | URL | ((...args: Array<unknown>) => unknown), string | URL | ((...args: Array<unknown>) => unknown), readonly [], never>>; /** TypeScript compiler options for Twoslash. */
|
|
571
571
|
compilerOptions: Schema.optional<typeof Schema.Unknown>;
|
|
572
572
|
}>>>; /** Multi-API portal configuration (mutually exclusive with `api`). */
|
|
573
573
|
apis: Schema.optional<Schema.mutable<Schema.Array$<Schema.mutable<Schema.Struct<{
|
|
@@ -575,8 +575,8 @@ declare const PluginOptions: Schema.mutable<Schema.Struct<{
|
|
|
575
575
|
name: Schema.optional<typeof Schema.String>; /** Base URL route for this package's API pages. */
|
|
576
576
|
baseRoute: Schema.optional<typeof Schema.String>; /** Subfolder name under `baseRoute` for API pages, or `null` to omit. */
|
|
577
577
|
apiFolder: Schema.optional<Schema.Union<[typeof Schema.String, typeof Schema.Null]>>; /** Path or loader for the `.api.json` model file (required). */
|
|
578
|
-
model: Schema.declare<string | ((...args: Array<unknown>) => unknown) | URL
|
|
579
|
-
packageJson: Schema.optional<Schema.declare<string | ((...args: Array<unknown>) => unknown) | URL
|
|
578
|
+
model: Schema.declare<string | URL | ((...args: Array<unknown>) => unknown), string | URL | ((...args: Array<unknown>) => unknown), readonly [], never>; /** Path or loader for the `package.json`. */
|
|
579
|
+
packageJson: Schema.optional<Schema.declare<string | URL | ((...args: Array<unknown>) => unknown), string | URL | ((...args: Array<unknown>) => unknown), readonly [], never>>; /** Shiki syntax-highlighting theme. */
|
|
580
580
|
theme: Schema.optional<Schema.Union<[typeof Schema.String, Schema.mutable<Schema.Struct<{
|
|
581
581
|
light: typeof Schema.String;
|
|
582
582
|
dark: typeof Schema.String;
|
|
@@ -604,7 +604,7 @@ declare const PluginOptions: Schema.mutable<Schema.Struct<{
|
|
|
604
604
|
externalPackages: Schema.optional<Schema.mutable<Schema.Array$<Schema.mutable<Schema.Struct<{
|
|
605
605
|
name: typeof Schema.String;
|
|
606
606
|
version: typeof Schema.String;
|
|
607
|
-
tsconfig: Schema.optional<Schema.declare<string | ((...args: Array<unknown>) => unknown) | URL
|
|
607
|
+
tsconfig: Schema.optional<Schema.declare<string | URL | ((...args: Array<unknown>) => unknown), string | URL | ((...args: Array<unknown>) => unknown), readonly [], never>>;
|
|
608
608
|
compilerOptions: Schema.optional<typeof Schema.Unknown>;
|
|
609
609
|
}>>>>>; /** Auto-detect external packages from `package.json` dependency fields. */
|
|
610
610
|
autoDetectDependencies: Schema.optional<Schema.mutable<Schema.Struct<{
|
|
@@ -652,7 +652,7 @@ declare const PluginOptions: Schema.mutable<Schema.Struct<{
|
|
|
652
652
|
default: () => ["markdownLink", "chatgpt", "claude"];
|
|
653
653
|
}>;
|
|
654
654
|
}>>>; /** Path to a `tsconfig.json` for Twoslash. */
|
|
655
|
-
tsconfig: Schema.optional<Schema.declare<string | ((...args: Array<unknown>) => unknown) | URL
|
|
655
|
+
tsconfig: Schema.optional<Schema.declare<string | URL | ((...args: Array<unknown>) => unknown), string | URL | ((...args: Array<unknown>) => unknown), readonly [], never>>; /** TypeScript compiler options for Twoslash. */
|
|
656
656
|
compilerOptions: Schema.optional<typeof Schema.Unknown>;
|
|
657
657
|
}>>>>>; /** Canonical site URL used for Open Graph absolute URLs. */
|
|
658
658
|
siteUrl: Schema.optional<typeof Schema.String>; /** Global Open Graph image configuration (overridden per-API). */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rspress-plugin-api-extractor",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "RSPress plugin for generating API documentation from TypeScript API Extractor models",
|
|
6
6
|
"keywords": [
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@effect/sql-sqlite-node": "^0.52.0",
|
|
39
39
|
"@microsoft/api-extractor-model": "^7.33.8",
|
|
40
40
|
"@shikijs/twoslash": "^4.3.0",
|
|
41
|
-
"api-extractor-llms": "0.
|
|
41
|
+
"api-extractor-llms": "0.2.0",
|
|
42
42
|
"clsx": "^2.1.1",
|
|
43
43
|
"effect": "^3.21.4",
|
|
44
44
|
"gray-matter": "^4.0.3",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"mdast-util-from-markdown": "^2.0.3",
|
|
48
48
|
"mdast-util-to-hast": "^13.2.1",
|
|
49
49
|
"open": "^11.0.0",
|
|
50
|
-
"prettier": "^3.8.
|
|
50
|
+
"prettier": "^3.8.5",
|
|
51
51
|
"react-markdown": "^10.1.0",
|
|
52
52
|
"semver-effect": "^0.2.1",
|
|
53
53
|
"shiki": "^4.3.0",
|
|
@@ -183,10 +183,8 @@ var TypeReferenceExtractor = class {
|
|
|
183
183
|
const isBuiltIn = packagePart === "" || packagePart.startsWith("\"");
|
|
184
184
|
const isInternal = packagePart === this.currentPackageName;
|
|
185
185
|
let symbolName;
|
|
186
|
-
if (symbolText.includes("."))
|
|
187
|
-
|
|
188
|
-
symbolName = parts[parts.length - 1].trim();
|
|
189
|
-
} else symbolName = symbolFromCanonical.trim();
|
|
186
|
+
if (symbolText.includes(".")) symbolName = symbolText.split(".")[0].trim();
|
|
187
|
+
else symbolName = symbolFromCanonical.trim();
|
|
190
188
|
return {
|
|
191
189
|
symbolName,
|
|
192
190
|
packageName: packagePart,
|