@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.
Files changed (41) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +2 -1
  3. package/package.json +9 -4
  4. package/src/generators/index.mjs +2 -0
  5. package/src/generators/json/README.md +151 -0
  6. package/src/generators/json/constants.mjs +57 -0
  7. package/src/generators/json/generate.mjs +65 -0
  8. package/src/generators/json/generated/schema.d.ts +351 -0
  9. package/src/generators/json/index.mjs +27 -0
  10. package/src/generators/json/schema.json +529 -0
  11. package/src/generators/json/types.d.ts +29 -0
  12. package/src/generators/json/utils/document.mjs +58 -0
  13. package/src/generators/json/utils/entry.mjs +87 -0
  14. package/src/generators/json/utils/lifecycle.mjs +61 -0
  15. package/src/generators/json/utils/markdown.mjs +57 -0
  16. package/src/generators/json/utils/node.mjs +153 -0
  17. package/src/generators/json/utils/schema.mjs +15 -0
  18. package/src/generators/json/utils/signature.mjs +185 -0
  19. package/src/generators/json/utils/types.mjs +28 -0
  20. package/src/generators/json-all/README.md +31 -0
  21. package/src/generators/json-all/constants.mjs +5 -0
  22. package/src/generators/json-all/generate.mjs +35 -0
  23. package/src/generators/json-all/index.mjs +25 -0
  24. package/src/generators/json-all/schema.json +22 -0
  25. package/src/generators/json-all/types.d.ts +20 -0
  26. package/src/generators/json-simple/generate.mjs +2 -7
  27. package/src/generators/metadata/maps/mdn.json +10 -2
  28. package/src/generators/metadata/types.d.ts +5 -0
  29. package/src/generators/metadata/utils/transformers.mjs +1 -1
  30. package/src/logger/logger.mjs +8 -0
  31. package/src/threading/chunk-worker.mjs +7 -0
  32. package/src/threading/index.mjs +1 -0
  33. package/src/utils/file.mjs +10 -0
  34. package/src/utils/hierarchy.mjs +50 -0
  35. package/src/utils/overloads.mjs +54 -0
  36. package/src/utils/queries/index.mjs +2 -0
  37. package/src/utils/queries/utils.mjs +15 -0
  38. package/src/utils/remark.mjs +1 -1
  39. package/src/utils/signature/constants.mjs +3 -0
  40. package/src/utils/signature/extractListItem.mjs +140 -0
  41. package/src/utils/stability.mjs +24 -0
