clean-jsdoc-theme 3.3.2 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/LICENSE +1 -1
  3. package/README.md +203 -310
  4. package/jsdoc-config.json +7 -5
  5. package/minify.js +48 -0
  6. package/package.json +10 -6
  7. package/publish.js +805 -870
  8. package/static/fonts/Inconsolata-Regular.ttf +0 -0
  9. package/static/fonts/OpenSans-Regular.ttf +0 -0
  10. package/static/fonts/WorkSans-Bold.ttf +0 -0
  11. package/static/scripts/core.js +576 -0
  12. package/static/scripts/core.min.js +23 -0
  13. package/static/scripts/resize.js +59 -54
  14. package/static/scripts/search.js +217 -56
  15. package/static/scripts/search.min.js +11 -0
  16. package/static/scripts/third-party/hljs-line-num.js +1 -0
  17. package/static/scripts/third-party/hljs.js +1173 -0
  18. package/static/scripts/third-party/popper.js +6 -0
  19. package/static/scripts/third-party/tippy.js +2 -0
  20. package/static/scripts/third-party/tocbot.js +1 -0
  21. package/static/styles/clean-jsdoc-theme-base.css +738 -190
  22. package/static/styles/clean-jsdoc-theme-dark.css +208 -121
  23. package/static/styles/clean-jsdoc-theme-light.css +241 -168
  24. package/static/styles/clean-jsdoc-theme.min.css +1 -0
  25. package/tmpl/container.tmpl +13 -12
  26. package/tmpl/details.tmpl +16 -16
  27. package/tmpl/examples.tmpl +3 -1
  28. package/tmpl/icons.tmpl +43 -5
  29. package/tmpl/layout.tmpl +60 -79
  30. package/tmpl/members.tmpl +1 -2
  31. package/tmpl/method.tmpl +3 -4
  32. package/tmpl/mobile-sidebar.tmpl +21 -0
  33. package/tmpl/navbar-actions.tmpl +19 -0
  34. package/tmpl/navbar-menu.tmpl +21 -0
  35. package/tmpl/navbar.tmpl +14 -0
  36. package/tmpl/returns.tmpl +1 -1
  37. package/tmpl/search.tmpl +17 -0
  38. package/tmpl/sidebar-items.tmpl +24 -0
  39. package/tmpl/sidebar-title.tmpl +10 -0
  40. package/tmpl/sidebar.tmpl +9 -0
  41. package/tmpl/source.tmpl +7 -2
  42. package/tmpl/toc.tmpl +4 -0
  43. package/helpers/navbarBuilder.js +0 -0
  44. package/static/fonts/MavenPro-Regular.ttf +0 -0
  45. package/static/fonts/Montserrat-Regular.ttf +0 -0
  46. package/static/fonts/Muli-Black.ttf +0 -0
  47. package/static/fonts/OFL-hind.txt +0 -93
  48. package/static/fonts/OFL-montserrat.txt +0 -93
  49. package/static/scripts/fix-code-block.js +0 -53
  50. package/static/scripts/fix-navbar.js +0 -25
  51. package/static/scripts/linenumber.js +0 -25
  52. package/static/scripts/misc.js +0 -217
  53. package/static/scripts/third-party/lang-css.js +0 -2
  54. package/static/scripts/third-party/prettify.js +0 -28
  55. package/static/styles/reset.css +0 -351
  56. package/static/styles/third-party/ionicons.min.css +0 -11
  57. package/static/styles/third-party/prettify-jsdoc.css +0 -111
  58. 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,318 +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
