ol-stac 0.0.0 → 0.0.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 (120) hide show
  1. package/README.md +1 -1
  2. package/events/ErrorEvent.d.ts +17 -0
  3. package/events/ErrorEvent.d.ts.map +1 -0
  4. package/{src/ol/events → events}/ErrorEvent.js +9 -11
  5. package/events/ErrorEvent.js.map +1 -0
  6. package/layer/STAC.d.ts +422 -0
  7. package/layer/STAC.d.ts.map +1 -0
  8. package/layer/STAC.js +698 -0
  9. package/layer/STAC.js.map +1 -0
  10. package/layer/stacUtil.d.ts +46 -0
  11. package/layer/stacUtil.d.ts.map +1 -0
  12. package/layer/stacUtil.js +154 -0
  13. package/layer/stacUtil.js.map +1 -0
  14. package/package.json +3 -85
  15. package/source/GeoTIFF2.d.ts +35 -0
  16. package/source/GeoTIFF2.d.ts.map +1 -0
  17. package/{src/ol/source → source}/GeoTIFF2.js +9 -16
  18. package/source/GeoTIFF2.js.map +1 -0
  19. package/.eslintignore +0 -2
  20. package/.github/workflows/deploy.yml +0 -67
  21. package/.github/workflows/publish.yml +0 -32
  22. package/.github/workflows/release.yml +0 -21
  23. package/.github/workflows/test.yml +0 -85
  24. package/CHANGELOG.md +0 -14
  25. package/DEVELOPING.md +0 -104
  26. package/config/jsdoc/api/conf.json +0 -38
  27. package/config/jsdoc/api/index.md +0 -1
  28. package/config/jsdoc/api/readme.md +0 -65
  29. package/config/jsdoc/api/template/README.md +0 -3
  30. package/config/jsdoc/api/template/publish.js +0 -743
  31. package/config/jsdoc/api/template/static/scripts/linenumber.js +0 -11
  32. package/config/jsdoc/api/template/static/scripts/main.js +0 -305
  33. package/config/jsdoc/api/template/static/scripts/prettify/Apache-License-2.0.txt +0 -202
  34. package/config/jsdoc/api/template/static/scripts/prettify/lang-css.js +0 -2
  35. package/config/jsdoc/api/template/static/scripts/prettify/prettify.js +0 -28
  36. package/config/jsdoc/api/template/static/styles/carbon.css +0 -65
  37. package/config/jsdoc/api/template/static/styles/jaguar.css +0 -512
  38. package/config/jsdoc/api/template/static/styles/prettify-jsdoc.css +0 -111
  39. package/config/jsdoc/api/template/static/styles/prettify-tomorrow.css +0 -132
  40. package/config/jsdoc/api/template/static/theme +0 -1
  41. package/config/jsdoc/api/template/tmpl/container.tmpl +0 -205
  42. package/config/jsdoc/api/template/tmpl/details.tmpl +0 -84
  43. package/config/jsdoc/api/template/tmpl/example.tmpl +0 -2
  44. package/config/jsdoc/api/template/tmpl/examples.tmpl +0 -16
  45. package/config/jsdoc/api/template/tmpl/exceptions.tmpl +0 -30
  46. package/config/jsdoc/api/template/tmpl/layout.tmpl +0 -92
  47. package/config/jsdoc/api/template/tmpl/mainpage.tmpl +0 -14
  48. package/config/jsdoc/api/template/tmpl/members.tmpl +0 -38
  49. package/config/jsdoc/api/template/tmpl/method.tmpl +0 -132
  50. package/config/jsdoc/api/template/tmpl/navigation.tmpl +0 -59
  51. package/config/jsdoc/api/template/tmpl/observables.tmpl +0 -39
  52. package/config/jsdoc/api/template/tmpl/params.tmpl +0 -109
  53. package/config/jsdoc/api/template/tmpl/properties.tmpl +0 -85
  54. package/config/jsdoc/api/template/tmpl/returns.tmpl +0 -72
  55. package/config/jsdoc/api/template/tmpl/source.tmpl +0 -8
  56. package/config/jsdoc/api/template/tmpl/stability.tmpl +0 -7
  57. package/config/jsdoc/api/template/tmpl/tutorial.tmpl +0 -19
  58. package/config/jsdoc/api/template/tmpl/type.tmpl +0 -7
  59. package/config/jsdoc/info/conf.json +0 -22
  60. package/config/jsdoc/info/publish.js +0 -175
  61. package/config/jsdoc/package.json +0 -4
  62. package/config/jsdoc/plugins/api.cjs +0 -181
  63. package/config/jsdoc/plugins/default-export.cjs +0 -35
  64. package/config/jsdoc/plugins/define-plugin.cjs +0 -33
  65. package/config/jsdoc/plugins/events.cjs +0 -39
  66. package/config/jsdoc/plugins/inline-options.cjs +0 -102
  67. package/config/jsdoc/plugins/markdown.cjs +0 -119
  68. package/config/jsdoc/plugins/observable.cjs +0 -69
  69. package/config/jsdoc/plugins/virtual-plugin.cjs +0 -16
  70. package/config/rollup-full-build.js +0 -24
  71. package/config/tsconfig-build.json +0 -25
  72. package/examples/.eslintrc +0 -29
  73. package/examples/index.html +0 -100
  74. package/examples/index.js +0 -109
  75. package/examples/planetary-computer.html +0 -14
  76. package/examples/planetary-computer.js +0 -53
  77. package/examples/resources/Jugl.js +0 -15
  78. package/examples/resources/common.js +0 -111
  79. package/examples/stac-collection-webmaplinks.html +0 -9
  80. package/examples/stac-collection-webmaplinks.js +0 -55
  81. package/examples/stac-item-from-object.html +0 -9
  82. package/examples/stac-item-from-object.js +0 -102
  83. package/examples/stac-item-tileserver.html +0 -9
  84. package/examples/stac-item-tileserver.js +0 -34
  85. package/examples/stac-item.html +0 -9
  86. package/examples/stac-item.js +0 -45
  87. package/examples/stac-itemcollection.html +0 -11
  88. package/examples/stac-itemcollection.js +0 -39
  89. package/examples/templates/example.html +0 -206
  90. package/examples/templates/readme.md +0 -3
  91. package/examples/webpack/config.mjs +0 -69
  92. package/examples/webpack/example-builder.js +0 -410
  93. package/site/build.js +0 -26
  94. package/site/layouts/default.hbs +0 -78
  95. package/site/src/doc/faq.md +0 -8
  96. package/site/src/doc/index.md +0 -22
  97. package/site/src/doc/quickstart.md +0 -121
  98. package/site/src/doc/tutorials/index.md +0 -8
  99. package/site/src/download/index.hbs +0 -62
  100. package/site/src/favicon.ico +0 -0
  101. package/site/src/index.hbs +0 -71
  102. package/site/src/theme/index.css +0 -26
  103. package/site/src/theme/site.css +0 -531
  104. package/src/ol/layer/STAC.js +0 -780
  105. package/src/ol/layer/stacUtil.js +0 -169
  106. package/tasks/.eslintrc +0 -5
  107. package/tasks/build-website.sh +0 -90
  108. package/tasks/create-release.js +0 -107
  109. package/tasks/generate-index.js +0 -125
  110. package/tasks/generate-info.js +0 -189
  111. package/tasks/get-latest-release.js +0 -36
  112. package/tasks/newest-tag.js +0 -52
  113. package/tasks/prepare-package.js +0 -46
  114. package/tasks/publish.sh +0 -90
  115. package/test/README.md +0 -56
  116. package/test/browser/.eslintrc +0 -14
  117. package/test/browser/karma.config.cjs +0 -94
  118. package/test/browser/spec/ol/layer/STAC.test.js +0 -18
  119. package/test/browser/test-extensions.js +0 -419
  120. package/tsconfig.json +0 -62
