blockbench-types 4.9.0 → 4.11.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.
Files changed (50) hide show
  1. package/.prettierignore +1 -0
  2. package/.prettierrc.json +9 -0
  3. package/README.md +3 -2
  4. package/package.json +43 -33
  5. package/scripts/generate_docs.js +243 -196
  6. package/tsconfig.json +13 -14
  7. package/types/action.d.ts +358 -279
  8. package/types/animation.d.ts +181 -147
  9. package/types/animation_controller.d.ts +105 -99
  10. package/types/blockbench.d.ts +136 -76
  11. package/types/canvas.d.ts +239 -228
  12. package/types/canvas_frame.d.ts +2 -2
  13. package/types/codec.d.ts +36 -32
  14. package/types/cube.d.ts +32 -11
  15. package/types/desktop.d.ts +14 -0
  16. package/types/dialog.d.ts +175 -38
  17. package/types/display_mode.d.ts +17 -6
  18. package/types/file_system.d.ts +159 -0
  19. package/types/format.d.ts +55 -12
  20. package/types/global.d.ts +49 -3
  21. package/types/group.d.ts +16 -5
  22. package/types/index.d.ts +1 -0
  23. package/types/interface.d.ts +21 -12
  24. package/types/io.d.ts +2 -2
  25. package/types/keyframe.d.ts +72 -58
  26. package/types/legacy.d.ts +2 -1
  27. package/types/math_util.d.ts +1 -1
  28. package/types/menu.d.ts +93 -78
  29. package/types/mesh.d.ts +89 -64
  30. package/types/misc.d.ts +114 -47
  31. package/types/mode.d.ts +14 -1
  32. package/types/molang.d.ts +17 -0
  33. package/types/outliner.d.ts +42 -23
  34. package/types/painter.d.ts +49 -11
  35. package/types/panel.d.ts +49 -21
  36. package/types/plugin.d.ts +52 -0
  37. package/types/preview.d.ts +71 -69
  38. package/types/preview_scene.d.ts +26 -17
  39. package/types/project.d.ts +54 -37
  40. package/types/screencam.d.ts +11 -6
  41. package/types/settings.d.ts +87 -85
  42. package/types/shared_actions.d.ts +25 -9
  43. package/types/texture_layers.d.ts +104 -105
  44. package/types/textures.d.ts +322 -313
  45. package/types/timeline.d.ts +60 -60
  46. package/types/undo.d.ts +109 -105
  47. package/types/util.d.ts +152 -37
  48. package/types/uveditor.d.ts +3 -0
  49. package/types/validator.d.ts +3 -2
  50. package/types/vue.d.ts +7 -0
@@ -1,117 +1,139 @@
1
- const TypeDoc = require("typedoc");
2
- const fs = require('fs');
3
- const PathModule = require('path');
1
+ const TypeDoc = require('typedoc')
2
+ const fs = require('fs')
3
+ const PathModule = require('path')
4
+
5
+ function getArg(key) {
6
+ let index = process.argv.indexOf('--'+key);
7
+ console.log(index)
8
+ if (index > 1) {
9
+ return process.argv[index+1];
10
+ }
11
+ }
4
12
 
5
- //const out_path = '../docs/';
6
- const out_path = '../../blockbench.net/content/api/';
13
+ const out_path = getArg('out') || '../generated/';
14
+ console.log(out_path)
7
15
 
