@@ -28,6 +28,10 @@ function getAncestorLinks(doclet) {
28
28
return helper . getAncestorLinks ( data , doclet ) ;
29
29
}
30
30
31
+ function getCategoryLink ( className , cat ) {
32
+ return '<a href="' + className + '.html#' + cat . toLowerCase ( ) . replace ( / [ ^ a - z 0 - 9 ] / gi, '-' ) + '-methods">' + cat + ' methods</a>' ;
33
+ }
34
+
31
35
function hashToLink ( doclet , hash ) {
32
36
if ( ! / ^ ( # .+ ) / . test ( hash ) ) { return hash ; }
33
37
@@ -223,6 +227,11 @@ function buildNav(members) {
223
227
members . classes . forEach ( function ( c ) {
224
228
if ( ! hasOwnProp . call ( seen , c . longname ) ) {
225
229
classNav += '<li>' + linkto ( c . longname , c . name ) + '</li>' ;
230
+ if ( c . longname in members . categories ) {
231
+ classNav += '<ul>' + members . categories [ c . longname ] . reduce ( function ( nav , cat ) {
232
+ return nav + '<li> ' + getCategoryLink ( c . longname , cat ) + '</li>' ;
233
+ } , '' ) + '</ul>' ;
234
+ }
226
235
}
227
236
seen [ c . longname ] = true ;
228
237
} ) ;
@@ -465,6 +474,19 @@ exports.publish = function(taffyData, opts, tutorials) {
465
474
466
475
var members = helper . getMembers ( data ) ;
467
476
members . tutorials = tutorials . children ;
477
+ members . categories = data ( 'method' ) . get ( ) . reduce ( function ( cats , method ) {
478
+ if ( ! ( method . memberof in cats ) ) {
479
+ cats [ method . memberof ] = [ ] ;
480
+ }
481
+
482
+ var cat = method . category || 'Other' ;
483
+ if ( cats [ method . memberof ] . indexOf ( cat ) === - 1 ) {
484
+ cats [ method . memberof ] . push ( cat ) ;
485
+ cats [ method . memberof ] = cats [ method . memberof ] . sort ( ) ;
486
+ }
487
+
488
+ return cats ;
489
+ } , { } ) ;
468
490
469
491
// output pretty-printed source files by default
470
492
var outputSourceFiles = conf [ 'default' ] && conf [ 'default' ] . outputSourceFiles !== false ? true :
0 commit comments