clean-jsdoc-theme 3.3.3 → 3.3.4

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 (59) hide show
  1. package/.eslintignore +4 -4
  2. package/.eslintrc.js +3 -3
  3. package/.github/ISSUE_TEMPLATE/bug_report.md +43 -43
  4. package/.github/ISSUE_TEMPLATE/feature_request.md +27 -27
  5. package/.github/pull_request_template.md +16 -16
  6. package/.github/workflows/codeql-analysis.yml +67 -67
  7. package/.prettierignore +2 -2
  8. package/.prettierrc +5 -5
  9. package/.stylelintignore +3 -3
  10. package/.stylelintrc +23 -23
  11. package/.travis.yml +30 -30
  12. package/CHANGELOG.md +216 -216
  13. package/CODE_OF_CONDUCT.md +76 -76
  14. package/CODE_OF_CONDUCT_HINDI.md +46 -46
  15. package/CONTRIBUTING.md +24 -24
  16. package/LICENSE +21 -21
  17. package/README.md +546 -546
  18. package/SECURITY.md +21 -21
  19. package/helpers/down-arrow.js +9 -9
  20. package/jsdoc-config.json +60 -60
  21. package/package.json +46 -46
  22. package/publish.js +1197 -1197
  23. package/static/fonts/Montserrat-Regular.ttf +0 -0
  24. package/static/fonts/OFL-hind.txt +0 -0
  25. package/static/fonts/OFL-montserrat.txt +0 -0
  26. package/static/scripts/fix-code-block.js +53 -53
  27. package/static/scripts/fix-navbar.js +25 -25
  28. package/static/scripts/linenumber.js +25 -25
  29. package/static/scripts/misc.js +217 -217
  30. package/static/scripts/resize.js +85 -85
  31. package/static/scripts/search.js +77 -77
  32. package/static/scripts/third-party/Apache-License-2.0.txt +202 -202
  33. package/static/scripts/third-party/fuse.js +8 -8
  34. package/static/scripts/third-party/lang-css.js +2 -2
  35. package/static/scripts/third-party/prettify.js +28 -28
  36. package/static/styles/clean-jsdoc-theme-base.css +393 -393
  37. package/static/styles/clean-jsdoc-theme-dark.css +324 -324
  38. package/static/styles/clean-jsdoc-theme-light.css +319 -319
  39. package/static/styles/reset.css +351 -351
  40. package/static/styles/third-party/ionicons.min.css +11 -11
  41. package/static/styles/third-party/prettify-jsdoc.css +111 -111
  42. package/static/styles/third-party/prettify-tomorrow.css +5 -5
  43. package/tmpl/augments.tmpl +10 -10
  44. package/tmpl/container.tmpl +189 -189
  45. package/tmpl/details.tmpl +208 -208
  46. package/tmpl/example.tmpl +3 -3
  47. package/tmpl/examples.tmpl +38 -38
  48. package/tmpl/exceptions.tmpl +32 -32
  49. package/tmpl/icons.tmpl +34 -34
  50. package/tmpl/layout.tmpl +165 -165
  51. package/tmpl/mainpage.tmpl +10 -10
  52. package/tmpl/members.tmpl +43 -43
  53. package/tmpl/method.tmpl +140 -140
  54. package/tmpl/params.tmpl +124 -124
  55. package/tmpl/properties.tmpl +109 -109
  56. package/tmpl/returns.tmpl +18 -18
  57. package/tmpl/source.tmpl +7 -7
  58. package/tmpl/tutorial.tmpl +19 -19
  59. package/tmpl/type.tmpl +6 -6