8
16
  async function main() {
9
- const app = new TypeDoc.Application();
17
+ const app = new TypeDoc.Application()
10
18
 
11
- // If you want TypeDoc to load tsconfig.json / typedoc.json files
12
- app.options.addReader(new TypeDoc.TSConfigReader());
13
- app.options.addReader(new TypeDoc.TypeDocReader());
19
+ // If you want TypeDoc to load tsconfig.json / typedoc.json files
20
+ app.options.addReader(new TypeDoc.TSConfigReader())
21
+ app.options.addReader(new TypeDoc.TypeDocReader())
14
22
 
15
- app.bootstrap({
23
+ app.bootstrap({
16
24
  entryPoints: [
17
- "./types/blockbench.d.ts",
18
- "./types/textures.d.ts",
19
- "./types/texture_layers.d.ts",
20
- "./types/action.d.ts",
21
- "./types/animation.d.ts",
22
- "./types/animation_controller.d.ts",
23
- "./types/canvas.d.ts",
24
- "./types/codec.d.ts",
25
- "./types/format.d.ts",
26
- "./types/global.d.ts",
27
- "./types/interface.d.ts",
28
- "./types/dialog.d.ts",
29
- "./types/panel.d.ts",
30
- "./types/keyframe.d.ts",
31
- "./types/legacy.d.ts",
32
- "./types/menu.d.ts",
33
- "./types/outliner.d.ts",
34
- "./types/group.d.ts",
35
- "./types/cube.d.ts",
36
- "./types/mesh.d.ts",
37
- "./types/plugin.d.ts",
38
- "./types/preview.d.ts",
39
- "./types/project.d.ts",
40
- "./types/mode.d.ts",
41
- "./types/settings.d.ts",
42
- "./types/timeline.d.ts",
43
- "./types/undo.d.ts",
44
- "./types/painter.d.ts",
45
- "./types/screencam.d.ts",
46
- "./types/validator.d.ts",
47
- "./types/shared_actions.d.ts",
48
- "./types/display_mode.d.ts",
49
- "./types/misc.d.ts",
50
- "./types/util.d.ts"
25
+ './types/blockbench.d.ts',
26
+ './types/textures.d.ts',
27
+ './types/texture_layers.d.ts',
28
+ './types/action.d.ts',
29
+ './types/animation.d.ts',
30
+ './types/animation_controller.d.ts',
31
+ './types/canvas.d.ts',
32
+ './types/codec.d.ts',
33
+ './types/format.d.ts',
34
+ './types/global.d.ts',
35
+ './types/interface.d.ts',
36
+ './types/dialog.d.ts',
37
+ './types/panel.d.ts',
38
+ './types/keyframe.d.ts',
39
+ './types/legacy.d.ts',
40
+ './types/menu.d.ts',
41
+ './types/outliner.d.ts',
42
+ './types/group.d.ts',
43
+ './types/cube.d.ts',
44
+ './types/mesh.d.ts',
45
+ './types/plugin.d.ts',
46
+ './types/preview.d.ts',
47
+ './types/project.d.ts',
48
+ './types/mode.d.ts',
49
+ './types/settings.d.ts',
50
+ './types/timeline.d.ts',
51
+ './types/undo.d.ts',
52
+ './types/painter.d.ts',
53
+ './types/screencam.d.ts',
54
+ './types/validator.d.ts',
55
+ './types/shared_actions.d.ts',
56
+ './types/display_mode.d.ts',
57
+ './types/misc.d.ts',
58
+ './types/util.d.ts',
51
59
  ],
52
60
  sort: ['source-order'],
53
- commentStyle: "all"
61
+ commentStyle: 'all',
54
62
  //json: "./json/test.json",
55
63
  //pretty: true
56
- });
64
+ })
57
65
 
58
- let skip_files = ['global', 'legacy'];
59
-
60
- console.log('Scanning...');
66
+ let skip_files = ['global', 'legacy']
61
67
 
62
- const project = app.convert();
68
+ console.log('Scanning...')
63
69
 
64
- if (!project) return; // Failed to parse types
70
+ const project = app.convert()
65
71
 
66
- console.log('Scanned types');
72
+ if (!project) return // Failed to parse types
73
+
74
+ console.log('Scanned types')
67
75
 
68
76
  const external = {
69
- 'ConditionResolvable': '[ConditionResolvable](https://github.com/JannisX11/blockbench-types/blob/main/types/util.d.ts#L1)',
77
+ ConditionResolvable:
78
+ '[ConditionResolvable](https://github.com/JannisX11/blockbench-types/blob/main/types/util.d.ts#L1)',
70
79
 
71
80
  'Vue.Component': '[Vue.Component](https://v2.vuejs.org/v2/guide/components.html)',
72
81
 
73
- 'Vector3': '[THREE.Vector3](https://threejs.org/docs/index.html#api/en/math/Vector3)',
74
- 'Euler': '[THREE.Euler](https://threejs.org/docs/index.html#api/en/math/Euler)',
75
- 'Quaternion': '[THREE.Quaternion](https://threejs.org/docs/index.html#api/en/math/Quaternion)',
76
- 'Object3D': '[THREE.Object3D](https://threejs.org/docs/index.html#api/en/core/Object3D)',
77
- 'PerspectiveCamera': '[THREE.PerspectiveCamera](https://threejs.org/docs/index.html#api/en/cameras/PerspectiveCamera)',
78
- 'OrthographicCamera': '[THREE.OrthographicCamera](https://threejs.org/docs/index.html#api/en/cameras/OrthographicCamera)',
79
- 'WebGLRenderer': '[THREE.WebGLRenderer](https://threejs.org/docs/index.html#api/en/renderers/WebGLRenderer)',
80
-
81
- 'HTMLElement': '[HTMLElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement)',
82
- 'HTMLCanvasElement': '[HTMLCanvasElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement)',
83
- 'HTMLAudioElement': '[HTMLAudioElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLAudioElement)',
84
- 'CanvasRenderingContext2D': '[CanvasRenderingContext2D](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D)',
85
- 'Date': '[Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)',
86
- 'Event': '[Event](https://developer.mozilla.org/en-US/docs/Web/API/Event)',
87
- 'PointerEvent': '[PointerEvent](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent)',
82
+ Vector3: '[THREE.Vector3](https://threejs.org/docs/index.html#api/en/math/Vector3)',
83
+ Euler: '[THREE.Euler](https://threejs.org/docs/index.html#api/en/math/Euler)',
84
+ Quaternion:
85
+ '[THREE.Quaternion](https://threejs.org/docs/index.html#api/en/math/Quaternion)',
86
+ Object3D: '[THREE.Object3D](https://threejs.org/docs/index.html#api/en/core/Object3D)',
87
+ PerspectiveCamera:
88
+ '[THREE.PerspectiveCamera](https://threejs.org/docs/index.html#api/en/cameras/PerspectiveCamera)',
89
+ OrthographicCamera:
90
+ '[THREE.OrthographicCamera](https://threejs.org/docs/index.html#api/en/cameras/OrthographicCamera)',
91
+ WebGLRenderer:
92
+ '[THREE.WebGLRenderer](https://threejs.org/docs/index.html#api/en/renderers/WebGLRenderer)',
93
+
94
+ HTMLElement: '[HTMLElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement)',
95
+ HTMLCanvasElement:
96
+ '[HTMLCanvasElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement)',
97
+ HTMLAudioElement:
98
+ '[HTMLAudioElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLAudioElement)',
99
+ CanvasRenderingContext2D:
100
+ '[CanvasRenderingContext2D](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D)',
101
+ Date: '[Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)',
102
+ Event: '[Event](https://developer.mozilla.org/en-US/docs/Web/API/Event)',
103
+ PointerEvent:
104
+ '[PointerEvent](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent)',
88
105
  }
89
- let top_level_references = {};
90
- let top_level_hidden_references = {};
106
+ let top_level_references = {}
107
+ let top_level_hidden_references = {}
91
108
  for (let file of project.children) {
92
- let file_name = file.name.replace(/[^\w]/gi, '');
109
+ let file_name = file.name.replace(/[^\w]/gi, '')
93
110
  for (let concept of file.children) {
94
- anchor_name = concept.name.replace(/[^\w]/gi, '').replace(/^_/, '').toLowerCase();
95
- if (anchor_name == file_name) anchor_name += '-1';
111
+ anchor_name = concept.name.replace(/[^\w]/gi, '').replace(/^_/, '').toLowerCase()
112
+ if (anchor_name == file_name) anchor_name += '-1'
96
113
 
97
114
  if (concept.kindString == 'Interface' || concept.kindString == 'Type alias') {
98
- top_level_hidden_references[concept.name] = `[${concept.name}](${concept.sources?.[0]?.url || ''})`;
115
+ top_level_hidden_references[concept.name] = `[${concept.name}](${
116
+ concept.sources?.[0]?.url || ''
117
+ })`
99
118
  } else {
100
- top_level_references[concept.name] = file_name + '#' + anchor_name;
119
+ top_level_references[concept.name] = file_name + '#' + anchor_name
101
120
  }
102
121
  }
103
122
  }
104
123
 
105
124
  function getReferenceLink(reference) {
106
- if (reference.qualifiedName && (external[reference.qualifiedName] || external[reference.name])) {
107
- return (external[reference.qualifiedName] || external[reference.name]);
125
+ if (
126
+ reference.qualifiedName &&
127
+ (external[reference.qualifiedName] || external[reference.name])
128
+ ) {
129
+ return external[reference.qualifiedName] || external[reference.name]
108
130
  }
109
131
  if (top_level_hidden_references[reference.name]) {
110
- return top_level_hidden_references[reference.name];
132
+ return top_level_hidden_references[reference.name]
111
133
  }
112
- let link = '#' + reference.name;
134
+ let link = '#' + reference.name
113
135
  if (top_level_references[reference.name]) {
114
- link = top_level_references[reference.name];
136
+ link = top_level_references[reference.name]
115
137
  }
116
138
  return `[${reference.name}](${link})`
117
139
  }
@@ -119,252 +141,277 @@ async function main() {
119
141
  if (!type) return 'Function'
120
142
 
121
143
  switch (type.type) {
122
- case 'reflection': return `[See types](${type.declaration?.sources?.[0]?.url || ''})`;
144
+ case 'reflection':
145
+ return `[See types](${type.declaration?.sources?.[0]?.url || ''})`
123
146
 
124
- case 'intrinsic': return '*' + type.name + '*';
147
+ case 'intrinsic':
148
+ return '*' + type.name + '*'
125
149
 
126
- case 'tuple': return 'Array';
150
+ case 'tuple':
151
+ return 'Array'
127
152
 
128
- case 'literal': return typeof type.value == 'string' ? ('`"' + type.value + '"`') : ('`' + type.value + '`');
153
+ case 'literal':
154
+ return typeof type.value == 'string'
155
+ ? '`"' + type.value + '"`'
156
+ : '`' + type.value + '`'
129
157
 
130
158
  case 'reference': {
131
159
  if (type.name == 'Partial' && type.typeArguments?.[0]) {
132
160
  return getType(type.typeArguments?.[0])
133
161
  }
134
162
  return getReferenceLink(type)
135
- };
163
+ }
136
164
 
137
- case 'array': return 'Array of ' + getType(type.elementType);
138
-
139
- case 'union': return type.types.map(t => getType(t)).join(' or ');
165
+ case 'array':
166
+ return 'Array of ' + getType(type.elementType)
140
167
 
141
- default: return '';
168
+ case 'union':
169
+ return type.types.map(t => getType(t)).join(' or ')
170
+
171
+ default:
172
+ return ''
142
173
  }
143
174
  }
144
175
  function addComments(object, lines, default_value) {
145
176
  if (object.comment?.summary) {
146
177
  for (let comment of object.comment.summary) {
147
- lines.push(comment.text, '');
178
+ lines.push(comment.text, '')
148
179
  }
149
180
  } else if (default_value) {
150
- lines.push(default_value, '');
181
+ lines.push(default_value, '')
151
182
  }
152
183
  }
153
184
  function addArgumentTree(arguments, lines) {
154
- if (arguments?.length) lines.push('##### Arguments:');
185
+ if (arguments?.length) lines.push('##### Arguments:')
155
186
  function generateArgumentList(list, depth) {
156
- list.forEach((object) => {
157
- let line = '';
158
- let is_nested = (object.type?.type == 'reference' && object.type.reflection && object.type.reflection.children && object.type.reflection.kindString == 'Interface');
187
+ list.forEach(object => {
188
+ let line = ''
189
+ let is_nested =
190
+ object.type?.type == 'reference' &&
191
+ object.type.reflection &&
192
+ object.type.reflection.children &&
193
+ object.type.reflection.kindString == 'Interface'
159
194
  for (let i = 0; i < depth; i++) {
160
- line += '\t';
195
+ line += '\t'
161
196
  }
162
- line += '* `' + object.name + '`: ' + (is_nested ? object.type?.name : getType(object.type));
163
- if (object.flags.isOptional) line += ' (Optional)';
197
+ line +=
198
+ '* `' +
199
+ object.name +
200
+ '`: ' +
201
+ (is_nested ? object.type?.name : getType(object.type))
202
+ if (object.flags.isOptional) line += ' (Optional)'
164
203
  if (object.comment?.summary) {
165
- line += ' -';
204
+ line += ' -'
166
205
  for (let comment of object.comment.summary) {
167
- line += ' ' + comment.text;
206
+ line += ' ' + comment.text
168
207
  }
169
208
  }
170
- lines.push(line);
209
+ lines.push(line)
171
210
 
172
211
  if (is_nested) {
173
- generateArgumentList(object.type.reflection.children, depth + 1);
212
+ generateArgumentList(object.type.reflection.children, depth + 1)
174
213
  }
175
214
  })
176
215
  }
177
- generateArgumentList(arguments, 0);
178
- lines.push('');
216
+ generateArgumentList(arguments, 0)
217
+ lines.push('')
179
218
  }
180
219
  function generateArgumentSuffix(arguments) {
181
220
  if (arguments && arguments.length) {
182
- let args = '';
183
- let required_args = arguments.filter(p => !p.flags.isOptional).map(p => p.name).join(', ');
184
- let optional_args = arguments.filter(p => p.flags.isOptional).map(p => p.name).join(', ');
221
+ let args = ''
222
+ let required_args = arguments
223
+ .filter(p => !p.flags.isOptional)
224
+ .map(p => p.name)
225
+ .join(', ')
226
+ let optional_args = arguments
227
+ .filter(p => p.flags.isOptional)
228
+ .map(p => p.name)
229
+ .join(', ')
185
230
  if (required_args && optional_args) {
186
- args = required_args + '[, ' + optional_args + ']';
231
+ args = required_args + '[, ' + optional_args + ']'
187
232
  } else if (required_args) {
188
233
  args = required_args
189
234
  } else if (optional_args) {
190
- args = '['+optional_args+']';
235
+ args = '[' + optional_args + ']'
191
236
  }
192
- return `( ${args} )`;
237
+ return `( ${args} )`
193
238
  } else {
194
- return '()';
239
+ return '()'
195
240
  }
196
241
  }
197
242
  function toTitleCase(input) {
198
- return input.split(/[ _.-]/).map(word => word[0].toUpperCase() + word.substring(1)).join(' ');
243
+ return input
244
+ .split(/[ _.-]/)
245
+ .map(word => word[0].toUpperCase() + word.substring(1))
246
+ .join(' ')
199
247
  }
200
248
 
201
-
202
-
203
-
204
- let num_files = 0;
249
+ let num_files = 0
205
250
  for (let file of project.children) {
206
- if (skip_files.includes(file.name)) continue;
207
-
208
- let file_name = file.name.replace(/[^\w]/gi, '');
209
- let display_name = toTitleCase(file.name);
210
- let markdown_lines = [
211
- '---', `title: ${display_name}`, '---',
212
- '',
213
- `# ${display_name}`
214
- ];
251
+ if (skip_files.includes(file.name)) continue
252
+
253
+ let file_name = file.name.replace(/[^\w]/gi, '')
254
+ let display_name = toTitleCase(file.name)
255
+ let markdown_lines = ['---', `title: ${display_name}`, '---', '', `# ${display_name}`]
215
256
  let addLine = (s, empty_after) => {
216
- markdown_lines.push(s || '');
217
- if (empty_after && s) markdown_lines.push('');
257
+ markdown_lines.push(s || '')
258
+ if (empty_after && s) markdown_lines.push('')
218
259
  }
219
260
 
220
-
221
261
  for (let concept of file.children) {
222
- if (concept.kindString == 'Interface') continue;
223
- if (concept.kindString == 'Type alias') continue;
262
+ if (concept.kindString == 'Interface') continue
263
+ if (concept.kindString == 'Type alias') continue
224
264
 
225
- if (concept.name.startsWith('_')) concept.name = concept.name.substring(1);
265
+ if (concept.name.startsWith('_')) concept.name = concept.name.substring(1)
226
266
 
227
267
  if (concept.kindString == 'Function') {
228
268
  for (let signature of concept.signatures) {
229
- let suffix = generateArgumentSuffix(signature.parameters);
230
- addLine(`## ${signature.name.replace(/^_/, '')}${suffix}`);
231
- addLine(`#### Global Function`, true);
269
+ let suffix = generateArgumentSuffix(signature.parameters)
270
+ addLine(`## ${signature.name.replace(/^_/, '')}${suffix}`)
271
+ addLine(`#### Global Function`, true)
232
272
 
233
- addComments(signature, markdown_lines);
273
+ addComments(signature, markdown_lines)
234
274
 
235
275
  if (signature.parameters) {
236
- addArgumentTree(signature.parameters, markdown_lines);
276
+ addArgumentTree(signature.parameters, markdown_lines)
237
277
  }
238
278
 
239
279
  if (signature.type && signature.type.name !== 'void') {
240
- addLine(`Returns: ${getType(signature.type)}`);
280
+ addLine(`Returns: ${getType(signature.type)}`)
241
281
  }
242
282
  }
243
- addLine();
283
+ addLine()
244
284
  } else {
245
- addLine(`## ${concept.name}`);
285
+ addLine(`## ${concept.name}`)
246
286
  }
247
287
  if (concept.kindString != 'Class' && concept.kindString != 'Function') {
248
- let kind = concept.kindString;
288
+ let kind = concept.kindString
249
289
  if (kind != 'Interface' && kind != 'Type alias' && kind != 'Namespace') {
250
- kind = 'Global ' + kind;
290
+ kind = 'Global ' + kind
251
291
  }
252
- addLine(`#### ${kind}`, true);
292
+ addLine(`#### ${kind}`, true)
253
293
  }
254
294
  if (concept.kindString == 'Variable') {
255
- addLine(`Type: ${getType(concept.type)}`, true);
295
+ addLine(`Type: ${getType(concept.type)}`, true)
256
296
  }
257
297
 
258
298
  // Extend
259
299
  if (concept.extendedTypes) {
260
300
  let parents = concept.extendedTypes.map(type => {
261
- return getReferenceLink(type);
262
- });
263
- addLine('Extends: ' + parents.join(', '), true);
301
+ return getReferenceLink(type)
302
+ })
303
+ addLine('Extends: ' + parents.join(', '), true)
264
304
  }
265
305
  if (concept.extendedBy) {
266
306
  let parents = concept.extendedBy.map(type => {
267
- return getReferenceLink(type);
268
- });
269
- addLine('Extended by: ' + parents.join(', '), true);
307
+ return getReferenceLink(type)
308
+ })
309
+ addLine('Extended by: ' + parents.join(', '), true)
270
310
  }
271
311
  // Comment
272
- addComments(concept, markdown_lines);
312
+ addComments(concept, markdown_lines)
273
313
 
274
314
  // Children
275
315
  if (concept.children) {
276
- if (concept.children[0]) {}
316
+ if (concept.children[0]) {
317
+ }
277
318
 
278
- let handled = [];
319
+ let handled = []
279
320
  // Constructor
280
321
  for (let child of concept.children) {
281
- if (child.kindString != 'Constructor') continue;
282
- let sig_i = 0;
322
+ if (child.kindString != 'Constructor') continue
323
+ let sig_i = 0
283
324
  for (let signature of child.signatures) {
284
- let suffix = generateArgumentSuffix(signature.parameters);
285
- addLine(`### ${signature.name}${suffix}`);
325
+ let suffix = generateArgumentSuffix(signature.parameters)
326
+ addLine(`### ${signature.name}${suffix}`)
286
327
 
287
328
  if (sig_i) {
288
- addLine(`*Alternative constructor signature*`, true);
289
- continue;
329
+ addLine(`*Alternative constructor signature*`, true)
330
+ continue
290
331
  }
291
- addComments(signature, markdown_lines, `Creates a new ${concept.name}`);
332
+ addComments(signature, markdown_lines, `Creates a new ${concept.name}`)
292
333
 
293
334
  if (signature.parameters) {
294
- addArgumentTree(signature.parameters, markdown_lines);
335
+ addArgumentTree(signature.parameters, markdown_lines)
295
336
  }
296
- sig_i++;
337
+ sig_i++
297
338
  //break; // Only use first signature in types for simplicity
298
339
  }
299
- addLine();
300
- handled.push(child.id);
340
+ addLine()
341
+ handled.push(child.id)
301
342
  }
302
343
 
303
344
  // Properties
304
- let properties = concept.children.filter(child => (child.kindString == 'Property' || child.kindString == 'Variable') && !child.type?.name?.startsWith('BlockbenchType') && !child.flags.isStatic);
345
+ let properties = concept.children.filter(
346
+ child =>
347
+ (child.kindString == 'Property' || child.kindString == 'Variable') &&
348
+ !child.type?.name?.startsWith('BlockbenchType') &&
349
+ !child.flags.isStatic
350
+ )
305
351
  if (properties.length) {
306
- addLine('| Property | Type | Description |');
307
- addLine('| -------- | ---- | ----------- |');
352
+ addLine('| Property | Type | Description |')
353
+ addLine('| -------- | ---- | ----------- |')
308
354
  }
309
355
  for (let child of properties) {
310
- addLine(`| ${child.name} | ${getType(child.type)} | ${child.comment?.summary?.[0]?.text || ''} |`);
311
- handled.push(child.id);
356
+ addLine(
357
+ `| ${child.name} | ${getType(child.type)} | ${
358
+ child.comment?.summary?.[0]?.text || ''
359
+ } |`
360
+ )
361
+ handled.push(child.id)
312
362
  }
313
363
  if (properties.length) {
314
- addLine();
364
+ addLine()
315
365
  }
316
366
 
317
367
  // Methods
318
368
  for (let child of concept.children) {
319
- if (child.kindString != 'Method' && child.kindString != 'Function') continue;
369
+ if (child.kindString != 'Method' && child.kindString != 'Function') continue
320
370
  for (let signature of child.signatures) {
321
- let prefix = child.flags.isStatic ? (concept.name + '.') : '';
322
- let suffix = generateArgumentSuffix(signature.parameters);
323
- addLine(`### ${prefix}${signature.name.replace(/^_/, '')}${suffix}`);
324
- addComments(signature, markdown_lines);
371
+ let prefix = child.flags.isStatic ? concept.name + '.' : ''
372
+ let suffix = generateArgumentSuffix(signature.parameters)
373
+ addLine(`### ${prefix}${signature.name.replace(/^_/, '')}${suffix}`)
374
+ addComments(signature, markdown_lines)
325
375
 
326
376
  if (signature.parameters) {
327
- addArgumentTree(signature.parameters, markdown_lines);
377
+ addArgumentTree(signature.parameters, markdown_lines)
328
378
  }
329
379
 
330
380
  if (signature.type && signature.type.name !== 'void') {
331
- addLine(`Returns: ${getType(signature.type)}`);
381
+ addLine(`Returns: ${getType(signature.type)}`)
332
382
  }
333
383
  }
334
- addLine();
335
- handled.push(child.id);
384
+ addLine()
385
+ handled.push(child.id)
336
386
  }
337
387
 
338
388
  // Misc
339
389
  for (let child of concept.children) {
340
- if (handled.includes(child.id)) continue;
341
- addLine(`### ${child.name}`);
342
- let kind = child.kindString;
390
+ if (handled.includes(child.id)) continue
391
+ addLine(`### ${child.name}`)
392
+ let kind = child.kindString
343
393
  if (child.flags.isStatic) {
344
- kind = 'Static ' + kind;
394
+ kind = 'Static ' + kind
345
395
  }
346
- addLine(kind, true);
396
+ addLine(kind, true)
347
397
  if (child.kindString == 'Property') {
348
- addLine(`Type: ${getType(child.type)}`, true);
398
+ addLine(`Type: ${getType(child.type)}`, true)
349
399
  }
350
- addComments(child, markdown_lines);
351
- addLine();
400
+ addComments(child, markdown_lines)
401
+ addLine()
352
402
  }
353
403
  }
354
404
 
355
-
356
- addLine();
405
+ addLine()
357
406
  }