@@ -1,743 +0,0 @@
1
- /* eslint-disable import/no-commonjs */
2
-
3
- /*global env: true */
4
-
5
- const hasOwnProp = Object.prototype.hasOwnProperty;
6
-
7
- // Work around an issue with hasOwnProperty in JSDoc's templateHelper.js.
8
- //TODO Fix in JSDoc.
9
- Object.prototype.hasOwnProperty = function (property) {
10
- return property in this;
11
- };
12
-
13
- const template = require('jsdoc/lib/jsdoc/template');
14
- const fs = require('jsdoc/lib/jsdoc/fs');
15
- const path = require('jsdoc/lib/jsdoc/path');
16
- const taffy = require('@jsdoc/salty').taffy;
17
- const handle = require('jsdoc/lib/jsdoc/util/error').handle;
18
- const helper = require('jsdoc/lib/jsdoc/util/templateHelper');
19
- const htmlsafe = helper.htmlsafe;
20
- const resolveAuthorLinks = helper.resolveAuthorLinks;
21
- const outdir = env.opts.destination;
22
-
23
- // Work around an issue with hasOwnProperty in JSDoc's templateHelper.js.
24
- //TODO Fix in JSDoc.
25
- Object.prototype.hasOwnProperty = hasOwnProp;
26
-
27
- let view;
28
- let data;
29
-
30
- function find(spec) {
31
- return helper.find(data, spec);
32
- }
33
-
34
- function getShortName(longname) {
35
- if (!longname.includes('module:ol/')) {
36
- return longname;
37
- }
38
- if (longname.includes('|')) {
39
- return longname;
40
- }
41
- if (longname.includes('<')) {
42
- return longname;
43
- }
44
- return longname.split(/[\~\.#\:]/).pop();
45
- }
46
-
47
- function linkto(longname, linkText, cssClass, fragmentId) {
48
- if (linkText) {
49
- return helper.linkto(longname, linkText, cssClass, fragmentId);
50
- }
51
-
52
- if (!longname.includes('module:ol/')) {
53
- return helper.linkto(longname, linkText, cssClass, fragmentId);
54
- }
55
-
56
- // check for `Array<foo|bar>` types (but allow `Array<foo>|Array<bar>` types)
57
- let openBrackets = 0;
58
- let parseTypes = false;
59
- for (const c of longname) {
60
- if (c === '<') {
61
- openBrackets += 1;
62
- continue;
63
- }
64
- if (c === '>') {
65
- openBrackets -= 1;
66
- continue;
67
- }
68
- if (openBrackets > 0 && c === '|') {
69
- parseTypes = true;
70
- break;
71
- }
72
- }
73
- if (parseTypes) {
74
- // collections or generics with unions get parsed by catharsis and
75
- // will unfortunamely include long module:ol/foo names
76
- return helper.linkto(longname, '', cssClass, fragmentId);
77
- }
78
-
79
- // handle union types
80
- if (longname.includes('|')) {
81
- return longname
82
- .split('|')
83
- .map((part) => linkto(part, '', cssClass, fragmentId))
84
- .join(' | ');
85
- }
86
-
87
- const match = longname.match(/(.+?)\.?<(.+)>$/);
88
- // handle generics and collections
89
- if (match) {
90
- return (
91
- linkto(match[1], '', cssClass, fragmentId) +
92
- '&lt;' +
93
- linkto(match[2], '', cssClass, fragmentId) +
94
- '>'
95
- );
96
- }
97
-
98
- return helper.linkto(
99
- longname,
100
- htmlsafe(getShortName(longname)),
101
- cssClass,
102
- fragmentId
103
- );
104
- }
105
-
106
- function tutoriallink(tutorial) {
107
- return helper.toTutorial(tutorial, null, {
108
- tag: 'em',
109
- classname: 'disabled',
110
- prefix: 'Tutorial: ',
111
- });
112
- }
113
-
114
- function getAncestorLinks(doclet) {
115
- return helper.getAncestorLinks(data, doclet);
116
- }
117
-
118
- function hashToLink(doclet, hash) {
119
- if (!/^(#.+)/.test(hash)) {
120
- return hash;
121
- }
122
-
123
- let url = helper.createLink(doclet);
124
-
125
- url = url.replace(/(#.+|$)/, hash);
126
- return '<a href="' + url + '">' + hash + '</a>';
127
- }
128
-
129
- function needsSignature(doclet) {
130
- let needsSig = false;
131
-
132
- // function and class definitions always get a signature
133
- if (doclet.kind === 'function' || doclet.kind === 'class') {
134
- needsSig = true;
135
- } else if (
136
- doclet.kind === 'typedef' &&
137
- doclet.type &&
138
- doclet.type.names &&
139
- doclet.type.names.length
140
- ) {
141
- // typedefs that contain functions get a signature, too
142
- for (let i = 0, l = doclet.type.names.length; i < l; i++) {
143
- if (doclet.type.names[i].toLowerCase() === 'function') {
144
- needsSig = true;
145
- break;
146
- }
147
- }
148
- }
149
-
150
- return needsSig;
151
- }
152
-
153
- function addSignatureParams(f) {
154
- const params = helper.getSignatureParams(f, 'optional');
155
-
156
- f.signature = (f.signature || '') + '(' + params.join(', ') + ')';
157
- }
158
-
159
- /**
160
- * Copied from https://github.com/jsdoc/jsdoc/blob/main/packages/jsdoc/lib/jsdoc/util/templateHelper.js
161
- * Modified to call our own `linkto` to shorten names.
162
- * @param {Object} doclet The doclet.
163
- * @param {Array} [doclet.yields] The returns.
164
- * @param {Array} [doclet.returns] The returns.
165
- * @param {string} cssClass The css class.
166
- * @return {Array} The returns.
167
- */
168
- function getSignatureReturns({yields, returns}, cssClass) {
169
- let returnTypes = [];
170
-
171
- if (yields || returns) {
172
- (yields || returns).forEach((r) => {
173
- if (r && r.type && r.type.names) {
174
- if (!returnTypes.length) {
175
- returnTypes = r.type.names;
176
- }
177
- }
178
- });
179
- }
180
-
181
- if (returnTypes && returnTypes.length) {
182
- returnTypes = returnTypes.map((r) => linkto(r, '', cssClass));
183
- }
184
-
185
- return returnTypes;
186
- }
187
-
188
- function addSignatureReturns(f) {
189
- const returnTypes = getSignatureReturns(f);
190
-
191
- f.signature = '<span class="signature">' + (f.signature || '') + '</span>';
192
-
193
- if (returnTypes.length) {
194
- f.signature +=
195
- '<span class="fa fa-arrow-circle-right"></span><span class="type-signature returnType">' +
196
- (returnTypes.length ? '{' + returnTypes.join(' | ') + '}' : '') +
197
- '</span>';
198
- }
199
- }
200
-
201
- function addSignatureTypes(f) {
202
- const types = helper.getSignatureTypes(f);
203
-
204
- f.signature =
205
- (f.signature || '') +
206
- '<span class="type-signature">' +
207
- (types.length ? ' :' + types.join('|') : '') +
208
- ' </span>';
209
- }
210
-
211
- function shortenPaths(files, commonPrefix) {
212
- // always use forward slashes
213
- Object.keys(files).forEach(function (file) {
214
- files[file].shortened = files[file].resolved
215
- .replace(commonPrefix, '')
216
- .replaceAll('\\', '/');
217
- });
218
-
219
- return files;
220
- }
221
-
222
- function resolveSourcePath(filepath) {
223
- return path.resolve(process.cwd(), filepath);
224
- }
225
-
226
- function getPathFromDoclet(doclet) {
227
- if (!doclet.meta) {
228
- return;
229
- }
230
-
231
- const filepath =
232
- doclet.meta.path && doclet.meta.path !== 'null'
233
- ? doclet.meta.path + '/' + doclet.meta.filename.split(/[\/\\]/).pop()
234
- : doclet.meta.filename;
235
-
236
- return filepath;
237
- }
238
-
239
- function preprocessLinks(text) {
240
- return text.replaceAll(
241
- /\{@link (module:ol\/\S+?)\}/g,
242
- (match, longname) => `{@link ${longname} ${getShortName(longname)}}`
243
- );
244
- }
245
-
246
- function generate(title, docs, filename, resolveLinks) {
247
- resolveLinks = resolveLinks === false ? false : true;
248
-
249
- const docData = {
250
- filename: filename,
251
- title: title,
252
- docs: docs,
253
- packageInfo: (find({kind: 'package'}) || [])[0],
254
- };
255
-
256
- const outpath = path.join(outdir, filename);
257
- let html = view.render('container.tmpl', docData);
258
-
259
- if (resolveLinks) {
260
- html = helper.resolveLinks(preprocessLinks(html)); // turn {@link foo} into <a href="foodoc.html">foo</a>
261
- }
262
-
263
- fs.writeFileSync(outpath, html, 'utf8');
264
- }
265
-
266
- function generateSourceFiles(sourceFiles) {
267
- Object.keys(sourceFiles).forEach(function (file) {
268
- let source;
269
- // links are keyed to the shortened path in each doclet's `meta.filename` property
270
- const sourceOutfile = helper.getUniqueFilename(sourceFiles[file].shortened);
271
- helper.registerLink(sourceFiles[file].shortened, sourceOutfile);
272
-
273
- try {
274
- source = {
275
- kind: 'source',
276
- code: helper.htmlsafe(
277
- fs.readFileSync(sourceFiles[file].resolved, 'utf8')
278
- ),
279
- };
280
- } catch (e) {
281
- handle(e);
282
- }
283
-
284
- generate(
285
- 'Source: ' + sourceFiles[file].shortened,
286
- [source],
287
- sourceOutfile,
288
- false
289
- );
290
- });
291
- }
292
-
293
- /**
294
- * Look for classes or functions with the same name as modules (which indicates that the module
295
- * exports only that class or function), then attach the classes or functions to the `module`
296
- * property of the appropriate module doclets. The name of each class or function is also updated
297
- * for display purposes. This function mutates the original arrays.
298
- *
299
- * @private
300
- * @param {Array<module:jsdoc/doclet.Doclet>} doclets The array of classes and functions to
301
- * check.
302
- * @param {Array<module:jsdoc/doclet.Doclet>} modules The array of module doclets to search.
303
- */
304
- function attachModuleSymbols(doclets, modules) {
305
- const symbols = {};
306
-
307
- // build a lookup table
308
- doclets.forEach(function (symbol) {
309
- symbols[symbol.longname] = symbol;
310
- });
311
-
312
- modules.forEach(function (module) {
313
- if (symbols[module.longname]) {
314
- module.module = symbols[module.longname];
315
- module.module.name =
316
- module.module.name.replace('module:', 'require("') + '")';
317
- }
318
- });
319
- }
320
-
321
- function getPrettyName(doclet) {
322
- const fullname = doclet.longname.replace('module:', '');
323
- if (doclet.isDefaultExport) {
324
- return fullname.split('~')[0];
325
- }
326
- return fullname;
327
- }
328
-
329
- /**
330
- * Create the navigation sidebar.
331
- * @param {Object} members The members that will be used to create the sidebar.
332
- * @param {Array<Object>} members.classes Classes.
333
- * @param {Array<Object>} members.externals Externals.
334
- * @param {Array<Object>} members.globals Globals.
335
- * @param {Array<Object>} members.mixins Mixins.
336
- * @param {Array<Object>} members.modules Modules.
337
- * @param {Array<Object>} members.namespaces Namespaces.
338
- * @param {Array<Object>} members.tutorials Tutorials.
339
- * @param {Array<Object>} members.events Events.
340
- * @return {string} The HTML for the navigation sidebar.
341
- */
342
- function buildNav(members) {
343
- const nav = [];
344
- members.classes.forEach(function (v) {
345
- // exclude interfaces from sidebar
346
- if (v.interface !== true) {
347
- nav.push({
348
- type: 'class',
349
- longname: v.longname,
350
- prettyname: getPrettyName(v),
351
- name: v.name,
352
- module: find({
353
- kind: 'module',
354
- longname: v.memberof,
355
- })[0],
356
- members: find({
357
- kind: 'member',
358
- memberof: v.longname,
359
- }),
360
- methods: find({
361
- kind: 'function',
362
- memberof: v.longname,
363
- }),
364
- typedefs: find({
365
- kind: 'typedef',
366
- memberof: v.longname,
367
- }),
368
- fires: v.fires,
369
- events: find({
370
- kind: 'event',
371
- memberof: v.longname,
372
- }),
373
- });
374
- }
375
- });
376
- members.modules.forEach(function (v) {
377
- const classes = find({
378
- kind: 'class',
379
- memberof: v.longname,
380
- });
381
- const members = find({
382
- kind: 'member',
383
- memberof: v.longname,
384
- });
385
- const methods = find({
386
- kind: 'function',
387
- memberof: v.longname,
388
- });
389
- const typedefs = find({
390
- kind: 'typedef',
391
- memberof: v.longname,
392
- });
393
- const events = find({
394
- kind: 'event',
395
- memberof: v.longname,
396
- });
397
- // Only add modules that contain more than just classes with their
398
- // associated Options typedef
399
- if (
400
- typedefs.length > classes.length ||
401
- members.length + methods.length > 0
402
- ) {
403
- nav.push({
404
- type: 'module',
405
- longname: v.longname,
406
- prettyname: getPrettyName(v),
407
- name: v.name,
408
- members: members,
409
- methods: methods,
410
- typedefs: typedefs,
411
- fires: v.fires,
412
- events: events,
413
- });
414
- }
415
- });
416
-
417
- nav.sort(function (a, b) {
418
- const prettyNameA = a.prettyname.toLowerCase();
419
- const prettyNameB = b.prettyname.toLowerCase();
420
- if (prettyNameA > prettyNameB) {
421
- return 1;
422
- }
423
- if (prettyNameA < prettyNameB) {
424
- return -1;
425
- }
426
- return 0;
427
- });
428
- return nav;
429
- }
430
-
431
- /**
432
- * @param {Object} taffyData See https://www.npmjs.com/package/@jsdoc/salty.
433
- * @param {Object} opts Options.
434
- * @param {Object} tutorials Tutorials.
435
- */
436
- exports.publish = function (taffyData, opts, tutorials) {
437
- data = taffyData;
438
-
439
- const conf = env.conf.templates || {};
440
- conf['default'] = conf['default'] || {};
441
-
442
- const templatePath = opts.template;
443
- view = new template.Template(templatePath + '/tmpl');
444
-
445
- // claim some special filenames in advance, so the All-Powerful Overseer of Filename Uniqueness
446
- // doesn't try to hand them out later
447
- const indexUrl = helper.getUniqueFilename('index');
448
- // don't call registerLink() on this one! 'index' is also a valid longname
449
-
450
- const globalUrl = helper.getUniqueFilename('global');
451
- helper.registerLink('global', globalUrl);
452
-
453
- // set up templating
454
- view.layout = 'layout.tmpl';
455
-
456
- // set up tutorials for helper
457
- helper.setTutorials(tutorials);
458
-
459
- data = helper.prune(data);
460
- data.sort('longname, version, since');
461
- helper.addEventListeners(data);
462
-
463
- let sourceFiles = {};
464
- const sourceFilePaths = [];
465
- data().each(function (doclet) {
466
- doclet.attribs = '';
467
-
468
- if (doclet.examples) {
469
- doclet.examples = doclet.examples.map(function (example) {
470
- let caption, code;
471
-
472
- const match = example.match(
473
- /^\s*<caption>([\s\S]+?)<\/caption>(?:\s*[\n\r])([\s\S]+)$/i
474
- );
475
- if (match) {
476
- caption = match[1];
477
- code = match[2];
478
- }
479
-
480
- return {
481
- caption: caption || '',
482
- code: code || example,
483
- };
484
- });
485
- }
486
- if (doclet.see) {
487
- doclet.see.forEach(function (seeItem, i) {
488
- doclet.see[i] = hashToLink(doclet, seeItem);
489
- });
490
- }
491
-
492
- // build a list of source files
493
- let sourcePath;
494
- let resolvedSourcePath;
495
- if (doclet.meta) {
496
- sourcePath = getPathFromDoclet(doclet);
497
- resolvedSourcePath = resolveSourcePath(sourcePath);
498
- sourceFiles[sourcePath] = {
499
- resolved: resolvedSourcePath,
500
- shortened: null,
501
- };
502
- sourceFilePaths.push(resolvedSourcePath);
503
- }
504
- });
505
-
506
- fs.mkPath(outdir);
507
-
508
- // copy the template's static files to outdir
509
- const fromDir = path.join(templatePath, 'static');
510
- const staticFiles = fs.ls(fromDir, 3);
511
-
512
- staticFiles.forEach(function (fileName) {
513
- const toDir = fs.toDir(fileName.replace(fromDir, outdir));
514
- fs.mkPath(toDir);
515
- fs.copyFileSync(fileName, toDir);
516
- });
517
-
518
- // copy user-specified static files to outdir
519
- let staticFilePaths;
520
- let staticFileFilter;
521
- let staticFileScanner;
522
- if (conf['default'].staticFiles) {
523
- staticFilePaths = conf['default'].staticFiles.paths || [];
524
- staticFileFilter = new (require('jsdoc/lib/jsdoc/src/filter').Filter)(
525
- conf['default'].staticFiles
526
- );
527
- staticFileScanner = new (require('jsdoc/lib/jsdoc/src/scanner').Scanner)();
528
-
529
- staticFilePaths.forEach(function (filePath) {
530
- const extraStaticFiles = staticFileScanner.scan(
531
- [filePath],
532
- 10,
533
- staticFileFilter
534
- );
535
-
536
- extraStaticFiles.forEach(function (fileName) {
537
- const sourcePath = fs.statSync(filePath).isDirectory()
538
- ? filePath
539
- : path.dirname(filePath);
540
- const toDir = fs.toDir(fileName.replace(sourcePath, outdir));
541
- fs.mkPath(toDir);
542
- fs.copyFileSync(fileName, toDir);
543
- });
544
- });
545
- }
546
-
547
- if (sourceFilePaths.length) {
548
- sourceFiles = shortenPaths(sourceFiles, path.commonPrefix(sourceFilePaths));
549
- }
550
- data().each(function (doclet) {
551
- const url = helper.createLink(doclet);
552
- helper.registerLink(doclet.longname, url);
553
-
554
- // replace the filename with a shortened version of the full path
555
- let docletPath;
556
- if (doclet.meta) {
557
- docletPath = getPathFromDoclet(doclet);
558
- docletPath = sourceFiles[docletPath].shortened;
559
- if (docletPath) {
560
- doclet.meta.filename = docletPath;
561
- }
562
- }
563
- });
564
-
565
- data().each(function (doclet) {
566
- const url = helper.longnameToUrl[doclet.longname];
567
-
568
- if (url.includes('#')) {
569
- doclet.id = helper.longnameToUrl[doclet.longname].split(/#/).pop();
570
- } else {
571
- doclet.id = doclet.name;
572
- }
573
-
574
- if (needsSignature(doclet)) {
575
- addSignatureParams(doclet);
576
- addSignatureReturns(doclet);
577
- }
578
- });
579
-
580
- // do this after the urls have all been generated
581
- data().each(function (doclet) {
582
- doclet.ancestors = getAncestorLinks(doclet);
583
-
584
- if (doclet.kind === 'member') {
585
- addSignatureTypes(doclet);
586
- }
587
-
588
- if (doclet.kind === 'constant') {
589
- addSignatureTypes(doclet);
590
- doclet.kind = 'member';
591
- }
592
- });
593
-
594
- const members = helper.getMembers(data);
595
- members.tutorials = tutorials.children;
596
-
597
- // add template helpers
598
- view.find = find;
599
- view.linkto = linkto;
600
- view.getShortName = getShortName;
601
- view.resolveAuthorLinks = resolveAuthorLinks;
602
- view.tutoriallink = tutoriallink;
603
- view.htmlsafe = htmlsafe;
604
- view.members = members; //@davidshimjs: To make navigation for customizing
605
-
606
- // once for all
607
- view.nav = buildNav(members);
608
-
609
- attachModuleSymbols(
610
- find({kind: ['class', 'function'], longname: {left: 'module:'}}),
611
- members.modules
612
- );
613
-
614
- // only output pretty-printed source files if requested; do this before generating any other
615
- // pages, so the other pages can link to the source files
616
- if (conf['default'].outputSourceFiles) {
617
- generateSourceFiles(sourceFiles);
618
- }
619
-
620
- if (members.globals.length) {
621
- generate('Global', [{kind: 'globalobj'}], globalUrl);
622
- }
623
-
624
- // the file type doclets come from @fileoverview tags in comment blocks with an @api tag
625
- const fileOverviews = find({kind: 'file'});
626
-
627
- view.navigationItems = view.nav.reduce(function (dict, item) {
628
- dict[item.longname] = item;
629
- return dict;
630
- }, {});
631
- const navigationHtml = helper.resolveLinks(
632
- view.nav.map((item) => view.partial('navigation.tmpl', {item})).join('')
633
- );
634
- const navHtmlPath = path.join(outdir, 'navigation.tmpl.html');
635
- fs.writeFileSync(navHtmlPath, navigationHtml, 'utf8');
636
-
637
- generate(
638
- 'Index',
639
- [
640
- {
641
- kind: 'mainpage',
642
- readme: opts.readme,
643
- longname: opts.mainpagetitle ? opts.mainpagetitle : 'Main Page',
644
- },
645
- ],
646
- indexUrl
647
- );
648
-
649
- // set up the lists that we'll use to generate pages
650
- const classes = taffy(members.classes);
651
- const modules = taffy(members.modules);
652
- const namespaces = taffy(members.namespaces);
653
- const mixins = taffy(members.mixins);
654
- const externals = taffy(members.externals);
655
-
656
- for (const longname in helper.longnameToUrl) {
657
- if (hasOwnProp.call(helper.longnameToUrl, longname)) {
658
- const myClasses = helper.find(classes, {longname: longname});
659
- if (myClasses.length) {
660
- generate(
661
- 'Class: ' + myClasses[0].name,
662
- myClasses,
663
- helper.longnameToUrl[longname]
664
- );
665
- }
666
-
667
- const myModules = helper.find(modules, {longname: longname});
668
- if (myModules.length) {
669
- // assign any file overview description as the module description
670
- myModules.forEach((moduleDoclet) => {
671
- fileOverviews.forEach((fileDoclet) => {
672
- if (fileDoclet.memberof !== moduleDoclet.longname) {
673
- return;
674
- }
675
- moduleDoclet.description = fileDoclet.description;
676
- });
677
- });
678
- generate(
679
- 'Module: ' + myModules[0].name,
680
- myModules,
681
- helper.longnameToUrl[longname]
682
- );
683
- }
684
-
685
- const myNamespaces = helper.find(namespaces, {longname: longname});
686
- if (myNamespaces.length) {
687
- generate(
688
- 'Namespace: ' + myNamespaces[0].name,
689
- myNamespaces,
690
- helper.longnameToUrl[longname]
691
- );
692
- }
693
-
694
- const myMixins = helper.find(mixins, {longname: longname});
695
- if (myMixins.length) {
696
- generate(
697
- 'Mixin: ' + myMixins[0].name,
698
- myMixins,
699
- helper.longnameToUrl[longname]
700
- );
701
- }
702
-
703
- const myExternals = helper.find(externals, {longname: longname});
704
- if (myExternals.length) {
705
- generate(
706
- 'External: ' + myExternals[0].name,
707
- myExternals,
708
- helper.longnameToUrl[longname]
709
- );
710
- }
711
- }
712
- }
713
-
714
- // TODO: move the tutorial functions to templateHelper.js
715
- function generateTutorial(title, tutorial, filename) {
716
- const tutorialData = {
717
- title: title,
718
- header: tutorial.title,
719
- content: tutorial.parse(),
720
- children: tutorial.children,
721
- };
722
-
723
- let html = view.render('tutorial.tmpl', tutorialData);
724
- // yes, you can use {@link} in tutorials too!
725
- html = helper.resolveLinks(html); // turn {@link foo} into <a href="foodoc.html">foo</a>
726
-
727
- const tutorialPath = path.join(outdir, filename);
728
- fs.writeFileSync(tutorialPath, html, 'utf8');
729
- }
730
-
731
- // tutorials can have only one parent so there is no risk for loops
732
- function saveChildren(node) {
733
- node.children.forEach(function (child) {
734
- generateTutorial(
735
- 'Tutorial: ' + child.title,
736
- child,
737
- helper.tutorialToUrl(child.name)
738
- );
739
- saveChildren(child);
740
- });
741
- }
742
- saveChildren(tutorials);
743
- };