@@ -0,0 +1,351 @@
1
+ /* eslint-disable */
2
+ /**
3
+ * Generated from `schema.json` by `scripts/generate-json-types.mjs`.
4
+ * Do not edit: change the schema and regenerate instead.
5
+ */
6
+
7
+ /**
8
+ * 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.
9
+ */
10
+ export type Document = Entry & {
11
+ /**
12
+ * The URL of the schema this document conforms to. Its last path segment is the schema version.
13
+ */
14
+ $schema: string;
15
+ /**
16
+ * The document's identifier: its path, slugged. Unique within a documentation set.
17
+ */
18
+ id: string;
19
+ /**
20
+ * The document's path inside the input tree, without extension. Cross-document links target `<path>.html`.
21
+ */
22
+ path: string;
23
+ /**
24
+ * The document's declared type: a module reference, a miscellaneous (conceptual) page, or a page of globals.
25
+ */
26
+ type: 'module' | 'misc' | 'global';
27
+ /**
28
+ * The name of the module the document describes, when it describes one.
29
+ */
30
+ module: string | null;
31
+ /**
32
+ * The version the document itself was introduced in.
33
+ */
34
+ introducedIn: string | null;
35
+ /**
36
+ * The implementation the document describes, when it links to one.
37
+ */
38
+ sourceLink: SourceLink | null;
39
+ /**
40
+ * The document's headings, nested by depth, in document order.
41
+ */
42
+ children: Node[];
43
+ };
44
+ /**
45
+ * A version string as authored, such as `v18.0.0`, or a release-process placeholder such as `REPLACEME`.
46
+ */
47
+ export type Version = string;
48
+ /**
49
+ * A heading below the document root.
50
+ */
51
+ export type Node = SectionNode | ClassNode | ConstructorNode | MethodNode | StaticMethodNode | PropertyNode | EventNode;
52
+ /**
53
+ * A heading that documents no API entry: prose, a deprecation, a command-line option.
54
+ */
55
+ export type SectionNode = Entry &
56
+ NodeBase & {
57
+ kind: 'section';
58
+ };
59
+ /**
60
+ * A class. Its constructors, methods, properties and events are its children.
61
+ */
62
+ export type ClassNode = Entry &
63
+ NodeBase & {
64
+ kind: 'class';
65
+ /**
66
+ * The class the class extends, when documented.
67
+ */
68
+ extends: Type | null;
69
+ };
70
+ /**
71
+ * A class constructor.
72
+ */
73
+ export type ConstructorNode = Entry &
74
+ NodeBase & {
75
+ kind: 'constructor';
76
+ signature: Signature;
77
+ };
78
+ /**
79
+ * A function or method.
80
+ */
81
+ export type MethodNode = Entry &
82
+ NodeBase & {
83
+ kind: 'method';
84
+ signature: Signature;
85
+ };
86
+ /**
87
+ * A static method of a class.
88
+ */
89
+ export type StaticMethodNode = Entry &
90
+ NodeBase & {
91
+ kind: 'staticMethod';
92
+ signature: Signature;
93
+ };
94
+ /**
95
+ * A property of a module, class or object.
96
+ */
97
+ export type PropertyNode = Entry &
98
+ NodeBase & {
99
+ kind: 'property';
100
+ /**
101
+ * The property's type, when documented.
102
+ */
103
+ type: Type | null;
104
+ /**
105
+ * The property's default value as authored, when documented.
106
+ */
107
+ default: string | null;
108
+ };
109
+ /**
110
+ * An event emitted by the parent class or module.
111
+ */
112
+ export type EventNode = Entry &
113
+ NodeBase & {
114
+ kind: 'event';
115
+ /**
116
+ * The arguments passed to the event's listeners.
117
+ */
118
+ parameters: Parameter[];
119
+ };
120
+
121
+ /**
122
+ * What every heading, the document's own included, carries: its metadata and its body.
123
+ */
124
+ export interface Entry {
125
+ /**
126
+ * The heading text as authored, inline Markdown included.
127
+ */
128
+ title: string;
129
+ /**
130
+ * The entry's stability index, when declared.
131
+ */
132
+ stability: Stability | null;
133
+ /**
134
+ * The versions the entry was added in, as authored.
135
+ */
136
+ added: Version[];
137
+ /**
138
+ * The versions the entry was deprecated in.
139
+ */
140
+ deprecated: Version[];
141
+ /**
142
+ * The versions the entry was removed in.
143
+ */
144
+ removed: Version[];
145
+ /**
146
+ * The Node-API versions the entry is available in.
147
+ */
148
+ napiVersion: number[];
149
+ /**
150
+ * The entry's change history, as authored.
151
+ */
152
+ changes: Change[];
153
+ /**
154
+ * 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.
155
+ */
156
+ description: string;
157
+ /**
158
+ * A one-paragraph plain-text summary: the entry's `llm_description` when declared, else its first paragraph.
159
+ */
160
+ summary: string;
161
+ /**
162
+ * The fenced code blocks in the body. They remain in the description too.
163
+ */
164
+ examples: Example[];
165
+ }
166
+ /**
167
+ * An entry's stability index.
168
+ */
169
+ export interface Stability {
170
+ /**
171
+ * The index as authored, including any sub-level, such as `1.1`.
172
+ */
173
+ index: string;
174
+ /**
175
+ * The text following the index, as Markdown.
176
+ */
177
+ description: string;
178
+ }
179
+ /**
180
+ * One record of an entry's change history.
181
+ */
182
+ export interface Change {
183
+ /**
184
+ * The versions the change shipped in.
185
+ */
186
+ versions: Version[];
187
+ /**
188
+ * The pull request that made the change.
189
+ */
190
+ prUrl: string | null;
191
+ /**
192
+ * The commit that made the change, on records that predate pull requests.
193
+ */
194
+ commit: string | null;
195
+ /**
196
+ * What changed, as Markdown.
197
+ */
198
+ description: string;
199
+ }
200
+ /**
201
+ * A fenced code block from an entry's body.
202
+ */
203
+ export interface Example {
204
+ /**
205
+ * The code block's language identifier.
206
+ */
207
+ language: string | null;
208
+ /**
209
+ * The code block's `displayName` attribute.
210
+ */
211
+ displayName: string | null;
212
+ /**
213
+ * The code.
214
+ */
215
+ code: string;
216
+ }
217
+ /**
218
+ * A link to the implementation a document describes.
219
+ */
220
+ export interface SourceLink {
221
+ /**
222
+ * The implementation's path, relative to the repository root, as authored.
223
+ */
224
+ path: string;
225
+ /**
226
+ * The implementation's URL, when a repository is configured.
227
+ */
228
+ url: string | null;
229
+ }
230
+ /**
231
+ * What every node below the document root carries, on top of an entry.
232
+ */
233
+ export interface NodeBase {
234
+ /**
235
+ * What the heading documents. Decides which further properties the node has.
236
+ */
237
+ kind: 'section' | 'class' | 'constructor' | 'method' | 'staticMethod' | 'property' | 'event';
238
+ /**
239
+ * The heading's slug, unique within the document. It is the heading's anchor in HTML output.
240
+ */
241
+ id: string;
242
+ /**
243
+ * The bare identifier the heading documents, or the heading's plain text for a section.
244
+ */
245
+ name: string;
246
+ /**
247
+ * Whether the entry is reached through its module, or available globally.
248
+ */
249
+ scope: 'module' | 'global';
250
+ /**
251
+ * For the second and later of several sibling headings documenting one callable, the `id` of the first.
252
+ */
253
+ overloadOf: string | null;
254
+ /**
255
+ * The headings nested under this one, in document order.
256
+ */
257
+ children: Node[];
258
+ }
259
+ /**
260
+ * A type annotation.
261
+ */
262
+ export interface Type {
263
+ /**
264
+ * The annotation as a TypeScript type expression, normalised: single-line, union members separated by ` | `.
265
+ */
266
+ text: string;
267
+ /**
268
+ * The resolved names in the text, by offset, non-overlapping.
269
+ */
270
+ links: TypeLink[];
271
+ }
272
+ /**
273
+ * A type name inside a type's text, resolved to documentation.
274
+ */
275
+ export interface TypeLink {
276
+ /**
277
+ * The resolved name, exactly as it appears in the text.
278
+ */
279
+ name: string;
280
+ /**
281
+ * Where the name is documented: a URL, or a link relative to the document.
282
+ */
283
+ href: string;
284
+ /**
285
+ * The offset of the name's first character in the text.
286
+ */
287
+ start: number;
288
+ /**
289
+ * The offset after the name's last character in the text.
290
+ */
291
+ end: number;
292
+ }
293
+ /**
294
+ * A callable's signature: the parameters declared in its heading, described by its typed list.
295
+ */
296
+ export interface Signature {
297
+ /**
298
+ * The parameters, in declaration order.
299
+ */
300
+ parameters: Parameter[];
301
+ /**
302
+ * The return value, when documented.
303
+ */
304
+ returns: Return | null;
305
+ }
306
+ /**
307
+ * A parameter of a signature or event, or a property of an object parameter.
308
+ */
309
+ export interface Parameter {
310
+ /**
311
+ * The parameter's name, without any rest marker.
312
+ */
313
+ name: string;
314
+ /**
315
+ * The parameter's type, when documented.
316
+ */
317
+ type: Type | null;
318
+ /**
319
+ * The parameter's description, as Markdown, without its default value.
320
+ */
321
+ description: string;
322
+ /**
323
+ * The default value as authored, such as `'utf8'` or `false`.
324
+ */
325
+ default: string | null;
326
+ /**
327
+ * Whether the parameter may be omitted: bracketed in the signature, or documented with a default.
328
+ */
329
+ optional: boolean;
330
+ /**
331
+ * Whether the parameter is a rest parameter.
332
+ */
333
+ rest: boolean;
334
+ /**
335
+ * The documented properties of an object parameter, or the arguments of a callback.
336
+ */
337
+ properties: Parameter[];
338
+ }
339
+ /**
340
+ * A signature's return value.
341
+ */
342
+ export interface Return {
343
+ /**
344
+ * The return type, when documented.
345
+ */
346
+ type: Type | null;
347
+ /**
348
+ * The return value's description, as Markdown.
349
+ */
350
+ description: string;
351
+ }
@@ -0,0 +1,27 @@
1
+ 'use strict';
2
+
3
+ import { SCHEMA_URL } from './constants.mjs';
4
+ import { generate, processChunk } from './generate.mjs';
5
+
6
+ /**
7
+ * This generator turns each API doc into a JSON document
8
+ *
9
+ * @type {import('./types').Generator}
10
+ */
11
+ export default {
12
+ name: 'json',
13
+
14
+ description:
15
+ 'Generates one JSON document per API doc, described by the doc-kit JSON schema',
16
+
17
+ dependsOn: '@doc-kit/core/metadata',
18
+
19
+ defaultConfiguration: {
20
+ schemaURL: SCHEMA_URL,
21
+ },
22
+
23
+ hasParallelProcessor: true,
24
+
25
+ generate,
26
+ processChunk,
27
+ };