clean-jsdoc-theme 3.3.3 → 4.0.2

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