@@ -29,9 +29,9 @@ function getAncestorLinks(doclet) {
29
29
30
30
function hashToLink ( doclet , hash ) {
31
31
if ( ! / ^ ( # .+ ) / . test ( hash ) ) { return hash ; }
32
-
32
+
33
33
var url = helper . createLink ( doclet ) ;
34
-
34
+
35
35
url = url . replace ( / ( # .+ | $ ) / , hash ) ;
36
36
return '<a href="' + url + '">' + hash + '</a>' ;
37
37
}
@@ -59,23 +59,23 @@ function needsSignature(doclet) {
59
59
60
60
function addSignatureParams ( f ) {
61
61
var params = helper . getSignatureParams ( f , 'optional' ) ;
62
-
62
+
63
63
f . signature = ( f . signature || '' ) + '(' + params . join ( ', ' ) + ')' ;
64
64
}
65
65
66
66
function addSignatureReturns ( f ) {
67
67
var returnTypes = helper . getSignatureReturns ( f ) ;
68
-
68
+
69
69
f . signature = '<span class="signature">' + ( f . signature || '' ) + '</span>' ;
70
-
70
+
71
71
if ( returnTypes . length ) {
72
72
f . signature += '<span class="glyphicon glyphicon-circle-arrow-right"></span><span class="type-signature returnType">' + ( returnTypes . length ? '{' + returnTypes . join ( '|' ) + '}' : '' ) + '</span>' ;
73
73
}
74
74
}
75
75
76
76
function addSignatureTypes ( f ) {
77
77
var types = helper . getSignatureTypes ( f ) ;
78
-
78
+
79
79
f . signature = ( f . signature || '' ) + '<span class="type-signature">' + ( types . length ? ' :' + types . join ( '|' ) : '' ) + '</span>' ;
80
80
}
81
81
@@ -84,7 +84,7 @@ function addAttribs(f) {
84
84
85
85
if ( attribs . length ) {
86
86
f . attribs = '<span class="type-signature ' + ( attribs [ 0 ] === 'static' ? 'static' : '' ) + '">' + htmlsafe ( attribs . length ? attribs . join ( ',' ) : '' ) + '</span>' ;
87
- }
87
+ }
88
88
}
89
89
90
90
function shortenPaths ( files , commonPrefix ) {
@@ -108,7 +108,7 @@ function getPathFromDoclet(doclet) {
108
108
doclet . meta . path + '/' + doclet . meta . filename :
109
109
doclet . meta . filename ;
110
110
}
111
-
111
+
112
112
function generate ( title , docs , filename , resolveLinks ) {
113
113
resolveLinks = resolveLinks === false ? false : true ;
114
114
@@ -117,13 +117,13 @@ function generate(title, docs, filename, resolveLinks) {
117
117
title : title ,
118
118
docs : docs
119
119
} ;
120
-
120
+
121
121
var outpath = path . join ( outdir , filename ) ,
122
122
html = view . render ( 'container.tmpl' , docData ) ;
123
-
123
+
124
124
if ( resolveLinks ) {
125
125
html = helper . resolveLinks ( html ) ; // turn {@link foo } into <a href="foodoc.html">foo</a>
126
-
126
+
127
127
// Add a link target for external links @davidshimjs
128
128
html = html . toString ( ) . replace ( / < a \s + ( [ ^ > ] * h r e f \s * = \s * [ ' " ] * [ ^ \s ' " ] * : \/ \/ ) / ig, '<a target="_blank" $1' ) ;
129
129
}
@@ -158,7 +158,7 @@ function generateSourceFiles(sourceFiles) {
158
158
* exports only that class or function), then attach the classes or functions to the `module`
159
159
* property of the appropriate module doclets. The name of each class or function is also updated
160
160
* for display purposes. This function mutates the original arrays.
161
- *
161
+ *
162
162
* @private
163
163
* @param {Array.<module:jsdoc/doclet.Doclet> } doclets - The array of classes and functions to
164
164
* check.
@@ -248,6 +248,32 @@ function buildNav(members) {
248
248
} ) ;
249
249
}
250
250
251
+ if ( members . modules . length ) {
252
+ _ . each ( members . modules , function ( v ) {
253
+ nav . push ( {
254
+ type : 'module' ,
255
+ longname : v . longname ,
256
+ name : v . name ,
257
+ members : find ( {
258
+ kind : 'member' ,
259
+ memberof : v . longname
260
+ } ) ,
261
+ methods : find ( {
262
+ kind : 'function' ,
263
+ memberof : v . longname
264
+ } ) ,
265
+ typedefs : find ( {
266
+ kind : 'typedef' ,
267
+ memberof : v . longname
268
+ } ) ,
269
+ events : find ( {
270
+ kind : 'event' ,
271
+ memberof : v . longname
272
+ } )
273
+ } ) ;
274
+ } ) ;
275
+ }
276
+
251
277
return nav ;
252
278
}
253
279
@@ -265,7 +291,7 @@ exports.publish = function(taffyData, opts, tutorials) {
265
291
266
292
var templatePath = opts . template ;
267
293
view = new template . Template ( templatePath + '/tmpl' ) ;
268
-
294
+
269
295
// claim some special filenames in advance, so the All-Powerful Overseer of Filename Uniqueness
270
296
// doesn't try to hand them out later
271
297
var indexUrl = helper . getUniqueFilename ( 'index' ) ;
@@ -288,7 +314,7 @@ exports.publish = function(taffyData, opts, tutorials) {
288
314
var sourceFilePaths = [ ] ;
289
315
data ( ) . each ( function ( doclet ) {
290
316
doclet . attribs = '' ;
291
-
317
+
292
318
if ( doclet . examples ) {
293
319
doclet . examples = doclet . examples . map ( function ( example ) {
294
320
var caption , code ;
@@ -321,7 +347,7 @@ exports.publish = function(taffyData, opts, tutorials) {
321
347
sourceFilePaths . push ( sourcePath ) ;
322
348
}
323
349
} ) ;
324
-
350
+
325
351
// update outdir if necessary, then create outdir
326
352
var packageInfo = ( find ( { kind : 'package' } ) || [ ] ) [ 0 ] ;
327
353
if ( packageInfo && packageInfo . name ) {
@@ -360,7 +386,7 @@ exports.publish = function(taffyData, opts, tutorials) {
360
386
} ) ;
361
387
} ) ;
362
388
}
363
-
389
+
364
390
if ( sourceFilePaths . length ) {
365
391
sourceFiles = shortenPaths ( sourceFiles , path . commonPrefix ( sourceFilePaths ) ) ;
366
392
}
@@ -378,7 +404,7 @@ exports.publish = function(taffyData, opts, tutorials) {
378
404
}
379
405
}
380
406
} ) ;
381
-
407
+
382
408
data ( ) . each ( function ( doclet ) {
383
409
var url = helper . longnameToUrl [ doclet . longname ] ;
384
410
@@ -388,14 +414,14 @@ exports.publish = function(taffyData, opts, tutorials) {
388
414
else {
389
415
doclet . id = doclet . name ;
390
416
}
391
-
417
+
392
418
if ( needsSignature ( doclet ) ) {
393
419
addSignatureParams ( doclet ) ;
394
420
addSignatureReturns ( doclet ) ;
395
421
addAttribs ( doclet ) ;
396
422
}
397
423
} ) ;
398
-
424
+
399
425
// do this after the urls have all been generated
400
426
data ( ) . each ( function ( doclet ) {
401
427
doclet . ancestors = getAncestorLinks ( doclet ) ;
@@ -404,14 +430,14 @@ exports.publish = function(taffyData, opts, tutorials) {
404
430
addSignatureTypes ( doclet ) ;
405
431
addAttribs ( doclet ) ;
406
432
}
407
-
433
+
408
434
if ( doclet . kind === 'constant' ) {
409
435
addSignatureTypes ( doclet ) ;
410
436
addAttribs ( doclet ) ;
411
437
doclet . kind = 'member' ;
412
438
}
413
439
} ) ;
414
-
440
+
415
441
var members = helper . getMembers ( data ) ;
416
442
members . tutorials = tutorials . children ;
417
443
@@ -435,7 +461,7 @@ exports.publish = function(taffyData, opts, tutorials) {
435
461
}
436
462
437
463
if ( members . globals . length ) { generate ( 'Global' , [ { kind : 'globalobj' } ] , globalUrl ) ; }
438
-
464
+
439
465
// index page displays information from package.json and lists files
440
466
var files = find ( { kind : 'file' } ) ,
441
467
packages = find ( { kind : 'package' } ) ;
@@ -452,14 +478,14 @@ exports.publish = function(taffyData, opts, tutorials) {
452
478
var namespaces = taffy ( members . namespaces ) ;
453
479
var mixins = taffy ( members . mixins ) ;
454
480
var externals = taffy ( members . externals ) ;
455
-
481
+
456
482
for ( var longname in helper . longnameToUrl ) {
457
483
if ( hasOwnProp . call ( helper . longnameToUrl , longname ) ) {
458
484
var myClasses = helper . find ( classes , { longname : longname } ) ;
459
485
if ( myClasses . length ) {
460
486
generate ( 'Class: ' + myClasses [ 0 ] . name , myClasses , helper . longnameToUrl [ longname ] ) ;
461
487
}
462
-
488
+
463
489
var myModules = helper . find ( modules , { longname : longname } ) ;
464
490
if ( myModules . length ) {
465
491
generate ( 'Module: ' + myModules [ 0 ] . name , myModules , helper . longnameToUrl [ longname ] ) ;
@@ -469,7 +495,7 @@ exports.publish = function(taffyData, opts, tutorials) {
469
495
if ( myNamespaces . length ) {
470
496
generate ( 'Namespace: ' + myNamespaces [ 0 ] . name , myNamespaces , helper . longnameToUrl [ longname ] ) ;
471
497
}
472
-
498
+
473
499
var myMixins = helper . find ( mixins , { longname : longname } ) ;
474
500
if ( myMixins . length ) {
475
501
generate ( 'Mixin: ' + myMixins [ 0 ] . name , myMixins , helper . longnameToUrl [ longname ] ) ;
@@ -490,16 +516,16 @@ exports.publish = function(taffyData, opts, tutorials) {
490
516
content : tutorial . parse ( ) ,
491
517
children : tutorial . children
492
518
} ;
493
-
519
+
494
520
var tutorialPath = path . join ( outdir , filename ) ,
495
521
html = view . render ( 'tutorial.tmpl' , tutorialData ) ;
496
-
522
+
497
523
// yes, you can use {@link } in tutorials too!
498
524
html = helper . resolveLinks ( html ) ; // turn {@link foo } into <a href="foodoc.html">foo</a>
499
-
525
+
500
526
fs . writeFileSync ( tutorialPath , html , 'utf8' ) ;
501
527
}
502
-
528
+
503
529
// tutorials can have only one parent so there is no risk for loops
504
530
function saveChildren ( node ) {
505
531
node . children . forEach ( function ( child ) {
0 commit comments