package/publish.js CHANGED
@@ -1,1197 +1,1197 @@
1
- /* global env: true */
2
-
3
- var doop = require('jsdoc/util/doop');
4
- var fs = require('jsdoc/fs');
5
- var helper = require('jsdoc/util/templateHelper');
6
- var logger = require('jsdoc/util/logger');
7
- var path = require('jsdoc/path');
8
- var taffy = require('taffydb').taffy;
9
- var template = require('jsdoc/template');
10
- var util = require('util');
11
- var fse = require('fs-extra');
12
-
13
- var htmlsafe = helper.htmlsafe;
14
- var linkto = helper.linkto;
15
- var resolveAuthorLinks = helper.resolveAuthorLinks;
16
- var hasOwnProp = Object.prototype.hasOwnProperty;
17
-
18
- /* prettier-ignore-start */
19
- // eslint-disable-next-line
20
- var themeOpts = (env && env.opts && env.opts['theme_opts']) || {};
21
- /* prettier-ignore-end */
22
-
23
- var data;
24
- var view;
25
- var searchListArray = [];
26
- var haveSearch =
27
- themeOpts.search === undefined ? true : Boolean(themeOpts.search);
28
-
29
- // eslint-disable-next-line no-restricted-globals
30
- var outdir = path.normalize(env.opts.destination);
31
-
32
- var SECTION_TYPE = {
33
- Classes: 'Classes',
34
- Modules: 'Modules',
35
- Externals: 'Externals',
36
- Events: 'Events',
37
- Namespaces: 'Namespaces',
38
- Mixins: 'Mixins',
39
- Tutorials: 'Tutorials',
40
- Interfaces: 'Interfaces',
41
- Global: 'Global',
42
- Menu: 'Menu'
43
- };
44
-
45
- var defaultSections = [
46
- SECTION_TYPE.Menu,
47
- SECTION_TYPE.Modules,
48
- SECTION_TYPE.Classes,
49
- SECTION_TYPE.Externals,
50
- SECTION_TYPE.Events,
51
- SECTION_TYPE.Namespaces,
52
- SECTION_TYPE.Mixins,
53
- SECTION_TYPE.Tutorials,
54
- SECTION_TYPE.Interfaces,
55
- SECTION_TYPE.Global
56
- ];
57
-
58
- function copyStaticFolder() {
59
- var staticDir = themeOpts.static_dir || undefined;
60
-
61
- if (staticDir) {
62
- for (var i = 0; i < staticDir.length; i++) {
63
- var output = path.join(outdir, staticDir[i]);
64
-
65
- fse.copySync(staticDir[i], output);
66
- }
67
- }
68
- }
69
-
70
- copyStaticFolder();
71
-
72
- function copyToOutputFolder(filePath) {
73
- var filePathNormalized = path.normalize(filePath);
74
-
75
- fs.copyFileSync(filePathNormalized, outdir);
76
- }
77
-
78
- function copyToOutputFolderFromArray(filePathArray) {
79
- var i = 0;
80
- var outputList = [];
81
-
82
- if (Array.isArray(filePathArray)) {
83
- for (; i < filePathArray.length; i++) {
84
- copyToOutputFolder(filePathArray[i]);
85
- outputList.push(path.basename(filePathArray[i]));
86
- }
87
- }
88
-
89
- return outputList;
90
- }
91
-
92
- function find(spec) {
93
- return helper.find(data, spec);
94
- }
95
-
96
- function tutoriallink(tutorial) {
97
- return helper.toTutorial(tutorial, null, {
98
- tag: 'em',
99
- classname: 'disabled',
100
- prefix: 'Tutorial: '
101
- });
102
- }
103
-
104
- function getAncestorLinks(doclet) {
105
- return helper.getAncestorLinks(data, doclet);
106
- }
107
-
108
- function hashToLink(doclet, hash) {
109
- if (!/^(#.+)/.test(hash)) {
110
- return hash;
111
- }
112
-
113
- var url = helper.createLink(doclet);
114
-
115
- url = url.replace(/(#.+|$)/, hash);
116
-
117
- return '<a href="' + url + '">' + hash + '</a>';
118
- }
119
-
120
- function needsSignature(doclet) {
121
- var needsSig = false;
122
-
123
- // function and class definitions always get a signature
124
- if (doclet.kind === 'function' || doclet.kind === 'class') {
125
- needsSig = true;
126
- }
127
- // typedefs that contain functions get a signature, too
128
- else if (
129
- doclet.kind === 'typedef' &&
130
- doclet.type &&
131
- doclet.type.names &&
132
- doclet.type.names.length
133
- ) {
134
- for (var i = 0, l = doclet.type.names.length; i < l; i++) {
135
- if (doclet.type.names[i].toLowerCase() === 'function') {
136
- needsSig = true;
137
- break;
138
- }
139
- }
140
- }
141
-
142
- return needsSig;
143
- }
144
-
145
- function getSignatureAttributes(item) {
146
- var attributes = [];
147
-
148
- if (item.optional) {
149
- attributes.push('opt');
150
- }
151
-
152
- if (item.nullable === true) {
153
- attributes.push('nullable');
154
- } else if (item.nullable === false) {
155
- attributes.push('non-null');
156
- }
157
-
158
- return attributes;
159
- }
160
-
161
- function updateItemName(item) {
162
- var attributes = getSignatureAttributes(item);
163
- var itemName = item.name || '';
164
-
165
- if (item.variable) {
166
- itemName = '&hellip;' + itemName;
167
- }
168
-
169
- if (attributes && attributes.length) {
170
- itemName = util.format(
171
- '%s<span class="signature-attributes">%s</span>',
172
- itemName,
173
- attributes.join(', ')
174
- );
175
- }
176
-
177
- return itemName;
178
- }
179
-
180
- function addParamAttributes(params) {
181
- return params
182
- .filter(function(param) {
183
- return param.name && param.name.indexOf('.') === -1;
184
- })
185
- .map(updateItemName);
186
- }
187
-
188
- function buildItemTypeStrings(item) {
189
- var types = [];
190
-
191
- if (item && item.type && item.type.names) {
192
- item.type.names.forEach(function(name) {
193
- types.push(linkto(name, htmlsafe(name)));
194
- });
195
- }
196
-
197
- return types;
198
- }
199
-
200
- function buildAttribsString(attribs) {
201
- var attribsString = '';
202
-
203
- if (attribs && attribs.length) {
204
- attribsString = htmlsafe(util.format('(%s) ', attribs.join(', ')));
205
- }
206
-
207
- return attribsString;
208
- }
209
-
210
- function addNonParamAttributes(items) {
211
- var types = [];
212
-
213
- items.forEach(function(item) {
214
- types = types.concat(buildItemTypeStrings(item));
215
- });
216
-
217
- return types;
218
- }
219
-
220
- function addSignatureParams(f) {
221
- var params = f.params ? addParamAttributes(f.params) : [];
222
-
223
- f.signature = util.format('%s(%s)', f.signature || '', params.join(', '));
224
- }
225
-
226
- function addSignatureReturns(f) {
227
- var attribs = [];
228
- var attribsString = '';
229
- var returnTypes = [];
230
- var returnTypesString = '';
231
-
232
- // jam all the return-type attributes into an array. this could create odd results (for example,
233
- // if there are both nullable and non-nullable return types), but let's assume that most people
234
- // who use multiple @return tags aren't using Closure Compiler type annotations, and vice-versa.
235
- if (f.returns) {
236
- f.returns.forEach(function(item) {
237
- helper.getAttribs(item).forEach(function(attrib) {
238
- if (attribs.indexOf(attrib) === -1) {
239
- attribs.push(attrib);
240
- }
241
- });
242
- });
243
-
244
- attribsString = buildAttribsString(attribs);
245
- }
246
-
247
- if (f.returns) {
248
- returnTypes = addNonParamAttributes(f.returns);
249
- }
250
- if (returnTypes.length) {
251
- returnTypesString = util.format(
252
- ' &rarr; %s{%s}',
253
- attribsString,
254
- returnTypes.join('|')
255
- );
256
- }
257
-
258
- f.signature =
259
- '<span class="signature">' +
260
- (f.signature || '') +
261
- '</span>' +
262
- '<span class="type-signature">' +
263
- returnTypesString +
264
- '</span>';
265
- }
266
-
267
- function addSignatureTypes(f) {
268
- var types = f.type ? buildItemTypeStrings(f) : [];
269
-
270
- f.signature =
271
- (f.signature || '') +
272
- '<span class="type-signature">' +
273
- (types.length ? ' :' + types.join('|') : '') +
274
- '</span>';
275
- }
276
-
277
- function addAttribs(f) {
278
- var attribs = helper.getAttribs(f);
279
- var attribsString = buildAttribsString(attribs);
280
-
281
- f.attribs = util.format(
282
- '<span class="type-signature">%s</span>',
283
- attribsString
284
- );
285
- }
286
-
287
- function shortenPaths(files, commonPrefix) {
288
- Object.keys(files).forEach(function(file) {
289
- files[file].shortened = files[file].resolved
290
- .replace(commonPrefix, '')
291
- // always use forward slashes
292
- .replace(/\\/g, '/');
293
- });
294
-
295
- return files;
296
- }
297
-
298
- function getPathFromDoclet(doclet) {
299
- if (!doclet.meta) {
300
- return null;
301
- }
302
-
303
- return doclet.meta.path && doclet.meta.path !== 'null' ?
304
- path.join(doclet.meta.path, doclet.meta.filename) :
305
- doclet.meta.filename;
306
- }
307
-
308
- function generate(type, title, docs, filename, resolveLinks) {
309
- resolveLinks = resolveLinks !== false;
310
-
311
- var docData = {
312
- type: type,
313
- title: title,
314
- docs: docs
315
- };
316
-
317
- var outpath = path.join(outdir, filename),
318
- html = view.render('container.tmpl', docData);
319
-
320
- if (resolveLinks) {
321
- html = helper.resolveLinks(html); // turn {@link foo} into <a href="foodoc.html">foo</a>
322
- }
323
-
324
- fs.writeFileSync(outpath, html, 'utf8');
325
- }
326
-
327
- function generateSourceFiles(sourceFiles, encoding) {
328
- encoding = encoding || 'utf8';
329
- Object.keys(sourceFiles).forEach(function(file) {
330
- var source;
331
- // links are keyed to the shortened path in each doclet's `meta.shortpath` property
332
- var sourceOutfile = helper.getUniqueFilename(
333
- sourceFiles[file].shortened
334
- );
335
-
336
- helper.registerLink(sourceFiles[file].shortened, sourceOutfile);
337
-
338
- try {
339
- source = {
340
- kind: 'source',
341
- code: helper.htmlsafe(
342
- fs.readFileSync(sourceFiles[file].resolved, encoding)
343
- )
344
- };
345
- } catch (e) {
346
- logger.error(
347
- 'Error while generating source file %s: %s',
348
- file,
349
- e.message
350
- );
351
- }
352
-
353
- generate(
354
- 'Source',
355
- sourceFiles[file].shortened,
356
- [source],
357
- sourceOutfile,
358
- false
359
- );
360
- });
361
- }
362
-
363
- /**
364
- * Look for classes or functions with the same name as modules (which indicates that the module
365
- * exports only that class or function), then attach the classes or functions to the `module`
366
- * property of the appropriate module doclets. The name of each class or function is also updated
367
- * for display purposes. This function mutates the original arrays.
368
- *
369
- * @private
370
- * @param {Array.<module:jsdoc/doclet.Doclet>} doclets - The array of classes and functions to
371
- * check.
372
- * @param {Array.<module:jsdoc/doclet.Doclet>} modules - The array of module doclets to search.
373
- */
374
- function attachModuleSymbols(doclets, modules) {
375
- var symbols = {};
376
-
377
- // build a lookup table
378
- doclets.forEach(function(symbol) {
379
- symbols[symbol.longname] = symbols[symbol.longname] || [];
380
- symbols[symbol.longname].push(symbol);
381
- });
382
-
383
- // eslint-disable-next-line array-callback-return
384
- return modules.map(function(module) {
385
- if (symbols[module.longname]) {
386
- module.modules = symbols[module.longname]
387
- // Only show symbols that have a description. Make an exception for classes, because
388
- // we want to show the constructor-signature heading no matter what.
389
- .filter(function(symbol) {
390
- return symbol.description || symbol.kind === 'class';
391
- })
392
- .map(function(symbol) {
393
- symbol = doop(symbol);
394
-
395
- if (symbol.kind === 'class' || symbol.kind === 'function') {
396
- symbol.name =
397
- symbol.name.replace('module:', '(require("') +
398
- '"))';
399
- }
400
-
401
- return symbol;
402
- });
403
- }
404
- });
405
- }
406
-
407
- function buildMenuNav(menu) {
408
- if (menu === undefined) {
409
- return '';
410
- }
411
-
412
- var m = '<ul>';
413
-
414
- menu.forEach(function(item) {
415
- // Setting default value for optional parameter
416
- var c = item.class || '';
417
- var id = item.id || '';
418
- var target = item.target || '';
419
-
420
- c += ' menu-link';
421
-
422
- m +=
423
- '<li class="menu-li">' +
424
- "<a href='" +
425
- item.link +
426
- "' class='" +
427
- c +
428
- "' id='" +
429
- id +
430
- "' target='" +
431
- target +
432
- "'>" +
433
- item.title +
434
- '</a></li>';
435
- });
436
-
437
- m += '</ul>';
438
-
439
- return m;
440
- }
441
-
442
- function buildSearch() {
443
- var searchHTML =
444
- '<div class="search-box" id="search-box">' +
445
- '<div class="search-box-input-container">' +
446
- '<input class="search-box-input" type="text" placeholder="Search..." id="search-box-input" />' +
447
- '<svg class="search-icon" alt="search-icon"><use xlink:href="#search-icon"></use></svg>' +
448
- '</div>';
449
-
450
- var searchItemContainer =
451
- '<div class="search-item-container" id="search-item-container"><ul class="search-item-ul" id="search-item-ul"></ul></div></div>';
452
-
453
- searchHTML += searchItemContainer;
454
-
455
- return searchHTML;
456
- }
457
-
458
- function buildFooter() {
459
- var footer = themeOpts.footer || '';
460
-
461
- return footer;
462
- }
463
-
464
- function getFavicon() {
465
- var favicon = themeOpts.favicon || undefined;
466
-
467
- return favicon;
468
- }
469
-
470
- // function copy
471
- function createDynamicStyleSheet() {
472
- var styleClass = themeOpts.create_style || undefined;
473
- /* prettier-ignore-start */
474
-
475
- return styleClass;
476
- }
477
-
478
- function createDynamicsScripts() {
479
- var scripts = themeOpts.add_scripts || undefined;
480
-
481
- return scripts;
482
- }
483
-
484
- function returnPathOfScriptScr() {
485
- var scriptPath = themeOpts.add_script_path || undefined;
486
-
487
- return scriptPath;
488
- }
489
-
490
- function returnPathOfStyleSrc() {
491
- var stylePath = themeOpts.add_style_path || undefined;
492
-
493
- return stylePath;
494
- }
495
-
496
- function includeCss() {
497
- var stylePath = themeOpts.include_css || undefined;
498
-
499
- if (stylePath) {
500
- stylePath = copyToOutputFolderFromArray(stylePath);
501
- }
502
-
503
- return stylePath;
504
- }
505
-
506
- function resizeable() {
507
- var resizeOpts = themeOpts.resizeable || {};
508
-
509
- return resizeOpts;
510
- }
511
-
512
- function codepen() {
513
- var codepenOpts = themeOpts.codepen || {};
514
-
515
- return codepenOpts;
516
- }
517
-
518
- function overlayScrollbarOptions() {
519
- var overlayOptions = themeOpts.overlay_scrollbar || undefined;
520
-
521
- if (overlayOptions) {
522
- return JSON.stringify(overlayOptions);
523
- }
524
-
525
- return undefined;
526
- }
527
-
528
- function includeScript() {
529
- var scriptPath = themeOpts.include_js || undefined;
530
-
531
- if (scriptPath) {
532
- scriptPath = copyToOutputFolderFromArray(scriptPath);
533
- }
534
-
535
- return scriptPath;
536
- }
537
-
538
- function getMetaTagData() {
539
- var meta = themeOpts.meta || undefined;
540
-
541
- return meta;
542
- }
543
-
544
- function getTheme() {
545
- var theme = themeOpts.theme || 'light';
546
- var baseThemeName = 'clean-jsdoc-theme';
547
- var themeSrc = `${baseThemeName}-${theme}.css`.trim();
548
-
549
- return themeSrc;
550
- }
551
-
552
- function search() {
553
- var searchOption = themeOpts.search;
554
-
555
- var obj = {
556
- list: searchListArray,
557
- options: JSON.stringify(searchOption)
558
- };
559
-
560
- return obj;
561
- }
562
-
563
- function buildMemberNav({
564
- items,
565
- itemHeading,
566
- itemsSeen,
567
- linktoFn,
568
- sectionName
569
- }) {
570
- var nav = '';
571
-
572
- if (items.length) {
573
- var itemsNav = '';
574
-
575
- items.forEach(function(item) {
576
- var methods =
577
- sectionName === SECTION_TYPE.Tutorials ||
578
- sectionName === SECTION_TYPE.Global ?
579
- [] :
580
- find({
581
- kind: 'function',
582
- memberof: item.longname,
583
- inherited: {'!is': Boolean(themeOpts.exclude_inherited)}
584
- });
585
-
586
- if (!hasOwnProp.call(item, 'longname')) {
587
- itemsNav += '<li>' + linktoFn('', item.name);
588
- itemsNav += '</li>';
589
- } else if (!hasOwnProp.call(itemsSeen, item.longname)) {
590
- /**
591
- * Only have accordion class name if it have any child.
592
- * Otherwise it didn't makes any sense.
593
- */
594
- var accordionClassName = methods.length ?
595
- '"accordion collapsed child"' :
596
- '"accordion-list"';
597
-
598
- /**
599
- * Id give to accordion.
600
- */
601
- var accordionId = methods.length ?
602
- Math.floor(Math.random() * 10000000) :
603
- '""';
604
-
605
- itemsNav +=
606
- '<li class=' +
607
- accordionClassName +
608
- ' id=' +
609
- accordionId +
610
- '>';
611
-
612
- var linkTitle = linktoFn(
613
- item.longname,
614
- item.name.replace(/^module:/, '')
615
- );
616
-
617
- if (methods.length) {
618
- itemsNav +=
619
- '<div class="accordion-heading child">' +
620
- linkTitle +
621
- '<svg><use xlink:href="#down-icon"></use></svg>' +
622
- '</div>';
623
- } else {
624
- itemsNav += linkTitle;
625
- }
626
-
627
- if (haveSearch) {
628
- searchListArray.push(
629
- JSON.stringify({
630
- title: item.name,
631
- link: linkto(item.longname, item.name)
632
- })
633
- );
634
- }
635
-
636
- if (methods.length) {
637
- itemsNav += "<ul class='methods accordion-content'>";
638
-
639
- methods.forEach(function(method) {
640
- var name = method.longname.split(method.scope === 'static' ? '.' : '#');
641
- var first = name[0];
642
- var last = name[1];
643
-
644
- name = first + ' &rtrif; ' + last;
645
-
646
- if (haveSearch) {
647
- searchListArray.push(
648
- JSON.stringify({
649
- title: method.longname,
650
- link: linkto(method.longname, name)
651
- })
652
- );
653
- }
654
- itemsNav += "<li data-type='method'>";
655
- itemsNav += linkto(method.longname, method.name);
656
- itemsNav += '</li>';
657
- });
658
-
659
- itemsNav += '</ul>';
660
- }
661
- itemsNav += '</li>';
662
- itemsSeen[item.longname] = true;
663
- }
664
- });
665
-
666
- if (itemsNav !== '') {
667
- nav +=
668
- '<div class="accordion collapsed" id="' +
669
- Math.floor(Math.random() * 10000000) +
670
- '" > <h3 class="accordion-heading">' +
671
- itemHeading +
672
- '<svg><use xlink:href="#down-icon"></use></svg>' +
673
- '</h3><ul class="accordion-content">' +
674
- itemsNav +
675
- '</ul> </div>';
676
- }
677
- }
678
-
679
- return nav;
680
- }
681
-
682
- function linktoTutorial(longName, name) {
683
- return tutoriallink(name);
684
- }
685
-
686
- function linktoExternal(longName, name) {
687
- return linkto(longName, name.replace(/(^"|"$)/g, ''));
688
- }
689
-
690
- /**
691
- * Create the navigation sidebar.
692
- * @param {object} members The members that will be used to create the sidebar.
693
- * @param {array<object>} members.classes
694
- * @param {array<object>} members.externals
695
- * @param {array<object>} members.globals
696
- * @param {array<object>} members.mixins
697
- * @param {array<object>} members.modules
698
- * @param {array<object>} members.namespaces
699
- * @param {array<object>} members.tutorials
700
- * @param {array<object>} members.events
701
- * @param {array<object>} members.interfaces
702
- * @return {string} The HTML for the navigation sidebar.
703
- */
704
- function buildNav(members) {
705
- var title = themeOpts.title || 'Home';
706
-
707
- var isHTML = RegExp.prototype.test.bind(/(<([^>]+)>)/i);
708
- var nav;
709
-
710
- if (!isHTML(title)) {
711
- nav =
712
- '<div class="navbar-heading" id="navbar-heading"><a href="index.html"><h2 class="navbar-heading-text">' +
713
- title +
714
- '</h2></a></div>';
715
- } else {
716
- nav = '<h2><a href="index.html">' + title + '</a></h2>';
717
- }
718
-
719
- if (haveSearch) {
720
- nav += buildSearch();
721
- }
722
- nav += '<div class="sidebar-main-content" id="sidebar-main-content">';
723
- var seen = {};
724
- var seenTutorials = {};
725
- var seenGlobal = {};
726
-
727
- var menu = themeOpts.menu || undefined;
728
- var sectionsOrder = themeOpts.sections || defaultSections;
729
-
730
- var sections = {
731
- [SECTION_TYPE.Menu]: buildMenuNav(menu),
732
-
733
- [SECTION_TYPE.Modules]: buildMemberNav({
734
- itemHeading: 'Modules',
735
- items: members.modules,
736
- itemsSeen: seen,
737
- linktoFn: linkto,
738
- sectionName: SECTION_TYPE.Modules
739
- }),
740
-
741
- [SECTION_TYPE.Classes]: buildMemberNav({
742
- itemHeading: 'Classes',
743
- items: members.classes,
744
- itemsSeen: seen,
745
- linktoFn: linkto,
746
- sectionName: SECTION_TYPE.Classes
747
- }),
748
-
749
- [SECTION_TYPE.Externals]: buildMemberNav({
750
- itemHeading: 'Externals',
751
- items: members.externals,
752
- itemsSeen: seen,
753
- linktoFn: linktoExternal,
754
- sectionName: SECTION_TYPE.Externals
755
- }),
756
-
757
- [SECTION_TYPE.Events]: buildMemberNav({
758
- itemHeading: 'Events',
759
- items: members.events,
760
- itemsSeen: seen,
761
- linktoFn: linkto,
762
- sectionName: SECTION_TYPE.Events
763
- }),
764
-
765
- [SECTION_TYPE.Namespaces]: buildMemberNav({
766
- itemHeading: 'Namespaces',
767
- items: members.namespaces,
768
- itemsSeen: seen,
769
- linktoFn: linkto,
770
- sectionName: SECTION_TYPE.Namespaces
771
- }),
772
-
773
- [SECTION_TYPE.Mixins]: buildMemberNav({
774
- itemHeading: 'Mixins',
775
- items: members.mixins,
776
- itemsSeen: seen,
777
- linktoFn: linkto,
778
- sectionName: SECTION_TYPE.Mixins
779
- }),
780
-
781
- [SECTION_TYPE.Tutorials]: buildMemberNav({
782
- itemHeading: 'Tutorials',
783
- items: members.tutorials,
784
- itemsSeen: seenTutorials,
785
- linktoFn: linktoTutorial,
786
- sectionName: SECTION_TYPE.Tutorials
787
- }),
788
-
789
- [SECTION_TYPE.Interfaces]: buildMemberNav({
790
- itemHeading: 'Interfaces',
791
- items: members.interfaces,
792
- itemsSeen: seen,
793
- linktoFn: linkto,
794
- sectionName: SECTION_TYPE.Interfaces
795
- }),
796
-
797
- [SECTION_TYPE.Global]: buildMemberNav({
798
- itemHeading: 'Global',
799
- items: members.globals,
800
- itemsSeen: seenGlobal,
801
- linktoFn: linkto,
802
- sectionName: SECTION_TYPE.Global
803
- })
804
- };
805
-
806
- sectionsOrder.forEach((section) => {
807
- if (SECTION_TYPE[section] !== undefined) {
808
- nav += sections[section];
809
- } else {
810
- var errorMsg = `While building nav. Section name: ${section} is not recognized.
811
- Accepted sections are: ${defaultSections.join(', ')}
812
- `;
813
-
814
- throw new Error(errorMsg);
815
- }
816
- });
817
-
818
- return nav;
819
- }
820
-
821
- /**
822
- @param {TAFFY} taffyData See <http://taffydb.com/>.
823
- @param {object} opts
824
- @param {Tutorial} tutorials
825
- */
826
- exports.publish = function(taffyData, opts, tutorials) {
827
- data = taffyData;
828
-
829
- // eslint-disable-next-line no-restricted-globals
830
- var conf = env.conf.templates || {};
831
-
832
- conf.default = conf.default || {};
833
-
834
- var templatePath = path.normalize(opts.template);
835
-
836
- view = new template.Template(path.join(templatePath, 'tmpl'));
837
-
838
- // claim some special filenames in advance, so the All-Powerful Overseer of Filename Uniqueness
839
- // doesn't try to hand them out later
840
- var indexUrl = helper.getUniqueFilename('index');
841
- // don't call registerLink() on this one! 'index' is also a valid longname
842
-
843
- var globalUrl = helper.getUniqueFilename('global');
844
-
845
- helper.registerLink('global', globalUrl);
846
-
847
- // set up templating
848
- view.layout = conf.default.layoutFile ?
849
- path.getResourcePath(
850
- path.dirname(conf.default.layoutFile),
851
- path.basename(conf.default.layoutFile)
852
- ) :
853
- 'layout.tmpl';
854
-
855
- // set up tutorials for helper
856
- helper.setTutorials(tutorials);
857
-
858
- data = helper.prune(data);
859
- data.sort('longname, version, since');
860
- helper.addEventListeners(data);
861
-
862
- var sourceFiles = {};
863
- var sourceFilePaths = [];
864
-
865
- data().each(function(doclet) {
866
- doclet.attribs = '';
867
-
868
- if (doclet.examples) {
869
- doclet.examples = doclet.examples.map(function(example) {
870
- var caption, code;
871
-
872
- if (example === undefined) {
873
- return {
874
- caption: '',
875
- code: ''
876
- };
877
- }
878
-
879
- if (
880
- example.match(
881
- /^\s*<caption>([\s\S]+?)<\/caption>(\s*[\n\r])([\s\S]+)$/i
882
- )
883
- ) {
884
- caption = RegExp.$1;
885
- code = RegExp.$3;
886
- }
887
-
888
- return {
889
- caption: caption || '',
890
- code: code || example
891
- };
892
- });
893
- }
894
- if (doclet.see) {
895
- doclet.see.forEach(function(seeItem, i) {
896
- doclet.see[i] = hashToLink(doclet, seeItem);
897
- });
898
- }
899
-
900
- // build a list of source files
901
- var sourcePath;
902
-
903
- if (doclet.meta) {
904
- sourcePath = getPathFromDoclet(doclet);
905
- sourceFiles[sourcePath] = {
906
- resolved: sourcePath,
907
- shortened: null
908
- };
909
- if (sourceFilePaths.indexOf(sourcePath) === -1) {
910
- sourceFilePaths.push(sourcePath);
911
- }
912
- }
913
- });
914
-
915
- // update outdir if necessary, then create outdir
916
- var packageInfo = (find({ kind: 'package' }) || [])[0];
917
-
918
- if (packageInfo && packageInfo.name) {
919
- outdir = path.join(outdir, packageInfo.name, packageInfo.version || '');
920
- }
921
- fs.mkPath(outdir);
922
-
923
- // copy the template's static files to outdir
924
- var fromDir = path.join(templatePath, 'static');
925
- var staticFiles = fs.ls(fromDir, 3);
926
-
927
- staticFiles.forEach(function(fileName) {
928
- var toDir = fs.toDir(fileName.replace(fromDir, outdir));
929
-
930
- fs.mkPath(toDir);
931
- fs.copyFileSync(fileName, toDir);
932
- });
933
-
934
- // copy user-specified static files to outdir
935
- var staticFilePaths;
936
- var staticFileFilter;
937
- var staticFileScanner;
938
-
939
- if (conf.default.staticFiles) {
940
- // The canonical property name is `include`. We accept `paths` for backwards compatibility
941
- // with a bug in JSDoc 3.2.x.
942
- staticFilePaths =
943
- conf.default.staticFiles.include ||
944
- conf.default.staticFiles.paths ||
945
- [];
946
- staticFileFilter = new (require('jsdoc/src/filter').Filter)(
947
- conf.default.staticFiles
948
- );
949
- staticFileScanner = new (require('jsdoc/src/scanner').Scanner)();
950
-
951
- staticFilePaths.forEach(function(filePath) {
952
- var extraStaticFiles = staticFileScanner.scan(
953
- [filePath],
954
- 10,
955
- staticFileFilter
956
- );
957
-
958
- extraStaticFiles.forEach(function(fileName) {
959
- var sourcePath = fs.toDir(filePath);
960
- var toDir = fs.toDir(fileName.replace(sourcePath, outdir));
961
-
962
- fs.mkPath(toDir);
963
- fs.copyFileSync(fileName, toDir);
964
- });
965
- });
966
- }
967
-
968
- if (sourceFilePaths.length) {
969
- sourceFiles = shortenPaths(
970
- sourceFiles,
971
- path.commonPrefix(sourceFilePaths)
972
- );
973
- }
974
- data().each(function(doclet) {
975
- var url = helper.createLink(doclet);
976
-
977
- helper.registerLink(doclet.longname, url);
978
-
979
- // add a shortened version of the full path
980
- var docletPath;
981
-
982
- if (doclet.meta) {
983
- docletPath = getPathFromDoclet(doclet);
984
- docletPath = sourceFiles[docletPath].shortened;
985
- if (docletPath) {
986
- doclet.meta.shortpath = docletPath;
987
- }
988
- }
989
- });
990
-
991
- data().each(function(doclet) {
992
- var url = helper.longnameToUrl[doclet.longname];
993
-
994
- if (url.indexOf('#') > -1) {
995
- doclet.id = helper.longnameToUrl[doclet.longname].split(/#/).pop();
996
- } else {
997
- doclet.id = doclet.name;
998
- }
999
-
1000
- if (needsSignature(doclet)) {
1001
- addSignatureParams(doclet);
1002
- addSignatureReturns(doclet);
1003
- addAttribs(doclet);
1004
- }
1005
- });
1006
-
1007
- // do this after the urls have all been generated
1008
- data().each(function(doclet) {
1009
- doclet.ancestors = getAncestorLinks(doclet);
1010
-
1011
- if (doclet.kind === 'member') {
1012
- addSignatureTypes(doclet);
1013
- addAttribs(doclet);
1014
- }
1015
-
1016
- if (doclet.kind === 'constant') {
1017
- addSignatureTypes(doclet);
1018
- addAttribs(doclet);
1019
- doclet.kind = 'member';
1020
- }
1021
- });
1022
-
1023
- var members = helper.getMembers(data);
1024
-
1025
- members.tutorials = tutorials.children;
1026
-
1027
- // output pretty-printed source files by default
1028
- var outputSourceFiles = Boolean(
1029
- conf.default && conf.default.outputSourceFiles !== false
1030
- );
1031
-
1032
- // add template helpers
1033
- view.find = find;
1034
- view.linkto = linkto;
1035
- view.resolveAuthorLinks = resolveAuthorLinks;
1036
- view.tutoriallink = tutoriallink;
1037
- view.htmlsafe = htmlsafe;
1038
- view.outputSourceFiles = outputSourceFiles;
1039
- view.footer = buildFooter();
1040
- view.favicon = getFavicon();
1041
- view.dynamicStyle = createDynamicStyleSheet();
1042
- view.dynamicStyleSrc = returnPathOfStyleSrc();
1043
- view.dynamicScript = createDynamicsScripts();
1044
- view.dynamicScriptSrc = returnPathOfScriptScr();
1045
- view.includeScript = includeScript();
1046
- view.includeCss = includeCss();
1047
- view.meta = getMetaTagData();
1048
- view.overlayScrollbar = overlayScrollbarOptions();
1049
- view.theme = getTheme();
1050
- // once for all
1051
- view.nav = buildNav(members);
1052
- view.search = search();
1053
- view.resizeable = resizeable();
1054
- view.codepen = codepen();
1055
- view.excludeInherited = Boolean(themeOpts.exclude_inherited);
1056
- attachModuleSymbols(
1057
- find({ longname: { left: 'module:' } }),
1058
- members.modules
1059
- );
1060
-
1061
- // generate the pretty-printed source files first so other pages can link to them
1062
- if (outputSourceFiles) {
1063
- generateSourceFiles(sourceFiles, opts.encoding);
1064
- }
1065
-
1066
- if (members.globals.length) {
1067
- generate('', 'Global', [{ kind: 'globalobj' }], globalUrl);
1068
- }
1069
-
1070
- // index page displays information from package.json and lists files
1071
- var files = find({ kind: 'file' });
1072
- var packages = find({ kind: 'package' });
1073
-
1074
- generate(
1075
- '',
1076
- 'Home',
1077
- packages
1078
- .concat([
1079
- {
1080
- kind: 'mainpage',
1081
- readme: opts.readme,
1082
- longname: opts.mainpagetitle ?
1083
- opts.mainpagetitle :
1084
- 'Main Page'
1085
- }
1086
- ])
1087
- .concat(files),
1088
- indexUrl
1089
- );
1090
-
1091
- // set up the lists that we'll use to generate pages
1092
- var classes = taffy(members.classes);
1093
- var modules = taffy(members.modules);
1094
- var namespaces = taffy(members.namespaces);
1095
- var mixins = taffy(members.mixins);
1096
- var externals = taffy(members.externals);
1097
- var interfaces = taffy(members.interfaces);
1098
-
1099
- Object.keys(helper.longnameToUrl).forEach(function(longname) {
1100
- var myModules = helper.find(modules, { longname: longname });
1101
-
1102
- if (myModules.length) {
1103
- generate(
1104
- 'Module',
1105
- myModules[0].name,
1106
- myModules,
1107
- helper.longnameToUrl[longname]
1108
- );
1109
- }
1110
-
1111
- var myClasses = helper.find(classes, { longname: longname });
1112
-
1113
- if (myClasses.length) {
1114
- generate(
1115
- 'Class',
1116
- myClasses[0].name,
1117
- myClasses,
1118
- helper.longnameToUrl[longname]
1119
- );
1120
- }
1121
-
1122
- var myNamespaces = helper.find(namespaces, { longname: longname });
1123
-
1124
- if (myNamespaces.length) {
1125
- generate(
1126
- 'Namespace',
1127
- myNamespaces[0].name,
1128
- myNamespaces,
1129
- helper.longnameToUrl[longname]
1130
- );
1131
- }
1132
-
1133
- var myMixins = helper.find(mixins, { longname: longname });
1134
-
1135
- if (myMixins.length) {
1136
- generate(
1137
- 'Mixin',
1138
- myMixins[0].name,
1139
- myMixins,
1140
- helper.longnameToUrl[longname]
1141
- );
1142
- }
1143
-
1144
- var myExternals = helper.find(externals, { longname: longname });
1145
-
1146
- if (myExternals.length) {
1147
- generate(
1148
- 'External',
1149
- myExternals[0].name,
1150
- myExternals,
1151
- helper.longnameToUrl[longname]
1152
- );
1153
- }
1154
-
1155
- var myInterfaces = helper.find(interfaces, { longname: longname });
1156
-
1157
- if (myInterfaces.length) {
1158
- generate(
1159
- 'Interface',
1160
- myInterfaces[0].name,
1161
- myInterfaces,
1162
- helper.longnameToUrl[longname]
1163
- );
1164
- }
1165
- });
1166
-
1167
- // TODO: move the tutorial functions to templateHelper.js
1168
- function generateTutorial(title, tutorial, filename) {
1169
- var tutorialData = {
1170
- title: title,
1171
- header: tutorial.title,
1172
- content: tutorial.parse(),
1173
- children: tutorial.children
1174
- };
1175
-
1176
- var tutorialPath = path.join(outdir, filename);
1177
- var html = view.render('tutorial.tmpl', tutorialData);
1178
-
1179
- // yes, you can use {@link} in tutorials too!
1180
- html = helper.resolveLinks(html); // turn {@link foo} into <a href="foodoc.html">foo</a>
1181
- fs.writeFileSync(tutorialPath, html, 'utf8');
1182
- }
1183
-
1184
- // tutorials can have only one parent so there is no risk for loops
1185
- function saveChildren(node) {
1186
- node.children.forEach(function(child) {
1187
- generateTutorial(
1188
- 'Tutorial: ' + child.title,
1189
- child,
1190
- helper.tutorialToUrl(child.name)
1191
- );
1192
- saveChildren(child);
1193
- });
1194
- }
1195
-
1196
- saveChildren(tutorials);
1197
- };
1
+ /* global env: true */
2
+
3
+ var doop = require('jsdoc/util/doop');
4
+ var fs = require('jsdoc/fs');
5
+ var helper = require('jsdoc/util/templateHelper');
6
+ var logger = require('jsdoc/util/logger');
7
+ var path = require('jsdoc/path');
8
+ var taffy = require('taffydb').taffy;
9
+ var template = require('jsdoc/template');
10
+ var util = require('util');
11
+ var fse = require('fs-extra');
12
+
13
+ var htmlsafe = helper.htmlsafe;
14
+ var linkto = helper.linkto;
15
+ var resolveAuthorLinks = helper.resolveAuthorLinks;
16
+ var hasOwnProp = Object.prototype.hasOwnProperty;
17
+
18
+ /* prettier-ignore-start */
19
+ // eslint-disable-next-line
20
+ var themeOpts = (env && env.opts && env.opts['theme_opts']) || {};
21
+ /* prettier-ignore-end */
22
+
23
+ var data;
24
+ var view;
25
+ var searchListArray = [];
26
+ var haveSearch =
27
+ themeOpts.search === undefined ? true : Boolean(themeOpts.search);
28
+
29
+ // eslint-disable-next-line no-restricted-globals
30
+ var outdir = path.normalize(env.opts.destination);
31
+
32
+ var SECTION_TYPE = {
33
+ Classes: 'Classes',
34
+ Modules: 'Modules',
35
+ Externals: 'Externals',
36
+ Events: 'Events',
37
+ Namespaces: 'Namespaces',
38
+ Mixins: 'Mixins',
39
+ Tutorials: 'Tutorials',
40
+ Interfaces: 'Interfaces',
41
+ Global: 'Global',
42
+ Menu: 'Menu'
43
+ };
44
+
45
+ var defaultSections = [
46
+ SECTION_TYPE.Menu,
47
+ SECTION_TYPE.Modules,
48
+ SECTION_TYPE.Classes,
49
+ SECTION_TYPE.Externals,
50
+ SECTION_TYPE.Events,
51
+ SECTION_TYPE.Namespaces,
52
+ SECTION_TYPE.Mixins,
53
+ SECTION_TYPE.Tutorials,
54
+ SECTION_TYPE.Interfaces,
55
+ SECTION_TYPE.Global
56
+ ];
57
+
58
+ function copyStaticFolder() {
59
+ var staticDir = themeOpts.static_dir || undefined;
60
+
61
+ if (staticDir) {
62
+ for (var i = 0; i < staticDir.length; i++) {
63
+ var output = path.join(outdir, staticDir[i]);
64
+
65
+ fse.copySync(staticDir[i], output);
66
+ }
67
+ }
68
+ }
69
+
70
+ copyStaticFolder();
71
+
72
+ function copyToOutputFolder(filePath) {
73
+ var filePathNormalized = path.normalize(filePath);
74
+
75
+ fs.copyFileSync(filePathNormalized, outdir);
76
+ }
77
+
78
+ function copyToOutputFolderFromArray(filePathArray) {
79
+ var i = 0;
80
+ var outputList = [];
81
+
82
+ if (Array.isArray(filePathArray)) {
83
+ for (; i < filePathArray.length; i++) {
84
+ copyToOutputFolder(filePathArray[i]);
85
+ outputList.push(path.basename(filePathArray[i]));
86
+ }
87
+ }
88
+
89
+ return outputList;
90
+ }
91
+
92
+ function find(spec) {
93
+ return helper.find(data, spec);
94
+ }
95
+
96
+ function tutoriallink(tutorial) {
97
+ return helper.toTutorial(tutorial, null, {
98
+ tag: 'em',
99
+ classname: 'disabled',
100
+ prefix: 'Tutorial: '
101
+ });
102
+ }
103
+
104
+ function getAncestorLinks(doclet) {
105
+ return helper.getAncestorLinks(data, doclet);
106
+ }
107
+
108
+ function hashToLink(doclet, hash) {
109
+ if (!/^(#.+)/.test(hash)) {
110
+ return hash;
111
+ }
112
+
113
+ var url = helper.createLink(doclet);
114
+
115
+ url = url.replace(/(#.+|$)/, hash);
116
+
117
+ return '<a href="' + url + '">' + hash + '</a>';
118
+ }
119
+
120
+ function needsSignature(doclet) {
121
+ var needsSig = false;
122
+
123
+ // function and class definitions always get a signature
124
+ if (doclet.kind === 'function' || doclet.kind === 'class') {
125
+ needsSig = true;
126
+ }
127
+ // typedefs that contain functions get a signature, too
128
+ else if (
129
+ doclet.kind === 'typedef' &&
130
+ doclet.type &&
131
+ doclet.type.names &&
132
+ doclet.type.names.length
133
+ ) {
134
+ for (var i = 0, l = doclet.type.names.length; i < l; i++) {
135
+ if (doclet.type.names[i].toLowerCase() === 'function') {
136
+ needsSig = true;
137
+ break;
138
+ }
139
+ }
140
+ }
141
+
142
+ return needsSig;
143
+ }
144
+
145
+ function getSignatureAttributes(item) {
146
+ var attributes = [];
147
+
148
+ if (item.optional) {
149
+ attributes.push('opt');
150
+ }
151
+
152
+ if (item.nullable === true) {
153
+ attributes.push('nullable');
154
+ } else if (item.nullable === false) {
155
+ attributes.push('non-null');
156
+ }
157
+
158
+ return attributes;
159
+ }
160
+
161
+ function updateItemName(item) {
162
+ var attributes = getSignatureAttributes(item);
163
+ var itemName = item.name || '';
164
+
165
+ if (item.variable) {
166
+ itemName = '&hellip;' + itemName;
167
+ }
168
+
169
+ if (attributes && attributes.length) {
170
+ itemName = util.format(
171
+ '%s<span class="signature-attributes">%s</span>',
172
+ itemName,
173
+ attributes.join(', ')
174
+ );
175
+ }
176
+
177
+ return itemName;
178
+ }
179
+
180
+ function addParamAttributes(params) {
181
+ return params
182
+ .filter(function(param) {
183
+ return param.name && param.name.indexOf('.') === -1;
184
+ })
185
+ .map(updateItemName);
186
+ }
187
+
188
+ function buildItemTypeStrings(item) {
189
+ var types = [];
190
+
191
+ if (item && item.type && item.type.names) {
192
+ item.type.names.forEach(function(name) {
193
+ types.push(linkto(name, htmlsafe(name)));
194
+ });
195
+ }
196
+
197
+ return types;
198
+ }
199
+
200
+ function buildAttribsString(attribs) {
201
+ var attribsString = '';
202
+
203
+ if (attribs && attribs.length) {
204
+ attribsString = htmlsafe(util.format('(%s) ', attribs.join(', ')));
205
+ }
206
+
207
+ return attribsString;
208
+ }
209
+
210
+ function addNonParamAttributes(items) {
211
+ var types = [];
212
+
213
+ items.forEach(function(item) {
214
+ types = types.concat(buildItemTypeStrings(item));
215
+ });
216
+
217
+ return types;
218
+ }
219
+
220
+ function addSignatureParams(f) {
221
+ var params = f.params ? addParamAttributes(f.params) : [];
222
+
223
+ f.signature = util.format('%s(%s)', f.signature || '', params.join(', '));
224
+ }
225
+
226
+ function addSignatureReturns(f) {
227
+ var attribs = [];
228
+ var attribsString = '';
229
+ var returnTypes = [];
230
+ var returnTypesString = '';
231
+
232
+ // jam all the return-type attributes into an array. this could create odd results (for example,
233
+ // if there are both nullable and non-nullable return types), but let's assume that most people
234
+ // who use multiple @return tags aren't using Closure Compiler type annotations, and vice-versa.
235
+ if (f.returns) {
236
+ f.returns.forEach(function(item) {
237
+ helper.getAttribs(item).forEach(function(attrib) {
238
+ if (attribs.indexOf(attrib) === -1) {
239
+ attribs.push(attrib);
240
+ }
241
+ });
242
+ });
243
+
244
+ attribsString = buildAttribsString(attribs);
245
+ }
246
+
247
+ if (f.returns) {
248
+ returnTypes = addNonParamAttributes(f.returns);
249
+ }
250
+ if (returnTypes.length) {
251
+ returnTypesString = util.format(
252
+ ' &rarr; %s{%s}',
253
+ attribsString,
254
+ returnTypes.join('|')
255
+ );
256
+ }
257
+
258
+ f.signature =
259
+ '<span class="signature">' +
260
+ (f.signature || '') +
261
+ '</span>' +
262
+ '<span class="type-signature">' +
263
+ returnTypesString +
264
+ '</span>';
265
+ }
266
+
267
+ function addSignatureTypes(f) {
268
+ var types = f.type ? buildItemTypeStrings(f) : [];
269
+
270
+ f.signature =
271
+ (f.signature || '') +
272
+ '<span class="type-signature">' +
273
+ (types.length ? ' :' + types.join('|') : '') +
274
+ '</span>';
275
+ }
276
+
277
+ function addAttribs(f) {
278
+ var attribs = helper.getAttribs(f);
279
+ var attribsString = buildAttribsString(attribs);
280
+
281
+ f.attribs = util.format(
282
+ '<span class="type-signature">%s</span>',
283
+ attribsString
284
+ );
285
+ }
286
+
287
+ function shortenPaths(files, commonPrefix) {
288
+ Object.keys(files).forEach(function(file) {
289
+ files[file].shortened = files[file].resolved
290
+ .replace(commonPrefix, '')
291
+ // always use forward slashes
292
+ .replace(/\\/g, '/');
293
+ });
294
+
295
+ return files;
296
+ }
297
+
298
+ function getPathFromDoclet(doclet) {
299
+ if (!doclet.meta) {
300
+ return null;
301
+ }
302
+
303
+ return doclet.meta.path && doclet.meta.path !== 'null' ?
304
+ path.join(doclet.meta.path, doclet.meta.filename) :
305
+ doclet.meta.filename;
306
+ }
307
+
308
+ function generate(type, title, docs, filename, resolveLinks) {
309
+ resolveLinks = resolveLinks !== false;
310
+
311
+ var docData = {
312
+ type: type,
313
+ title: title,
314
+ docs: docs
315
+ };
316
+
317
+ var outpath = path.join(outdir, filename),
318
+ html = view.render('container.tmpl', docData);
319
+
320
+ if (resolveLinks) {
321
+ html = helper.resolveLinks(html); // turn {@link foo} into <a href="foodoc.html">foo</a>
322
+ }
323
+
324
+ fs.writeFileSync(outpath, html, 'utf8');
325
+ }
326
+
327
+ function generateSourceFiles(sourceFiles, encoding) {
328
+ encoding = encoding || 'utf8';
329
+ Object.keys(sourceFiles).forEach(function(file) {
330
+ var source;
331
+ // links are keyed to the shortened path in each doclet's `meta.shortpath` property
332
+ var sourceOutfile = helper.getUniqueFilename(
333
+ sourceFiles[file].shortened
334
+ );
335
+
336
+ helper.registerLink(sourceFiles[file].shortened, sourceOutfile);
337
+
338
+ try {
339
+ source = {
340
+ kind: 'source',
341
+ code: helper.htmlsafe(
342
+ fs.readFileSync(sourceFiles[file].resolved, encoding)
343
+ )
344
+ };
345
+ } catch (e) {
346
+ logger.error(
347
+ 'Error while generating source file %s: %s',
348
+ file,
349
+ e.message
350
+ );
351
+ }
352
+
353
+ generate(
354
+ 'Source',
355
+ sourceFiles[file].shortened,
356
+ [source],
357
+ sourceOutfile,
358
+ false
359
+ );
360
+ });
361
+ }
362
+
363
+ /**
364
+ * Look for classes or functions with the same name as modules (which indicates that the module
365
+ * exports only that class or function), then attach the classes or functions to the `module`
366
+ * property of the appropriate module doclets. The name of each class or function is also updated
367
+ * for display purposes. This function mutates the original arrays.
368
+ *
369
+ * @private
370
+ * @param {Array.<module:jsdoc/doclet.Doclet>} doclets - The array of classes and functions to
371
+ * check.
372
+ * @param {Array.<module:jsdoc/doclet.Doclet>} modules - The array of module doclets to search.
373
+ */
374
+ function attachModuleSymbols(doclets, modules) {
375
+ var symbols = {};
376
+
377
+ // build a lookup table
378
+ doclets.forEach(function(symbol) {
379
+ symbols[symbol.longname] = symbols[symbol.longname] || [];
380
+ symbols[symbol.longname].push(symbol);
381
+ });
382
+
383
+ // eslint-disable-next-line array-callback-return
384
+ return modules.map(function(module) {
385
+ if (symbols[module.longname]) {
386
+ module.modules = symbols[module.longname]
387
+ // Only show symbols that have a description. Make an exception for classes, because
388
+ // we want to show the constructor-signature heading no matter what.
389
+ .filter(function(symbol) {
390
+ return symbol.description || symbol.kind === 'class';
391
+ })
392
+ .map(function(symbol) {
393
+ symbol = doop(symbol);
394
+
395
+ if (symbol.kind === 'class' || symbol.kind === 'function') {
396
+ symbol.name =
397
+ symbol.name.replace('module:', '(require("') +
398
+ '"))';
399
+ }
400
+
401
+ return symbol;
402
+ });
403
+ }
404
+ });
405
+ }
406
+
407
+ function buildMenuNav(menu) {
408
+ if (menu === undefined) {
409
+ return '';
410
+ }
411
+
412
+ var m = '<ul>';
413
+
414
+ menu.forEach(function(item) {
415
+ // Setting default value for optional parameter
416
+ var c = item.class || '';
417
+ var id = item.id || '';
418
+ var target = item.target || '';
419
+
420
+ c += ' menu-link';
421
+
422
+ m +=
423
+ '<li class="menu-li">' +
424
+ "<a href='" +
425
+ item.link +
426
+ "' class='" +
427
+ c +
428
+ "' id='" +
429
+ id +
430
+ "' target='" +
431
+ target +
432
+ "'>" +
433
+ item.title +
434
+ '</a></li>';
435
+ });
436
+
437
+ m += '</ul>';
438
+
439
+ return m;
440
+ }
441
+
442
+ function buildSearch() {
443
+ var searchHTML =
444
+ '<div class="search-box" id="search-box">' +
445
+ '<div class="search-box-input-container">' +
446
+ '<input class="search-box-input" type="text" placeholder="Search..." id="search-box-input" />' +
447
+ '<svg class="search-icon" alt="search-icon"><use xlink:href="#search-icon"></use></svg>' +
448
+ '</div>';
449
+
450
+ var searchItemContainer =
451
+ '<div class="search-item-container" id="search-item-container"><ul class="search-item-ul" id="search-item-ul"></ul></div></div>';
452
+
453
+ searchHTML += searchItemContainer;
454
+
455
+ return searchHTML;
456
+ }
457
+
458
+ function buildFooter() {
459
+ var footer = themeOpts.footer || '';
460
+
461
+ return footer;
462
+ }
463
+
464
+ function getFavicon() {
465
+ var favicon = themeOpts.favicon || undefined;
466
+
467
+ return favicon;
468
+ }
469
+
470
+ // function copy
471
+ function createDynamicStyleSheet() {
472
+ var styleClass = themeOpts.create_style || undefined;
473
+ /* prettier-ignore-start */
474
+
475
+ return styleClass;
476
+ }
477
+
478
+ function createDynamicsScripts() {
479
+ var scripts = themeOpts.add_scripts || undefined;
480
+
481
+ return scripts;
482
+ }
483
+
484
+ function returnPathOfScriptScr() {
485
+ var scriptPath = themeOpts.add_script_path || undefined;
486
+
487
+ return scriptPath;
488
+ }
489
+
490
+ function returnPathOfStyleSrc() {
491
+ var stylePath = themeOpts.add_style_path || undefined;
492
+
493
+ return stylePath;
494
+ }
495
+
496
+ function includeCss() {
497
+ var stylePath = themeOpts.include_css || undefined;
498
+
499
+ if (stylePath) {
500
+ stylePath = copyToOutputFolderFromArray(stylePath);
501
+ }
502
+
503
+ return stylePath;
504
+ }
505
+
506
+ function resizeable() {
507
+ var resizeOpts = themeOpts.resizeable || {};
508
+
509
+ return resizeOpts;
510
+ }
511
+
512
+ function codepen() {
513
+ var codepenOpts = themeOpts.codepen || {};
514
+
515
+ return codepenOpts;
516
+ }
517
+
518
+ function overlayScrollbarOptions() {
519
+ var overlayOptions = themeOpts.overlay_scrollbar || undefined;
520
+
521
+ if (overlayOptions) {
522
+ return JSON.stringify(overlayOptions);
523
+ }
524
+
525
+ return undefined;
526
+ }
527
+
528
+ function includeScript() {
529
+ var scriptPath = themeOpts.include_js || undefined;
530
+
531
+ if (scriptPath) {
532
+ scriptPath = copyToOutputFolderFromArray(scriptPath);
533
+ }
534
+
535
+ return scriptPath;
536
+ }
537
+
538
+ function getMetaTagData() {
539
+ var meta = themeOpts.meta || undefined;
540
+
541
+ return meta;
542
+ }
543
+
544
+ function getTheme() {
545
+ var theme = themeOpts.theme || 'light';
546
+ var baseThemeName = 'clean-jsdoc-theme';
547
+ var themeSrc = `${baseThemeName}-${theme}.css`.trim();
548
+
549
+ return themeSrc;
550
+ }
551
+
552
+ function search() {
553
+ var searchOption = themeOpts.search;
554
+
555
+ var obj = {
556
+ list: searchListArray,
557
+ options: JSON.stringify(searchOption)
558
+ };
559
+
560
+ return obj;
561
+ }
562
+
563
+ function buildMemberNav({
564
+ items,
565
+ itemHeading,
566
+ itemsSeen,
567
+ linktoFn,
568
+ sectionName
569
+ }) {
570
+ var nav = '';
571
+
572
+ if (items.length) {
573
+ var itemsNav = '';
574
+
575
+ items.forEach(function(item) {
576
+ var methods =
577
+ sectionName === SECTION_TYPE.Tutorials ||
578
+ sectionName === SECTION_TYPE.Global ?
579
+ [] :
580
+ find({
581
+ kind: 'function',
582
+ memberof: item.longname,
583
+ inherited: {'!is': Boolean(themeOpts.exclude_inherited)}
584
+ });
585
+
586
+ if (!hasOwnProp.call(item, 'longname')) {
587
+ itemsNav += '<li>' + linktoFn('', item.name);
588
+ itemsNav += '</li>';
589
+ } else if (!hasOwnProp.call(itemsSeen, item.longname)) {
590
+ /**
591
+ * Only have accordion class name if it have any child.
592
+ * Otherwise it didn't makes any sense.
593
+ */
594
+ var accordionClassName = methods.length ?
595
+ '"accordion collapsed child"' :
596
+ '"accordion-list"';
597
+
598
+ /**
599
+ * Id give to accordion.
600
+ */
601
+ var accordionId = methods.length ?
602
+ Math.floor(Math.random() * 10000000) :
603
+ '""';
604
+
605
+ itemsNav +=
606
+ '<li class=' +
607
+ accordionClassName +
608
+ ' id=' +
609
+ accordionId +
610
+ '>';
611
+
612
+ var linkTitle = linktoFn(
613
+ item.longname,
614
+ item.name.replace(/^module:/, '')
615
+ );
616
+
617
+ if (methods.length) {
618
+ itemsNav +=
619
+ '<div class="accordion-heading child">' +
620
+ linkTitle +
621
+ '<svg><use xlink:href="#down-icon"></use></svg>' +
622
+ '</div>';
623
+ } else {
624
+ itemsNav += linkTitle;
625
+ }
626
+
627
+ if (haveSearch) {
628
+ searchListArray.push(
629
+ JSON.stringify({
630
+ title: item.name,
631
+ link: linkto(item.longname, item.name)
632
+ })
633
+ );
634
+ }
635
+
636
+ if (methods.length) {
637
+ itemsNav += "<ul class='methods accordion-content'>";
638
+
639
+ methods.forEach(function(method) {
640
+ var name = method.longname.split(method.scope === 'static' ? '.' : '#');
641
+ var first = name[0];
642
+ var last = name[1];
643
+
644
+ name = first + ' &rtrif; ' + last;
645
+
646
+ if (haveSearch) {
647
+ searchListArray.push(
648
+ JSON.stringify({
649
+ title: method.longname,
650
+ link: linkto(method.longname, name)
651
+ })
652
+ );
653
+ }
654
+ itemsNav += "<li data-type='method'>";
655
+ itemsNav += linkto(method.longname, method.name);
656
+ itemsNav += '</li>';
657
+ });
658
+
659
+ itemsNav += '</ul>';
660
+ }
661
+ itemsNav += '</li>';
662
+ itemsSeen[item.longname] = true;
663
+ }
664
+ });
665
+
666
+ if (itemsNav !== '') {
667
+ nav +=
668
+ '<div class="accordion collapsed" id="' +
669
+ Math.floor(Math.random() * 10000000) +
670
+ '" > <h3 class="accordion-heading">' +
671
+ itemHeading +
672
+ '<svg><use xlink:href="#down-icon"></use></svg>' +
673
+ '</h3><ul class="accordion-content">' +
674
+ itemsNav +
675
+ '</ul> </div>';
676
+ }
677
+ }
678
+
679
+ return nav;
680
+ }
681
+
682
+ function linktoTutorial(longName, name) {
683
+ return tutoriallink(name);
684
+ }
685
+
686
+ function linktoExternal(longName, name) {
687
+ return linkto(longName, name.replace(/(^"|"$)/g, ''));
688
+ }
689
+
690
+ /**
691
+ * Create the navigation sidebar.
692
+ * @param {object} members The members that will be used to create the sidebar.
693
+ * @param {array<object>} members.classes
694
+ * @param {array<object>} members.externals
695
+ * @param {array<object>} members.globals
696
+ * @param {array<object>} members.mixins
697
+ * @param {array<object>} members.modules
698
+ * @param {array<object>} members.namespaces
699
+ * @param {array<object>} members.tutorials
700
+ * @param {array<object>} members.events
701
+ * @param {array<object>} members.interfaces
702
+ * @return {string} The HTML for the navigation sidebar.
703
+ */
704
+ function buildNav(members) {
705
+ var title = themeOpts.title || 'Home';
706
+
707
+ var isHTML = RegExp.prototype.test.bind(/(<([^>]+)>)/i);
708
+ var nav;
709
+
710
+ if (!isHTML(title)) {
711
+ nav =
712
+ '<div class="navbar-heading" id="navbar-heading"><a href="index.html"><h2 class="navbar-heading-text">' +
713
+ title +
714
+ '</h2></a></div>';
715
+ } else {
716
+ nav = '<h2><a href="index.html">' + title + '</a></h2>';
717
+ }
718
+
719
+ if (haveSearch) {
720
+ nav += buildSearch();
721
+ }
722
+ nav += '<div class="sidebar-main-content" id="sidebar-main-content">';
723
+ var seen = {};
724
+ var seenTutorials = {};
725
+ var seenGlobal = {};
726
+
727
+ var menu = themeOpts.menu || undefined;
728
+ var sectionsOrder = themeOpts.sections || defaultSections;
729
+
730
+ var sections = {
731
+ [SECTION_TYPE.Menu]: buildMenuNav(menu),
732
+
733
+ [SECTION_TYPE.Modules]: buildMemberNav({
734
+ itemHeading: 'Modules',
735
+ items: members.modules,
736
+ itemsSeen: seen,
737
+ linktoFn: linkto,
738
+ sectionName: SECTION_TYPE.Modules
739
+ }),
740
+
741
+ [SECTION_TYPE.Classes]: buildMemberNav({
742
+ itemHeading: 'Classes',
743
+ items: members.classes,
744
+ itemsSeen: seen,
745
+ linktoFn: linkto,
746
+ sectionName: SECTION_TYPE.Classes
747
+ }),
748
+
749
+ [SECTION_TYPE.Externals]: buildMemberNav({
750
+ itemHeading: 'Externals',
751
+ items: members.externals,
752
+ itemsSeen: seen,
753
+ linktoFn: linktoExternal,
754
+ sectionName: SECTION_TYPE.Externals
755
+ }),
756
+
757
+ [SECTION_TYPE.Events]: buildMemberNav({
758
+ itemHeading: 'Events',
759
+ items: members.events,
760
+ itemsSeen: seen,
761
+ linktoFn: linkto,
762
+ sectionName: SECTION_TYPE.Events
763
+ }),
764
+
765
+ [SECTION_TYPE.Namespaces]: buildMemberNav({
766
+ itemHeading: 'Namespaces',
767
+ items: members.namespaces,
768
+ itemsSeen: seen,
769
+ linktoFn: linkto,
770
+ sectionName: SECTION_TYPE.Namespaces
771
+ }),
772
+
773
+ [SECTION_TYPE.Mixins]: buildMemberNav({
774
+ itemHeading: 'Mixins',
775
+ items: members.mixins,
776
+ itemsSeen: seen,
777
+ linktoFn: linkto,
778
+ sectionName: SECTION_TYPE.Mixins
779
+ }),
780
+
781
+ [SECTION_TYPE.Tutorials]: buildMemberNav({
782
+ itemHeading: 'Tutorials',
783
+ items: members.tutorials,
784
+ itemsSeen: seenTutorials,
785
+ linktoFn: linktoTutorial,
786
+ sectionName: SECTION_TYPE.Tutorials
787
+ }),
788
+
789
+ [SECTION_TYPE.Interfaces]: buildMemberNav({
790
+ itemHeading: 'Interfaces',
791
+ items: members.interfaces,
792
+ itemsSeen: seen,
793
+ linktoFn: linkto,
794
+ sectionName: SECTION_TYPE.Interfaces
795
+ }),
796
+
797
+ [SECTION_TYPE.Global]: buildMemberNav({
798
+ itemHeading: 'Global',
799
+ items: members.globals,
800
+ itemsSeen: seenGlobal,
801
+ linktoFn: linkto,
802
+ sectionName: SECTION_TYPE.Global
803
+ })
804
+ };
805
+
806
+ sectionsOrder.forEach((section) => {
807
+ if (SECTION_TYPE[section] !== undefined) {
808
+ nav += sections[section];
809
+ } else {
810
+ var errorMsg = `While building nav. Section name: ${section} is not recognized.
811
+ Accepted sections are: ${defaultSections.join(', ')}
812
+ `;
813
+
814
+ throw new Error(errorMsg);
815
+ }
816
+ });
817
+
818
+ return nav;
819
+ }
820
+
821
+ /**
822
+ @param {TAFFY} taffyData See <http://taffydb.com/>.
823
+ @param {object} opts
824
+ @param {Tutorial} tutorials
825
+ */
826
+ exports.publish = function(taffyData, opts, tutorials) {
827
+ data = taffyData;
828
+
829
+ // eslint-disable-next-line no-restricted-globals
830
+ var conf = env.conf.templates || {};
831
+
832
+ conf.default = conf.default || {};
833
+
834
+ var templatePath = path.normalize(opts.template);
835
+
836
+ view = new template.Template(path.join(templatePath, 'tmpl'));
837
+
838
+ // claim some special filenames in advance, so the All-Powerful Overseer of Filename Uniqueness
839
+ // doesn't try to hand them out later
840
+ var indexUrl = helper.getUniqueFilename('index');
841
+ // don't call registerLink() on this one! 'index' is also a valid longname
842
+
843
+ var globalUrl = helper.getUniqueFilename('global');
844
+
845
+ helper.registerLink('global', globalUrl);
846
+
847
+ // set up templating
848
+ view.layout = conf.default.layoutFile ?
849
+ path.getResourcePath(
850
+ path.dirname(conf.default.layoutFile),
851
+ path.basename(conf.default.layoutFile)
852
+ ) :
853
+ 'layout.tmpl';
854
+
855
+ // set up tutorials for helper
856
+ helper.setTutorials(tutorials);
857
+
858
+ data = helper.prune(data);
859
+ data.sort('longname, version, since');
860
+ helper.addEventListeners(data);
861
+
862
+ var sourceFiles = {};
863
+ var sourceFilePaths = [];
864
+
865
+ data().each(function(doclet) {
866
+ doclet.attribs = '';
867
+
868
+ if (doclet.examples) {
869
+ doclet.examples = doclet.examples.map(function(example) {
870
+ var caption, code;
871
+
872
+ if (example === undefined) {
873
+ return {
874
+ caption: '',
875
+ code: ''
876
+ };
877
+ }
878
+
879
+ if (
880
+ example.match(
881
+ /^\s*<caption>([\s\S]+?)<\/caption>(\s*[\n\r])([\s\S]+)$/i
882
+ )
883
+ ) {
884
+ caption = RegExp.$1;
885
+ code = RegExp.$3;
886
+ }
887
+
888
+ return {
889
+ caption: caption || '',
890
+ code: code || example
891
+ };
892
+ });
893
+ }
894
+ if (doclet.see) {
895
+ doclet.see.forEach(function(seeItem, i) {
896
+ doclet.see[i] = hashToLink(doclet, seeItem);
897
+ });
898
+ }
899
+
900
+ // build a list of source files
901
+ var sourcePath;
902
+
903
+ if (doclet.meta) {
904
+ sourcePath = getPathFromDoclet(doclet);
905
+ sourceFiles[sourcePath] = {
906
+ resolved: sourcePath,
907
+ shortened: null
908
+ };
909
+ if (sourceFilePaths.indexOf(sourcePath) === -1) {
910
+ sourceFilePaths.push(sourcePath);
911
+ }
912
+ }
913
+ });
914
+
915
+ // update outdir if necessary, then create outdir
916
+ var packageInfo = (find({ kind: 'package' }) || [])[0];
917
+
918
+ if (packageInfo && packageInfo.name) {
919
+ outdir = path.join(outdir, packageInfo.name, packageInfo.version || '');
920
+ }
921
+ fs.mkPath(outdir);
922
+
923
+ // copy the template's static files to outdir
924
+ var fromDir = path.join(templatePath, 'static');
925
+ var staticFiles = fs.ls(fromDir, 3);
926
+
927
+ staticFiles.forEach(function(fileName) {
928
+ var toDir = fs.toDir(fileName.replace(fromDir, outdir));
929
+
930
+ fs.mkPath(toDir);
931
+ fs.copyFileSync(fileName, toDir);
932
+ });
933
+
934
+ // copy user-specified static files to outdir
935
+ var staticFilePaths;
936
+ var staticFileFilter;
937
+ var staticFileScanner;
938
+
939
+ if (conf.default.staticFiles) {
940
+ // The canonical property name is `include`. We accept `paths` for backwards compatibility
941
+ // with a bug in JSDoc 3.2.x.
942
+ staticFilePaths =
943
+ conf.default.staticFiles.include ||
944
+ conf.default.staticFiles.paths ||
945
+ [];
946
+ staticFileFilter = new (require('jsdoc/src/filter').Filter)(
947
+ conf.default.staticFiles
948
+ );
949
+ staticFileScanner = new (require('jsdoc/src/scanner').Scanner)();
950
+
951
+ staticFilePaths.forEach(function(filePath) {
952
+ var extraStaticFiles = staticFileScanner.scan(
953
+ [filePath],
954
+ 10,
955
+ staticFileFilter
956
+ );
957
+
958
+ extraStaticFiles.forEach(function(fileName) {
959
+ var sourcePath = fs.toDir(filePath);
960
+ var toDir = fs.toDir(fileName.replace(sourcePath, outdir));
961
+
962
+ fs.mkPath(toDir);
963
+ fs.copyFileSync(fileName, toDir);
964
+ });
965
+ });
966
+ }
967
+
968
+ if (sourceFilePaths.length) {
969
+ sourceFiles = shortenPaths(
970
+ sourceFiles,
971
+ path.commonPrefix(sourceFilePaths)
972
+ );
973
+ }
974
+ data().each(function(doclet) {
975
+ var url = helper.createLink(doclet);
976
+
977
+ helper.registerLink(doclet.longname, url);
978
+
979
+ // add a shortened version of the full path
980
+ var docletPath;
981
+
982
+ if (doclet.meta) {
983
+ docletPath = getPathFromDoclet(doclet);
984
+ docletPath = sourceFiles[docletPath].shortened;
985
+ if (docletPath) {
986
+ doclet.meta.shortpath = docletPath;
987
+ }
988
+ }
989
+ });
990
+
991
+ data().each(function(doclet) {
992
+ var url = helper.longnameToUrl[doclet.longname];
993
+
994
+ if (url.indexOf('#') > -1) {
995
+ doclet.id = helper.longnameToUrl[doclet.longname].split(/#/).pop();
996
+ } else {
997
+ doclet.id = doclet.name;
998
+ }
999
+
1000
+ if (needsSignature(doclet)) {
1001
+ addSignatureParams(doclet);
1002
+ addSignatureReturns(doclet);
1003
+ addAttribs(doclet);
1004
+ }
1005
+ });
1006
+
1007
+ // do this after the urls have all been generated
1008
+ data().each(function(doclet) {
1009
+ doclet.ancestors = getAncestorLinks(doclet);
1010
+
1011
+ if (doclet.kind === 'member') {
1012
+ addSignatureTypes(doclet);
1013
+ addAttribs(doclet);
1014
+ }
1015
+
1016
+ if (doclet.kind === 'constant') {
1017
+ addSignatureTypes(doclet);
1018
+ addAttribs(doclet);
1019
+ doclet.kind = 'member';
1020
+ }
1021
+ });
1022
+
1023
+ var members = helper.getMembers(data);
1024
+
1025
+ members.tutorials = tutorials.children;
1026
+
1027
+ // output pretty-printed source files by default
1028
+ var outputSourceFiles = Boolean(
1029
+ conf.default && conf.default.outputSourceFiles !== false
1030
+ );
1031
+
1032
+ // add template helpers
1033
+ view.find = find;
1034
+ view.linkto = linkto;
1035
+ view.resolveAuthorLinks = resolveAuthorLinks;
1036
+ view.tutoriallink = tutoriallink;
1037
+ view.htmlsafe = htmlsafe;
1038
+ view.outputSourceFiles = outputSourceFiles;
1039
+ view.footer = buildFooter();
1040
+ view.favicon = getFavicon();
1041
+ view.dynamicStyle = createDynamicStyleSheet();
1042
+ view.dynamicStyleSrc = returnPathOfStyleSrc();
1043
+ view.dynamicScript = createDynamicsScripts();
1044
+ view.dynamicScriptSrc = returnPathOfScriptScr();
1045
+ view.includeScript = includeScript();
1046
+ view.includeCss = includeCss();
1047
+ view.meta = getMetaTagData();
1048
+ view.overlayScrollbar = overlayScrollbarOptions();
1049
+ view.theme = getTheme();
1050
+ // once for all
1051
+ view.nav = buildNav(members);
1052
+ view.search = search();
1053
+ view.resizeable = resizeable();
1054
+ view.codepen = codepen();
1055
+ view.excludeInherited = Boolean(themeOpts.exclude_inherited);
1056
+ attachModuleSymbols(
1057
+ find({ longname: { left: 'module:' } }),
1058
+ members.modules
1059
+ );
1060
+
1061
+ // generate the pretty-printed source files first so other pages can link to them
1062
+ if (outputSourceFiles) {
1063
+ generateSourceFiles(sourceFiles, opts.encoding);
1064
+ }
1065
+
1066
+ if (members.globals.length) {
1067
+ generate('', 'Global', [{ kind: 'globalobj' }], globalUrl);
1068
+ }
1069
+
1070
+ // index page displays information from package.json and lists files
1071
+ var files = find({ kind: 'file' });
1072
+ var packages = find({ kind: 'package' });
1073
+
1074
+ generate(
1075
+ '',
1076
+ 'Home',
1077
+ packages
1078
+ .concat([
1079
+ {
1080
+ kind: 'mainpage',
1081
+ readme: opts.readme,
1082
+ longname: opts.mainpagetitle ?
1083
+ opts.mainpagetitle :
1084
+ 'Main Page'
1085
+ }
1086
+ ])
1087
+ .concat(files),
1088
+ indexUrl
1089
+ );
1090
+
1091
+ // set up the lists that we'll use to generate pages
1092
+ var classes = taffy(members.classes);
1093
+ var modules = taffy(members.modules);
1094
+ var namespaces = taffy(members.namespaces);
1095
+ var mixins = taffy(members.mixins);
1096
+ var externals = taffy(members.externals);
1097
+ var interfaces = taffy(members.interfaces);
1098
+
1099
+ Object.keys(helper.longnameToUrl).forEach(function(longname) {
1100
+ var myModules = helper.find(modules, { longname: longname });
1101
+
1102
+ if (myModules.length) {
1103
+ generate(
1104
+ 'Module',
1105
+ myModules[0].name,
1106
+ myModules,
1107
+ helper.longnameToUrl[longname]
1108
+ );
1109
+ }
1110
+
1111
+ var myClasses = helper.find(classes, { longname: longname });
1112
+
1113
+ if (myClasses.length) {
1114
+ generate(
1115
+ 'Class',
1116
+ myClasses[0].name,
1117
+ myClasses,
1118
+ helper.longnameToUrl[longname]
1119
+ );
1120
+ }
1121
+
1122
+ var myNamespaces = helper.find(namespaces, { longname: longname });
1123
+
1124
+ if (myNamespaces.length) {
1125
+ generate(
1126
+ 'Namespace',
1127
+ myNamespaces[0].name,
1128
+ myNamespaces,
1129
+ helper.longnameToUrl[longname]
1130
+ );
1131
+ }
1132
+
1133
+ var myMixins = helper.find(mixins, { longname: longname });
1134
+
1135
+ if (myMixins.length) {
1136
+ generate(
1137
+ 'Mixin',
1138
+ myMixins[0].name,
1139
+ myMixins,
1140
+ helper.longnameToUrl[longname]
1141
+ );
1142
+ }
1143
+
1144
+ var myExternals = helper.find(externals, { longname: longname });
1145
+
1146
+ if (myExternals.length) {
1147
+ generate(
1148
+ 'External',
1149
+ myExternals[0].name,
1150
+ myExternals,
1151
+ helper.longnameToUrl[longname]
1152
+ );
1153
+ }
1154
+
1155
+ var myInterfaces = helper.find(interfaces, { longname: longname });
1156
+
1157
+ if (myInterfaces.length) {
1158
+ generate(
1159
+ 'Interface',
1160
+ myInterfaces[0].name,
1161
+ myInterfaces,
1162
+ helper.longnameToUrl[longname]
1163
+ );
1164
+ }
1165
+ });
1166
+
1167
+ // TODO: move the tutorial functions to templateHelper.js
1168
+ function generateTutorial(title, tutorial, filename) {
1169
+ var tutorialData = {
1170
+ title: title,
1171
+ header: tutorial.title,
1172
+ content: tutorial.parse(),
1173
+ children: tutorial.children
1174
+ };
1175
+
1176
+ var tutorialPath = path.join(outdir, filename);
1177
+ var html = view.render('tutorial.tmpl', tutorialData);
1178
+
1179
+ // yes, you can use {@link} in tutorials too!
1180
+ html = helper.resolveLinks(html); // turn {@link foo} into <a href="foodoc.html">foo</a>
1181
+ fs.writeFileSync(tutorialPath, html, 'utf8');
1182
+ }
1183
+
1184
+ // tutorials can have only one parent so there is no risk for loops
1185
+ function saveChildren(node) {
1186
+ node.children.forEach(function(child) {
1187
+ generateTutorial(
1188
+ 'Tutorial: ' + child.title,
1189
+ child,
1190
+ helper.tutorialToUrl(child.name)
1191
+ );
1192
+ saveChildren(child);
1193
+ });
1194
+ }
1195
+
1196
+ saveChildren(tutorials);
1197
+ };