@braintree/jsdoc-template 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 (55) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/LICENSE +27 -0
  3. package/README.md +89 -0
  4. package/package.json +51 -0
  5. package/publish.js +676 -0
  6. package/static/fonts/OpenSans-Bold-webfont.eot +0 -0
  7. package/static/fonts/OpenSans-Bold-webfont.svg +1830 -0
  8. package/static/fonts/OpenSans-Bold-webfont.woff +0 -0
  9. package/static/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
  10. package/static/fonts/OpenSans-BoldItalic-webfont.svg +1830 -0
  11. package/static/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
  12. package/static/fonts/OpenSans-Italic-webfont.eot +0 -0
  13. package/static/fonts/OpenSans-Italic-webfont.svg +1830 -0
  14. package/static/fonts/OpenSans-Italic-webfont.woff +0 -0
  15. package/static/fonts/OpenSans-Light-webfont.eot +0 -0
  16. package/static/fonts/OpenSans-Light-webfont.svg +1831 -0
  17. package/static/fonts/OpenSans-Light-webfont.woff +0 -0
  18. package/static/fonts/OpenSans-LightItalic-webfont.eot +0 -0
  19. package/static/fonts/OpenSans-LightItalic-webfont.svg +1835 -0
  20. package/static/fonts/OpenSans-LightItalic-webfont.woff +0 -0
  21. package/static/fonts/OpenSans-Regular-webfont.eot +0 -0
  22. package/static/fonts/OpenSans-Regular-webfont.svg +1831 -0
  23. package/static/fonts/OpenSans-Regular-webfont.woff +0 -0
  24. package/static/fonts/OpenSans-Semibold-webfont.eot +0 -0
  25. package/static/fonts/OpenSans-Semibold-webfont.svg +1830 -0
  26. package/static/fonts/OpenSans-Semibold-webfont.ttf +0 -0
  27. package/static/fonts/OpenSans-Semibold-webfont.woff +0 -0
  28. package/static/fonts/OpenSans-SemiboldItalic-webfont.eot +0 -0
  29. package/static/fonts/OpenSans-SemiboldItalic-webfont.svg +1830 -0
  30. package/static/fonts/OpenSans-SemiboldItalic-webfont.ttf +0 -0
  31. package/static/fonts/OpenSans-SemiboldItalic-webfont.woff +0 -0
  32. package/static/icons/home.svg +4 -0
  33. package/static/icons/search.svg +4 -0
  34. package/static/scripts/linenumber.js +23 -0
  35. package/static/scripts/pagelocation.js +89 -0
  36. package/static/styles/collapse.css +27 -0
  37. package/static/styles/jsdoc-default.css +953 -0
  38. package/static/styles/prettify-jsdoc.css +111 -0
  39. package/static/styles/prettify-tomorrow.css +138 -0
  40. package/tmpl/augments.tmpl +10 -0
  41. package/tmpl/container.tmpl +213 -0
  42. package/tmpl/details.tmpl +223 -0
  43. package/tmpl/example.tmpl +2 -0
  44. package/tmpl/examples.tmpl +14 -0
  45. package/tmpl/exceptions.tmpl +28 -0
  46. package/tmpl/layout.tmpl +150 -0
  47. package/tmpl/mainpage.tmpl +9 -0
  48. package/tmpl/members.tmpl +38 -0
  49. package/tmpl/method.tmpl +128 -0
  50. package/tmpl/params.tmpl +125 -0
  51. package/tmpl/properties.tmpl +111 -0
  52. package/tmpl/returns.tmpl +17 -0
  53. package/tmpl/source.tmpl +9 -0
  54. package/tmpl/tutorial.tmpl +23 -0
  55. package/tmpl/type.tmpl +11 -0
