vitepress-plugin-api-extractor 0.1.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/ApiExtractor.js +96 -0
- package/Categories.js +49 -0
- package/Generate.js +220 -0
- package/Registry.js +117 -0
- package/Twoslash.js +43 -0
- package/TwoslashCache.js +102 -0
- package/emit/frontmatter.js +58 -0
- package/emit/markdown.js +199 -0
- package/emit/sidebar.js +37 -0
- package/index.d.ts +477 -0
- package/index.js +11 -0
- package/package.json +65 -0
- package/tsdoc-metadata.json +11 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,477 @@
|
|
|
1
|
+
import { ShikiTransformer } from "shiki";
|
|
2
|
+
import { Block, CrossLinkData, NavTree, Page, WorkItemCategory } from "@tsdoctor/pages";
|
|
3
|
+
import { Model } from "@tsdoctor/model";
|
|
4
|
+
import { TypeRegistry } from "@tsdoctor/registry";
|
|
5
|
+
import { TwoslashCacheStats, TwoslashResultCache, TypeResolutionCompilerOptions, Vfs } from "@tsdoctor/vfs";
|
|
6
|
+
import { Context, Effect, FileSystem, Layer, Option, Path, Result } from "effect";
|
|
7
|
+
import "@effected/xdg";
|
|
8
|
+
import { HeadTag } from "@tsdoctor/seo";
|
|
9
|
+
import { FlowContent, MarkdownStringifyError } from "@effected/markdown";
|
|
10
|
+
import { TwoslashTypesCache } from "@shikijs/twoslash";
|
|
11
|
+
//#region src/Categories.d.ts
|
|
12
|
+
/**
|
|
13
|
+
* A category as this adapter configures it: how items match it, where its
|
|
14
|
+
* pages live, and how its sidebar group presents.
|
|
15
|
+
*
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
interface CategoryConfig extends WorkItemCategory {
|
|
19
|
+
/** Whether the sidebar group can be collapsed. Defaults to `true`. */
|
|
20
|
+
readonly collapsible?: boolean | undefined;
|
|
21
|
+
/** Whether the sidebar group starts collapsed. Defaults to `true`. */
|
|
22
|
+
readonly collapsed?: boolean | undefined;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The default categories, in sidebar order.
|
|
26
|
+
*
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
declare const DEFAULT_CATEGORIES: Readonly<Record<string, CategoryConfig>>;
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/emit/sidebar.d.ts
|
|
32
|
+
/**
|
|
33
|
+
* One VitePress sidebar item — the subset of the default theme's
|
|
34
|
+
* `SidebarItem` this adapter emits. Arrays are mutable because VitePress's
|
|
35
|
+
* own `Sidebar` type is, and a `ReadonlyArray` would not assign to it.
|
|
36
|
+
*
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
interface SidebarItem {
|
|
40
|
+
/** The item label. */
|
|
41
|
+
readonly text: string;
|
|
42
|
+
/** The page route, when the item is a link. */
|
|
43
|
+
readonly link?: string;
|
|
44
|
+
/** Child items, when the item is a group. */
|
|
45
|
+
readonly items?: SidebarItem[];
|
|
46
|
+
/** Whether a group starts collapsed; absent leaves it always open. */
|
|
47
|
+
readonly collapsed?: boolean;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* A multi-sidebar object: sidebar items keyed by the path prefix they
|
|
51
|
+
* apply to.
|
|
52
|
+
*
|
|
53
|
+
* @public
|
|
54
|
+
*/
|
|
55
|
+
type SidebarMulti = Record<string, SidebarItem[]>;
|
|
56
|
+
/**
|
|
57
|
+
* The sidebar items for one API: the index link, then one group per
|
|
58
|
+
* category in the tree's order.
|
|
59
|
+
*
|
|
60
|
+
* @public
|
|
61
|
+
*/
|
|
62
|
+
declare function sidebarItems(tree: NavTree): SidebarItem[];
|
|
63
|
+
/**
|
|
64
|
+
* The `themeConfig.sidebar` entry for one API, keyed by its base route so
|
|
65
|
+
* the sidebar shows only under the API's pages.
|
|
66
|
+
*
|
|
67
|
+
* @public
|
|
68
|
+
*/
|
|
69
|
+
declare function sidebarFor(tree: NavTree): SidebarMulti;
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/Registry.d.ts
|
|
72
|
+
/**
|
|
73
|
+
* The XDG namespace every tsdoctor cache lives under — shared with the
|
|
74
|
+
* RSPress plugin so both adapters read one type cache and one Twoslash
|
|
75
|
+
* result cache.
|
|
76
|
+
*
|
|
77
|
+
* @public
|
|
78
|
+
*/
|
|
79
|
+
declare const TSDOCTOR_NAMESPACE = "tsdoctor";
|
|
80
|
+
/**
|
|
81
|
+
* An external package to load declarations for.
|
|
82
|
+
*
|
|
83
|
+
* @public
|
|
84
|
+
*/
|
|
85
|
+
interface ExternalPackage {
|
|
86
|
+
/** The npm package name. */
|
|
87
|
+
readonly name: string;
|
|
88
|
+
/** The version spec as declared: exact, range or dist-tag. */
|
|
89
|
+
readonly version: string;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* The outcome of {@link loadExternalTypes}: what merged, what was skipped
|
|
93
|
+
* and why. Never a failure.
|
|
94
|
+
*
|
|
95
|
+
* @public
|
|
96
|
+
*/
|
|
97
|
+
interface ExternalTypesReport {
|
|
98
|
+
/** Packages whose declarations were merged. */
|
|
99
|
+
readonly loaded: ReadonlyArray<string>;
|
|
100
|
+
/** Packages dropped because no published version matched, or loading failed. */
|
|
101
|
+
readonly skipped: ReadonlyArray<string>;
|
|
102
|
+
/** A human-readable reason when the whole batch degraded. */
|
|
103
|
+
readonly warning?: string;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* The external packages a documented package's manifest declares, in the
|
|
107
|
+
* `dependencies` and `peerDependencies` fields.
|
|
108
|
+
*
|
|
109
|
+
* @public
|
|
110
|
+
*/
|
|
111
|
+
declare function externalPackagesOf(packageJson: Record<string, unknown> | undefined): ReadonlyArray<ExternalPackage>;
|
|
112
|
+
/**
|
|
113
|
+
* Resolve each package to an exact published version and merge its
|
|
114
|
+
* declarations into `vfs`, in place. First-party packages (the ones being
|
|
115
|
+
* documented) are excluded: their api.json-derived declarations are
|
|
116
|
+
* authoritative and a published copy would clobber them.
|
|
117
|
+
*
|
|
118
|
+
* @remarks
|
|
119
|
+
* Degrades, never fails: an unresolvable package is skipped, and an
|
|
120
|
+
* infrastructure failure (no HOME for XDG, an unreachable CDN) leaves the
|
|
121
|
+
* VFS as it was with a `warning` in the report.
|
|
122
|
+
*
|
|
123
|
+
* @public
|
|
124
|
+
*/
|
|
125
|
+
declare const loadExternalTypes: (vfs: Vfs, packages: readonly ExternalPackage[], documented: ReadonlySet<string>) => Effect.Effect<{
|
|
126
|
+
loaded: never[];
|
|
127
|
+
skipped: string[];
|
|
128
|
+
warning: string;
|
|
129
|
+
} | {
|
|
130
|
+
warning?: never;
|
|
131
|
+
loaded: string[];
|
|
132
|
+
skipped: string[];
|
|
133
|
+
}, never, TypeRegistry>;
|
|
134
|
+
//#endregion
|
|
135
|
+
//#region src/Generate.d.ts
|
|
136
|
+
/**
|
|
137
|
+
* The input to {@link generate}.
|
|
138
|
+
*
|
|
139
|
+
* @public
|
|
140
|
+
*/
|
|
141
|
+
interface GenerateInput {
|
|
142
|
+
/** The bundle folder: the api.json model plus its package.json and tsconfig. */
|
|
143
|
+
readonly dir: string;
|
|
144
|
+
/** Base for resolving `dir` and `docsDir`. */
|
|
145
|
+
readonly cwd: string;
|
|
146
|
+
/** VitePress's source directory; pages are written under it. */
|
|
147
|
+
readonly docsDir: string;
|
|
148
|
+
/** The route the API is mounted at, e.g. `/api`. */
|
|
149
|
+
readonly baseRoute: string;
|
|
150
|
+
/** The API's display name — the last title part, when the site names one. */
|
|
151
|
+
readonly apiName?: string | undefined;
|
|
152
|
+
/** The site origin, for canonical and Open Graph URLs; absent leaves them root-relative. */
|
|
153
|
+
readonly siteOrigin?: string | undefined;
|
|
154
|
+
/** VitePress's `base`. */
|
|
155
|
+
readonly base?: string | undefined;
|
|
156
|
+
/** Category overrides, merged over {@link DEFAULT_CATEGORIES} by key. */
|
|
157
|
+
readonly categories?: Readonly<Record<string, Partial<CategoryConfig>>> | undefined;
|
|
158
|
+
/** External packages to load declarations for; defaults to the manifest's dependencies. */
|
|
159
|
+
readonly externalPackages?: ReadonlyArray<ExternalPackage> | undefined;
|
|
160
|
+
/** Whether examples carry `@noErrors`; defaults to `true`. */
|
|
161
|
+
readonly suppressExampleErrors?: boolean | undefined;
|
|
162
|
+
/** The source repository, when the site links to it. */
|
|
163
|
+
readonly source?: {
|
|
164
|
+
readonly url: string;
|
|
165
|
+
readonly ref?: string | undefined;
|
|
166
|
+
} | undefined;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* What generation produced, for the site's config and for the report.
|
|
170
|
+
*
|
|
171
|
+
* @public
|
|
172
|
+
*/
|
|
173
|
+
interface GenerateResult {
|
|
174
|
+
/** The documented package's name. */
|
|
175
|
+
readonly packageName: string;
|
|
176
|
+
/** The API's base route. */
|
|
177
|
+
readonly baseRoute: string;
|
|
178
|
+
/** The `themeConfig.sidebar` entry. */
|
|
179
|
+
readonly sidebar: SidebarMulti;
|
|
180
|
+
/** The combined virtual file system Twoslash checks against. */
|
|
181
|
+
readonly vfs: Vfs;
|
|
182
|
+
/** The resolved compiler options. */
|
|
183
|
+
readonly compilerOptions: TypeResolutionCompilerOptions;
|
|
184
|
+
/** Every page route written, in generation order. */
|
|
185
|
+
readonly routes: ReadonlyArray<string>;
|
|
186
|
+
/** The cross-link route map the pages were linked against. */
|
|
187
|
+
readonly crossLinkData: CrossLinkData;
|
|
188
|
+
/** What external type loading did. */
|
|
189
|
+
readonly externalTypes: ExternalTypesReport;
|
|
190
|
+
/** Items no category matched; they got no page. */
|
|
191
|
+
readonly uncategorized: ReadonlyArray<string>;
|
|
192
|
+
/** Items whose examples Prettier could not format, by display name. */
|
|
193
|
+
readonly formatFailures: ReadonlyArray<string>;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Generate the API pages for one bundle.
|
|
197
|
+
*
|
|
198
|
+
* @remarks
|
|
199
|
+
* Fails typed on what a user can fix — a missing bundle folder, an
|
|
200
|
+
* unreadable model — and degrades on what is an enhancement (external types,
|
|
201
|
+
* a manifest the SEO layer cannot decode, an example Prettier rejects). The
|
|
202
|
+
* error channel is the union of `@tsdoctor/bundle`'s discovery errors,
|
|
203
|
+
* `@tsdoctor/model`'s load errors and the platform's write errors.
|
|
204
|
+
*
|
|
205
|
+
* @public
|
|
206
|
+
*/
|
|
207
|
+
declare const generate: (input: GenerateInput) => Effect.Effect<{
|
|
208
|
+
packageName: string;
|
|
209
|
+
baseRoute: string;
|
|
210
|
+
sidebar: SidebarMulti;
|
|
211
|
+
vfs: Vfs;
|
|
212
|
+
compilerOptions: {
|
|
213
|
+
readonly target?: "es2015" | "es2016" | "es2017" | "es2018" | "es2019" | "es2020" | "es2021" | "es2022" | "es2023" | "es2024" | "es2025" | "es5" | "es6" | "esnext";
|
|
214
|
+
readonly module?: "amd" | "commonjs" | "es2015" | "es2020" | "es2022" | "es6" | "esnext" | "node16" | "node18" | "node20" | "nodenext" | "none" | "preserve" | "system" | "umd";
|
|
215
|
+
readonly moduleResolution?: "bundler" | "classic" | "node" | "node10" | "node16" | "nodenext";
|
|
216
|
+
readonly jsx?: "preserve" | "react" | "react-jsx" | "react-jsxdev" | "react-native";
|
|
217
|
+
readonly lib?: readonly ("decorators" | "decorators.legacy" | "dom" | "dom.asynciterable" | "dom.iterable" | "es2015" | "es2015.collection" | "es2015.core" | "es2015.generator" | "es2015.iterable" | "es2015.promise" | "es2015.proxy" | "es2015.reflect" | "es2015.symbol" | "es2015.symbol.wellknown" | "es2016" | "es2016.array.include" | "es2016.intl" | "es2017" | "es2017.arraybuffer" | "es2017.date" | "es2017.intl" | "es2017.object" | "es2017.sharedmemory" | "es2017.string" | "es2017.typedarrays" | "es2018" | "es2018.asyncgenerator" | "es2018.asynciterable" | "es2018.intl" | "es2018.promise" | "es2018.regexp" | "es2019" | "es2019.array" | "es2019.intl" | "es2019.object" | "es2019.string" | "es2019.symbol" | "es2020" | "es2020.bigint" | "es2020.date" | "es2020.intl" | "es2020.number" | "es2020.promise" | "es2020.sharedmemory" | "es2020.string" | "es2020.symbol.wellknown" | "es2021" | "es2021.intl" | "es2021.promise" | "es2021.string" | "es2021.weakref" | "es2022" | "es2022.array" | "es2022.error" | "es2022.intl" | "es2022.object" | "es2022.regexp" | "es2022.string" | "es2023" | "es2023.array" | "es2023.collection" | "es2023.intl" | "es2024" | "es2024.arraybuffer" | "es2024.collection" | "es2024.object" | "es2024.promise" | "es2024.regexp" | "es2024.sharedmemory" | "es2024.string" | "es2025" | "es2025.collection" | "es2025.float16" | "es2025.intl" | "es2025.iterator" | "es2025.promise" | "es2025.regexp" | "es5" | "es6" | "es7" | "esnext" | "esnext.array" | "esnext.asynciterable" | "esnext.bigint" | "esnext.collection" | "esnext.date" | "esnext.decorators" | "esnext.disposable" | "esnext.error" | "esnext.float16" | "esnext.intl" | "esnext.iterator" | "esnext.object" | "esnext.promise" | "esnext.regexp" | "esnext.sharedmemory" | "esnext.string" | "esnext.symbol" | "esnext.temporal" | "esnext.typedarrays" | "esnext.weakref" | "scripthost" | "webworker" | "webworker.asynciterable" | "webworker.importscripts" | "webworker.iterable")[];
|
|
218
|
+
readonly types?: readonly string[];
|
|
219
|
+
readonly typeRoots?: readonly string[];
|
|
220
|
+
readonly strict?: boolean;
|
|
221
|
+
readonly skipLibCheck?: boolean;
|
|
222
|
+
readonly esModuleInterop?: boolean;
|
|
223
|
+
readonly allowSyntheticDefaultImports?: boolean;
|
|
224
|
+
};
|
|
225
|
+
routes: string[];
|
|
226
|
+
crossLinkData: CrossLinkData;
|
|
227
|
+
externalTypes: {
|
|
228
|
+
loaded: never[];
|
|
229
|
+
skipped: string[];
|
|
230
|
+
warning: string;
|
|
231
|
+
} | {
|
|
232
|
+
warning?: never;
|
|
233
|
+
loaded: string[];
|
|
234
|
+
skipped: string[];
|
|
235
|
+
};
|
|
236
|
+
uncategorized: string[];
|
|
237
|
+
formatFailures: string[];
|
|
238
|
+
}, import("@tsdoctor/bundle").BundleDiscoveryError | import("@tsdoctor/bundle").BundleLayerError | Model.ModelNotFoundError | Model.ModelParseError | import("effect/PlatformError").PlatformError, FileSystem.FileSystem | Path.Path | TypeRegistry>;
|
|
239
|
+
/**
|
|
240
|
+
* The services {@link generate} runs over: the platform plus the registry.
|
|
241
|
+
*
|
|
242
|
+
* @public
|
|
243
|
+
*/
|
|
244
|
+
type GenerateServices = FileSystem.FileSystem | Path.Path | TypeRegistry;
|
|
245
|
+
//#endregion
|
|
246
|
+
//#region src/TwoslashCache.d.ts
|
|
247
|
+
/**
|
|
248
|
+
* The stats a persisted generation reports, with the environment it was
|
|
249
|
+
* stored under.
|
|
250
|
+
*
|
|
251
|
+
* @public
|
|
252
|
+
*/
|
|
253
|
+
interface TwoslashCacheReport extends TwoslashCacheStats {
|
|
254
|
+
/** The type-environment hash the generation is keyed by. */
|
|
255
|
+
readonly envHash: string;
|
|
256
|
+
/** Whether the underlying store degraded at construction. */
|
|
257
|
+
readonly degraded: boolean;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* The Twoslash generation store's contract.
|
|
261
|
+
*
|
|
262
|
+
* @public
|
|
263
|
+
*/
|
|
264
|
+
interface TwoslashCacheStoreShape {
|
|
265
|
+
/**
|
|
266
|
+
* Open the generation for `envHash` — seeded from the store — and hold it
|
|
267
|
+
* until {@link TwoslashCacheStoreShape.persist}.
|
|
268
|
+
*/
|
|
269
|
+
readonly open: (envHash: string) => Effect.Effect<TwoslashResultCache>;
|
|
270
|
+
/**
|
|
271
|
+
* Persist what this build produced, if a generation was opened and it is
|
|
272
|
+
* dirty; report the stats either way.
|
|
273
|
+
*/
|
|
274
|
+
readonly persist: () => Effect.Effect<Option.Option<TwoslashCacheReport>>;
|
|
275
|
+
}
|
|
276
|
+
declare const TwoslashCacheStore_base: Context.ServiceClass<TwoslashCacheStore, "vitepress-plugin-api-extractor/TwoslashCacheStore", TwoslashCacheStoreShape>;
|
|
277
|
+
/**
|
|
278
|
+
* The Twoslash generation store.
|
|
279
|
+
*
|
|
280
|
+
* @public
|
|
281
|
+
*/
|
|
282
|
+
declare class TwoslashCacheStore extends TwoslashCacheStore_base {
|
|
283
|
+
/**
|
|
284
|
+
* The live store over the XDG sqlite cache.
|
|
285
|
+
*
|
|
286
|
+
* @remarks
|
|
287
|
+
* `Layer.suspend` because the composition below is declared after this
|
|
288
|
+
* class: a static initializer runs while the module body is still
|
|
289
|
+
* evaluating, so naming those consts directly throws at import time with a
|
|
290
|
+
* clean typecheck.
|
|
291
|
+
*/
|
|
292
|
+
static readonly layer: Layer.Layer<TwoslashCacheStore>;
|
|
293
|
+
/** An always-cold in-memory store, for tests. */
|
|
294
|
+
static readonly layerTest: Layer.Layer<TwoslashCacheStore>;
|
|
295
|
+
}
|
|
296
|
+
//#endregion
|
|
297
|
+
//#region src/ApiExtractor.d.ts
|
|
298
|
+
/**
|
|
299
|
+
* The options {@link apiExtractor} takes.
|
|
300
|
+
*
|
|
301
|
+
* @public
|
|
302
|
+
*/
|
|
303
|
+
interface ApiExtractorOptions {
|
|
304
|
+
/** The bundle folder: the api.json model plus its package.json and tsconfig. */
|
|
305
|
+
readonly dir: string;
|
|
306
|
+
/** Base for resolving `dir` and `docsDir`. Defaults to `process.cwd()`. */
|
|
307
|
+
readonly cwd?: string | undefined;
|
|
308
|
+
/** VitePress's source directory. Defaults to `docs`. */
|
|
309
|
+
readonly docsDir?: string | undefined;
|
|
310
|
+
/** The route the API is mounted at. Defaults to `/api`. */
|
|
311
|
+
readonly baseRoute?: string | undefined;
|
|
312
|
+
/** The API's display name — the last title part, when the site names one. */
|
|
313
|
+
readonly name?: string | undefined;
|
|
314
|
+
/** The site origin, for canonical and Open Graph URLs. */
|
|
315
|
+
readonly siteOrigin?: string | undefined;
|
|
316
|
+
/** VitePress's `base`, when set. */
|
|
317
|
+
readonly base?: string | undefined;
|
|
318
|
+
/** Category overrides, merged over the defaults by key. */
|
|
319
|
+
readonly categories?: Readonly<Record<string, Partial<CategoryConfig>>> | undefined;
|
|
320
|
+
/** External packages to load declarations for; defaults to the manifest's dependencies. */
|
|
321
|
+
readonly externalPackages?: ReadonlyArray<ExternalPackage> | undefined;
|
|
322
|
+
/** Whether examples carry `@noErrors`. Defaults to `true`. */
|
|
323
|
+
readonly suppressExampleErrors?: boolean | undefined;
|
|
324
|
+
/** The source repository, when the site links to it. */
|
|
325
|
+
readonly source?: {
|
|
326
|
+
readonly url: string;
|
|
327
|
+
readonly ref?: string | undefined;
|
|
328
|
+
} | undefined;
|
|
329
|
+
/** Whether to print a one-line summary. Defaults to `true`. */
|
|
330
|
+
readonly log?: boolean | undefined;
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* What {@link apiExtractor} returns for the site to merge into its config.
|
|
334
|
+
*
|
|
335
|
+
* @public
|
|
336
|
+
*/
|
|
337
|
+
interface ApiExtractorResult {
|
|
338
|
+
/** The `themeConfig.sidebar` entry for the API. */
|
|
339
|
+
readonly sidebar: SidebarMulti;
|
|
340
|
+
/** The `markdown.codeTransformers` entries: the Twoslash transformer. */
|
|
341
|
+
readonly codeTransformers: ReadonlyArray<ShikiTransformer>;
|
|
342
|
+
/** Hooks for the site's config. */
|
|
343
|
+
readonly hooks: {
|
|
344
|
+
/** Persist the Twoslash result cache; the site's `buildEnd`. */
|
|
345
|
+
readonly buildEnd: () => Promise<TwoslashCacheReport | undefined>;
|
|
346
|
+
};
|
|
347
|
+
/** What generation produced. */
|
|
348
|
+
readonly generated: GenerateResult;
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Generate the API pages and return what the site's config needs.
|
|
352
|
+
*
|
|
353
|
+
* @example
|
|
354
|
+
* ```ts
|
|
355
|
+
* // .vitepress/config.mts
|
|
356
|
+
* import { defineConfig } from "vitepress";
|
|
357
|
+
* import { apiExtractor } from "vitepress-plugin-api-extractor";
|
|
358
|
+
*
|
|
359
|
+
* const api = await apiExtractor({ dir: "./lib/models/kitchensink" });
|
|
360
|
+
*
|
|
361
|
+
* export default defineConfig({
|
|
362
|
+
* themeConfig: { sidebar: api.sidebar },
|
|
363
|
+
* markdown: { codeTransformers: [...api.codeTransformers] },
|
|
364
|
+
* buildEnd: async () => { await api.hooks.buildEnd(); },
|
|
365
|
+
* });
|
|
366
|
+
* ```
|
|
367
|
+
*
|
|
368
|
+
* @public
|
|
369
|
+
*/
|
|
370
|
+
declare function apiExtractor(options: ApiExtractorOptions): Promise<ApiExtractorResult>;
|
|
371
|
+
//#endregion
|
|
372
|
+
//#region src/emit/frontmatter.d.ts
|
|
373
|
+
/**
|
|
374
|
+
* One VitePress head entry: a pair for an attribute-only tag, a triple when
|
|
375
|
+
* the tag carries inner HTML.
|
|
376
|
+
*
|
|
377
|
+
* @public
|
|
378
|
+
*/
|
|
379
|
+
type HeadConfig = [string, Record<string, string>] | [string, Record<string, string>, string];
|
|
380
|
+
/**
|
|
381
|
+
* Render a neutral head tag into VitePress's `HeadConfig` entry.
|
|
382
|
+
*
|
|
383
|
+
* @public
|
|
384
|
+
*/
|
|
385
|
+
declare function headConfig(tag: HeadTag): HeadConfig;
|
|
386
|
+
/**
|
|
387
|
+
* The facts a page's frontmatter is built from.
|
|
388
|
+
*
|
|
389
|
+
* @public
|
|
390
|
+
*/
|
|
391
|
+
interface FrontmatterInput {
|
|
392
|
+
/** The page title. */
|
|
393
|
+
readonly title: string;
|
|
394
|
+
/** The page description. */
|
|
395
|
+
readonly description: string;
|
|
396
|
+
/** Every head tag the page carries. */
|
|
397
|
+
readonly headTags?: ReadonlyArray<HeadTag> | undefined;
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Emit the frontmatter block for a page: `title`, `description` and, when
|
|
401
|
+
* the page carries any, `head` in VitePress's `HeadConfig[]` shape.
|
|
402
|
+
*
|
|
403
|
+
* @public
|
|
404
|
+
*/
|
|
405
|
+
declare function emitFrontmatter(input: FrontmatterInput): string;
|
|
406
|
+
//#endregion
|
|
407
|
+
//#region src/emit/markdown.d.ts
|
|
408
|
+
/**
|
|
409
|
+
* The fence info string that triggers Twoslash under VitePress's default
|
|
410
|
+
* `explicitTrigger`.
|
|
411
|
+
*
|
|
412
|
+
* @public
|
|
413
|
+
*/
|
|
414
|
+
declare const TWOSLASH_META = "twoslash";
|
|
415
|
+
/**
|
|
416
|
+
* Render one block to flow nodes.
|
|
417
|
+
*
|
|
418
|
+
* @public
|
|
419
|
+
*/
|
|
420
|
+
declare function markdownBlockTree(block: Block): ReadonlyArray<FlowContent>;
|
|
421
|
+
/**
|
|
422
|
+
* Render a page's body to flow nodes — the pre-serialization form of
|
|
423
|
+
* {@link emitMarkdownBody}.
|
|
424
|
+
*
|
|
425
|
+
* @public
|
|
426
|
+
*/
|
|
427
|
+
declare function markdownTree(page: Page): ReadonlyArray<FlowContent>;
|
|
428
|
+
/**
|
|
429
|
+
* Emit a page's markdown body. No frontmatter — the adapter assembles that
|
|
430
|
+
* from the page facts (see `emit/frontmatter.ts`).
|
|
431
|
+
*
|
|
432
|
+
* @remarks
|
|
433
|
+
* A stringify failure is surfaced rather than thrown: the prose inside a
|
|
434
|
+
* block arrived from a builder and may carry any node the kit admits, and the
|
|
435
|
+
* kit's own error names what it could not serialize.
|
|
436
|
+
*
|
|
437
|
+
* @public
|
|
438
|
+
*/
|
|
439
|
+
declare function emitMarkdownBody(page: Page): Result.Result<string, MarkdownStringifyError>;
|
|
440
|
+
//#endregion
|
|
441
|
+
//#region src/Twoslash.d.ts
|
|
442
|
+
/**
|
|
443
|
+
* Everything one Twoslash transformer needs.
|
|
444
|
+
*
|
|
445
|
+
* @public
|
|
446
|
+
*/
|
|
447
|
+
interface TwoslashTransformerOptions {
|
|
448
|
+
/** Declaration files every code block is checked against. */
|
|
449
|
+
readonly vfs: Vfs;
|
|
450
|
+
/** The configuration to check under; defaults apply when omitted. */
|
|
451
|
+
readonly compilerOptions?: TypeResolutionCompilerOptions | undefined;
|
|
452
|
+
/** The persisted result cache; a hit skips the type-check entirely. */
|
|
453
|
+
readonly typesCache?: TwoslashTypesCache | undefined;
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Fingerprint the type environment: the declarations plus the compiler that
|
|
457
|
+
* interprets them, so a generation cached by one TypeScript is never served
|
|
458
|
+
* by another.
|
|
459
|
+
*
|
|
460
|
+
* @public
|
|
461
|
+
*/
|
|
462
|
+
declare function environmentHash(vfs: Vfs): string;
|
|
463
|
+
/**
|
|
464
|
+
* Build the Shiki transformer for VitePress's `markdown.codeTransformers`.
|
|
465
|
+
*
|
|
466
|
+
* @remarks
|
|
467
|
+
* Errors never throw: `noErrorValidation` lets a diagnostic render as an
|
|
468
|
+
* annotation, and `throws: false` keeps `@shikijs/vitepress-twoslash` from
|
|
469
|
+
* failing the build on one (it would, by default, on CI). Examples are
|
|
470
|
+
* documentation, not a test suite.
|
|
471
|
+
*
|
|
472
|
+
* @public
|
|
473
|
+
*/
|
|
474
|
+
declare function makeTwoslashTransformer(options: TwoslashTransformerOptions): ShikiTransformer;
|
|
475
|
+
//#endregion
|
|
476
|
+
export { type ApiExtractorOptions, type ApiExtractorResult, type CategoryConfig, DEFAULT_CATEGORIES, type ExternalPackage, type ExternalTypesReport, type FrontmatterInput, type GenerateInput, type GenerateResult, type GenerateServices, type HeadConfig, type SidebarItem, type SidebarMulti, TSDOCTOR_NAMESPACE, TWOSLASH_META, type TwoslashCacheReport, TwoslashCacheStore, type TwoslashCacheStoreShape, type TwoslashTransformerOptions, apiExtractor, emitFrontmatter, emitMarkdownBody, environmentHash, externalPackagesOf, generate, headConfig, loadExternalTypes, makeTwoslashTransformer, markdownBlockTree, markdownTree, sidebarFor, sidebarItems };
|
|
477
|
+
//# sourceMappingURL=index.d.ts.map
|
package/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DEFAULT_CATEGORIES } from "./Categories.js";
|
|
2
|
+
import { emitFrontmatter, headConfig } from "./emit/frontmatter.js";
|
|
3
|
+
import { TWOSLASH_META, emitMarkdownBody, markdownBlockTree, markdownTree } from "./emit/markdown.js";
|
|
4
|
+
import { sidebarFor, sidebarItems } from "./emit/sidebar.js";
|
|
5
|
+
import { TSDOCTOR_NAMESPACE, externalPackagesOf, loadExternalTypes } from "./Registry.js";
|
|
6
|
+
import { generate } from "./Generate.js";
|
|
7
|
+
import { environmentHash, makeTwoslashTransformer } from "./Twoslash.js";
|
|
8
|
+
import { TwoslashCacheStore } from "./TwoslashCache.js";
|
|
9
|
+
import { apiExtractor } from "./ApiExtractor.js";
|
|
10
|
+
|
|
11
|
+
export { DEFAULT_CATEGORIES, TSDOCTOR_NAMESPACE, TWOSLASH_META, TwoslashCacheStore, apiExtractor, emitFrontmatter, emitMarkdownBody, environmentHash, externalPackagesOf, generate, headConfig, loadExternalTypes, makeTwoslashTransformer, markdownBlockTree, markdownTree, sidebarFor, sidebarItems };
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "vitepress-plugin-api-extractor",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "VitePress adapter for generating API documentation from TypeScript API Extractor models: markdown pages over the @tsdoctor/pages IR, a sidebar from its navigation tree, and Twoslash type-checking over the same virtual file system the RSPress plugin resolves.",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"vitepress",
|
|
8
|
+
"plugin",
|
|
9
|
+
"api-extractor",
|
|
10
|
+
"documentation",
|
|
11
|
+
"typescript",
|
|
12
|
+
"twoslash"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://github.com/spencerbeggs/tsdoctor#readme",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/spencerbeggs/tsdoctor/issues"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/spencerbeggs/tsdoctor.git",
|
|
21
|
+
"directory": "platforms/vitepress"
|
|
22
|
+
},
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"author": {
|
|
25
|
+
"name": "C. Spencer Beggs",
|
|
26
|
+
"email": "spencer@beggs.codes",
|
|
27
|
+
"url": "https://spencerbeg.gs"
|
|
28
|
+
},
|
|
29
|
+
"sideEffects": false,
|
|
30
|
+
"type": "module",
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"types": "./index.d.ts",
|
|
34
|
+
"import": "./index.js",
|
|
35
|
+
"default": "./index.js"
|
|
36
|
+
},
|
|
37
|
+
"./package.json": "./package.json"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@effect/platform-node": "4.0.0-rc.109",
|
|
41
|
+
"@effected/markdown": "^0.8.0",
|
|
42
|
+
"@effected/package-json": "^0.13.0",
|
|
43
|
+
"@effected/store": "^0.6.0",
|
|
44
|
+
"@effected/tsconfig-json": "^0.7.0",
|
|
45
|
+
"@effected/xdg": "^0.3.0",
|
|
46
|
+
"@microsoft/api-extractor-model": "^7.33.11",
|
|
47
|
+
"@shikijs/twoslash": "^4.4.3",
|
|
48
|
+
"@shikijs/vitepress-twoslash": "^4.4.3",
|
|
49
|
+
"@tsdoctor/bundle": "0.2.2",
|
|
50
|
+
"@tsdoctor/model": "0.6.0",
|
|
51
|
+
"@tsdoctor/pages": "0.1.0",
|
|
52
|
+
"@tsdoctor/registry": "0.3.1",
|
|
53
|
+
"@tsdoctor/seo": "0.1.1",
|
|
54
|
+
"@tsdoctor/vfs": "0.2.0",
|
|
55
|
+
"effect": "4.0.0-rc.109",
|
|
56
|
+
"shiki": "^4.4.3",
|
|
57
|
+
"typescript": "^6.0.3"
|
|
58
|
+
},
|
|
59
|
+
"peerDependencies": {
|
|
60
|
+
"vitepress": "^2.0.0-alpha.19"
|
|
61
|
+
},
|
|
62
|
+
"engines": {
|
|
63
|
+
"node": ">=24.11.0"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
+
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
+
{
|
|
4
|
+
"tsdocVersion": "0.12",
|
|
5
|
+
"toolPackages": [
|
|
6
|
+
{
|
|
7
|
+
"packageName": "@microsoft/api-extractor",
|
|
8
|
+
"packageVersion": "7.59.0"
|
|
9
|
+
}
|
|
10
|
+
]
|
|
11
|
+
}
|