clean-jsdoc-theme 4.1.6 → 4.1.8

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