358
407
 
359
-
360
-
361
- fs.writeFileSync(PathModule.resolve(__dirname, out_path, `${file_name}.md`), markdown_lines.join('\r\n'), "utf-8");
362
- num_files++;
408
+ const path = PathModule.resolve(__dirname, out_path, `${file_name}.md`)
409
+ fs.mkdirSync(PathModule.dirname(path), { recursive: true })
410
+ fs.writeFileSync(path, markdown_lines.join('\r\n'), 'utf-8')
411
+ num_files++
363
412
  }
364
413
 
365
- console.log(`Generated ${num_files} api doc files`);
366
-
367
-
414
+ console.log(`Generated ${num_files} api doc files`)
368
415
  }
369
416
 
370
- main().catch(console.error);
417
+ main().catch(console.error)
package/tsconfig.json CHANGED
@@ -1,16 +1,15 @@
1
1
  {
2
- "include": [
3
- "./types/**/*"
4
- ],
5
- "compilerOptions": {
6
- "module": "commonjs",
7
- "target": "ES2020",
8
- "outDir": "out",
2
+ "include": ["./types/**/*"],
3
+ "compilerOptions": {
4
+ "module": "commonjs",
5
+ "target": "ES2020",
6
+ "outDir": "out",
9
7
  "lib": ["dom", "ES2020"],
10
- "sourceMap": true,
11
- "rootDir": "."
12
- },
13
- "exclude": [
14
- "node_modules"
15
- ]
16
- }
8
+ "sourceMap": true,
9
+ "rootDir": ".",
10
+ "strict": true,
11
+ "noImplicitAny": true,
12
+ "esModuleInterop": true
13
+ },
14
+ "exclude": ["./node_modules/**/*"]
15
+ }