@tsdoctor/pages 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/Blocks.js +358 -0
- package/Build.js +525 -0
- package/Examples.js +237 -0
- package/LICENSE +21 -0
- package/Llms.js +282 -0
- package/Markdown.js +155 -0
- package/Nav.js +148 -0
- package/Page.js +80 -0
- package/README.md +32 -0
- package/Scope.js +56 -0
- package/TwoslashDirectives.js +63 -0
- package/WorkItems.js +162 -0
- package/index.d.ts +1193 -0
- package/index.js +12 -0
- package/package.json +54 -0
- package/tsdoc-metadata.json +11 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,1193 @@
|
|
|
1
|
+
import { FlowContent, MarkdownStringifyError, PhrasingContent } from "@effected/markdown";
|
|
2
|
+
import { Effect, Option, Result, Schema } from "effect";
|
|
3
|
+
import { ApiItem, ApiItemKind, ApiPackage } from "@microsoft/api-extractor-model";
|
|
4
|
+
import { ApiItems, CrossLinker, ImportStatement, Routes } from "@tsdoctor/model";
|
|
5
|
+
//#region src/Blocks.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* A run of block-level mdast — a summary paragraph, a remarks section.
|
|
8
|
+
*
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
declare const Prose: Schema.$Array<Schema.Codec<FlowContent, FlowContent, never, never>>;
|
|
12
|
+
/**
|
|
13
|
+
* A run of inline mdast — a one-line description, a table cell, a
|
|
14
|
+
* deprecation message.
|
|
15
|
+
*
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
declare const Inline: Schema.$Array<Schema.Codec<PhrasingContent, PhrasingContent, never, never>>;
|
|
19
|
+
/**
|
|
20
|
+
* The TSDoc release tag a page's title badge is derived from.
|
|
21
|
+
*
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
24
|
+
declare const ReleaseTag: Schema.Literals<readonly ["Public", "Beta", "Alpha", "Internal"]>;
|
|
25
|
+
declare const CodeText_base: Schema.Class<CodeText, Schema.Struct<{
|
|
26
|
+
/** The directive-stripped text a reader sees and copies. */
|
|
27
|
+
readonly display: Schema.String;
|
|
28
|
+
/** The type-check text: hidden imports, cut marker, directives intact. */
|
|
29
|
+
readonly source: Schema.String;
|
|
30
|
+
}>, {}>;
|
|
31
|
+
/**
|
|
32
|
+
* The two spellings of one code block: what a reader sees and what the
|
|
33
|
+
* type-checker sees.
|
|
34
|
+
*
|
|
35
|
+
* @remarks
|
|
36
|
+
* `source` is the type-check text — hidden `import type` lines, then
|
|
37
|
+
* `// ---cut---`, then the code, Twoslash directives intact. `display` is
|
|
38
|
+
* the directive-stripped text a reader sees and copies. RSPress spends them
|
|
39
|
+
* as two props; VitePress puts `source` in a `ts twoslash` fence and lets the
|
|
40
|
+
* cut marker hide the preamble. Carrying both is one field of redundancy
|
|
41
|
+
* against a transformer per framework.
|
|
42
|
+
*
|
|
43
|
+
* @public
|
|
44
|
+
*/
|
|
45
|
+
declare class CodeText extends CodeText_base {}
|
|
46
|
+
declare const ParameterRow_base: Schema.Class<ParameterRow, Schema.Struct<{
|
|
47
|
+
/** The parameter name as declared. */
|
|
48
|
+
readonly name: Schema.String;
|
|
49
|
+
/** The parameter's type text from the declaration excerpt, when the declaration carries one. */
|
|
50
|
+
readonly type: Schema.optionalKey<Schema.String>;
|
|
51
|
+
/** The `@param` description, cross-linked. */
|
|
52
|
+
readonly description: Schema.$Array<Schema.Codec<PhrasingContent, PhrasingContent, never, never>>;
|
|
53
|
+
}>, {}>;
|
|
54
|
+
/**
|
|
55
|
+
* One row of a parameters table.
|
|
56
|
+
*
|
|
57
|
+
* @public
|
|
58
|
+
*/
|
|
59
|
+
declare class ParameterRow extends ParameterRow_base {}
|
|
60
|
+
declare const EnumMemberRow_base: Schema.Class<EnumMemberRow, Schema.Struct<{
|
|
61
|
+
/** The member name. */
|
|
62
|
+
readonly name: Schema.String;
|
|
63
|
+
/** The initializer value, when the declaration carries one. */
|
|
64
|
+
readonly value: Schema.optionalKey<Schema.String>;
|
|
65
|
+
/** The member's summary, cross-linked. */
|
|
66
|
+
readonly description: Schema.$Array<Schema.Codec<PhrasingContent, PhrasingContent, never, never>>;
|
|
67
|
+
}>, {}>;
|
|
68
|
+
/**
|
|
69
|
+
* One row of an enum members table.
|
|
70
|
+
*
|
|
71
|
+
* @public
|
|
72
|
+
*/
|
|
73
|
+
declare class EnumMemberRow extends EnumMemberRow_base {}
|
|
74
|
+
/**
|
|
75
|
+
* The role a class or interface member plays, which decides its heading
|
|
76
|
+
* group and how an emitter labels it.
|
|
77
|
+
*
|
|
78
|
+
* @public
|
|
79
|
+
*/
|
|
80
|
+
declare const MemberRole: Schema.Literals<readonly ["constructor", "property", "method", "getter", "call-signature", "construct-signature", "index-signature"]>;
|
|
81
|
+
declare const Member_base: Schema.Class<Member, Schema.Struct<{
|
|
82
|
+
/** Which heading group the member belongs to and how it is labelled. */
|
|
83
|
+
readonly role: Schema.Literals<readonly ["constructor", "property", "method", "getter", "call-signature", "construct-signature", "index-signature"]>;
|
|
84
|
+
/** The member's display name (`constructor` for constructors). */
|
|
85
|
+
readonly name: Schema.String;
|
|
86
|
+
/** The anchor id, computed once by the model's member-anchor algorithm. */
|
|
87
|
+
readonly anchor: Schema.String;
|
|
88
|
+
/** The member signature in its owner's context. */
|
|
89
|
+
readonly code: typeof CodeText;
|
|
90
|
+
/** The member's summary, cross-linked. */
|
|
91
|
+
readonly summary: Schema.optionalKey<Schema.$Array<Schema.Codec<PhrasingContent, PhrasingContent, never, never>>>;
|
|
92
|
+
/** The member's parameters, when it has any. */
|
|
93
|
+
readonly parameters: Schema.optionalKey<Schema.$Array<typeof ParameterRow>>;
|
|
94
|
+
/** The `@returns` description, cross-linked. */
|
|
95
|
+
readonly returns: Schema.optionalKey<Schema.$Array<Schema.Codec<PhrasingContent, PhrasingContent, never, never>>>;
|
|
96
|
+
}>, {}>;
|
|
97
|
+
/**
|
|
98
|
+
* One member of a class or interface: its own signature, summary and the
|
|
99
|
+
* anchor id every cross-link to it resolves against.
|
|
100
|
+
*
|
|
101
|
+
* @remarks
|
|
102
|
+
* `anchor` arrives as data from `ApiItems.memberAnchors` in
|
|
103
|
+
* `@tsdoctor/model`, threaded through the work item. No emitter recomputes
|
|
104
|
+
* it — the route map's `#fragment` and the page's element id must come from
|
|
105
|
+
* one computation, or cross-links land nowhere.
|
|
106
|
+
*
|
|
107
|
+
* @public
|
|
108
|
+
*/
|
|
109
|
+
declare class Member extends Member_base {}
|
|
110
|
+
declare const Example_base: Schema.Class<Example, Schema.Struct<{
|
|
111
|
+
/** The fence language after normalization (`typescript` for TS/JS). */
|
|
112
|
+
readonly language: Schema.String;
|
|
113
|
+
/** The formatted example. */
|
|
114
|
+
readonly code: typeof CodeText;
|
|
115
|
+
/** Whether the example is handed to Twoslash. */
|
|
116
|
+
readonly typeChecked: Schema.Boolean;
|
|
117
|
+
}>, {}>;
|
|
118
|
+
/**
|
|
119
|
+
* One example: its language, its code and whether it is type-checked.
|
|
120
|
+
*
|
|
121
|
+
* @remarks
|
|
122
|
+
* A non-TypeScript example is never type-checked; emitters render its
|
|
123
|
+
* `display` in a plain fence. A type-checked example carries the `@noErrors`
|
|
124
|
+
* directive and the package import in `source`.
|
|
125
|
+
*
|
|
126
|
+
* @public
|
|
127
|
+
*/
|
|
128
|
+
declare class Example extends Example_base {}
|
|
129
|
+
declare const MemberIndexEntry_base: Schema.Class<MemberIndexEntry, Schema.Struct<{
|
|
130
|
+
/** The member's display name. */
|
|
131
|
+
readonly name: Schema.String;
|
|
132
|
+
/** The route of the member's own page. */
|
|
133
|
+
readonly route: Schema.String;
|
|
134
|
+
/** The member's summary, cross-linked. */
|
|
135
|
+
readonly summary: Schema.optionalKey<Schema.$Array<Schema.Codec<PhrasingContent, PhrasingContent, never, never>>>;
|
|
136
|
+
}>, {}>;
|
|
137
|
+
/**
|
|
138
|
+
* One entry in a namespace page's member index.
|
|
139
|
+
*
|
|
140
|
+
* @public
|
|
141
|
+
*/
|
|
142
|
+
declare class MemberIndexEntry extends MemberIndexEntry_base {}
|
|
143
|
+
declare const Title_base: Schema.Class<Title, Schema.Struct<{
|
|
144
|
+
readonly kind: Schema.tag<"title">;
|
|
145
|
+
/** The item's display name. */
|
|
146
|
+
readonly name: Schema.String;
|
|
147
|
+
/** The release tag; emitters badge anything other than `Public`. */
|
|
148
|
+
readonly releaseTag: Schema.Literals<readonly ["Public", "Beta", "Alpha", "Internal"]>;
|
|
149
|
+
/** The `@deprecated` message, cross-linked, when present. */
|
|
150
|
+
readonly deprecation: Schema.optionalKey<Schema.$Array<Schema.Codec<PhrasingContent, PhrasingContent, never, never>>>;
|
|
151
|
+
}>, {}>;
|
|
152
|
+
/**
|
|
153
|
+
* The page title, with the release-tag badge and deprecation notice that
|
|
154
|
+
* render beside it.
|
|
155
|
+
*
|
|
156
|
+
* @public
|
|
157
|
+
*/
|
|
158
|
+
declare class Title extends Title_base {}
|
|
159
|
+
declare const AvailableFrom_base: Schema.Class<AvailableFrom, Schema.Struct<{
|
|
160
|
+
readonly kind: Schema.tag<"available-from">;
|
|
161
|
+
/** The package name the entry points are spelled under. */
|
|
162
|
+
readonly packageName: Schema.String;
|
|
163
|
+
/** Entry point names; `default` denotes the package root. */
|
|
164
|
+
readonly entryPoints: Schema.$Array<Schema.String>;
|
|
165
|
+
}>, {}>;
|
|
166
|
+
/**
|
|
167
|
+
* The "Available from" line for an item exported from several entry points.
|
|
168
|
+
*
|
|
169
|
+
* @public
|
|
170
|
+
*/
|
|
171
|
+
declare class AvailableFrom extends AvailableFrom_base {}
|
|
172
|
+
/**
|
|
173
|
+
* The role a prose block plays, which decides whether an emitter gives it a
|
|
174
|
+
* heading and what the heading says.
|
|
175
|
+
*
|
|
176
|
+
* @public
|
|
177
|
+
*/
|
|
178
|
+
declare const ProseRole: Schema.Literals<readonly ["summary", "remarks", "returns"]>;
|
|
179
|
+
declare const ProseBlock_base: Schema.Class<ProseBlock, Schema.Struct<{
|
|
180
|
+
readonly kind: Schema.tag<"prose">;
|
|
181
|
+
/** Which section this is. */
|
|
182
|
+
readonly role: Schema.Literals<readonly ["summary", "remarks", "returns"]>;
|
|
183
|
+
/** The section body, cross-linked. */
|
|
184
|
+
readonly content: Schema.$Array<Schema.Codec<FlowContent, FlowContent, never, never>>;
|
|
185
|
+
}>, {}>;
|
|
186
|
+
/**
|
|
187
|
+
* A prose section: the summary, the remarks, a function's returns.
|
|
188
|
+
*
|
|
189
|
+
* @public
|
|
190
|
+
*/
|
|
191
|
+
declare class ProseBlock extends ProseBlock_base {}
|
|
192
|
+
declare const SourceLink_base: Schema.Class<SourceLink, Schema.Struct<{
|
|
193
|
+
readonly kind: Schema.tag<"source-link">;
|
|
194
|
+
/** The resolved source URL. */
|
|
195
|
+
readonly href: Schema.String;
|
|
196
|
+
}>, {}>;
|
|
197
|
+
/**
|
|
198
|
+
* The link to the item's source code.
|
|
199
|
+
*
|
|
200
|
+
* @public
|
|
201
|
+
*/
|
|
202
|
+
declare class SourceLink extends SourceLink_base {}
|
|
203
|
+
declare const Signature_base: Schema.Class<Signature, Schema.Struct<{
|
|
204
|
+
readonly kind: Schema.tag<"signature">;
|
|
205
|
+
/** The signature text pair. */
|
|
206
|
+
readonly code: typeof CodeText;
|
|
207
|
+
/** Whether a parameters table follows directly (functions). */
|
|
208
|
+
readonly hasParameters: Schema.optionalKey<Schema.Boolean>;
|
|
209
|
+
/** Whether a members table follows directly (enums). */
|
|
210
|
+
readonly hasMembers: Schema.optionalKey<Schema.Boolean>;
|
|
211
|
+
}>, {}>;
|
|
212
|
+
/**
|
|
213
|
+
* The item's full signature block — a function signature, a class or
|
|
214
|
+
* interface skeleton listing every member, an enum with its members.
|
|
215
|
+
*
|
|
216
|
+
* @public
|
|
217
|
+
*/
|
|
218
|
+
declare class Signature extends Signature_base {}
|
|
219
|
+
declare const BaseClass_base: Schema.Class<BaseClass, Schema.Struct<{
|
|
220
|
+
readonly kind: Schema.tag<"base-class">;
|
|
221
|
+
/** The exported class. */
|
|
222
|
+
readonly className: Schema.String;
|
|
223
|
+
/** The unexported base declaration's name. */
|
|
224
|
+
readonly baseName: Schema.String;
|
|
225
|
+
/** The package the base is not exported from. */
|
|
226
|
+
readonly packageName: Schema.String;
|
|
227
|
+
/** The base declaration's signature. */
|
|
228
|
+
readonly code: typeof CodeText;
|
|
229
|
+
}>, {}>;
|
|
230
|
+
/**
|
|
231
|
+
* The inline "Base Class" section for a synthetic base declaration — the
|
|
232
|
+
* unexported `Foo_base` an exported class extends.
|
|
233
|
+
*
|
|
234
|
+
* @remarks
|
|
235
|
+
* The section heading slugs to `SyntheticBases.BASE_CLASS_ANCHOR` in
|
|
236
|
+
* `@tsdoctor/model`, which is where the base name's cross-link route points.
|
|
237
|
+
*
|
|
238
|
+
* @public
|
|
239
|
+
*/
|
|
240
|
+
declare class BaseClass extends BaseClass_base {}
|
|
241
|
+
declare const MemberGroup_base: Schema.Class<MemberGroup, Schema.Struct<{
|
|
242
|
+
readonly kind: Schema.tag<"member-group">;
|
|
243
|
+
/** The group heading. */
|
|
244
|
+
readonly title: Schema.String;
|
|
245
|
+
/** The members, in declaration order. */
|
|
246
|
+
readonly members: Schema.$Array<typeof Member>;
|
|
247
|
+
}>, {}>;
|
|
248
|
+
/**
|
|
249
|
+
* A heading group of members — "Constructors", "Static Methods",
|
|
250
|
+
* "Properties", "Call Signatures" — in the order the page lists them.
|
|
251
|
+
*
|
|
252
|
+
* @public
|
|
253
|
+
*/
|
|
254
|
+
declare class MemberGroup extends MemberGroup_base {}
|
|
255
|
+
declare const ParameterTable_base: Schema.Class<ParameterTable, Schema.Struct<{
|
|
256
|
+
readonly kind: Schema.tag<"parameters">;
|
|
257
|
+
/** The rows, in declaration order. */
|
|
258
|
+
readonly rows: Schema.$Array<typeof ParameterRow>;
|
|
259
|
+
}>, {}>;
|
|
260
|
+
/**
|
|
261
|
+
* A parameters table at page level — a function's parameters, adjacent to
|
|
262
|
+
* its signature.
|
|
263
|
+
*
|
|
264
|
+
* @public
|
|
265
|
+
*/
|
|
266
|
+
declare class ParameterTable extends ParameterTable_base {}
|
|
267
|
+
declare const EnumMemberTable_base: Schema.Class<EnumMemberTable, Schema.Struct<{
|
|
268
|
+
readonly kind: Schema.tag<"enum-members">;
|
|
269
|
+
/** The rows, in declaration order. */
|
|
270
|
+
readonly rows: Schema.$Array<typeof EnumMemberRow>;
|
|
271
|
+
}>, {}>;
|
|
272
|
+
/**
|
|
273
|
+
* An enum's members table, adjacent to its signature.
|
|
274
|
+
*
|
|
275
|
+
* @public
|
|
276
|
+
*/
|
|
277
|
+
declare class EnumMemberTable extends EnumMemberTable_base {}
|
|
278
|
+
declare const ExampleGroup_base: Schema.Class<ExampleGroup, Schema.Struct<{
|
|
279
|
+
readonly kind: Schema.tag<"examples">;
|
|
280
|
+
/** The examples, in TSDoc order. */
|
|
281
|
+
readonly items: Schema.$Array<typeof Example>;
|
|
282
|
+
}>, {}>;
|
|
283
|
+
/**
|
|
284
|
+
* The "Examples" section.
|
|
285
|
+
*
|
|
286
|
+
* @public
|
|
287
|
+
*/
|
|
288
|
+
declare class ExampleGroup extends ExampleGroup_base {}
|
|
289
|
+
declare const SeeAlso_base: Schema.Class<SeeAlso, Schema.Struct<{
|
|
290
|
+
readonly kind: Schema.tag<"see-also">;
|
|
291
|
+
/** The references, in TSDoc order. */
|
|
292
|
+
readonly references: Schema.$Array<Schema.$Array<Schema.Codec<PhrasingContent, PhrasingContent, never, never>>>;
|
|
293
|
+
}>, {}>;
|
|
294
|
+
/**
|
|
295
|
+
* The "See Also" section — one cross-linked reference per `@see` tag.
|
|
296
|
+
*
|
|
297
|
+
* @public
|
|
298
|
+
*/
|
|
299
|
+
declare class SeeAlso extends SeeAlso_base {}
|
|
300
|
+
declare const MemberIndex_base: Schema.Class<MemberIndex, Schema.Struct<{
|
|
301
|
+
readonly kind: Schema.tag<"member-index">;
|
|
302
|
+
/** The section heading. */
|
|
303
|
+
readonly title: Schema.String;
|
|
304
|
+
/** The entries, in declaration order. */
|
|
305
|
+
readonly entries: Schema.$Array<typeof MemberIndexEntry>;
|
|
306
|
+
}>, {}>;
|
|
307
|
+
/**
|
|
308
|
+
* A namespace page's index of one member kind — "Classes", "Functions" —
|
|
309
|
+
* linking to each member's own page.
|
|
310
|
+
*
|
|
311
|
+
* @public
|
|
312
|
+
*/
|
|
313
|
+
declare class MemberIndex extends MemberIndex_base {}
|
|
314
|
+
/**
|
|
315
|
+
* The closed vocabulary: every block a page may carry.
|
|
316
|
+
*
|
|
317
|
+
* @remarks
|
|
318
|
+
* Narrow on `kind`. Construct the variant classes rather than the union's
|
|
319
|
+
* inherited `make`, which typechecks against every member and yields a
|
|
320
|
+
* many-branch error when it fails.
|
|
321
|
+
*
|
|
322
|
+
* @public
|
|
323
|
+
*/
|
|
324
|
+
declare const Block: Schema.Union<readonly [typeof Title, typeof AvailableFrom, typeof ProseBlock, typeof SourceLink, typeof Signature, typeof BaseClass, typeof MemberGroup, typeof ParameterTable, typeof EnumMemberTable, typeof ExampleGroup, typeof SeeAlso, typeof MemberIndex]>;
|
|
325
|
+
/**
|
|
326
|
+
* A block instance — one member of the `Block` union.
|
|
327
|
+
*
|
|
328
|
+
* @public
|
|
329
|
+
*/
|
|
330
|
+
type Block = typeof Block.Type;
|
|
331
|
+
/**
|
|
332
|
+
* The discriminant values of the `Block` union.
|
|
333
|
+
*
|
|
334
|
+
* @public
|
|
335
|
+
*/
|
|
336
|
+
type BlockKind = Block["kind"];
|
|
337
|
+
//#endregion
|
|
338
|
+
//#region src/Examples.d.ts
|
|
339
|
+
declare const ExampleFormatError_base: Schema.Class<ExampleFormatError, Schema.TaggedStruct<"ExampleFormatError", {
|
|
340
|
+
/** The fence language the parser was chosen for. */
|
|
341
|
+
readonly language: Schema.String;
|
|
342
|
+
/** The original Prettier error. */
|
|
343
|
+
readonly cause: Schema.Defect;
|
|
344
|
+
}>, import("effect/Cause").YieldableError>;
|
|
345
|
+
/**
|
|
346
|
+
* Prettier could not format an example.
|
|
347
|
+
*
|
|
348
|
+
* @remarks
|
|
349
|
+
* Malformed example code is author input, so this is a typed failure rather
|
|
350
|
+
* than a defect. The original Prettier error rides in `cause` rather than
|
|
351
|
+
* being flattened to a string; an adapter that reports it (the RSPress
|
|
352
|
+
* `PrettierError` event) reads the message from there and falls back to the
|
|
353
|
+
* unformatted code.
|
|
354
|
+
*
|
|
355
|
+
* @public
|
|
356
|
+
*/
|
|
357
|
+
declare class ExampleFormatError extends ExampleFormatError_base {
|
|
358
|
+
get message(): string;
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* A raw example as extracted from TSDoc.
|
|
362
|
+
*
|
|
363
|
+
* @public
|
|
364
|
+
*/
|
|
365
|
+
interface RawExample {
|
|
366
|
+
/** The fence language as written. */
|
|
367
|
+
readonly language: string;
|
|
368
|
+
/** The fence body. */
|
|
369
|
+
readonly code: string;
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* An example prepared for Twoslash: the import line and the `@noErrors`
|
|
373
|
+
* directive added, and the language normalized.
|
|
374
|
+
*
|
|
375
|
+
* @public
|
|
376
|
+
*/
|
|
377
|
+
interface PreparedExample {
|
|
378
|
+
/** The code with the package import and directives prepended. */
|
|
379
|
+
readonly code: string;
|
|
380
|
+
/** Whether the example is TypeScript/JavaScript and therefore type-checked. */
|
|
381
|
+
readonly isTypeScript: boolean;
|
|
382
|
+
/** The normalized language: `typescript` for TS/JS, otherwise as written. */
|
|
383
|
+
readonly language: string;
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Prepare an example for Twoslash: prepend `import { name } from "pkg"`
|
|
387
|
+
* unless the example already imports the package, and prepend `// @noErrors`
|
|
388
|
+
* when errors are suppressed. Non-TypeScript examples pass through untouched.
|
|
389
|
+
*
|
|
390
|
+
* @param example - The example with language and code
|
|
391
|
+
* @param apiItemName - The documented item, imported at the top of the example
|
|
392
|
+
* @param packageName - The package to import it from
|
|
393
|
+
* @param suppressErrors - Whether to suppress TypeScript errors (default `true`)
|
|
394
|
+
* @public
|
|
395
|
+
*/
|
|
396
|
+
declare function prepareExampleCode(example: RawExample, apiItemName: string, packageName: string, suppressErrors?: boolean): PreparedExample;
|
|
397
|
+
/**
|
|
398
|
+
* Strip Twoslash directives from code for display: config directives
|
|
399
|
+
* (`// @noErrors`, `// @errors: 2304`, `// @filename: …`), annotation markers
|
|
400
|
+
* (`// ^?`) and the cut directives — `// ---cut---` removes itself and every
|
|
401
|
+
* line before it, `// ---cut-after---` itself and every line after, and a
|
|
402
|
+
* `// ---cut-start---` / `// ---cut-end---` pair removes the range between.
|
|
403
|
+
*
|
|
404
|
+
* @param code - The code containing Twoslash directives
|
|
405
|
+
* @returns The code a reader sees and copies
|
|
406
|
+
* @public
|
|
407
|
+
*/
|
|
408
|
+
declare function stripTwoslashDirectives(code: string): string;
|
|
409
|
+
/**
|
|
410
|
+
* Prepend hidden imports to code using the Twoslash cut directive, so the
|
|
411
|
+
* type-checker resolves external types while the reader never sees the
|
|
412
|
+
* import lines. Returns the code unchanged when there is nothing to import.
|
|
413
|
+
*
|
|
414
|
+
* @param code - The code to prepend imports to
|
|
415
|
+
* @param imports - The import statements to add
|
|
416
|
+
* @public
|
|
417
|
+
*/
|
|
418
|
+
declare function prependHiddenImports(code: string, imports: ReadonlyArray<ImportStatement>): string;
|
|
419
|
+
/**
|
|
420
|
+
* Build both spellings of a code block from its type-check text: the
|
|
421
|
+
* `source` as given, the `display` with every directive stripped.
|
|
422
|
+
*
|
|
423
|
+
* @param source - The type-check text — hidden imports, cut marker, directives intact
|
|
424
|
+
* @public
|
|
425
|
+
*/
|
|
426
|
+
declare function codeText(source: string): CodeText;
|
|
427
|
+
/**
|
|
428
|
+
* Add logical blank lines between code sections for visual clarity: after an
|
|
429
|
+
* import block, before a section comment and before a `return`.
|
|
430
|
+
*
|
|
431
|
+
* @remarks
|
|
432
|
+
* Runs after Prettier, which does not insert breathing room of its own. Lines
|
|
433
|
+
* inside a multi-line import and Twoslash directive lines never trigger a
|
|
434
|
+
* rule, so a directive stays attached to the line it annotates.
|
|
435
|
+
*
|
|
436
|
+
* @param code - Prettier-formatted code
|
|
437
|
+
* @public
|
|
438
|
+
*/
|
|
439
|
+
declare function addLogicalBlankLines(code: string): string;
|
|
440
|
+
/**
|
|
441
|
+
* Format example code with Prettier, then add logical blank lines. A
|
|
442
|
+
* language Prettier has no parser for is returned unchanged.
|
|
443
|
+
*
|
|
444
|
+
* @param code - The code to format
|
|
445
|
+
* @param language - The fence language (`typescript`, `ts`, `js`, …)
|
|
446
|
+
* @public
|
|
447
|
+
*/
|
|
448
|
+
declare const formatExampleCode: (code: string, language: string) => Effect.Effect<string, ExampleFormatError>;
|
|
449
|
+
/**
|
|
450
|
+
* Build an {@link Example} block item from a raw TSDoc example: prepare it
|
|
451
|
+
* for Twoslash, format it, and produce both code spellings once.
|
|
452
|
+
*
|
|
453
|
+
* @remarks
|
|
454
|
+
* A non-TypeScript example is not type-checked, so its `display` and
|
|
455
|
+
* `source` are the same formatted text and emitters render it in a plain
|
|
456
|
+
* fence.
|
|
457
|
+
*
|
|
458
|
+
* @param example - The example with language and code
|
|
459
|
+
* @param apiItemName - The documented item, imported at the top of the example
|
|
460
|
+
* @param packageName - The package to import it from
|
|
461
|
+
* @param suppressErrors - Whether to suppress TypeScript errors (default `true`)
|
|
462
|
+
* @public
|
|
463
|
+
*/
|
|
464
|
+
declare const buildExample: (example: RawExample, apiItemName: string, packageName: string, suppressErrors?: boolean) => Effect.Effect<Example, ExampleFormatError>;
|
|
465
|
+
//#endregion
|
|
466
|
+
//#region src/Nav.d.ts
|
|
467
|
+
declare const NavEntry_base: Schema.Class<NavEntry, Schema.Struct<{
|
|
468
|
+
/** The category key the page was categorized under. */
|
|
469
|
+
readonly categoryKey: Schema.String;
|
|
470
|
+
/** The sidebar label — the display name, qualified for a namespace member. */
|
|
471
|
+
readonly label: Schema.String;
|
|
472
|
+
/** The file basename without extension (`foo` for `class/foo.mdx`). */
|
|
473
|
+
readonly name: Schema.String;
|
|
474
|
+
/** The page route. */
|
|
475
|
+
readonly route: Schema.String;
|
|
476
|
+
}>, {}>;
|
|
477
|
+
/**
|
|
478
|
+
* A page's place in the navigation tree, carried on the page itself.
|
|
479
|
+
*
|
|
480
|
+
* @public
|
|
481
|
+
*/
|
|
482
|
+
declare class NavEntry extends NavEntry_base {}
|
|
483
|
+
declare const NavCategory_base: Schema.Class<NavCategory, Schema.Struct<{
|
|
484
|
+
/** The group label. */
|
|
485
|
+
readonly displayName: Schema.String;
|
|
486
|
+
/** The folder the category's pages live in. */
|
|
487
|
+
readonly folderName: Schema.String;
|
|
488
|
+
/** Whether the group can be collapsed; absent means the renderer's default. */
|
|
489
|
+
readonly collapsible: Schema.optionalKey<Schema.Boolean>;
|
|
490
|
+
/** Whether the group starts collapsed; absent means the renderer's default. */
|
|
491
|
+
readonly collapsed: Schema.optionalKey<Schema.Boolean>;
|
|
492
|
+
/** Heading depths surfaced in an overview; absent means the renderer's default. */
|
|
493
|
+
readonly overviewHeaders: Schema.optionalKey<Schema.$Array<Schema.Number>>;
|
|
494
|
+
}>, {}>;
|
|
495
|
+
/**
|
|
496
|
+
* The per-category presentation facts a tree carries for its groups.
|
|
497
|
+
*
|
|
498
|
+
* @public
|
|
499
|
+
*/
|
|
500
|
+
declare class NavCategory extends NavCategory_base {}
|
|
501
|
+
declare const NavPage_base: Schema.Class<NavPage, Schema.Struct<{
|
|
502
|
+
/** The sidebar label. */
|
|
503
|
+
readonly label: Schema.String;
|
|
504
|
+
/** The file basename without extension. */
|
|
505
|
+
readonly name: Schema.String;
|
|
506
|
+
/** The page route. */
|
|
507
|
+
readonly route: Schema.String;
|
|
508
|
+
}>, {}>;
|
|
509
|
+
/**
|
|
510
|
+
* One page in a group.
|
|
511
|
+
*
|
|
512
|
+
* @public
|
|
513
|
+
*/
|
|
514
|
+
declare class NavPage extends NavPage_base {}
|
|
515
|
+
declare const NavGroup_base: Schema.Class<NavGroup, Schema.Struct<{
|
|
516
|
+
/** The category key. */
|
|
517
|
+
readonly key: Schema.String;
|
|
518
|
+
/** The category presentation facts. */
|
|
519
|
+
readonly category: typeof NavCategory;
|
|
520
|
+
/** The group's pages, sorted by label. */
|
|
521
|
+
readonly pages: Schema.$Array<typeof NavPage>;
|
|
522
|
+
}>, {}>;
|
|
523
|
+
/**
|
|
524
|
+
* One category group with its pages, already sorted.
|
|
525
|
+
*
|
|
526
|
+
* @public
|
|
527
|
+
*/
|
|
528
|
+
declare class NavGroup extends NavGroup_base {}
|
|
529
|
+
declare const NavTree_base: Schema.Class<NavTree, Schema.Struct<{
|
|
530
|
+
/** The API's base route; the index page lives at its root. */
|
|
531
|
+
readonly baseRoute: Schema.String;
|
|
532
|
+
/** The index page. */
|
|
533
|
+
readonly index: typeof NavPage;
|
|
534
|
+
/** The category groups that received at least one page, in category order. */
|
|
535
|
+
readonly groups: Schema.$Array<typeof NavGroup>;
|
|
536
|
+
}>, {}>;
|
|
537
|
+
/**
|
|
538
|
+
* The navigation tree for one API.
|
|
539
|
+
*
|
|
540
|
+
* @public
|
|
541
|
+
*/
|
|
542
|
+
declare class NavTree extends NavTree_base {}
|
|
543
|
+
/**
|
|
544
|
+
* The input to {@link buildNav}.
|
|
545
|
+
*
|
|
546
|
+
* @public
|
|
547
|
+
*/
|
|
548
|
+
interface BuildNavInput {
|
|
549
|
+
/** The API's base route. */
|
|
550
|
+
readonly baseRoute: string;
|
|
551
|
+
/** The categories in the order they were configured — insertion order is the group order. */
|
|
552
|
+
readonly categories: Readonly<Record<string, NavCategory>>;
|
|
553
|
+
/** Every generated page's entry, in any order. */
|
|
554
|
+
readonly entries: ReadonlyArray<NavEntry>;
|
|
555
|
+
}
|
|
556
|
+
/**
|
|
557
|
+
* The label of the index page every tree carries.
|
|
558
|
+
*
|
|
559
|
+
* @public
|
|
560
|
+
*/
|
|
561
|
+
declare const NAV_INDEX_LABEL = "API Reference";
|
|
562
|
+
/**
|
|
563
|
+
* Sort pages the way the sidebar lists them: alphabetically by label.
|
|
564
|
+
*
|
|
565
|
+
* @public
|
|
566
|
+
*/
|
|
567
|
+
declare function sortNavPages(pages: ReadonlyArray<NavPage>): ReadonlyArray<NavPage>;
|
|
568
|
+
/**
|
|
569
|
+
* Build the navigation tree for one API from its categories and its pages.
|
|
570
|
+
*
|
|
571
|
+
* @remarks
|
|
572
|
+
* Groups follow `categories`' insertion order and a category with no page
|
|
573
|
+
* is dropped rather than rendered empty. An entry whose category key names
|
|
574
|
+
* no configured category is dropped too — it could not have been generated
|
|
575
|
+
* into a folder — so the tree only ever describes pages that exist.
|
|
576
|
+
*
|
|
577
|
+
* @public
|
|
578
|
+
*/
|
|
579
|
+
declare function buildNav(input: BuildNavInput): NavTree;
|
|
580
|
+
//#endregion
|
|
581
|
+
//#region src/Page.d.ts
|
|
582
|
+
/**
|
|
583
|
+
* The neutral head tag, as a schema — the same shape as `@tsdoctor/seo`'s
|
|
584
|
+
* `HeadTag` interface, so a value from `headTags` is accepted unchanged.
|
|
585
|
+
*
|
|
586
|
+
* @public
|
|
587
|
+
*/
|
|
588
|
+
declare const HeadTag: Schema.Struct<{
|
|
589
|
+
/** The element name. */
|
|
590
|
+
readonly tag: Schema.Literals<readonly ["meta", "link", "script"]>;
|
|
591
|
+
/** The element attributes. */
|
|
592
|
+
readonly attrs: Schema.$Record<Schema.String, Schema.String>;
|
|
593
|
+
/** Element content; only meaningful for `script`. */
|
|
594
|
+
readonly body: Schema.optionalKey<Schema.String>;
|
|
595
|
+
}>;
|
|
596
|
+
/**
|
|
597
|
+
* A neutral head tag value.
|
|
598
|
+
*
|
|
599
|
+
* @public
|
|
600
|
+
*/
|
|
601
|
+
type HeadTag = typeof HeadTag.Type;
|
|
602
|
+
/**
|
|
603
|
+
* The kind of symbol a page documents — which builder produced it, and
|
|
604
|
+
* which component imports and block layout an emitter chooses.
|
|
605
|
+
*
|
|
606
|
+
* @public
|
|
607
|
+
*/
|
|
608
|
+
declare const PageKind: Schema.Literals<readonly ["class", "interface", "function", "type-alias", "enum", "variable", "namespace"]>;
|
|
609
|
+
/**
|
|
610
|
+
* A page kind value.
|
|
611
|
+
*
|
|
612
|
+
* @public
|
|
613
|
+
*/
|
|
614
|
+
type PageKind = typeof PageKind.Type;
|
|
615
|
+
declare const Page_base: Schema.Class<Page, Schema.Struct<{
|
|
616
|
+
/** The kind of symbol the page documents. */
|
|
617
|
+
readonly kind: Schema.Literals<readonly ["class", "interface", "function", "type-alias", "enum", "variable", "namespace"]>;
|
|
618
|
+
/** The documented item's display name — the first title part. */
|
|
619
|
+
readonly entityName: Schema.String;
|
|
620
|
+
/** The category's singular name (`Class`, `Function`) — the second title part. */
|
|
621
|
+
readonly singularName: Schema.String;
|
|
622
|
+
/** The API's display name — the last title part, when the site names one. */
|
|
623
|
+
readonly apiName: Schema.optionalKey<Schema.String>;
|
|
624
|
+
/** The page description: the item's summary, or the fallback the generators used. */
|
|
625
|
+
readonly description: Schema.String;
|
|
626
|
+
/** The page route. */
|
|
627
|
+
readonly route: Schema.String;
|
|
628
|
+
/** Every `<head>` tag the page carries, from `@tsdoctor/seo`. */
|
|
629
|
+
readonly headTags: Schema.$Array<Schema.Struct<{
|
|
630
|
+
/** The element name. */
|
|
631
|
+
readonly tag: Schema.Literals<readonly ["meta", "link", "script"]>;
|
|
632
|
+
/** The element attributes. */
|
|
633
|
+
readonly attrs: Schema.$Record<Schema.String, Schema.String>;
|
|
634
|
+
/** Element content; only meaningful for `script`. */
|
|
635
|
+
readonly body: Schema.optionalKey<Schema.String>;
|
|
636
|
+
}>>;
|
|
637
|
+
/** The page body, in order. */
|
|
638
|
+
readonly blocks: Schema.$Array<Schema.Union<readonly [typeof Title, typeof AvailableFrom, typeof ProseBlock, typeof SourceLink, typeof Signature, typeof BaseClass, typeof MemberGroup, typeof ParameterTable, typeof EnumMemberTable, typeof ExampleGroup, typeof SeeAlso, typeof MemberIndex]>>;
|
|
639
|
+
/** The page's place in the navigation tree. */
|
|
640
|
+
readonly nav: typeof NavEntry;
|
|
641
|
+
}>, {}>;
|
|
642
|
+
/**
|
|
643
|
+
* One generated API page.
|
|
644
|
+
*
|
|
645
|
+
* @public
|
|
646
|
+
*/
|
|
647
|
+
declare class Page extends Page_base {
|
|
648
|
+
/**
|
|
649
|
+
* The structured page title: `{entityName} | {singularName} | API | {apiName}`,
|
|
650
|
+
* the last part omitted when the site names no API.
|
|
651
|
+
*/
|
|
652
|
+
get title(): string;
|
|
653
|
+
}
|
|
654
|
+
//#endregion
|
|
655
|
+
//#region src/Build.d.ts
|
|
656
|
+
/**
|
|
657
|
+
* The description a page carries when its item has no summary.
|
|
658
|
+
*
|
|
659
|
+
* @public
|
|
660
|
+
*/
|
|
661
|
+
declare const NO_DESCRIPTION = "No description available.";
|
|
662
|
+
/**
|
|
663
|
+
* A member of a namespace, as the adapter's work item carries it: the
|
|
664
|
+
* qualified name decides the page route and the sidebar label.
|
|
665
|
+
*
|
|
666
|
+
* @public
|
|
667
|
+
*/
|
|
668
|
+
interface NamespaceMemberFacts {
|
|
669
|
+
/** `Namespace.member`, as the route's last segment and the nav label. */
|
|
670
|
+
readonly qualifiedName: string;
|
|
671
|
+
}
|
|
672
|
+
/**
|
|
673
|
+
* The input to {@link buildPage}: the item plus every fact the adapter's
|
|
674
|
+
* work item and API configuration contribute.
|
|
675
|
+
*
|
|
676
|
+
* @public
|
|
677
|
+
*/
|
|
678
|
+
interface BuildPageInput {
|
|
679
|
+
/** The documented item. */
|
|
680
|
+
readonly item: ApiItem;
|
|
681
|
+
/** The category key the item was categorized under. */
|
|
682
|
+
readonly categoryKey: string;
|
|
683
|
+
/** The category's singular name — the second title part. */
|
|
684
|
+
readonly singularName: string;
|
|
685
|
+
/** The category folder the page lives in. */
|
|
686
|
+
readonly folderName: string;
|
|
687
|
+
/** The API's base route. */
|
|
688
|
+
readonly baseRoute: string;
|
|
689
|
+
/** The package name examples import from and "Available from" spells. */
|
|
690
|
+
readonly packageName: string;
|
|
691
|
+
/** The API's display name — the last title part, when the site names one. */
|
|
692
|
+
readonly apiName?: string | undefined;
|
|
693
|
+
/** Present when the item is a namespace member documented on its own page. */
|
|
694
|
+
readonly namespaceMember?: NamespaceMemberFacts | undefined;
|
|
695
|
+
/** Entry points the item is exported from; more than one yields an "Available from" line. */
|
|
696
|
+
readonly availableFrom?: ReadonlyArray<string> | undefined;
|
|
697
|
+
/** The unexported base declaration a class extends, rendered inline. */
|
|
698
|
+
readonly syntheticBase?: ApiItem | undefined;
|
|
699
|
+
/** Anchor id per member, keyed by canonical reference, from `ApiItems.memberAnchors`. */
|
|
700
|
+
readonly memberAnchors?: ReadonlyMap<string, string> | undefined;
|
|
701
|
+
/** The source repository, when the site links to it. */
|
|
702
|
+
readonly source?: ApiItems.SourceLinkTarget | undefined;
|
|
703
|
+
/** Whether examples carry `@noErrors`; defaults to `true`. */
|
|
704
|
+
readonly suppressExampleErrors?: boolean | undefined;
|
|
705
|
+
/** The cross-linker built from the API's route map. */
|
|
706
|
+
readonly linker: CrossLinker;
|
|
707
|
+
/** Head tags for the page, when the adapter has them before building. */
|
|
708
|
+
readonly headTags?: ReadonlyArray<HeadTag> | undefined;
|
|
709
|
+
/**
|
|
710
|
+
* Called when Prettier cannot format an example; the example then carries
|
|
711
|
+
* its unformatted code. Absent, the failure is silent.
|
|
712
|
+
*/
|
|
713
|
+
readonly onExampleFormatError?: ((error: ExampleFormatError) => Effect.Effect<void>) | undefined;
|
|
714
|
+
}
|
|
715
|
+
/**
|
|
716
|
+
* The input to {@link buildIndexPage}.
|
|
717
|
+
*
|
|
718
|
+
* @public
|
|
719
|
+
*/
|
|
720
|
+
interface BuildIndexPageInput {
|
|
721
|
+
/** The package the index introduces. */
|
|
722
|
+
readonly packageName: string;
|
|
723
|
+
/** The API's base route; the index lives at its root. */
|
|
724
|
+
readonly baseRoute: string;
|
|
725
|
+
}
|
|
726
|
+
declare const IndexPage_base: Schema.Class<IndexPage, Schema.Struct<{
|
|
727
|
+
/** The page route (`{baseRoute}/index`). */
|
|
728
|
+
readonly route: Schema.String;
|
|
729
|
+
/** The page title. */
|
|
730
|
+
readonly title: Schema.String;
|
|
731
|
+
/** The page description. */
|
|
732
|
+
readonly description: Schema.String;
|
|
733
|
+
}>, {}>;
|
|
734
|
+
/**
|
|
735
|
+
* The API landing page: frontmatter facts only, no blocks.
|
|
736
|
+
*
|
|
737
|
+
* @public
|
|
738
|
+
*/
|
|
739
|
+
declare class IndexPage extends IndexPage_base {}
|
|
740
|
+
/**
|
|
741
|
+
* The label of the index page.
|
|
742
|
+
*
|
|
743
|
+
* @public
|
|
744
|
+
*/
|
|
745
|
+
declare const INDEX_PAGE_TITLE = "API Reference";
|
|
746
|
+
/**
|
|
747
|
+
* Build the API landing page.
|
|
748
|
+
*
|
|
749
|
+
* @public
|
|
750
|
+
*/
|
|
751
|
+
declare function buildIndexPage(input: BuildIndexPageInput): IndexPage;
|
|
752
|
+
/**
|
|
753
|
+
* Whether {@link buildPage} produces a page for an item of this kind.
|
|
754
|
+
*
|
|
755
|
+
* @public
|
|
756
|
+
*/
|
|
757
|
+
declare function isPageKind(kind: ApiItemKind): boolean;
|
|
758
|
+
/**
|
|
759
|
+
* Build the page for one item, or none for an item kind that gets no page.
|
|
760
|
+
*
|
|
761
|
+
* @remarks
|
|
762
|
+
* The route is `{baseRoute}/{folderName}/{name}` with the name lowercased;
|
|
763
|
+
* a namespace member's last segment is its lowercased qualified name, which
|
|
764
|
+
* is also its sidebar label. Only Prettier can fail here, and that failure
|
|
765
|
+
* degrades through {@link BuildPageInput.onExampleFormatError}, so the
|
|
766
|
+
* error channel is `never`.
|
|
767
|
+
*
|
|
768
|
+
* @public
|
|
769
|
+
*/
|
|
770
|
+
declare const buildPage: (input: BuildPageInput) => Effect.Effect<Option.Option<Page>>;
|
|
771
|
+
//#endregion
|
|
772
|
+
//#region src/Llms.d.ts
|
|
773
|
+
/**
|
|
774
|
+
* A parsed link entry from llms.txt format.
|
|
775
|
+
*
|
|
776
|
+
* @example
|
|
777
|
+
* ```text
|
|
778
|
+
* - [Page Title](/path/to/page): Page description
|
|
779
|
+
* ```
|
|
780
|
+
*
|
|
781
|
+
* @public
|
|
782
|
+
*/
|
|
783
|
+
interface LlmsTxtEntry {
|
|
784
|
+
title: string;
|
|
785
|
+
url: string;
|
|
786
|
+
description: string | undefined;
|
|
787
|
+
}
|
|
788
|
+
/**
|
|
789
|
+
* A pointer to a per-package llms.txt file, appended to the global llms.txt.
|
|
790
|
+
*
|
|
791
|
+
* @public
|
|
792
|
+
*/
|
|
793
|
+
interface PackagePointer {
|
|
794
|
+
name: string;
|
|
795
|
+
llmsTxtUrl: string;
|
|
796
|
+
}
|
|
797
|
+
/**
|
|
798
|
+
* Input for generating a per-package llms.txt index.
|
|
799
|
+
*
|
|
800
|
+
* @public
|
|
801
|
+
*/
|
|
802
|
+
interface PackageLlmsTxtInput {
|
|
803
|
+
name: string;
|
|
804
|
+
packageName: string;
|
|
805
|
+
guidePages: LlmsTxtEntry[];
|
|
806
|
+
apiPages: LlmsTxtEntry[];
|
|
807
|
+
}
|
|
808
|
+
/**
|
|
809
|
+
* A page with its URL and full markdown content, used for llms-full.txt generation.
|
|
810
|
+
*
|
|
811
|
+
* @public
|
|
812
|
+
*/
|
|
813
|
+
interface PageContent {
|
|
814
|
+
url: string;
|
|
815
|
+
content: string;
|
|
816
|
+
}
|
|
817
|
+
/**
|
|
818
|
+
* Parse a single line from llms.txt format.
|
|
819
|
+
*
|
|
820
|
+
* Recognizes the pattern: `- [title](url): description`
|
|
821
|
+
* The description portion (`: description`) is optional.
|
|
822
|
+
*
|
|
823
|
+
* @param line - A single line from an llms.txt file
|
|
824
|
+
* @returns Parsed entry or null for non-link lines (headers, empty lines, plain text)
|
|
825
|
+
*
|
|
826
|
+
* @public
|
|
827
|
+
*/
|
|
828
|
+
declare function parseLlmsTxtLine(line: string): LlmsTxtEntry | null;
|
|
829
|
+
/**
|
|
830
|
+
* Filter API page entries from global llms.txt content.
|
|
831
|
+
*
|
|
832
|
+
* Removes lines whose parsed URL is in the `apiRoutes` set.
|
|
833
|
+
* Appends pointer lines for per-package llms files when `pointers` is non-empty.
|
|
834
|
+
*
|
|
835
|
+
* @param content - Full llms.txt content string
|
|
836
|
+
* @param apiRoutes - Set of API route paths to remove
|
|
837
|
+
* @param pointers - Per-package pointer entries to append
|
|
838
|
+
* @returns Filtered llms.txt content
|
|
839
|
+
*
|
|
840
|
+
* @public
|
|
841
|
+
*/
|
|
842
|
+
declare function filterLlmsTxt(content: string, apiRoutes: Set<string>, pointers: PackagePointer[]): string;
|
|
843
|
+
/**
|
|
844
|
+
* Metadata for a package scope, used to generate structured llms.txt.
|
|
845
|
+
*
|
|
846
|
+
* @public
|
|
847
|
+
*/
|
|
848
|
+
interface PackageScopeInfo {
|
|
849
|
+
/** Display name (e.g., "Kitchen Sink") */
|
|
850
|
+
name: string;
|
|
851
|
+
/** npm package name */
|
|
852
|
+
packageName: string;
|
|
853
|
+
/** Package version (e.g., "1.0.0") or undefined */
|
|
854
|
+
version: string | undefined;
|
|
855
|
+
/** Package description or undefined */
|
|
856
|
+
description: string | undefined;
|
|
857
|
+
/** Package-level route prefix (e.g., "/kitchensink") */
|
|
858
|
+
packageRoute: string;
|
|
859
|
+
/** URL to the per-package llms-api.txt */
|
|
860
|
+
llmsApiTxtUrl: string;
|
|
861
|
+
}
|
|
862
|
+
/**
|
|
863
|
+
* Generate a structured global llms.txt that groups pages by package scope.
|
|
864
|
+
*
|
|
865
|
+
* Output format:
|
|
866
|
+
* ```
|
|
867
|
+
* # {site title}
|
|
868
|
+
*
|
|
869
|
+
* ## Others
|
|
870
|
+
* - [Blog Post](/blog/post.md)
|
|
871
|
+
*
|
|
872
|
+
* ## Packages
|
|
873
|
+
*
|
|
874
|
+
* ### {name} {version}
|
|
875
|
+
* {description}
|
|
876
|
+
* - [Guide Page](/pkg/guides/guide.md)
|
|
877
|
+
* - [API Reference](/pkg/llms-api.txt)
|
|
878
|
+
* ```
|
|
879
|
+
*
|
|
880
|
+
* @param content - Original RSPress-generated llms.txt content
|
|
881
|
+
* @param apiRoutes - Set of API route paths to exclude as individual entries
|
|
882
|
+
* @param packages - Package scope metadata
|
|
883
|
+
* @returns Restructured llms.txt content
|
|
884
|
+
*
|
|
885
|
+
* @public
|
|
886
|
+
*/
|
|
887
|
+
declare function generateStructuredLlmsTxt(content: string, apiRoutes: Set<string>, packages: PackageScopeInfo[]): string;
|
|
888
|
+
/**
|
|
889
|
+
* Filter API page content sections from global llms-full.txt.
|
|
890
|
+
*
|
|
891
|
+
* Sections are delimited by `---\nurl: {path}\n---` frontmatter blocks.
|
|
892
|
+
* Removes entire sections whose URL matches a known API route.
|
|
893
|
+
*
|
|
894
|
+
* @param content - Full llms-full.txt content string
|
|
895
|
+
* @param apiRoutes - Set of API route paths to remove
|
|
896
|
+
* @returns Filtered llms-full.txt content
|
|
897
|
+
*
|
|
898
|
+
* @public
|
|
899
|
+
*/
|
|
900
|
+
declare function filterLlmsFullTxt(content: string, apiRoutes: Set<string>): string;
|
|
901
|
+
/**
|
|
902
|
+
* Generate a per-package llms.txt index.
|
|
903
|
+
*
|
|
904
|
+
* Output format:
|
|
905
|
+
* ```
|
|
906
|
+
* # {name}
|
|
907
|
+
*
|
|
908
|
+
* ## Guides
|
|
909
|
+
*
|
|
910
|
+
* - [Guide Title](/path): Description
|
|
911
|
+
*
|
|
912
|
+
* ## API Reference
|
|
913
|
+
*
|
|
914
|
+
* - [ApiItem](/path): Description
|
|
915
|
+
* ```
|
|
916
|
+
*
|
|
917
|
+
* Sections with no entries are omitted.
|
|
918
|
+
*
|
|
919
|
+
* @param input - Package name, guide pages, and API pages
|
|
920
|
+
* @returns Generated llms.txt content
|
|
921
|
+
*
|
|
922
|
+
* @public
|
|
923
|
+
*/
|
|
924
|
+
declare function generatePackageLlmsTxt(input: PackageLlmsTxtInput): string;
|
|
925
|
+
/**
|
|
926
|
+
* Concatenate page contents with frontmatter delimiters.
|
|
927
|
+
*
|
|
928
|
+
* Used for llms-full.txt, llms-docs.txt, and llms-api.txt generation
|
|
929
|
+
* (pass different page sets for each).
|
|
930
|
+
*
|
|
931
|
+
* Output format:
|
|
932
|
+
* ```
|
|
933
|
+
* ---
|
|
934
|
+
* url: /path/to/page
|
|
935
|
+
* ---
|
|
936
|
+
*
|
|
937
|
+
* Content here...
|
|
938
|
+
*
|
|
939
|
+
*
|
|
940
|
+
* ---
|
|
941
|
+
* url: /path/to/next
|
|
942
|
+
* ---
|
|
943
|
+
*
|
|
944
|
+
* More content...
|
|
945
|
+
* ```
|
|
946
|
+
*
|
|
947
|
+
* @param pages - Array of page URLs and their markdown content
|
|
948
|
+
* @returns Concatenated content with frontmatter delimiters
|
|
949
|
+
*
|
|
950
|
+
* @public
|
|
951
|
+
*/
|
|
952
|
+
declare function generatePackageLlmsFullTxt(pages: PageContent[]): string;
|
|
953
|
+
//#endregion
|
|
954
|
+
//#region src/Markdown.d.ts
|
|
955
|
+
/**
|
|
956
|
+
* Render one block to flow nodes.
|
|
957
|
+
*
|
|
958
|
+
* @public
|
|
959
|
+
*/
|
|
960
|
+
declare function markdownBlockTree(block: Block): ReadonlyArray<FlowContent>;
|
|
961
|
+
/**
|
|
962
|
+
* Render a page's body to flow nodes — the pre-serialization form of
|
|
963
|
+
* {@link renderMarkdownResult}.
|
|
964
|
+
*
|
|
965
|
+
* @public
|
|
966
|
+
*/
|
|
967
|
+
declare function markdownTree(page: Page): ReadonlyArray<FlowContent>;
|
|
968
|
+
/**
|
|
969
|
+
* Render a page's body to a markdown string. No frontmatter: that is the
|
|
970
|
+
* adapter's, built from the page facts.
|
|
971
|
+
*
|
|
972
|
+
* @remarks
|
|
973
|
+
* A stringify failure on a tree this module built itself is surfaced rather
|
|
974
|
+
* than thrown, because the prose inside a block arrived from a builder and
|
|
975
|
+
* may carry any node the kit admits; the kit's own error names what it could
|
|
976
|
+
* not serialize.
|
|
977
|
+
*
|
|
978
|
+
* @public
|
|
979
|
+
*/
|
|
980
|
+
declare function renderMarkdownResult(page: Page): Result.Result<string, MarkdownStringifyError>;
|
|
981
|
+
/**
|
|
982
|
+
* The Effect form of {@link renderMarkdownResult}.
|
|
983
|
+
*
|
|
984
|
+
* @public
|
|
985
|
+
*/
|
|
986
|
+
declare const renderMarkdown: (page: Page) => Effect.Effect<string, MarkdownStringifyError>;
|
|
987
|
+
//#endregion
|
|
988
|
+
//#region src/Scope.d.ts
|
|
989
|
+
/**
|
|
990
|
+
* API scope naming — the helpers that turn a package name and a base route
|
|
991
|
+
* into the identifiers every adapter must agree on.
|
|
992
|
+
*
|
|
993
|
+
* @remarks
|
|
994
|
+
* These sit beside the navigation tree rather than in an adapter because the
|
|
995
|
+
* scope string is load-bearing across frameworks: it keys Twoslash cache
|
|
996
|
+
* generations and names the per-package llms files. Two adapters deriving it
|
|
997
|
+
* differently would silently miss each other's caches. The multiVersion /
|
|
998
|
+
* i18n output-directory layout is NOT here — that is a framework's product
|
|
999
|
+
* policy and stays adapter-side.
|
|
1000
|
+
*
|
|
1001
|
+
* @packageDocumentation
|
|
1002
|
+
*/
|
|
1003
|
+
/**
|
|
1004
|
+
* Extract the unscoped name from a possibly scoped package name:
|
|
1005
|
+
* `@scope/pkg` becomes `pkg`, `pkg` stays `pkg`.
|
|
1006
|
+
*
|
|
1007
|
+
* @public
|
|
1008
|
+
*/
|
|
1009
|
+
declare function unscopedName(packageName: string): string;
|
|
1010
|
+
/**
|
|
1011
|
+
* Normalize a base route: ensure a leading slash, strip a trailing slash,
|
|
1012
|
+
* and keep the root as `/`.
|
|
1013
|
+
*
|
|
1014
|
+
* @public
|
|
1015
|
+
*/
|
|
1016
|
+
declare function normalizeBaseRoute(route: string): string;
|
|
1017
|
+
/**
|
|
1018
|
+
* The API scope key derived from a base route: its first path segment,
|
|
1019
|
+
* falling back to the package name so a single-API site mounted at `/`
|
|
1020
|
+
* still gets a non-empty scope.
|
|
1021
|
+
*
|
|
1022
|
+
* @remarks
|
|
1023
|
+
* Load-bearing and previously duplicated. Config resolution registers each
|
|
1024
|
+
* API's Twoslash environment under this key and the build program looks it
|
|
1025
|
+
* up by the same key; if two derivations disagree, every lookup misses and
|
|
1026
|
+
* per-scope type-checking degrades to build-wide with no error and nothing
|
|
1027
|
+
* visibly wrong in the output. One definition matters more than the
|
|
1028
|
+
* duplication was costing.
|
|
1029
|
+
*
|
|
1030
|
+
* @public
|
|
1031
|
+
*/
|
|
1032
|
+
declare function apiScopeOf(baseRoute: string, packageName: string): string;
|
|
1033
|
+
//#endregion
|
|
1034
|
+
//#region src/TwoslashDirectives.d.ts
|
|
1035
|
+
/**
|
|
1036
|
+
* Twoslash directive detection — the regexes that decide which lines of a
|
|
1037
|
+
* code block are notation rather than code.
|
|
1038
|
+
*
|
|
1039
|
+
* @remarks
|
|
1040
|
+
* These mirror the upstream Twoslash source
|
|
1041
|
+
* (`twoslashes/twoslash`, `packages/twoslash/src/regexp.ts`). All patterns
|
|
1042
|
+
* allow an optional space after `//`, so both `// @noErrors` and `//@noErrors`
|
|
1043
|
+
* are recognized, as Twoslash itself does. They live in the IR package
|
|
1044
|
+
* because the display/source split depends on them and both adapters must
|
|
1045
|
+
* strip the same lines.
|
|
1046
|
+
*
|
|
1047
|
+
* @packageDocumentation
|
|
1048
|
+
*/
|
|
1049
|
+
/**
|
|
1050
|
+
* The four cut directive forms.
|
|
1051
|
+
*
|
|
1052
|
+
* @public
|
|
1053
|
+
*/
|
|
1054
|
+
type CutDirective = "cut-before" | "cut-after" | "cut-start" | "cut-end";
|
|
1055
|
+
/**
|
|
1056
|
+
* Test whether a trimmed line is any Twoslash directive — a config flag or
|
|
1057
|
+
* value, a filename marker, an annotation marker or a cut directive.
|
|
1058
|
+
*
|
|
1059
|
+
* @param trimmedLine - The line with leading and trailing whitespace removed
|
|
1060
|
+
* @returns `true` if the line is a Twoslash directive
|
|
1061
|
+
* @public
|
|
1062
|
+
*/
|
|
1063
|
+
declare function isTwoslashDirective(trimmedLine: string): boolean;
|
|
1064
|
+
/**
|
|
1065
|
+
* Classify a cut directive line.
|
|
1066
|
+
*
|
|
1067
|
+
* @param trimmedLine - The line with leading and trailing whitespace removed
|
|
1068
|
+
* @returns The cut form, or `null` if the line is not a cut directive
|
|
1069
|
+
* @public
|
|
1070
|
+
*/
|
|
1071
|
+
declare function classifyCutDirective(trimmedLine: string): CutDirective | null;
|
|
1072
|
+
//#endregion
|
|
1073
|
+
//#region src/WorkItems.d.ts
|
|
1074
|
+
/**
|
|
1075
|
+
* Lower number = higher priority for which page a bare cross-link name
|
|
1076
|
+
* resolves to.
|
|
1077
|
+
*
|
|
1078
|
+
* @public
|
|
1079
|
+
*/
|
|
1080
|
+
declare function crossLinkKindPriority(kind: string): number;
|
|
1081
|
+
/**
|
|
1082
|
+
* The facts a category contributes to work-item preparation: how items are
|
|
1083
|
+
* matched to it and where its pages live.
|
|
1084
|
+
*
|
|
1085
|
+
* @public
|
|
1086
|
+
*/
|
|
1087
|
+
interface WorkItemCategory extends ApiItems.CategorySpec {
|
|
1088
|
+
/** The category's plural display name. */
|
|
1089
|
+
readonly displayName: string;
|
|
1090
|
+
/** The category's singular name — the second title part. */
|
|
1091
|
+
readonly singularName: string;
|
|
1092
|
+
/** The folder the category's pages live in. */
|
|
1093
|
+
readonly folderName: string;
|
|
1094
|
+
}
|
|
1095
|
+
/**
|
|
1096
|
+
* One page to build: the item plus every fact the builder needs from the
|
|
1097
|
+
* model that the item alone does not carry.
|
|
1098
|
+
*
|
|
1099
|
+
* @public
|
|
1100
|
+
*/
|
|
1101
|
+
interface WorkItem<C extends WorkItemCategory = WorkItemCategory> {
|
|
1102
|
+
/** The documented item. */
|
|
1103
|
+
readonly item: ApiItem;
|
|
1104
|
+
/** The category key the item was categorized under. */
|
|
1105
|
+
readonly categoryKey: string;
|
|
1106
|
+
/** The category the item was categorized under. */
|
|
1107
|
+
readonly categoryConfig: C;
|
|
1108
|
+
/** Present when the item is a namespace member documented on its own page. */
|
|
1109
|
+
readonly namespaceMember?: ApiItems.NamespaceMember;
|
|
1110
|
+
/** Entry points this item is available from. */
|
|
1111
|
+
readonly availableFrom?: string[];
|
|
1112
|
+
/**
|
|
1113
|
+
* Unexported base declaration referenced by this class's extends clause
|
|
1114
|
+
* (the `Foo_base` variable TypeScript emits for `Schema.Class`-style
|
|
1115
|
+
* patterns). Rendered inline on the class page instead of its own page.
|
|
1116
|
+
*/
|
|
1117
|
+
readonly syntheticBase?: ApiItem;
|
|
1118
|
+
/**
|
|
1119
|
+
* Anchor id per member, keyed by the member's canonical reference.
|
|
1120
|
+
*
|
|
1121
|
+
* @remarks
|
|
1122
|
+
* Computed here rather than in the page builder so the `#fragment` in the
|
|
1123
|
+
* cross-link route map and the id the page emits come from ONE computation
|
|
1124
|
+
* and cannot drift. Present for classes and interfaces.
|
|
1125
|
+
*/
|
|
1126
|
+
readonly memberAnchors?: ReadonlyMap<string, string>;
|
|
1127
|
+
}
|
|
1128
|
+
/**
|
|
1129
|
+
* The cross-link maps: display name to route, and display name to item kind
|
|
1130
|
+
* (used only to arbitrate which kind owns a bare name).
|
|
1131
|
+
*
|
|
1132
|
+
* @public
|
|
1133
|
+
*/
|
|
1134
|
+
interface CrossLinkData {
|
|
1135
|
+
/** Display name (or `Class.member` key) to route path. */
|
|
1136
|
+
readonly routes: Map<string, string>;
|
|
1137
|
+
/** Display name to API item kind. */
|
|
1138
|
+
readonly kinds: Map<string, string>;
|
|
1139
|
+
}
|
|
1140
|
+
/**
|
|
1141
|
+
* The input to {@link prepareWorkItems}.
|
|
1142
|
+
*
|
|
1143
|
+
* @public
|
|
1144
|
+
*/
|
|
1145
|
+
interface PrepareWorkItemsInput<C extends WorkItemCategory = WorkItemCategory> {
|
|
1146
|
+
/** The loaded API model. */
|
|
1147
|
+
readonly apiPackage: ApiPackage;
|
|
1148
|
+
/** The categories, in the order their groups are listed. */
|
|
1149
|
+
readonly categories: Readonly<Record<string, C>>;
|
|
1150
|
+
/** The API's base route. */
|
|
1151
|
+
readonly baseRoute: string;
|
|
1152
|
+
}
|
|
1153
|
+
/**
|
|
1154
|
+
* The result of {@link prepareWorkItems}.
|
|
1155
|
+
*
|
|
1156
|
+
* @remarks
|
|
1157
|
+
* `uncategorized` and `collisions` are returned rather than reported: the
|
|
1158
|
+
* RSPress adapter emits an `ItemSkipped` event per uncategorized item and
|
|
1159
|
+
* throws `Routes.RouteCollisionError` on any collision, and a second adapter
|
|
1160
|
+
* decides for itself. A caller that ignores `collisions` will write two
|
|
1161
|
+
* distinct items to one route, so check it.
|
|
1162
|
+
*
|
|
1163
|
+
* @public
|
|
1164
|
+
*/
|
|
1165
|
+
interface PrepareWorkItemsResult<C extends WorkItemCategory = WorkItemCategory> {
|
|
1166
|
+
/** Every page to build, top-level items first then namespace members. */
|
|
1167
|
+
readonly workItems: WorkItem<C>[];
|
|
1168
|
+
/** The cross-link maps both prose and code linkers consume. */
|
|
1169
|
+
readonly crossLinkData: CrossLinkData;
|
|
1170
|
+
/** Items no category matched; they get no page. */
|
|
1171
|
+
readonly uncategorized: ReadonlyArray<ApiItem>;
|
|
1172
|
+
/** Distinct items that would share one output route. */
|
|
1173
|
+
readonly collisions: ReadonlyArray<Routes.RouteCollision>;
|
|
1174
|
+
}
|
|
1175
|
+
/**
|
|
1176
|
+
* Prepare the flat list of work items to build and the cross-link maps.
|
|
1177
|
+
*
|
|
1178
|
+
* @remarks
|
|
1179
|
+
* Resolves entry points into deduplicated items, detects synthetic base
|
|
1180
|
+
* declarations (excluded from categorization, collision detection and work
|
|
1181
|
+
* items — the owner class page renders them inline), categorizes, detects
|
|
1182
|
+
* route collisions on the lowercased `folder/name` route, builds the route
|
|
1183
|
+
* map with bare names owned by the highest-priority kind and member routes
|
|
1184
|
+
* from the model's anchors, adds namespace member routes (qualified always,
|
|
1185
|
+
* unqualified PascalCase when unambiguous), routes synthetic base names to
|
|
1186
|
+
* the owner's `#base-class` anchor, and flattens everything into work items.
|
|
1187
|
+
*
|
|
1188
|
+
* @public
|
|
1189
|
+
*/
|
|
1190
|
+
declare function prepareWorkItems<C extends WorkItemCategory>(input: PrepareWorkItemsInput<C>): PrepareWorkItemsResult<C>;
|
|
1191
|
+
//#endregion
|
|
1192
|
+
export { AvailableFrom, BaseClass, Block, type BlockKind, type BuildIndexPageInput, type BuildNavInput, type BuildPageInput, CodeText, type CrossLinkData, type CutDirective, EnumMemberRow, EnumMemberTable, Example, ExampleFormatError, ExampleGroup, type HeadTag, INDEX_PAGE_TITLE, IndexPage, Inline, type LlmsTxtEntry, Member, MemberGroup, MemberIndex, MemberIndexEntry, MemberRole, NAV_INDEX_LABEL, NO_DESCRIPTION, type NamespaceMemberFacts, NavCategory, NavEntry, NavGroup, NavPage, NavTree, type PackageLlmsTxtInput, type PackagePointer, type PackageScopeInfo, Page, type PageContent, PageKind, ParameterRow, ParameterTable, type PrepareWorkItemsInput, type PrepareWorkItemsResult, type PreparedExample, Prose, ProseBlock, ProseRole, type RawExample, ReleaseTag, SeeAlso, Signature, SourceLink, Title, type WorkItem, type WorkItemCategory, addLogicalBlankLines, apiScopeOf, buildExample, buildIndexPage, buildNav, buildPage, classifyCutDirective, codeText, crossLinkKindPriority, filterLlmsFullTxt, filterLlmsTxt, formatExampleCode, generatePackageLlmsFullTxt, generatePackageLlmsTxt, generateStructuredLlmsTxt, isPageKind, isTwoslashDirective, markdownBlockTree, markdownTree, normalizeBaseRoute, parseLlmsTxtLine, prepareExampleCode, prepareWorkItems, prependHiddenImports, renderMarkdown, renderMarkdownResult, sortNavPages, stripTwoslashDirectives, unscopedName };
|
|
1193
|
+
//# sourceMappingURL=index.d.ts.map
|