- });
584
-
585
- if (!hasOwnProp.call(item, 'longname')) {
586
- itemsNav += '<li>' + linktoFn('', item.name);
587
- itemsNav += '</li>';
588
- } else if (!hasOwnProp.call(itemsSeen, item.longname)) {
589
- /**
590
- * Only have accordion class name if it have any child.
591
- * Otherwise it didn't makes any sense.
592
- */
593
- var accordionClassName = methods.length ?
594
- '"accordion collapsed child"' :
595
- '"accordion-list"';
596
-
597
- /**
598
- * Id give to accordion.
599
- */
600
- var accordionId = methods.length ?
601
- Math.floor(Math.random() * 10000000) :
602
- '""';
603
-
604
- itemsNav +=
605
- '<li class=' +
606
- accordionClassName +
607
- ' id=' +
608
- accordionId +
609
- '>';
610
-
611
- var linkTitle = linktoFn(
612
- item.longname,
613
- item.name.replace(/^module:/, '')
614
- );
615
-
616
- if (methods.length) {
617
- itemsNav +=
618
- '<div class="accordion-heading child">' +
619
- linkTitle +
620
- '<svg><use xlink:href="#down-icon"></use></svg>' +
621
- '</div>';
622
- } else {
623
- itemsNav += linkTitle;
624
- }
625
-
626
- if (haveSearch) {
627
- searchListArray.push(
628
- JSON.stringify({
629
- title: item.name,
630
- link: linkto(item.longname, item.name)
631
- })
632
- );
633
- }
634
-
635
- if (methods.length) {
636
- itemsNav += "<ul class='methods accordion-content'>";
637
-
638
- methods.forEach(function(method) {
639
- var name = method.longname.split('#');
640
- var first = name[0];
641
- var last = name[1];
642
-
643
- name = first + ' &rtrif; ' + last;
644
-
645
- if (haveSearch) {
646
- searchListArray.push(
647
- JSON.stringify({
648
- title: method.longname,
649
- link: linkto(method.longname, name)
650
- })
651
- );
652
- }
653
- itemsNav += "<li data-type='method'>";
654
- itemsNav += linkto(method.longname, method.name);
655
- itemsNav += '</li>';
656
- });
657
-
658
- itemsNav += '</ul>';
659
- }
660
- itemsNav += '</li>';
661
- itemsSeen[item.longname] = true;
662
- }
663
- });
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
+ );
664
548
 
665
- if (itemsNav !== '') {
666
- nav +=
667
- '<div class="accordion collapsed" id="' +
668
- Math.floor(Math.random() * 10000000) +
669
- '" > <h3 class="accordion-heading">' +
670
- itemHeading +
671
- '<svg><use xlink:href="#down-icon"></use></svg>' +
672
- '</h3><ul class="accordion-content">' +
673
- itemsNav +
674
- '</ul> </div>';
549
+ if (hasSearch) {
550
+ searchListArray.push({
551
+ title: item.name,
552
+ link: linkto(item.longname, item.name),
553
+ description: item.description
554
+ });
675
555
  }
676
- }
677
556
 
678
- 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;
679
591
  }
680
592
 
681
593
  function linktoTutorial(longName, name) {
682
- return tutoriallink(name);
594
+ return tutoriallink(name);
683
595
  }
684
596
 
685
597
  function linktoExternal(longName, name) {
686
- 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
+ };
687
606
  }
688
607
 
689
608
  /**
@@ -700,121 +619,120 @@ function linktoExternal(longName, name) {
700
619
  * @param {array<object>} members.interfaces
701
620
  * @return {string} The HTML for the navigation sidebar.
702
621
  */
