@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/Blocks.js
ADDED
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
import { FlowContent, PhrasingContent } from "@effected/markdown";
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
|
|
4
|
+
//#region src/Blocks.ts
|
|
5
|
+
/**
|
|
6
|
+
* The block vocabulary — the things a generated API page is built from,
|
|
7
|
+
* named once so every adapter emits the same page in its own dialect.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* Each block is a `Schema.Class` carrying `Schema.tag` on a domain-named
|
|
11
|
+
* discriminant, `kind`, and the vocabulary is closed by the `Block`
|
|
12
|
+
* union. Not `Data.TaggedEnum`: the IR must be decodable, validated at
|
|
13
|
+
* construction and serializable as a stable artifact. Not
|
|
14
|
+
* `Schema.TaggedClass`: it hardwires `_tag`, and a vocabulary that sits
|
|
15
|
+
* beside mdast nodes discriminated on `type` reads better with its own key.
|
|
16
|
+
*
|
|
17
|
+
* Prose inside a block is `@effected/markdown` mdast — already cross-linked
|
|
18
|
+
* by the builder, so every emitter renders identical links. Code-bearing
|
|
19
|
+
* blocks carry a {@link CodeText} pair: `display` (what a reader sees and
|
|
20
|
+
* copies) and `source` (what the type-checker sees), produced once by the
|
|
21
|
+
* `Examples` module and never derived from each other in an emitter.
|
|
22
|
+
*
|
|
23
|
+
* @packageDocumentation
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* A run of block-level mdast — a summary paragraph, a remarks section.
|
|
27
|
+
*
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
const Prose = Schema.Array(FlowContent);
|
|
31
|
+
/**
|
|
32
|
+
* A run of inline mdast — a one-line description, a table cell, a
|
|
33
|
+
* deprecation message.
|
|
34
|
+
*
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
const Inline = Schema.Array(PhrasingContent);
|
|
38
|
+
/**
|
|
39
|
+
* The TSDoc release tag a page's title badge is derived from.
|
|
40
|
+
*
|
|
41
|
+
* @public
|
|
42
|
+
*/
|
|
43
|
+
const ReleaseTag = Schema.Literals([
|
|
44
|
+
"Public",
|
|
45
|
+
"Beta",
|
|
46
|
+
"Alpha",
|
|
47
|
+
"Internal"
|
|
48
|
+
]);
|
|
49
|
+
/**
|
|
50
|
+
* The two spellings of one code block: what a reader sees and what the
|
|
51
|
+
* type-checker sees.
|
|
52
|
+
*
|
|
53
|
+
* @remarks
|
|
54
|
+
* `source` is the type-check text — hidden `import type` lines, then
|
|
55
|
+
* `// ---cut---`, then the code, Twoslash directives intact. `display` is
|
|
56
|
+
* the directive-stripped text a reader sees and copies. RSPress spends them
|
|
57
|
+
* as two props; VitePress puts `source` in a `ts twoslash` fence and lets the
|
|
58
|
+
* cut marker hide the preamble. Carrying both is one field of redundancy
|
|
59
|
+
* against a transformer per framework.
|
|
60
|
+
*
|
|
61
|
+
* @public
|
|
62
|
+
*/
|
|
63
|
+
var CodeText = class extends Schema.Class("CodeText")({
|
|
64
|
+
/** The directive-stripped text a reader sees and copies. */
|
|
65
|
+
display: Schema.String,
|
|
66
|
+
/** The type-check text: hidden imports, cut marker, directives intact. */
|
|
67
|
+
source: Schema.String
|
|
68
|
+
}) {};
|
|
69
|
+
/**
|
|
70
|
+
* One row of a parameters table.
|
|
71
|
+
*
|
|
72
|
+
* @public
|
|
73
|
+
*/
|
|
74
|
+
var ParameterRow = class extends Schema.Class("ParameterRow")({
|
|
75
|
+
/** The parameter name as declared. */
|
|
76
|
+
name: Schema.String,
|
|
77
|
+
/** The parameter's type text from the declaration excerpt, when the declaration carries one. */
|
|
78
|
+
type: Schema.optionalKey(Schema.String),
|
|
79
|
+
/** The `@param` description, cross-linked. */
|
|
80
|
+
description: Inline
|
|
81
|
+
}) {};
|
|
82
|
+
/**
|
|
83
|
+
* One row of an enum members table.
|
|
84
|
+
*
|
|
85
|
+
* @public
|
|
86
|
+
*/
|
|
87
|
+
var EnumMemberRow = class extends Schema.Class("EnumMemberRow")({
|
|
88
|
+
/** The member name. */
|
|
89
|
+
name: Schema.String,
|
|
90
|
+
/** The initializer value, when the declaration carries one. */
|
|
91
|
+
value: Schema.optionalKey(Schema.String),
|
|
92
|
+
/** The member's summary, cross-linked. */
|
|
93
|
+
description: Inline
|
|
94
|
+
}) {};
|
|
95
|
+
/**
|
|
96
|
+
* The role a class or interface member plays, which decides its heading
|
|
97
|
+
* group and how an emitter labels it.
|
|
98
|
+
*
|
|
99
|
+
* @public
|
|
100
|
+
*/
|
|
101
|
+
const MemberRole = Schema.Literals([
|
|
102
|
+
"constructor",
|
|
103
|
+
"property",
|
|
104
|
+
"method",
|
|
105
|
+
"getter",
|
|
106
|
+
"call-signature",
|
|
107
|
+
"construct-signature",
|
|
108
|
+
"index-signature"
|
|
109
|
+
]);
|
|
110
|
+
/**
|
|
111
|
+
* One member of a class or interface: its own signature, summary and the
|
|
112
|
+
* anchor id every cross-link to it resolves against.
|
|
113
|
+
*
|
|
114
|
+
* @remarks
|
|
115
|
+
* `anchor` arrives as data from `ApiItems.memberAnchors` in
|
|
116
|
+
* `@tsdoctor/model`, threaded through the work item. No emitter recomputes
|
|
117
|
+
* it — the route map's `#fragment` and the page's element id must come from
|
|
118
|
+
* one computation, or cross-links land nowhere.
|
|
119
|
+
*
|
|
120
|
+
* @public
|
|
121
|
+
*/
|
|
122
|
+
var Member = class extends Schema.Class("Member")({
|
|
123
|
+
/** Which heading group the member belongs to and how it is labelled. */
|
|
124
|
+
role: MemberRole,
|
|
125
|
+
/** The member's display name (`constructor` for constructors). */
|
|
126
|
+
name: Schema.String,
|
|
127
|
+
/** The anchor id, computed once by the model's member-anchor algorithm. */
|
|
128
|
+
anchor: Schema.String,
|
|
129
|
+
/** The member signature in its owner's context. */
|
|
130
|
+
code: CodeText,
|
|
131
|
+
/** The member's summary, cross-linked. */
|
|
132
|
+
summary: Schema.optionalKey(Inline),
|
|
133
|
+
/** The member's parameters, when it has any. */
|
|
134
|
+
parameters: Schema.optionalKey(Schema.Array(ParameterRow)),
|
|
135
|
+
/** The `@returns` description, cross-linked. */
|
|
136
|
+
returns: Schema.optionalKey(Inline)
|
|
137
|
+
}) {};
|
|
138
|
+
/**
|
|
139
|
+
* One example: its language, its code and whether it is type-checked.
|
|
140
|
+
*
|
|
141
|
+
* @remarks
|
|
142
|
+
* A non-TypeScript example is never type-checked; emitters render its
|
|
143
|
+
* `display` in a plain fence. A type-checked example carries the `@noErrors`
|
|
144
|
+
* directive and the package import in `source`.
|
|
145
|
+
*
|
|
146
|
+
* @public
|
|
147
|
+
*/
|
|
148
|
+
var Example = class extends Schema.Class("Example")({
|
|
149
|
+
/** The fence language after normalization (`typescript` for TS/JS). */
|
|
150
|
+
language: Schema.String,
|
|
151
|
+
/** The formatted example. */
|
|
152
|
+
code: CodeText,
|
|
153
|
+
/** Whether the example is handed to Twoslash. */
|
|
154
|
+
typeChecked: Schema.Boolean
|
|
155
|
+
}) {};
|
|
156
|
+
/**
|
|
157
|
+
* One entry in a namespace page's member index.
|
|
158
|
+
*
|
|
159
|
+
* @public
|
|
160
|
+
*/
|
|
161
|
+
var MemberIndexEntry = class extends Schema.Class("MemberIndexEntry")({
|
|
162
|
+
/** The member's display name. */
|
|
163
|
+
name: Schema.String,
|
|
164
|
+
/** The route of the member's own page. */
|
|
165
|
+
route: Schema.String,
|
|
166
|
+
/** The member's summary, cross-linked. */
|
|
167
|
+
summary: Schema.optionalKey(Inline)
|
|
168
|
+
}) {};
|
|
169
|
+
/**
|
|
170
|
+
* The page title, with the release-tag badge and deprecation notice that
|
|
171
|
+
* render beside it.
|
|
172
|
+
*
|
|
173
|
+
* @public
|
|
174
|
+
*/
|
|
175
|
+
var Title = class extends Schema.Class("Title")({
|
|
176
|
+
kind: Schema.tag("title"),
|
|
177
|
+
/** The item's display name. */
|
|
178
|
+
name: Schema.String,
|
|
179
|
+
/** The release tag; emitters badge anything other than `Public`. */
|
|
180
|
+
releaseTag: ReleaseTag,
|
|
181
|
+
/** The `@deprecated` message, cross-linked, when present. */
|
|
182
|
+
deprecation: Schema.optionalKey(Inline)
|
|
183
|
+
}) {};
|
|
184
|
+
/**
|
|
185
|
+
* The "Available from" line for an item exported from several entry points.
|
|
186
|
+
*
|
|
187
|
+
* @public
|
|
188
|
+
*/
|
|
189
|
+
var AvailableFrom = class extends Schema.Class("AvailableFrom")({
|
|
190
|
+
kind: Schema.tag("available-from"),
|
|
191
|
+
/** The package name the entry points are spelled under. */
|
|
192
|
+
packageName: Schema.String,
|
|
193
|
+
/** Entry point names; `default` denotes the package root. */
|
|
194
|
+
entryPoints: Schema.Array(Schema.String)
|
|
195
|
+
}) {};
|
|
196
|
+
/**
|
|
197
|
+
* The role a prose block plays, which decides whether an emitter gives it a
|
|
198
|
+
* heading and what the heading says.
|
|
199
|
+
*
|
|
200
|
+
* @public
|
|
201
|
+
*/
|
|
202
|
+
const ProseRole = Schema.Literals([
|
|
203
|
+
"summary",
|
|
204
|
+
"remarks",
|
|
205
|
+
"returns"
|
|
206
|
+
]);
|
|
207
|
+
/**
|
|
208
|
+
* A prose section: the summary, the remarks, a function's returns.
|
|
209
|
+
*
|
|
210
|
+
* @public
|
|
211
|
+
*/
|
|
212
|
+
var ProseBlock = class extends Schema.Class("ProseBlock")({
|
|
213
|
+
kind: Schema.tag("prose"),
|
|
214
|
+
/** Which section this is. */
|
|
215
|
+
role: ProseRole,
|
|
216
|
+
/** The section body, cross-linked. */
|
|
217
|
+
content: Prose
|
|
218
|
+
}) {};
|
|
219
|
+
/**
|
|
220
|
+
* The link to the item's source code.
|
|
221
|
+
*
|
|
222
|
+
* @public
|
|
223
|
+
*/
|
|
224
|
+
var SourceLink = class extends Schema.Class("SourceLink")({
|
|
225
|
+
kind: Schema.tag("source-link"),
|
|
226
|
+
/** The resolved source URL. */
|
|
227
|
+
href: Schema.String
|
|
228
|
+
}) {};
|
|
229
|
+
/**
|
|
230
|
+
* The item's full signature block — a function signature, a class or
|
|
231
|
+
* interface skeleton listing every member, an enum with its members.
|
|
232
|
+
*
|
|
233
|
+
* @public
|
|
234
|
+
*/
|
|
235
|
+
var Signature = class extends Schema.Class("Signature")({
|
|
236
|
+
kind: Schema.tag("signature"),
|
|
237
|
+
/** The signature text pair. */
|
|
238
|
+
code: CodeText,
|
|
239
|
+
/** Whether a parameters table follows directly (functions). */
|
|
240
|
+
hasParameters: Schema.optionalKey(Schema.Boolean),
|
|
241
|
+
/** Whether a members table follows directly (enums). */
|
|
242
|
+
hasMembers: Schema.optionalKey(Schema.Boolean)
|
|
243
|
+
}) {};
|
|
244
|
+
/**
|
|
245
|
+
* The inline "Base Class" section for a synthetic base declaration — the
|
|
246
|
+
* unexported `Foo_base` an exported class extends.
|
|
247
|
+
*
|
|
248
|
+
* @remarks
|
|
249
|
+
* The section heading slugs to `SyntheticBases.BASE_CLASS_ANCHOR` in
|
|
250
|
+
* `@tsdoctor/model`, which is where the base name's cross-link route points.
|
|
251
|
+
*
|
|
252
|
+
* @public
|
|
253
|
+
*/
|
|
254
|
+
var BaseClass = class extends Schema.Class("BaseClass")({
|
|
255
|
+
kind: Schema.tag("base-class"),
|
|
256
|
+
/** The exported class. */
|
|
257
|
+
className: Schema.String,
|
|
258
|
+
/** The unexported base declaration's name. */
|
|
259
|
+
baseName: Schema.String,
|
|
260
|
+
/** The package the base is not exported from. */
|
|
261
|
+
packageName: Schema.String,
|
|
262
|
+
/** The base declaration's signature. */
|
|
263
|
+
code: CodeText
|
|
264
|
+
}) {};
|
|
265
|
+
/**
|
|
266
|
+
* A heading group of members — "Constructors", "Static Methods",
|
|
267
|
+
* "Properties", "Call Signatures" — in the order the page lists them.
|
|
268
|
+
*
|
|
269
|
+
* @public
|
|
270
|
+
*/
|
|
271
|
+
var MemberGroup = class extends Schema.Class("MemberGroup")({
|
|
272
|
+
kind: Schema.tag("member-group"),
|
|
273
|
+
/** The group heading. */
|
|
274
|
+
title: Schema.String,
|
|
275
|
+
/** The members, in declaration order. */
|
|
276
|
+
members: Schema.Array(Member)
|
|
277
|
+
}) {};
|
|
278
|
+
/**
|
|
279
|
+
* A parameters table at page level — a function's parameters, adjacent to
|
|
280
|
+
* its signature.
|
|
281
|
+
*
|
|
282
|
+
* @public
|
|
283
|
+
*/
|
|
284
|
+
var ParameterTable = class extends Schema.Class("ParameterTable")({
|
|
285
|
+
kind: Schema.tag("parameters"),
|
|
286
|
+
/** The rows, in declaration order. */
|
|
287
|
+
rows: Schema.Array(ParameterRow)
|
|
288
|
+
}) {};
|
|
289
|
+
/**
|
|
290
|
+
* An enum's members table, adjacent to its signature.
|
|
291
|
+
*
|
|
292
|
+
* @public
|
|
293
|
+
*/
|
|
294
|
+
var EnumMemberTable = class extends Schema.Class("EnumMemberTable")({
|
|
295
|
+
kind: Schema.tag("enum-members"),
|
|
296
|
+
/** The rows, in declaration order. */
|
|
297
|
+
rows: Schema.Array(EnumMemberRow)
|
|
298
|
+
}) {};
|
|
299
|
+
/**
|
|
300
|
+
* The "Examples" section.
|
|
301
|
+
*
|
|
302
|
+
* @public
|
|
303
|
+
*/
|
|
304
|
+
var ExampleGroup = class extends Schema.Class("ExampleGroup")({
|
|
305
|
+
kind: Schema.tag("examples"),
|
|
306
|
+
/** The examples, in TSDoc order. */
|
|
307
|
+
items: Schema.Array(Example)
|
|
308
|
+
}) {};
|
|
309
|
+
/**
|
|
310
|
+
* The "See Also" section — one cross-linked reference per `@see` tag.
|
|
311
|
+
*
|
|
312
|
+
* @public
|
|
313
|
+
*/
|
|
314
|
+
var SeeAlso = class extends Schema.Class("SeeAlso")({
|
|
315
|
+
kind: Schema.tag("see-also"),
|
|
316
|
+
/** The references, in TSDoc order. */
|
|
317
|
+
references: Schema.Array(Inline)
|
|
318
|
+
}) {};
|
|
319
|
+
/**
|
|
320
|
+
* A namespace page's index of one member kind — "Classes", "Functions" —
|
|
321
|
+
* linking to each member's own page.
|
|
322
|
+
*
|
|
323
|
+
* @public
|
|
324
|
+
*/
|
|
325
|
+
var MemberIndex = class extends Schema.Class("MemberIndex")({
|
|
326
|
+
kind: Schema.tag("member-index"),
|
|
327
|
+
/** The section heading. */
|
|
328
|
+
title: Schema.String,
|
|
329
|
+
/** The entries, in declaration order. */
|
|
330
|
+
entries: Schema.Array(MemberIndexEntry)
|
|
331
|
+
}) {};
|
|
332
|
+
/**
|
|
333
|
+
* The closed vocabulary: every block a page may carry.
|
|
334
|
+
*
|
|
335
|
+
* @remarks
|
|
336
|
+
* Narrow on `kind`. Construct the variant classes rather than the union's
|
|
337
|
+
* inherited `make`, which typechecks against every member and yields a
|
|
338
|
+
* many-branch error when it fails.
|
|
339
|
+
*
|
|
340
|
+
* @public
|
|
341
|
+
*/
|
|
342
|
+
const Block = Schema.Union([
|
|
343
|
+
Title,
|
|
344
|
+
AvailableFrom,
|
|
345
|
+
ProseBlock,
|
|
346
|
+
SourceLink,
|
|
347
|
+
Signature,
|
|
348
|
+
BaseClass,
|
|
349
|
+
MemberGroup,
|
|
350
|
+
ParameterTable,
|
|
351
|
+
EnumMemberTable,
|
|
352
|
+
ExampleGroup,
|
|
353
|
+
SeeAlso,
|
|
354
|
+
MemberIndex
|
|
355
|
+
]);
|
|
356
|
+
|
|
357
|
+
//#endregion
|
|
358
|
+
export { AvailableFrom, BaseClass, Block, CodeText, EnumMemberRow, EnumMemberTable, Example, ExampleGroup, Inline, Member, MemberGroup, MemberIndex, MemberIndexEntry, MemberRole, ParameterRow, ParameterTable, Prose, ProseBlock, ProseRole, ReleaseTag, SeeAlso, Signature, SourceLink, Title };
|