@doc-kit/core 1.1.0 → 1.2.1
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/CHANGELOG.md +16 -0
- package/README.md +2 -1
- package/package.json +9 -4
- package/src/generators/index.mjs +2 -0
- package/src/generators/json/README.md +151 -0
- package/src/generators/json/constants.mjs +57 -0
- package/src/generators/json/generate.mjs +65 -0
- package/src/generators/json/generated/schema.d.ts +351 -0
- package/src/generators/json/index.mjs +27 -0
- package/src/generators/json/schema.json +529 -0
- package/src/generators/json/types.d.ts +29 -0
- package/src/generators/json/utils/document.mjs +58 -0
- package/src/generators/json/utils/entry.mjs +87 -0
- package/src/generators/json/utils/lifecycle.mjs +61 -0
- package/src/generators/json/utils/markdown.mjs +57 -0
- package/src/generators/json/utils/node.mjs +153 -0
- package/src/generators/json/utils/schema.mjs +15 -0
- package/src/generators/json/utils/signature.mjs +185 -0
- package/src/generators/json/utils/types.mjs +28 -0
- package/src/generators/json-all/README.md +31 -0
- package/src/generators/json-all/constants.mjs +5 -0
- package/src/generators/json-all/generate.mjs +35 -0
- package/src/generators/json-all/index.mjs +25 -0
- package/src/generators/json-all/schema.json +22 -0
- package/src/generators/json-all/types.d.ts +20 -0
- package/src/generators/json-simple/generate.mjs +2 -7
- package/src/generators/metadata/maps/mdn.json +10 -2
- package/src/generators/metadata/types.d.ts +5 -0
- package/src/generators/metadata/utils/transformers.mjs +1 -1
- package/src/logger/logger.mjs +8 -0
- package/src/threading/chunk-worker.mjs +7 -0
- package/src/threading/index.mjs +1 -0
- package/src/utils/file.mjs +10 -0
- package/src/utils/hierarchy.mjs +50 -0
- package/src/utils/overloads.mjs +54 -0
- package/src/utils/queries/index.mjs +2 -0
- package/src/utils/queries/utils.mjs +15 -0
- package/src/utils/remark.mjs +1 -1
- package/src/utils/signature/constants.mjs +3 -0
- package/src/utils/signature/extractListItem.mjs +140 -0
- package/src/utils/stability.mjs +24 -0
|
@@ -0,0 +1,529 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$id": "https://doc-kit.nodejs.org/schemas/api-doc/1.0.1.json",
|
|
4
|
+
"title": "Document",
|
|
5
|
+
"description": "One API documentation source file, as emitted by the doc-kit `json` generator. The file is the root of a tree of nodes, one per heading, in document order.",
|
|
6
|
+
"allOf": [
|
|
7
|
+
{ "$ref": "#/definitions/Entry" },
|
|
8
|
+
{
|
|
9
|
+
"type": "object",
|
|
10
|
+
"properties": {
|
|
11
|
+
"$schema": {
|
|
12
|
+
"type": "string",
|
|
13
|
+
"description": "The URL of the schema this document conforms to. Its last path segment is the schema version."
|
|
14
|
+
},
|
|
15
|
+
"id": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"description": "The document's identifier: its path, slugged. Unique within a documentation set.",
|
|
18
|
+
"examples": ["fs", "child_process"]
|
|
19
|
+
},
|
|
20
|
+
"path": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"description": "The document's path inside the input tree, without extension. Cross-document links target `<path>.html`.",
|
|
23
|
+
"examples": ["/fs"]
|
|
24
|
+
},
|
|
25
|
+
"type": {
|
|
26
|
+
"type": "string",
|
|
27
|
+
"enum": ["module", "misc", "global"],
|
|
28
|
+
"description": "The document's declared type: a module reference, a miscellaneous (conceptual) page, or a page of globals."
|
|
29
|
+
},
|
|
30
|
+
"module": {
|
|
31
|
+
"type": ["string", "null"],
|
|
32
|
+
"description": "The name of the module the document describes, when it describes one.",
|
|
33
|
+
"examples": ["fs"]
|
|
34
|
+
},
|
|
35
|
+
"introducedIn": {
|
|
36
|
+
"type": ["string", "null"],
|
|
37
|
+
"description": "The version the document itself was introduced in."
|
|
38
|
+
},
|
|
39
|
+
"sourceLink": {
|
|
40
|
+
"oneOf": [{ "$ref": "#/definitions/SourceLink" }, { "type": "null" }],
|
|
41
|
+
"description": "The implementation the document describes, when it links to one."
|
|
42
|
+
},
|
|
43
|
+
"children": {
|
|
44
|
+
"type": "array",
|
|
45
|
+
"items": { "$ref": "#/definitions/Node" },
|
|
46
|
+
"description": "The document's headings, nested by depth, in document order."
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"required": [
|
|
50
|
+
"$schema",
|
|
51
|
+
"id",
|
|
52
|
+
"path",
|
|
53
|
+
"type",
|
|
54
|
+
"module",
|
|
55
|
+
"introducedIn",
|
|
56
|
+
"sourceLink",
|
|
57
|
+
"children"
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
"definitions": {
|
|
62
|
+
"Version": {
|
|
63
|
+
"title": "Version",
|
|
64
|
+
"type": "string",
|
|
65
|
+
"description": "A version string as authored, such as `v18.0.0`, or a release-process placeholder such as `REPLACEME`.",
|
|
66
|
+
"examples": ["v18.0.0"]
|
|
67
|
+
},
|
|
68
|
+
"SourceLink": {
|
|
69
|
+
"title": "SourceLink",
|
|
70
|
+
"type": "object",
|
|
71
|
+
"description": "A link to the implementation a document describes.",
|
|
72
|
+
"properties": {
|
|
73
|
+
"path": {
|
|
74
|
+
"type": "string",
|
|
75
|
+
"description": "The implementation's path, relative to the repository root, as authored.",
|
|
76
|
+
"examples": ["lib/fs.js"]
|
|
77
|
+
},
|
|
78
|
+
"url": {
|
|
79
|
+
"type": ["string", "null"],
|
|
80
|
+
"description": "The implementation's URL, when a repository is configured."
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
"required": ["path", "url"],
|
|
84
|
+
"additionalProperties": false
|
|
85
|
+
},
|
|
86
|
+
"Stability": {
|
|
87
|
+
"title": "Stability",
|
|
88
|
+
"type": "object",
|
|
89
|
+
"description": "An entry's stability index.",
|
|
90
|
+
"properties": {
|
|
91
|
+
"index": {
|
|
92
|
+
"type": "string",
|
|
93
|
+
"pattern": "^[0-5](\\.[0-9])?$",
|
|
94
|
+
"description": "The index as authored, including any sub-level, such as `1.1`."
|
|
95
|
+
},
|
|
96
|
+
"description": {
|
|
97
|
+
"type": "string",
|
|
98
|
+
"description": "The text following the index, as Markdown."
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
"required": ["index", "description"],
|
|
102
|
+
"additionalProperties": false
|
|
103
|
+
},
|
|
104
|
+
"Change": {
|
|
105
|
+
"title": "Change",
|
|
106
|
+
"type": "object",
|
|
107
|
+
"description": "One record of an entry's change history.",
|
|
108
|
+
"properties": {
|
|
109
|
+
"versions": {
|
|
110
|
+
"type": "array",
|
|
111
|
+
"items": { "$ref": "#/definitions/Version" },
|
|
112
|
+
"description": "The versions the change shipped in."
|
|
113
|
+
},
|
|
114
|
+
"prUrl": {
|
|
115
|
+
"type": ["string", "null"],
|
|
116
|
+
"description": "The pull request that made the change."
|
|
117
|
+
},
|
|
118
|
+
"commit": {
|
|
119
|
+
"type": ["string", "null"],
|
|
120
|
+
"description": "The commit that made the change, on records that predate pull requests."
|
|
121
|
+
},
|
|
122
|
+
"description": {
|
|
123
|
+
"type": "string",
|
|
124
|
+
"description": "What changed, as Markdown."
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
"required": ["versions", "prUrl", "commit", "description"],
|
|
128
|
+
"additionalProperties": false
|
|
129
|
+
},
|
|
130
|
+
"Example": {
|
|
131
|
+
"title": "Example",
|
|
132
|
+
"type": "object",
|
|
133
|
+
"description": "A fenced code block from an entry's body.",
|
|
134
|
+
"properties": {
|
|
135
|
+
"language": {
|
|
136
|
+
"type": ["string", "null"],
|
|
137
|
+
"description": "The code block's language identifier."
|
|
138
|
+
},
|
|
139
|
+
"displayName": {
|
|
140
|
+
"type": ["string", "null"],
|
|
141
|
+
"description": "The code block's `displayName` attribute."
|
|
142
|
+
},
|
|
143
|
+
"code": {
|
|
144
|
+
"type": "string",
|
|
145
|
+
"description": "The code."
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
"required": ["language", "displayName", "code"],
|
|
149
|
+
"additionalProperties": false
|
|
150
|
+
},
|
|
151
|
+
"TypeLink": {
|
|
152
|
+
"title": "TypeLink",
|
|
153
|
+
"type": "object",
|
|
154
|
+
"description": "A type name inside a type's text, resolved to documentation.",
|
|
155
|
+
"properties": {
|
|
156
|
+
"name": {
|
|
157
|
+
"type": "string",
|
|
158
|
+
"description": "The resolved name, exactly as it appears in the text."
|
|
159
|
+
},
|
|
160
|
+
"href": {
|
|
161
|
+
"type": "string",
|
|
162
|
+
"description": "Where the name is documented: a URL, or a link relative to the document."
|
|
163
|
+
},
|
|
164
|
+
"start": {
|
|
165
|
+
"type": "integer",
|
|
166
|
+
"minimum": 0,
|
|
167
|
+
"description": "The offset of the name's first character in the text."
|
|
168
|
+
},
|
|
169
|
+
"end": {
|
|
170
|
+
"type": "integer",
|
|
171
|
+
"minimum": 0,
|
|
172
|
+
"description": "The offset after the name's last character in the text."
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
"required": ["name", "href", "start", "end"],
|
|
176
|
+
"additionalProperties": false
|
|
177
|
+
},
|
|
178
|
+
"Type": {
|
|
179
|
+
"title": "Type",
|
|
180
|
+
"type": "object",
|
|
181
|
+
"description": "A type annotation.",
|
|
182
|
+
"properties": {
|
|
183
|
+
"text": {
|
|
184
|
+
"type": "string",
|
|
185
|
+
"description": "The annotation as a TypeScript type expression, normalised: single-line, union members separated by ` | `.",
|
|
186
|
+
"examples": ["string | Buffer | URL"]
|
|
187
|
+
},
|
|
188
|
+
"links": {
|
|
189
|
+
"type": "array",
|
|
190
|
+
"items": { "$ref": "#/definitions/TypeLink" },
|
|
191
|
+
"description": "The resolved names in the text, by offset, non-overlapping."
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
"required": ["text", "links"],
|
|
195
|
+
"additionalProperties": false
|
|
196
|
+
},
|
|
197
|
+
"Parameter": {
|
|
198
|
+
"title": "Parameter",
|
|
199
|
+
"type": "object",
|
|
200
|
+
"description": "A parameter of a signature or event, or a property of an object parameter.",
|
|
201
|
+
"properties": {
|
|
202
|
+
"name": {
|
|
203
|
+
"type": "string",
|
|
204
|
+
"description": "The parameter's name, without any rest marker."
|
|
205
|
+
},
|
|
206
|
+
"type": {
|
|
207
|
+
"oneOf": [{ "$ref": "#/definitions/Type" }, { "type": "null" }],
|
|
208
|
+
"description": "The parameter's type, when documented."
|
|
209
|
+
},
|
|
210
|
+
"description": {
|
|
211
|
+
"type": "string",
|
|
212
|
+
"description": "The parameter's description, as Markdown, without its default value."
|
|
213
|
+
},
|
|
214
|
+
"default": {
|
|
215
|
+
"type": ["string", "null"],
|
|
216
|
+
"description": "The default value as authored, such as `'utf8'` or `false`.",
|
|
217
|
+
"examples": ["'utf8'"]
|
|
218
|
+
},
|
|
219
|
+
"optional": {
|
|
220
|
+
"type": "boolean",
|
|
221
|
+
"description": "Whether the parameter may be omitted: bracketed in the signature, or documented with a default."
|
|
222
|
+
},
|
|
223
|
+
"rest": {
|
|
224
|
+
"type": "boolean",
|
|
225
|
+
"description": "Whether the parameter is a rest parameter."
|
|
226
|
+
},
|
|
227
|
+
"properties": {
|
|
228
|
+
"type": "array",
|
|
229
|
+
"items": { "$ref": "#/definitions/Parameter" },
|
|
230
|
+
"description": "The documented properties of an object parameter, or the arguments of a callback."
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
"required": [
|
|
234
|
+
"name",
|
|
235
|
+
"type",
|
|
236
|
+
"description",
|
|
237
|
+
"default",
|
|
238
|
+
"optional",
|
|
239
|
+
"rest",
|
|
240
|
+
"properties"
|
|
241
|
+
],
|
|
242
|
+
"additionalProperties": false
|
|
243
|
+
},
|
|
244
|
+
"Return": {
|
|
245
|
+
"title": "Return",
|
|
246
|
+
"type": "object",
|
|
247
|
+
"description": "A signature's return value.",
|
|
248
|
+
"properties": {
|
|
249
|
+
"type": {
|
|
250
|
+
"oneOf": [{ "$ref": "#/definitions/Type" }, { "type": "null" }],
|
|
251
|
+
"description": "The return type, when documented."
|
|
252
|
+
},
|
|
253
|
+
"description": {
|
|
254
|
+
"type": "string",
|
|
255
|
+
"description": "The return value's description, as Markdown."
|
|
256
|
+
}
|
|
257
|
+
},
|
|
258
|
+
"required": ["type", "description"],
|
|
259
|
+
"additionalProperties": false
|
|
260
|
+
},
|
|
261
|
+
"Signature": {
|
|
262
|
+
"title": "Signature",
|
|
263
|
+
"type": "object",
|
|
264
|
+
"description": "A callable's signature: the parameters declared in its heading, described by its typed list.",
|
|
265
|
+
"properties": {
|
|
266
|
+
"parameters": {
|
|
267
|
+
"type": "array",
|
|
268
|
+
"items": { "$ref": "#/definitions/Parameter" },
|
|
269
|
+
"description": "The parameters, in declaration order."
|
|
270
|
+
},
|
|
271
|
+
"returns": {
|
|
272
|
+
"oneOf": [{ "$ref": "#/definitions/Return" }, { "type": "null" }],
|
|
273
|
+
"description": "The return value, when documented."
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
"required": ["parameters", "returns"],
|
|
277
|
+
"additionalProperties": false
|
|
278
|
+
},
|
|
279
|
+
"Entry": {
|
|
280
|
+
"title": "Entry",
|
|
281
|
+
"type": "object",
|
|
282
|
+
"description": "What every heading, the document's own included, carries: its metadata and its body.",
|
|
283
|
+
"properties": {
|
|
284
|
+
"title": {
|
|
285
|
+
"type": "string",
|
|
286
|
+
"description": "The heading text as authored, inline Markdown included.",
|
|
287
|
+
"examples": ["`fs.readFile(path[, options], callback)`"]
|
|
288
|
+
},
|
|
289
|
+
"stability": {
|
|
290
|
+
"oneOf": [{ "$ref": "#/definitions/Stability" }, { "type": "null" }],
|
|
291
|
+
"description": "The entry's stability index, when declared."
|
|
292
|
+
},
|
|
293
|
+
"added": {
|
|
294
|
+
"type": "array",
|
|
295
|
+
"items": { "$ref": "#/definitions/Version" },
|
|
296
|
+
"description": "The versions the entry was added in, as authored."
|
|
297
|
+
},
|
|
298
|
+
"deprecated": {
|
|
299
|
+
"type": "array",
|
|
300
|
+
"items": { "$ref": "#/definitions/Version" },
|
|
301
|
+
"description": "The versions the entry was deprecated in."
|
|
302
|
+
},
|
|
303
|
+
"removed": {
|
|
304
|
+
"type": "array",
|
|
305
|
+
"items": { "$ref": "#/definitions/Version" },
|
|
306
|
+
"description": "The versions the entry was removed in."
|
|
307
|
+
},
|
|
308
|
+
"napiVersion": {
|
|
309
|
+
"type": "array",
|
|
310
|
+
"items": { "type": "number" },
|
|
311
|
+
"description": "The Node-API versions the entry is available in."
|
|
312
|
+
},
|
|
313
|
+
"changes": {
|
|
314
|
+
"type": "array",
|
|
315
|
+
"items": { "$ref": "#/definitions/Change" },
|
|
316
|
+
"description": "The entry's change history, as authored."
|
|
317
|
+
},
|
|
318
|
+
"description": {
|
|
319
|
+
"type": "string",
|
|
320
|
+
"description": "The entry's body as Markdown: everything under the heading except its metadata, stability index, and the typed list a signature or type was taken from. Empty when the entry has no body."
|
|
321
|
+
},
|
|
322
|
+
"summary": {
|
|
323
|
+
"type": "string",
|
|
324
|
+
"description": "A one-paragraph plain-text summary: the entry's `llm_description` when declared, else its first paragraph."
|
|
325
|
+
},
|
|
326
|
+
"examples": {
|
|
327
|
+
"type": "array",
|
|
328
|
+
"items": { "$ref": "#/definitions/Example" },
|
|
329
|
+
"description": "The fenced code blocks in the body. They remain in the description too."
|
|
330
|
+
}
|
|
331
|
+
},
|
|
332
|
+
"required": [
|
|
333
|
+
"title",
|
|
334
|
+
"stability",
|
|
335
|
+
"added",
|
|
336
|
+
"deprecated",
|
|
337
|
+
"removed",
|
|
338
|
+
"napiVersion",
|
|
339
|
+
"changes",
|
|
340
|
+
"description",
|
|
341
|
+
"summary",
|
|
342
|
+
"examples"
|
|
343
|
+
]
|
|
344
|
+
},
|
|
345
|
+
"NodeBase": {
|
|
346
|
+
"title": "NodeBase",
|
|
347
|
+
"type": "object",
|
|
348
|
+
"description": "What every node below the document root carries, on top of an entry.",
|
|
349
|
+
"properties": {
|
|
350
|
+
"kind": {
|
|
351
|
+
"type": "string",
|
|
352
|
+
"enum": [
|
|
353
|
+
"section",
|
|
354
|
+
"class",
|
|
355
|
+
"constructor",
|
|
356
|
+
"method",
|
|
357
|
+
"staticMethod",
|
|
358
|
+
"property",
|
|
359
|
+
"event"
|
|
360
|
+
],
|
|
361
|
+
"description": "What the heading documents. Decides which further properties the node has."
|
|
362
|
+
},
|
|
363
|
+
"id": {
|
|
364
|
+
"type": "string",
|
|
365
|
+
"description": "The heading's slug, unique within the document. It is the heading's anchor in HTML output.",
|
|
366
|
+
"examples": ["fsreadfilepath-options-callback"]
|
|
367
|
+
},
|
|
368
|
+
"name": {
|
|
369
|
+
"type": "string",
|
|
370
|
+
"description": "The bare identifier the heading documents, or the heading's plain text for a section.",
|
|
371
|
+
"examples": ["readFile", "Server", "close"]
|
|
372
|
+
},
|
|
373
|
+
"scope": {
|
|
374
|
+
"type": "string",
|
|
375
|
+
"enum": ["module", "global"],
|
|
376
|
+
"description": "Whether the entry is reached through its module, or available globally."
|
|
377
|
+
},
|
|
378
|
+
"overloadOf": {
|
|
379
|
+
"type": ["string", "null"],
|
|
380
|
+
"description": "For the second and later of several sibling headings documenting one callable, the `id` of the first."
|
|
381
|
+
},
|
|
382
|
+
"children": {
|
|
383
|
+
"type": "array",
|
|
384
|
+
"items": { "$ref": "#/definitions/Node" },
|
|
385
|
+
"description": "The headings nested under this one, in document order."
|
|
386
|
+
}
|
|
387
|
+
},
|
|
388
|
+
"required": ["kind", "id", "name", "scope", "overloadOf", "children"]
|
|
389
|
+
},
|
|
390
|
+
"SectionNode": {
|
|
391
|
+
"title": "SectionNode",
|
|
392
|
+
"description": "A heading that documents no API entry: prose, a deprecation, a command-line option.",
|
|
393
|
+
"allOf": [
|
|
394
|
+
{ "$ref": "#/definitions/Entry" },
|
|
395
|
+
{ "$ref": "#/definitions/NodeBase" },
|
|
396
|
+
{
|
|
397
|
+
"type": "object",
|
|
398
|
+
"properties": {
|
|
399
|
+
"kind": { "const": "section" }
|
|
400
|
+
},
|
|
401
|
+
"required": ["kind"]
|
|
402
|
+
}
|
|
403
|
+
]
|
|
404
|
+
},
|
|
405
|
+
"ClassNode": {
|
|
406
|
+
"title": "ClassNode",
|
|
407
|
+
"description": "A class. Its constructors, methods, properties and events are its children.",
|
|
408
|
+
"allOf": [
|
|
409
|
+
{ "$ref": "#/definitions/Entry" },
|
|
410
|
+
{ "$ref": "#/definitions/NodeBase" },
|
|
411
|
+
{
|
|
412
|
+
"type": "object",
|
|
413
|
+
"properties": {
|
|
414
|
+
"kind": { "const": "class" },
|
|
415
|
+
"extends": {
|
|
416
|
+
"oneOf": [{ "$ref": "#/definitions/Type" }, { "type": "null" }],
|
|
417
|
+
"description": "The class the class extends, when documented."
|
|
418
|
+
}
|
|
419
|
+
},
|
|
420
|
+
"required": ["kind", "extends"]
|
|
421
|
+
}
|
|
422
|
+
]
|
|
423
|
+
},
|
|
424
|
+
"ConstructorNode": {
|
|
425
|
+
"title": "ConstructorNode",
|
|
426
|
+
"description": "A class constructor.",
|
|
427
|
+
"allOf": [
|
|
428
|
+
{ "$ref": "#/definitions/Entry" },
|
|
429
|
+
{ "$ref": "#/definitions/NodeBase" },
|
|
430
|
+
{
|
|
431
|
+
"type": "object",
|
|
432
|
+
"properties": {
|
|
433
|
+
"kind": { "const": "constructor" },
|
|
434
|
+
"signature": { "$ref": "#/definitions/Signature" }
|
|
435
|
+
},
|
|
436
|
+
"required": ["kind", "signature"]
|
|
437
|
+
}
|
|
438
|
+
]
|
|
439
|
+
},
|
|
440
|
+
"MethodNode": {
|
|
441
|
+
"title": "MethodNode",
|
|
442
|
+
"description": "A function or method.",
|
|
443
|
+
"allOf": [
|
|
444
|
+
{ "$ref": "#/definitions/Entry" },
|
|
445
|
+
{ "$ref": "#/definitions/NodeBase" },
|
|
446
|
+
{
|
|
447
|
+
"type": "object",
|
|
448
|
+
"properties": {
|
|
449
|
+
"kind": { "const": "method" },
|
|
450
|
+
"signature": { "$ref": "#/definitions/Signature" }
|
|
451
|
+
},
|
|
452
|
+
"required": ["kind", "signature"]
|
|
453
|
+
}
|
|
454
|
+
]
|
|
455
|
+
},
|
|
456
|
+
"StaticMethodNode": {
|
|
457
|
+
"title": "StaticMethodNode",
|
|
458
|
+
"description": "A static method of a class.",
|
|
459
|
+
"allOf": [
|
|
460
|
+
{ "$ref": "#/definitions/Entry" },
|
|
461
|
+
{ "$ref": "#/definitions/NodeBase" },
|
|
462
|
+
{
|
|
463
|
+
"type": "object",
|
|
464
|
+
"properties": {
|
|
465
|
+
"kind": { "const": "staticMethod" },
|
|
466
|
+
"signature": { "$ref": "#/definitions/Signature" }
|
|
467
|
+
},
|
|
468
|
+
"required": ["kind", "signature"]
|
|
469
|
+
}
|
|
470
|
+
]
|
|
471
|
+
},
|
|
472
|
+
"PropertyNode": {
|
|
473
|
+
"title": "PropertyNode",
|
|
474
|
+
"description": "A property of a module, class or object.",
|
|
475
|
+
"allOf": [
|
|
476
|
+
{ "$ref": "#/definitions/Entry" },
|
|
477
|
+
{ "$ref": "#/definitions/NodeBase" },
|
|
478
|
+
{
|
|
479
|
+
"type": "object",
|
|
480
|
+
"properties": {
|
|
481
|
+
"kind": { "const": "property" },
|
|
482
|
+
"type": {
|
|
483
|
+
"oneOf": [{ "$ref": "#/definitions/Type" }, { "type": "null" }],
|
|
484
|
+
"description": "The property's type, when documented."
|
|
485
|
+
},
|
|
486
|
+
"default": {
|
|
487
|
+
"type": ["string", "null"],
|
|
488
|
+
"description": "The property's default value as authored, when documented."
|
|
489
|
+
}
|
|
490
|
+
},
|
|
491
|
+
"required": ["kind", "type", "default"]
|
|
492
|
+
}
|
|
493
|
+
]
|
|
494
|
+
},
|
|
495
|
+
"EventNode": {
|
|
496
|
+
"title": "EventNode",
|
|
497
|
+
"description": "An event emitted by the parent class or module.",
|
|
498
|
+
"allOf": [
|
|
499
|
+
{ "$ref": "#/definitions/Entry" },
|
|
500
|
+
{ "$ref": "#/definitions/NodeBase" },
|
|
501
|
+
{
|
|
502
|
+
"type": "object",
|
|
503
|
+
"properties": {
|
|
504
|
+
"kind": { "const": "event" },
|
|
505
|
+
"parameters": {
|
|
506
|
+
"type": "array",
|
|
507
|
+
"items": { "$ref": "#/definitions/Parameter" },
|
|
508
|
+
"description": "The arguments passed to the event's listeners."
|
|
509
|
+
}
|
|
510
|
+
},
|
|
511
|
+
"required": ["kind", "parameters"]
|
|
512
|
+
}
|
|
513
|
+
]
|
|
514
|
+
},
|
|
515
|
+
"Node": {
|
|
516
|
+
"title": "Node",
|
|
517
|
+
"description": "A heading below the document root.",
|
|
518
|
+
"oneOf": [
|
|
519
|
+
{ "$ref": "#/definitions/SectionNode" },
|
|
520
|
+
{ "$ref": "#/definitions/ClassNode" },
|
|
521
|
+
{ "$ref": "#/definitions/ConstructorNode" },
|
|
522
|
+
{ "$ref": "#/definitions/MethodNode" },
|
|
523
|
+
{ "$ref": "#/definitions/StaticMethodNode" },
|
|
524
|
+
{ "$ref": "#/definitions/PropertyNode" },
|
|
525
|
+
{ "$ref": "#/definitions/EventNode" }
|
|
526
|
+
]
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { MetadataEntry } from '../metadata/types';
|
|
2
|
+
import type { Document } from './generated/schema';
|
|
3
|
+
|
|
4
|
+
export type * from './generated/schema';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* What a worker needs, besides the entries, to build a document.
|
|
8
|
+
*/
|
|
9
|
+
export interface Dependencies {
|
|
10
|
+
/** The resolved `$schema` URL every document carries */
|
|
11
|
+
schemaURL: string;
|
|
12
|
+
/** The base URL source links resolve against, or `null` without a repository */
|
|
13
|
+
sourceURL: string | null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface Configuration {
|
|
17
|
+
/** Where the schema is published */
|
|
18
|
+
schemaURL: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type Generator = GeneratorMetadata<
|
|
22
|
+
Configuration,
|
|
23
|
+
Generate<Array<MetadataEntry>, AsyncGenerator<Array<Document>>>,
|
|
24
|
+
ProcessChunk<
|
|
25
|
+
{ head: MetadataEntry; entries: Array<MetadataEntry> },
|
|
26
|
+
Array<Document>,
|
|
27
|
+
Dependencies
|
|
28
|
+
>
|
|
29
|
+
>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
import { buildHierarchy } from '#utils/hierarchy.mjs';
|
|
4
|
+
import { annotateOverloads } from '#utils/overloads.mjs';
|
|
5
|
+
|
|
6
|
+
import { DOCUMENT_TYPES } from '../constants.mjs';
|
|
7
|
+
import { buildEntry, entryBody } from './entry.mjs';
|
|
8
|
+
import { buildNode } from './node.mjs';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Builds a document from a module's entries.
|
|
12
|
+
*
|
|
13
|
+
* @param {import('../../metadata/types').MetadataEntry} head The module's title entry
|
|
14
|
+
* @param {Array<import('../../metadata/types').MetadataEntry>} entries All of the module's entries, in document order
|
|
15
|
+
* @param {import('../types').Dependencies} dependencies
|
|
16
|
+
* @returns {import('../types').Document}
|
|
17
|
+
*/
|
|
18
|
+
export const buildDocument = (head, entries, { schemaURL, sourceURL }) => {
|
|
19
|
+
annotateOverloads(entries);
|
|
20
|
+
|
|
21
|
+
const type = DOCUMENT_TYPES.has(head.type) ? head.type : 'module';
|
|
22
|
+
const scope = type === 'global' ? 'global' : 'module';
|
|
23
|
+
|
|
24
|
+
// The title entry is the root; any other root (a second title, an entry
|
|
25
|
+
// with no shallower heading before it) is treated as a child of it
|
|
26
|
+
const roots = buildHierarchy(entries);
|
|
27
|
+
const root = roots.find(node => node.entry === head) ?? roots[0];
|
|
28
|
+
const children = [
|
|
29
|
+
...(root?.children ?? []),
|
|
30
|
+
...roots.filter(node => node !== root),
|
|
31
|
+
].map(node => buildNode(node, scope));
|
|
32
|
+
|
|
33
|
+
const { title, ...entry } = buildEntry(head, entryBody(head));
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
$schema: schemaURL,
|
|
37
|
+
id: head.api,
|
|
38
|
+
path: head.path,
|
|
39
|
+
type,
|
|
40
|
+
module:
|
|
41
|
+
typeof head.name === 'string'
|
|
42
|
+
? head.name
|
|
43
|
+
: type === 'module'
|
|
44
|
+
? head.api
|
|
45
|
+
: null,
|
|
46
|
+
title,
|
|
47
|
+
introducedIn:
|
|
48
|
+
head.introduced_in == null ? null : String(head.introduced_in),
|
|
49
|
+
sourceLink: head.source_link
|
|
50
|
+
? {
|
|
51
|
+
path: String(head.source_link),
|
|
52
|
+
url: sourceURL ? `${sourceURL}${head.source_link}` : null,
|
|
53
|
+
}
|
|
54
|
+
: null,
|
|
55
|
+
...entry,
|
|
56
|
+
children,
|
|
57
|
+
};
|
|
58
|
+
};
|