703
- function buildNav(members) {
704
- var title = themeOpts.title || 'Home';
622
+ function buildSidebar(members) {
623
+ var title = themeOpts.title || 'Home';
705
624
 
706
- var isHTML = RegExp.prototype.test.bind(/(<([^>]+)>)/i);
707
- var nav;
625
+ var isHTML = RegExp.prototype.test.bind(/(<([^>]+)>)/i);
708
626
 
709
- if (!isHTML(title)) {
710
- nav =
711
- '<div class="navbar-heading" id="navbar-heading"><a href="index.html"><h2 class="navbar-heading-text">' +
712
- title +
713
- '</h2></a></div>';
714
- } else {
715
- nav = '<h2><a href="index.html">' + title + '</a></h2>';
716
- }
627
+ var nav = {
628
+ sections: []
629
+ };
717
630
 
718
- if (haveSearch) {
719
- nav += buildSearch();
720
- }
721
- nav += '<div class="sidebar-main-content" id="sidebar-main-content">';
722
- var seen = {};
723
- var seenTutorials = {};
724
- var seenGlobal = {};
725
-
726
- var menu = themeOpts.menu || undefined;
727
- var sectionsOrder = themeOpts.sections || defaultSections;
728
-
729
- var sections = {
730
- [SECTION_TYPE.Menu]: buildMenuNav(menu),
731
-
732
- [SECTION_TYPE.Modules]: buildMemberNav({
733
- itemHeading: 'Modules',
734
- items: members.modules,
735
- itemsSeen: {},
736
- linktoFn: linkto,
737
- sectionName: SECTION_TYPE.Modules
738
- }),
739
-
740
- [SECTION_TYPE.Classes]: buildMemberNav({
741
- itemHeading: 'Classes',
742
- items: members.classes,
743
- itemsSeen: seen,
744
- linktoFn: linkto,
745
- sectionName: SECTION_TYPE.Classes
746
- }),
747
-
748
- [SECTION_TYPE.Externals]: buildMemberNav({
749
- itemHeading: 'Externals',
750
- items: members.externals,
751
- itemsSeen: seen,
752
- linktoFn: linktoExternal,
753
- sectionName: SECTION_TYPE.Externals
754
- }),
755
-
756
- [SECTION_TYPE.Events]: buildMemberNav({
757
- itemHeading: 'Events',
758
- items: members.events,
759
- itemsSeen: seen,
760
- linktoFn: linkto,
761
- sectionName: SECTION_TYPE.Events
762
- }),
763
-
764
- [SECTION_TYPE.Namespaces]: buildMemberNav({
765
- itemHeading: 'Namespaces',
766
- items: members.namespaces,
767
- itemsSeen: seen,
768
- linktoFn: linkto,
769
- sectionName: SECTION_TYPE.Namespaces
770
- }),
771
-
772
- [SECTION_TYPE.Mixins]: buildMemberNav({
773
- itemHeading: 'Mixins',
774
- items: members.mixins,
775
- itemsSeen: seen,
776
- linktoFn: linkto,
777
- sectionName: SECTION_TYPE.Mixins
778
- }),
779
-
780
- [SECTION_TYPE.Tutorials]: buildMemberNav({
781
- itemHeading: 'Tutorials',
782
- items: members.tutorials,
783
- itemsSeen: seenTutorials,
784
- linktoFn: linktoTutorial,
785
- sectionName: SECTION_TYPE.Tutorials
786
- }),
787
-
788
- [SECTION_TYPE.Interfaces]: buildMemberNav({
789
- itemHeading: 'Interfaces',
790
- items: members.interfaces,
791
- itemsSeen: seen,
792
- linktoFn: linkto,
793
- sectionName: SECTION_TYPE.Interfaces
794
- }),
795
-
796
- [SECTION_TYPE.Global]: buildMemberNav({
797
- itemHeading: 'Global',
798
- items: members.globals,
799
- itemsSeen: seenGlobal,
800
- linktoFn: linkto,
801
- sectionName: SECTION_TYPE.Global
802
- })
631
+ if (!isHTML(title)) {
632
+ nav.title = {
633
+ title,
634
+ isHTML: false
803
635
  };
804
-
805
- sectionsOrder.forEach((section) => {
806
- if (SECTION_TYPE[section] !== undefined) {
807
- nav += sections[section];
808
- } else {
809
- 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.
810
728
  Accepted sections are: ${defaultSections.join(', ')}
811
729
  `;
812
730
 
813
- throw new Error(errorMsg);
814
- }
815
- });
731
+ throw new Error(errorMsg);
732
+ }
733
+ });
816
734
 
817
- return nav;
735
+ return nav;
818
736
  }
819
737
 
820
738
  /**
@@ -823,374 +741,391 @@ function buildNav(members) {
823
741
  @param {Tutorial} tutorials
824
742
  */
825
743
  exports.publish = function(taffyData, opts, tutorials) {
826
- data = taffyData;
827
-
828
- // eslint-disable-next-line no-restricted-globals
829
- var conf = env.conf.templates || {};
830
-
831
- conf.default = conf.default || {};
744
+ data = taffyData;
832
745
 
833
- var templatePath = path.normalize(opts.template);
746
+ // eslint-disable-next-line no-restricted-globals
747
+ var conf = env.conf.templates || {};
834
748
 
835
- view = new template.Template(path.join(templatePath, 'tmpl'));
749
+ conf.default = conf.default || {};
836
750
 
837
- // claim some special filenames in advance, so the All-Powerful Overseer of Filename Uniqueness
838
- // doesn't try to hand them out later
839
- var indexUrl = helper.getUniqueFilename('index');
840
- // don't call registerLink() on this one! 'index' is also a valid longname
751
+ var templatePath = path.normalize(opts.template);
841
752
 
842
- var globalUrl = helper.getUniqueFilename('global');
753
+ view = new template.Template(path.join(templatePath, 'tmpl'));
843
754
 
844
- 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
845
759
 
846
- // set up templating
847
- view.layout = conf.default.layoutFile ?
848
- path.getResourcePath(
849
- path.dirname(conf.default.layoutFile),
850
- path.basename(conf.default.layoutFile)
851
- ) :
852
- 'layout.tmpl';
760
+ var globalUrl = helper.getUniqueFilename('global');
853
761
 
854
- // set up tutorials for helper
855
- helper.setTutorials(tutorials);
762
+ helper.registerLink('global', globalUrl);
856
763
 
857
- data = helper.prune(data);
858
- data.sort('longname, version, since');
859
- 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';
860
771
 
861
- var sourceFiles = {};
862
- var sourceFilePaths = [];
772
+ // set up tutorials for helper
773
+ helper.setTutorials(tutorials);
863
774
 
864
- data().each(function(doclet) {
865
- doclet.attribs = '';
775
+ data = helper.prune(data);
776
+ data.sort('longname, version, since');
777
+ helper.addEventListeners(data);
866
778
 
867
- if (doclet.examples) {
868
- doclet.examples = doclet.examples.map(function(example) {
869
- var caption, code;
779
+ var sourceFiles = {};
780
+ var sourceFilePaths = [];
870
781
 
871
- if (example === undefined) {
872
- return {
873
- caption: '',
874
- code: ''
875
- };
876
- }
782
+ data().each(function(doclet) {
783
+ doclet.attribs = '';
877
784
 
878
- if (
879
- example.match(
880
- /^\s*<caption>([\s\S]+?)<\/caption>(\s*[\n\r])([\s\S]+)$/i
881
- )
882
- ) {
883
- caption = RegExp.$1;
884
- code = RegExp.$3;
885
- }
785
+ if (doclet.examples) {
786
+ doclet.examples = doclet.examples.map(function(example) {
787
+ var caption, code;
886
788
 
887
- return {
888
- caption: caption || '',
889
- code: code || example
890
- };
891
- });
789
+ if (example === undefined) {
790
+ return {
791
+ caption: '',
792
+ code: ''
793
+ };
892
794
  }
893
- if (doclet.see) {
894
- doclet.see.forEach(function(seeItem, i) {
895
- doclet.see[i] = hashToLink(doclet, seeItem);
896
- });
897
- }
898
-
899
- // build a list of source files
900
- var sourcePath;
901
795
 
902
- if (doclet.meta) {
903
- sourcePath = getPathFromDoclet(doclet);
904
- sourceFiles[sourcePath] = {
905
- resolved: sourcePath,
906
- shortened: null
907
- };
908
- if (sourceFilePaths.indexOf(sourcePath) === -1) {
909
- sourceFilePaths.push(sourcePath);
910
- }
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;
911
803
  }
912
- });
913
804
 
914
- // update outdir if necessary, then create outdir
915
- 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
+ }
916
816
 
917
- if (packageInfo && packageInfo.name) {
918
- 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
+ }
919
829
  }
920
- fs.mkPath(outdir);
830
+ });
921
831
 
922
- // copy the template's static files to outdir
923
- var fromDir = path.join(templatePath, 'static');
924
- var staticFiles = fs.ls(fromDir, 3);
832
+ // update outdir if necessary, then create outdir
833
+ var packageInfo = (find({ kind: 'package' }) || [])[0];
925
834
 
926
- staticFiles.forEach(function(fileName) {
927
- 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);
928
839
 
929
- fs.mkPath(toDir);
930
- fs.copyFileSync(fileName, toDir);
931
- });
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));
932
846
 
933
- // copy user-specified static files to outdir
934
- var staticFilePaths;
935
- var staticFileFilter;
936
- var staticFileScanner;
847
+ fs.mkPath(toDir);
848
+ fs.copyFileSync(fileName, toDir);
849
+ });
937
850
 
938
- if (conf.default.staticFiles) {
939
- // The canonical property name is `include`. We accept `paths` for backwards compatibility
940
- // with a bug in JSDoc 3.2.x.
941
- 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 =
942
860
  conf.default.staticFiles.include ||
943
861
  conf.default.staticFiles.paths ||
944
862
  [];
945
- staticFileFilter = new (require('jsdoc/src/filter').Filter)(
946
- conf.default.staticFiles
947
- );
948
- staticFileScanner = new (require('jsdoc/src/scanner').Scanner)();
949
-
950
- staticFilePaths.forEach(function(filePath) {
951
- var extraStaticFiles = staticFileScanner.scan(
952
- [filePath],
953
- 10,
954
- staticFileFilter
955
- );
956
-
957
- extraStaticFiles.forEach(function(fileName) {
958
- var sourcePath = fs.toDir(filePath);
959
- var toDir = fs.toDir(fileName.replace(sourcePath, outdir));
960
-
961
- fs.mkPath(toDir);
962
- fs.copyFileSync(fileName, toDir);
963
- });
964
- });
965
- }
966
-
967
- if (sourceFilePaths.length) {
968
- sourceFiles = shortenPaths(
969
- sourceFiles,
970
- path.commonPrefix(sourceFilePaths)
971
- );
972
- }
973
- data().each(function(doclet) {
974
- 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)();
975
867
 
976
- helper.registerLink(doclet.longname, url);
868
+ staticFilePaths.forEach(function(filePath) {
869
+ var extraStaticFiles = staticFileScanner.scan(
870
+ [filePath],
871
+ 10,
872
+ staticFileFilter
873
+ );
977
874
 
978
- // add a shortened version of the full path
979
- var docletPath;
875
+ extraStaticFiles.forEach(function(fileName) {
876
+ var sourcePath = fs.toDir(filePath);
877
+ var toDir = fs.toDir(fileName.replace(sourcePath, outdir));
980
878
 
981
- if (doclet.meta) {
982
- docletPath = getPathFromDoclet(doclet);
983
- docletPath = sourceFiles[docletPath].shortened;
984
- if (docletPath) {
985
- doclet.meta.shortpath = docletPath;
986
- }
987
- }
879
+ fs.mkPath(toDir);
880
+ fs.copyFileSync(fileName, toDir);
881
+ });
988
882
  });
883
+ }
989
884
 
990
- data().each(function(doclet) {
991
- var url = helper.longnameToUrl[doclet.longname];
992
-
993
- if (url.indexOf('#') > -1) {
994
- doclet.id = helper.longnameToUrl[doclet.longname].split(/#/).pop();
995
- } else {
996
- doclet.id = doclet.name;
997
- }
998
-
999
- if (needsSignature(doclet)) {
1000
- addSignatureParams(doclet);
1001
- addSignatureReturns(doclet);
1002
- addAttribs(doclet);
1003
- }
1004
- });
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);
1005
893
 
1006
- // do this after the urls have all been generated
1007
- data().each(function(doclet) {
1008
- doclet.ancestors = getAncestorLinks(doclet);
894
+ helper.registerLink(doclet.longname, url);
1009
895
 
1010
- if (doclet.kind === 'member') {
1011
- addSignatureTypes(doclet);
1012
- addAttribs(doclet);
1013
- }
896
+ // add a shortened version of the full path
897
+ var docletPath;
1014
898
 
1015
- if (doclet.kind === 'constant') {
1016
- addSignatureTypes(doclet);
1017
- addAttribs(doclet);
1018
- doclet.kind = 'member';
1019
- }
1020
- });
899
+ if (doclet.meta) {
900
+ docletPath = getPathFromDoclet(doclet);
901
+ docletPath = sourceFiles[docletPath].shortened;
902
+ if (docletPath) {
903
+ doclet.meta.shortpath = docletPath;
904
+ }
905
+ }
906
+ });
1021
907
 
1022
- var members = helper.getMembers(data);
908
+ data().each(function(doclet) {
909
+ var url = helper.longnameToUrl[doclet.longname];
1023
910
 
1024
- 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
+ }
1025
916
 
1026
- // output pretty-printed source files by default
1027
- var outputSourceFiles = Boolean(
1028
- conf.default && conf.default.outputSourceFiles !== false
1029
- );
917
+ if (needsSignature(doclet)) {
918
+ addSignatureParams(doclet);
919
+ addSignatureReturns(doclet);
920
+ addAttribs(doclet);
921
+ }
922
+ });
1030
923
 
1031
- // add template helpers
1032
- view.find = find;
1033
- view.linkto = linkto;
1034
- view.resolveAuthorLinks = resolveAuthorLinks;
1035
- view.tutoriallink = tutoriallink;
1036
- view.htmlsafe = htmlsafe;
1037
- view.outputSourceFiles = outputSourceFiles;
1038
- view.footer = buildFooter();
1039
- view.favicon = getFavicon();
1040
- view.dynamicStyle = createDynamicStyleSheet();
1041
- view.dynamicStyleSrc = returnPathOfStyleSrc();
1042
- view.dynamicScript = createDynamicsScripts();
1043
- view.dynamicScriptSrc = returnPathOfScriptScr();
1044
- view.includeScript = includeScript();
1045
- view.includeCss = includeCss();
1046
- view.meta = getMetaTagData();
1047
- view.overlayScrollbar = overlayScrollbarOptions();
1048
- view.theme = getTheme();
1049
- // once for all
1050
- view.nav = buildNav(members);
1051
- view.search = search();
1052
- view.resizeable = resizeable();
1053
- view.codepen = codepen();
1054
- view.excludeInherited = Boolean(themeOpts.exclude_inherited);
1055
- attachModuleSymbols(
1056
- find({ longname: { left: 'module:' } }),
1057
- members.modules
1058
- );
924
+ // do this after the urls have all been generated
925
+ data().each(function(doclet) {
926
+ doclet.ancestors = getAncestorLinks(doclet);
1059
927
 
1060
- // generate the pretty-printed source files first so other pages can link to them
1061
- if (outputSourceFiles) {
1062
- generateSourceFiles(sourceFiles, opts.encoding);
928
+ if (doclet.kind === 'member') {
929
+ addSignatureTypes(doclet);
930
+ addAttribs(doclet);
1063
931
  }
1064
932
 
1065
- if (members.globals.length) {
1066
- generate('', 'Global', [{ kind: 'globalobj' }], globalUrl);
933
+ if (doclet.kind === 'constant') {
934
+ addSignatureTypes(doclet);
935
+ addAttribs(doclet);
936
+ doclet.kind = 'member';
1067
937
  }
1068
-
1069
- // index page displays information from package.json and lists files
1070
- var files = find({ kind: 'file' });
1071
- var packages = find({ kind: 'package' });
1072
-
1073
- generate(
1074
- '',
1075
- 'Home',
1076
- packages
1077
- .concat([
1078
- {
1079
- kind: 'mainpage',
1080
- readme: opts.readme,
1081
- longname: opts.mainpagetitle ?
1082
- opts.mainpagetitle :
1083
- 'Main Page'
1084
- }
1085
- ])
1086
- .concat(files),
1087
- 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
+ })
1088
987
  );
1089
-
1090
- // set up the lists that we'll use to generate pages
1091
- var classes = taffy(members.classes);
1092
- var modules = taffy(members.modules);
1093
- var namespaces = taffy(members.namespaces);
1094
- var mixins = taffy(members.mixins);
1095
- var externals = taffy(members.externals);
1096
- var interfaces = taffy(members.interfaces);
1097
-
1098
- Object.keys(helper.longnameToUrl).forEach(function(longname) {
1099
- var myModules = helper.find(modules, { longname: longname });
1100
-
1101
- if (myModules.length) {
1102
- generate(
1103
- 'Module',
1104
- myModules[0].name,
1105
- myModules,
1106
- helper.longnameToUrl[longname]
1107
- );
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'
1108
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
+ }
1109
1039
 
1110
- var myClasses = helper.find(classes, { longname: longname });
1111
-
1112
- if (myClasses.length) {
1113
- generate(
1114
- 'Class',
1115
- myClasses[0].name,
1116
- myClasses,
1117
- helper.longnameToUrl[longname]
1118
- );
1119
- }
1040
+ var myClasses = helper.find(classes, { longname: longname });
1120
1041
 
1121
- 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
+ }
1122
1050
 
1123
- if (myNamespaces.length) {
1124
- generate(
1125
- 'Namespace',
1126
- myNamespaces[0].name,
1127
- myNamespaces,
1128
- helper.longnameToUrl[longname]
1129
- );
1130
- }
1051
+ var myNamespaces = helper.find(namespaces, { longname: longname });
1131
1052
 
1132
- 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
+ }
1133
1061
 
1134
- if (myMixins.length) {
1135
- generate(
1136
- 'Mixin',
1137
- myMixins[0].name,
1138
- myMixins,
1139
- helper.longnameToUrl[longname]
1140
- );
1141
- }
1062
+ var myMixins = helper.find(mixins, { longname: longname });
1142
1063
 
1143
- 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
+ }
1144
1072
 
1145
- if (myExternals.length) {
1146
- generate(
1147
- 'External',
1148
- myExternals[0].name,
1149
- myExternals,
1150
- helper.longnameToUrl[longname]
1151
- );
1152
- }
1073
+ var myExternals = helper.find(externals, { longname: longname });
1153
1074
 
1154
- 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
+ }
1155
1083
 
1156
- if (myInterfaces.length) {
1157
- generate(
1158
- 'Interface',
1159
- myInterfaces[0].name,
1160
- myInterfaces,
1161
- helper.longnameToUrl[longname]
1162
- );
1163
- }
1164
- });
1084
+ var myInterfaces = helper.find(interfaces, { longname: longname });
1165
1085
 
1166
- // TODO: move the tutorial functions to templateHelper.js
1167
- function generateTutorial(title, tutorial, filename) {
1168
- var tutorialData = {
1169
- title: title,
1170
- header: tutorial.title,
1171
- content: tutorial.parse(),
1172
- children: tutorial.children
1173
- };
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
+ };
1174
1104
 
1175
- var tutorialPath = path.join(outdir, filename);
1176
- var html = view.render('tutorial.tmpl', tutorialData);
1105
+ var tutorialPath = path.join(outdir, filename);
1106
+ var html = view.render('tutorial.tmpl', tutorialData);
1177
1107
 
1178
- // yes, you can use {@link} in tutorials too!
1179
- html = helper.resolveLinks(html); // turn {@link foo} into <a href="foodoc.html">foo</a>
1180
- fs.writeFileSync(tutorialPath, html, 'utf8');
1181
- }
1108
+ // yes, you can use {@link} in tutorials too!
1109
+ html = helper.resolveLinks(html); // turn {@link foo} into <a href="foodoc.html">foo</a>
1182
1110
 
1183
- // tutorials can have only one parent so there is no risk for loops
1184
- function saveChildren(node) {
1185
- node.children.forEach(function(child) {
1186
- generateTutorial(
1187
- 'Tutorial: ' + child.title,
1188
- child,
1189
- helper.tutorialToUrl(child.name)
1190
- );
1191
- saveChildren(child);
1192
- });
1193
- }
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
+ }
1194
1129
 
1195
- saveChildren(tutorials);
1130
+ saveChildren(tutorials);
1196
1131
  };