package/publish.js ADDED
@@ -0,0 +1,676 @@
1
+ /* global env: true */
2
+ /* eslint-disable vars-on-top, valid-jsdoc */
3
+ 'use strict';
4
+
5
+ var doop = require('jsdoc/util/doop');
6
+ var fs = require('jsdoc/fs');
7
+ var helper = require('jsdoc/util/templateHelper');
8
+ var logger = require('jsdoc/util/logger');
9
+ var path = require('jsdoc/path');
10
+ var taffy = require('@jsdoc/salty').taffy;
11
+ var template = require('jsdoc/template');
12
+ var util = require('util');
13
+
14
+ var htmlsafe = helper.htmlsafe;
15
+ var linkto = helper.linkto;
16
+ var resolveAuthorLinks = helper.resolveAuthorLinks;
17
+ var hasOwnProp = Object.prototype.hasOwnProperty;
18
+
19
+ var data, view;
20
+
21
+ var outdir = path.normalize(env.opts.destination);
22
+
23
+ function find(spec) {
24
+ return helper.find(data, spec);
25
+ }
26
+
27
+ function tutoriallink(tutorial) {
28
+ return helper.toTutorial(tutorial, null, {tag: 'em', classname: 'disabled', prefix: 'Tutorial: '});
29
+ }
30
+
31
+ function getAncestorLinks(doclet) {
32
+ return helper.getAncestorLinks(data, doclet);
33
+ }
34
+
35
+ function hashToLink(doclet, hash) {
36
+ if (!/^(#.+)/.test(hash)) { return hash; }
37
+
38
+ var url = helper.createLink(doclet);
39
+
40
+ url = url.replace(/(#.+|$)/, hash);
41
+
42
+ return '<a href="' + url + '">' + hash + '</a>';
43
+ }
44
+
45
+ function needsSignature(doclet) {
46
+ var i, l;
47
+ var needsSig = false;
48
+
49
+ // function and class definitions always get a signature
50
+ if (doclet.kind === 'function' || doclet.kind === 'class') {
51
+ needsSig = true;
52
+ } else if (doclet.kind === 'typedef' && doclet.type && doclet.type.names &&
53
+ doclet.type.names.length) { // typedefs that contain functions get a signature, too
54
+ for (i = 0, l = doclet.type.names.length; i < l; i++) {
55
+ if (doclet.type.names[i].toLowerCase() === 'function') {
56
+ needsSig = true;
57
+ break;
58
+ }
59
+ }
60
+ }
61
+
62
+ return needsSig;
63
+ }
64
+
65
+ function getSignatureAttributes(item) {
66
+ var attributes = [];
67
+
68
+ if (item.optional) {
69
+ attributes.push('opt');
70
+ }
71
+
72
+ if (item.nullable === true) {
73
+ attributes.push('nullable');
74
+ } else if (item.nullable === false) {
75
+ attributes.push('non-null');
76
+ }
77
+
78
+ return attributes;
79
+ }
80
+
81
+ function updateItemName(item) {
82
+ var attributes = getSignatureAttributes(item);
83
+ var itemName = item.name || '';
84
+
85
+ if (item.variable) {
86
+ itemName = '&hellip;' + itemName;
87
+ }
88
+
89
+ if (attributes && attributes.length) {
90
+ itemName = util.format('%s<span class="signature-attributes">%s</span>', itemName,
91
+ attributes.join(', '));
92
+ }
93
+
94
+ return itemName;
95
+ }
96
+
97
+ function addParamAttributes(params) {
98
+ return params.filter(function (param) {
99
+ return param.name && param.name.indexOf('.') === -1;
100
+ }).map(updateItemName);
101
+ }
102
+
103
+ function buildItemTypeStrings(item) {
104
+ var types = [];
105
+
106
+ if (item && item.type && item.type.names) {
107
+ item.type.names.forEach(function (name) {
108
+ types.push(linkto(name, htmlsafe(name)));
109
+ });
110
+ }
111
+
112
+ return types;
113
+ }
114
+
115
+ function buildAttribsString(attribs) {
116
+ var attribsString = '';
117
+
118
+ if (attribs && attribs.length) {
119
+ attribsString = htmlsafe(util.format('(%s) ', attribs.join(', ')));
120
+ }
121
+
122
+ return attribsString;
123
+ }
124
+
125
+ function addNonParamAttributes(items) {
126
+ var types = [];
127
+
128
+ items.forEach(function (item) {
129
+ types = types.concat(buildItemTypeStrings(item));
130
+ });
131
+
132
+ return types;
133
+ }
134
+
135
+ function addSignatureParams(f) {
136
+ var params = f.params ? addParamAttributes(f.params) : [];
137
+
138
+ f.signature = util.format('%s(%s)', f.signature || '', params.join(', '));
139
+ }
140
+
141
+ function addSignatureReturns(f) {
142
+ var attribs = [];
143
+ var attribsString = '';
144
+ var returnTypes = [];
145
+ var returnTypesString = '';
146
+
147
+ // jam all the return-type attributes into an array. this could create odd results (for example,
148
+ // if there are both nullable and non-nullable return types), but let's assume that most people
149
+ // who use multiple @return tags aren't using Closure Compiler type annotations, and vice-versa.
150
+ if (f.returns) {
151
+ f.returns.forEach(function (item) {
152
+ helper.getAttribs(item).forEach(function (attrib) {
153
+ if (attribs.indexOf(attrib) === -1) {
154
+ attribs.push(attrib);
155
+ }
156
+ });
157
+ });
158
+
159
+ attribsString = buildAttribsString(attribs);
160
+ }
161
+
162
+ if (f.returns) {
163
+ returnTypes = addNonParamAttributes(f.returns);
164
+ }
165
+ if (returnTypes.length) {
166
+ returnTypesString = util.format(' &rarr; %s{%s}', attribsString, returnTypes.join('|'));
167
+ }
168
+
169
+ f.signature = '<span class="signature">' + (f.signature || '') + '</span>' +
170
+ '<span class="type-signature">' + returnTypesString + '</span>';
171
+ }
172
+
173
+ function addSignatureTypes(f) {
174
+ var types = f.type ? buildItemTypeStrings(f) : [];
175
+
176
+ f.signature = (f.signature || '') + '<span class="type-signature">' +
177
+ (types.length ? ' :' + types.join('|') : '') + '</span>';
178
+ }
179
+
180
+ function addAttribs(f) {
181
+ var attribs = helper.getAttribs(f);
182
+ var attribsString = buildAttribsString(attribs);
183
+
184
+ f.attribs = util.format('<span class="type-signature">%s</span>', attribsString);
185
+ }
186
+
187
+ function shortenPaths(files, commonPrefix) {
188
+ Object.keys(files).forEach(function (file) {
189
+ files[file].shortened = files[file].resolved.replace(commonPrefix, '')
190
+ // always use forward slashes
191
+ .replace(/\\/g, '/');
192
+ });
193
+
194
+ return files;
195
+ }
196
+
197
+ function getPathFromDoclet(doclet) {
198
+ if (!doclet.meta) {
199
+ return null;
200
+ }
201
+
202
+ return doclet.meta.path && doclet.meta.path !== 'null' ?
203
+ path.join(doclet.meta.path, doclet.meta.filename) :
204
+ doclet.meta.filename;
205
+ }
206
+
207
+ function generate(type, title, docs, filename, resolveLinks) {
208
+ resolveLinks = resolveLinks !== false;
209
+
210
+ var docData = {
211
+ type: type,
212
+ title: title,
213
+ docs: docs
214
+ };
215
+
216
+ var outpath = path.join(outdir, filename);
217
+ var html = view.render('container.tmpl', docData);
218
+
219
+ if (resolveLinks) {
220
+ html = helper.resolveLinks(html); // turn {@link foo} into <a href="foodoc.html">foo</a>
221
+ }
222
+
223
+ if (typeof env.conf.templates.postProcess === 'function') {
224
+ html = env.conf.templates.postProcess(html);
225
+ }
226
+
227
+ fs.writeFileSync(outpath, html, 'utf8');
228
+ }
229
+
230
+ function generateSourceFiles(sourceFiles, encoding) {
231
+ encoding = encoding || 'utf8';
232
+ Object.keys(sourceFiles).forEach(function (file) {
233
+ var source;
234
+ // links are keyed to the shortened path in each doclet's `meta.shortpath` property
235
+ var sourceOutfile = helper.getUniqueFilename(sourceFiles[file].shortened);
236
+
237
+ helper.registerLink(sourceFiles[file].shortened, sourceOutfile);
238
+
239
+ try {
240
+ source = {
241
+ kind: 'source',
242
+ code: helper.htmlsafe(fs.readFileSync(sourceFiles[file].resolved, encoding))
243
+ };
244
+ } catch (e) {
245
+ logger.error('Error while generating source file %s: %s', file, e.message);
246
+ }
247
+
248
+ generate('Source', sourceFiles[file].shortened, [source], sourceOutfile, false);
249
+ });
250
+ }
251
+
252
+ /**
253
+ * Look for classes or functions with the same name as modules (which indicates that the module
254
+ * exports only that class or function), then attach the classes or functions to the `module`
255
+ * property of the appropriate module doclets. The name of each class or function is also updated
256
+ * for display purposes. This function mutates the original arrays.
257
+ *
258
+ * @private
259
+ * @param {Array.<module:jsdoc/doclet.Doclet>} doclets - The array of classes and functions to
260
+ * check.
261
+ * @param {Array.<module:jsdoc/doclet.Doclet>} modules - The array of module doclets to search.
262
+ */
263
+ function attachModuleSymbols(doclets, modules) {
264
+ var symbols = {};
265
+
266
+ // build a lookup table
267
+ doclets.forEach(function (symbol) {
268
+ symbols[symbol.longname] = symbols[symbol.longname] || [];
269
+ symbols[symbol.longname].push(symbol);
270
+ });
271
+
272
+ return modules.map(function (module) {
273
+ if (symbols[module.longname]) {
274
+ module.modules = symbols[module.longname]
275
+ // Only show symbols that have a description. Make an exception for classes, because
276
+ // we want to show the constructor-signature heading no matter what.
277
+ .filter(function (symbol) {
278
+ return symbol.description || symbol.kind === 'class';
279
+ })
280
+ .map(function (symbol) {
281
+ symbol = doop(symbol);
282
+
283
+ if (symbol.kind === 'class' || symbol.kind === 'function') {
284
+ symbol.name = symbol.name.replace('module:', '(require("') + '"))';
285
+ }
286
+
287
+ return symbol;
288
+ });
289
+ }
290
+ });
291
+ }
292
+
293
+ function buildMemberNav(items, itemHeading, itemsSeen, linktoFn) {
294
+ var nav = '';
295
+ var itemsNav = '';
296
+
297
+ if (items && items.length) {
298
+ items.forEach(function (item) {
299
+ var methods = find({kind: 'function', memberof: item.longname});
300
+
301
+ if (!hasOwnProp.call(item, 'longname')) {
302
+ itemsNav += '<li id="' + item.name.replace('/', '_') + '-nav">' + linktoFn('', item.name);
303
+ itemsNav += '</li>';
304
+ } else if (!hasOwnProp.call(itemsSeen, item.longname)) {
305
+ // replace '/' in url to match ID in some section
306
+ itemsNav += '<li id="' + item.name.replace('/', '_') + '-nav">' + linktoFn(item.longname, item.name.replace(/^module:/, ''));
307
+ if (methods.length) {
308
+ itemsNav += "<ul class='methods'>";
309
+
310
+ methods.forEach(function (method) {
311
+ itemsNav += '<li data-type="method" id="' + item.name.replace('/', '_') + '-' + method.name + '-nav">';
312
+ itemsNav += linkto(method.longname, method.name);
313
+ itemsNav += '</li>';
314
+ });
315
+
316
+ itemsNav += '</ul>';
317
+ }
318
+ itemsNav += '</li>';
319
+ itemsSeen[item.longname] = true;
320
+ }
321
+ });
322
+
323
+ if (itemsNav !== '') {
324
+ nav += '<h3>' + itemHeading + '</h3><ul>' + itemsNav + '</ul>';
325
+ }
326
+ }
327
+
328
+ return nav;
329
+ }
330
+
331
+ // TODO: as needed, comment back in later
332
+ // function linktoTutorial(longName, name) {
333
+ // return tutoriallink(name);
334
+ // }
335
+
336
+ // function linktoExternal(longName, name) {
337
+ // return linkto(longName, name.replace(/(^"|"$)/g, ''));
338
+ // }
339
+
340
+ /**
341
+ * Create the navigation sidebar.
342
+ * @param {object} members The members that will be used to create the sidebar.
343
+ * @param {array<object>} members.classes
344
+ * @param {array<object>} members.externals
345
+ * @param {array<object>} members.globals
346
+ * @param {array<object>} members.mixins
347
+ * @param {array<object>} members.modules
348
+ * @param {array<object>} members.namespaces
349
+ * @param {array<object>} members.tutorials
350
+ * @param {array<object>} members.events
351
+ * @param {array<object>} members.interfaces
352
+ * @return {string} The HTML for the navigation sidebar.
353
+ */
354
+ function buildNav(members) {
355
+ var nav = '';
356
+ var globalNav = '';
357
+ var seen = {};
358
+ // var seenTutorials = {};
359
+
360
+ nav += buildMemberNav(members.classes, 'Classes', seen, linkto);
361
+ nav += buildMemberNav(members.modules, 'Modules', {}, linkto);
362
+ // TODO: as needed, comment back in later
363
+ // nav += buildMemberNav(members.externals, 'Externals', seen, linktoExternal);
364
+ // nav += buildMemberNav(members.events, 'Events', seen, linkto);
365
+ // nav += buildMemberNav(members.namespaces, 'Namespaces', seen, linkto);
366
+ // nav += buildMemberNav(members.mixins, 'Mixins', seen, linkto);
367
+ // nav += buildMemberNav(members.tutorials, 'Tutorials', seenTutorials, linktoTutorial);
368
+ // nav += buildMemberNav(members.interfaces, 'Interfaces', seen, linkto);
369
+
370
+ if (members.globals.length) {
371
+ members.globals.forEach(function (g) {
372
+ if (g.kind !== 'typedef' && !hasOwnProp.call(seen, g.longname)) {
373
+ globalNav += '<li>' + linkto(g.longname, g.name) + '</li>';
374
+ }
375
+ seen[g.longname] = true;
376
+ });
377
+
378
+ if (!globalNav) {
379
+ // turn the heading into a link so you can actually get to the global page
380
+ nav += '<h3 id="global-nav">' + linkto('global', 'Global') + '</h3>';
381
+ } else {
382
+ nav += '<h3 id="global-nav">Global</h3><ul>' + globalNav + '</ul>';
383
+ }
384
+ }
385
+
386
+ return nav;
387
+ }
388
+
389
+ /**
390
+ technically taffyDB object, but we use `@jsdoc/salty` to pull into database form
391
+ @param {TAFFY} taffyData See <http://taffydb.com/>.
392
+ @param {object} opts
393
+ @param {Tutorial} tutorials
394
+ */
395
+ exports.publish = function (taffyData, opts, tutorials) {
396
+ var conf, templatePath, indexUrl, globalUrl, sourceFiles, sourceFilePaths, staticFilePaths, staticFileFilter, staticFileScanner;
397
+
398
+ data = taffyData;
399
+
400
+ conf = env.conf.templates || {};
401
+ conf.default = conf.default || {};
402
+
403
+ templatePath = path.normalize(opts.template);
404
+
405
+ view = new template.Template(path.join(templatePath, 'tmpl'));
406
+
407
+ // claim some special filenames in advance, so the All-Powerful Overseer of Filename Uniqueness
408
+ // doesn't try to hand them out later
409
+ indexUrl = helper.getUniqueFilename('index');
410
+
411
+ // don't call registerLink() on this one! 'index' is also a valid longname
412
+ globalUrl = helper.getUniqueFilename('global');
413
+
414
+ helper.registerLink('global', globalUrl);
415
+
416
+ // set up templating
417
+ view.layout = conf.default.layoutFile ?
418
+ path.getResourcePath(path.dirname(conf.default.layoutFile),
419
+ path.basename(conf.default.layoutFile)) :
420
+ 'layout.tmpl';
421
+
422
+ // set up tutorials for helper
423
+ helper.setTutorials(tutorials);
424
+
425
+ data = helper.prune(data);
426
+ if (!conf.disableSort) {
427
+ data.sort('longname, version, since');
428
+ }
429
+ helper.addEventListeners(data);
430
+
431
+ sourceFiles = {};
432
+ sourceFilePaths = [];
433
+
434
+ data().each(function (doclet) {
435
+ doclet.attribs = '';
436
+
437
+ if (doclet.examples) {
438
+ doclet.examples = doclet.examples.map(function (example) {
439
+ var caption, code;
440
+
441
+ if (example.match(/^\s*<caption>([\s\S]+?)<\/caption>(\s*[\n\r])([\s\S]+)$/i)) {
442
+ caption = RegExp.$1;
443
+ code = RegExp.$3;
444
+ }
445
+
446
+ return {
447
+ caption: caption || '',
448
+ code: code || example
449
+ };
450
+ });
451
+ }
452
+ if (doclet.see) {
453
+ doclet.see.forEach(function (seeItem, i) {
454
+ doclet.see[i] = hashToLink(doclet, seeItem);
455
+ });
456
+ }
457
+
458
+ // build a list of source files
459
+ var sourcePath;
460
+
461
+ if (doclet.meta) {
462
+ sourcePath = getPathFromDoclet(doclet);
463
+ sourceFiles[sourcePath] = {
464
+ resolved: sourcePath,
465
+ shortened: null
466
+ };
467
+ if (sourceFilePaths.indexOf(sourcePath) === -1) {
468
+ sourceFilePaths.push(sourcePath);
469
+ }
470
+ }
471
+ });
472
+
473
+ // update outdir if necessary, then create outdir
474
+ var packageInfo = (find({kind: 'package'}) || [])[0];
475
+
476
+ if (packageInfo && packageInfo.name) {
477
+ outdir = path.join(outdir, packageInfo.name, packageInfo.version || '');
478
+ }
479
+ fs.mkPath(outdir);
480
+
481
+ // copy the template's static files to outdir
482
+ var fromDir = path.join(templatePath, 'static');
483
+ var staticFiles = fs.ls(fromDir, 3);
484
+
485
+ staticFiles.forEach(function (fileName) {
486
+ var toDir = fs.toDir(fileName.replace(fromDir, outdir));
487
+
488
+ fs.mkPath(toDir);
489
+ fs.copyFileSync(fileName, toDir);
490
+ });
491
+
492
+ // copy user-specified static files to outdir
493
+ if (conf.default.staticFiles) {
494
+ // The canonical property name is `include`. We accept `paths` for backwards compatibility
495
+ // with a bug in JSDoc 3.2.x.
496
+ staticFilePaths = conf.default.staticFiles.include ||
497
+ conf.default.staticFiles.paths ||
498
+ [];
499
+ staticFileFilter = new (require('jsdoc/src/filter')).Filter(conf.default.staticFiles);
500
+ staticFileScanner = new (require('jsdoc/src/scanner')).Scanner();
501
+
502
+ staticFilePaths.forEach(function (filePath) {
503
+ var extraStaticFiles = staticFileScanner.scan([filePath], 10, staticFileFilter);
504
+
505
+ extraStaticFiles.forEach(function (fileName) {
506
+ var sourcePath = fs.toDir(filePath);
507
+ var toDir = fs.toDir(fileName.replace(sourcePath, outdir));
508
+
509
+ fs.mkPath(toDir);
510
+ fs.copyFileSync(fileName, toDir);
511
+ });
512
+ });
513
+ }
514
+
515
+ if (sourceFilePaths.length) {
516
+ sourceFiles = shortenPaths(sourceFiles, path.commonPrefix(sourceFilePaths));
517
+ }
518
+ data().each(function (doclet) {
519
+ var docletPath;
520
+ var url = helper.createLink(doclet);
521
+
522
+ helper.registerLink(doclet.longname, url);
523
+
524
+ // add a shortened version of the full path
525
+ if (doclet.meta) {
526
+ docletPath = getPathFromDoclet(doclet);
527
+ docletPath = sourceFiles[docletPath].shortened;
528
+ if (docletPath) {
529
+ doclet.meta.shortpath = docletPath;
530
+ }
531
+ }
532
+ });
533
+
534
+ data().each(function (doclet) {
535
+ var url = helper.longnameToUrl[doclet.longname];
536
+
537
+ if (url.indexOf('#') > -1) {
538
+ doclet.id = helper.longnameToUrl[doclet.longname].split(/#/).pop();
539
+ } else {
540
+ doclet.id = doclet.name;
541
+ }
542
+
543
+ if (needsSignature(doclet)) {
544
+ addSignatureParams(doclet);
545
+ addSignatureReturns(doclet);
546
+ addAttribs(doclet);
547
+ }
548
+ });
549
+
550
+ // do this after the urls have all been generated
551
+ data().each(function (doclet) {
552
+ doclet.ancestors = getAncestorLinks(doclet);
553
+
554
+ if ((doclet.kind === 'member' || doclet.kind === 'event' || doclet.kind === 'typedef') && doclet.signature == null) {
555
+ addSignatureTypes(doclet);
556
+ addAttribs(doclet);
557
+ }
558
+
559
+ if (doclet.kind === 'constant') {
560
+ addSignatureTypes(doclet);
561
+ addAttribs(doclet);
562
+ doclet.kind = 'member';
563
+ }
564
+ });
565
+
566
+ var members = helper.getMembers(data);
567
+
568
+ members.tutorials = tutorials.children;
569
+
570
+ // output pretty-printed source files by default
571
+ var outputSourceFiles = conf.default && conf.default.outputSourceFiles !== false;
572
+
573
+ // add template helpers
574
+ view.find = find;
575
+ view.linkto = linkto;
576
+ view.resolveAuthorLinks = resolveAuthorLinks;
577
+ view.tutoriallink = tutoriallink;
578
+ view.htmlsafe = htmlsafe;
579
+ view.outputSourceFiles = outputSourceFiles;
580
+
581
+ // once for all
582
+ view.nav = buildNav(members);
583
+ attachModuleSymbols(find({longname: {left: 'module:'}}), members.modules);
584
+
585
+ // generate the pretty-printed source files first so other pages can link to them
586
+ if (outputSourceFiles) {
587
+ generateSourceFiles(sourceFiles, opts.encoding);
588
+ }
589
+
590
+ if (members.globals.length) {
591
+ generate('', 'Global', [{kind: 'globalobj'}], globalUrl);
592
+ }
593
+
594
+ // index page displays information from package.json and lists files
595
+ var files = find({kind: 'file'});
596
+ var packages = find({kind: 'package'});
597
+
598
+ generate('', 'Home',
599
+ packages.concat(
600
+ [{kind: 'mainpage', readme: opts.readme, longname: opts.mainpagetitle ? opts.mainpagetitle : 'Main Page'}]
601
+ ).concat(files),
602
+ indexUrl);
603
+
604
+ // set up the lists that we'll use to generate pages
605
+ var classes = taffy(members.classes);
606
+ var modules = taffy(members.modules);
607
+ var namespaces = taffy(members.namespaces);
608
+ var mixins = taffy(members.mixins);
609
+ var externals = taffy(members.externals);
610
+ var interfaces = taffy(members.interfaces);
611
+
612
+ Object.keys(helper.longnameToUrl).forEach(function (longname) {
613
+ var myModules = helper.find(modules, {longname: longname});
614
+
615
+ if (myModules.length) {
616
+ generate('Module', myModules[0].name, myModules, helper.longnameToUrl[longname]);
617
+ }
618
+
619
+ var myClasses = helper.find(classes, {longname: longname});
620
+
621
+ if (myClasses.length) {
622
+ generate('Class', myClasses[0].name, myClasses, helper.longnameToUrl[longname]);
623
+ }
624
+
625
+ var myNamespaces = helper.find(namespaces, {longname: longname});
626
+
627
+ if (myNamespaces.length) {
628
+ generate('Namespace', myNamespaces[0].name, myNamespaces, helper.longnameToUrl[longname]);
629
+ }
630
+
631
+ var myMixins = helper.find(mixins, {longname: longname});
632
+
633
+ if (myMixins.length) {
634
+ generate('Mixin', myMixins[0].name, myMixins, helper.longnameToUrl[longname]);
635
+ }
636
+
637
+ var myExternals = helper.find(externals, {longname: longname});
638
+
639
+ if (myExternals.length) {
640
+ generate('External', myExternals[0].name, myExternals, helper.longnameToUrl[longname]);
641
+ }
642
+
643
+ var myInterfaces = helper.find(interfaces, {longname: longname});
644
+
645
+ if (myInterfaces.length) {
646
+ generate('Interface', myInterfaces[0].name, myInterfaces, helper.longnameToUrl[longname]);
647
+ }
648
+ });
649
+
650
+ // TODO: move the tutorial functions to templateHelper.js
651
+ function generateTutorial(title, tutorial, filename) {
652
+ var tutorialData = {
653
+ title: title,
654
+ header: tutorial.title,
655
+ content: tutorial.parse(),
656
+ children: tutorial.children
657
+ };
658
+
659
+ var tutorialPath = path.join(outdir, filename);
660
+ var html = view.render('tutorial.tmpl', tutorialData);
661
+
662
+ // yes, you can use {@link} in tutorials too!
663
+ html = helper.resolveLinks(html); // turn {@link foo} into <a href="foodoc.html">foo</a>
664
+ fs.writeFileSync(tutorialPath, html, 'utf8');
665
+ }
666
+
667
+ // tutorials can have only one parent so there is no risk for loops
668
+ function saveChildren(node) {
669
+ node.children.forEach(function (child) {
670
+ generateTutorial('Tutorial: ' + child.title, child, helper.tutorialToUrl(child.name));
671
+ saveChildren(child);
672
+ });
673
+ }
674
+
675
+ saveChildren(tutorials);
676
+ };