@@ -348,28 +348,59 @@ Doc.prototype = {
348
348
349
349
} ,
350
350
351
+ prepare_type_hint_class_name : function ( type ) {
352
+ var typeClass = type . toLowerCase ( ) . match ( / ^ [ - \w ] + / ) || [ ] ;
353
+ typeClass = typeClass [ 0 ] ? typeClass [ 0 ] : 'object' ;
354
+ return 'label type-hint type-hint-' + typeClass ;
355
+ } ,
356
+
351
357
html_usage_parameters : function ( dom ) {
352
- dom . h ( 'Parameters' , this . param , function ( param ) {
353
- dom . tag ( 'code' , function ( ) {
354
- dom . text ( param . name ) ;
355
- if ( param . optional ) {
356
- dom . tag ( 'i' , function ( ) {
357
- dom . text ( '(optional' ) ;
358
- if ( param [ 'default' ] ) {
359
- dom . text ( '=' + param [ 'default' ] ) ;
360
- }
361
- dom . text ( ')' ) ;
362
- } ) ;
358
+ var self = this ;
359
+ var params = this . param ? this . param : [ ] ;
360
+ if ( params . length > 0 ) {
361
+ dom . html ( '<h2 id="parameters">Parameters</h2>' ) ;
362
+ dom . html ( '<table class="variables-matrix table table-bordered table-striped">' ) ;
363
+ dom . html ( '<thead>' ) ;
364
+ dom . html ( '<tr>' ) ;
365
+ dom . html ( '<th>Param</th>' ) ;
366
+ dom . html ( '<th>Type</th>' ) ;
367
+ dom . html ( '<th>Details</th>' ) ;
368
+ dom . html ( '</tr>' ) ;
369
+ dom . html ( '</thead>' ) ;
370
+ dom . html ( '<tbody>' ) ;
371
+ for ( var i = 0 ; i < params . length ; i ++ ) {
372
+ param = params [ i ] ;
373
+ var name = param . name ;
374
+ var types = param . type ;
375
+ if ( types [ 0 ] == '(' ) {
376
+ types = types . substr ( 1 ) ;
363
377
}
364
- dom . text ( ' – {' ) ;
365
- dom . text ( param . type ) ;
378
+
379
+ var limit = types . length - 1 ;
380
+ if ( types . charAt ( limit ) == ')' && types . charAt ( limit - 1 ) != '(' ) {
381
+ types = types . substr ( 0 , limit ) ;
382
+ }
383
+ types = types . split ( / \| (? ! [ \( \) \w \| \s ] + > ) / ) ;
384
+ var description = param . description ;
366
385
if ( param . optional ) {
367
- dom . text ( '=' ) ;
386
+ name += ' <div><em>(optional)</em></div>' ;
368
387
}
369
- dom . text ( '} – ' ) ;
370
- } ) ;
371
- dom . html ( param . description ) ;
372
- } ) ;
388
+ dom . html ( '<tr>' ) ;
389
+ dom . html ( '<td>' + name + '</td>' ) ;
390
+ dom . html ( '<td>' ) ;
391
+ for ( var j = 0 ; j < types . length ; j ++ ) {
392
+ var type = types [ j ] ;
393
+ dom . html ( '<a href="" class="' + self . prepare_type_hint_class_name ( type ) + '">' ) ;
394
+ dom . text ( type ) ;
395
+ dom . html ( '</a>' ) ;
396
+ }
397
+ dom . html ( '</td>' ) ;
398
+ dom . html ( '<td>' + description + '</td>' ) ;
399
+ dom . html ( '</tr>' ) ;
400
+ } ;
401
+ dom . html ( '</tbody>' ) ;
402
+ dom . html ( '</table>' ) ;
403
+ }
373
404
if ( this . animations ) {
374
405
dom . h ( 'Animations' , this . animations , function ( animations ) {
375
406
dom . html ( '<ul>' ) ;
@@ -387,11 +418,19 @@ Doc.prototype = {
387
418
html_usage_returns : function ( dom ) {
388
419
var self = this ;
389
420
if ( self . returns ) {
390
- dom . h ( 'Returns' , function ( ) {
391
- dom . tag ( 'code' , '{' + self . returns . type + '}' ) ;
392
- dom . text ( '– ' ) ;
393
- dom . html ( self . returns . description ) ;
394
- } ) ;
421
+ dom . html ( '<h2 id="returns">Returns</h2>' ) ;
422
+ dom . html ( '<table class="variables-matrix">' ) ;
423
+ dom . html ( '<tr>' ) ;
424
+ dom . html ( '<td>' ) ;
425
+ dom . html ( '<a href="" class="' + self . prepare_type_hint_class_name ( self . returns . type ) + '">' ) ;
426
+ dom . text ( self . returns . type ) ;
427
+ dom . html ( '</a>' ) ;
428
+ dom . html ( '</td>' ) ;
429
+ dom . html ( '<td>' ) ;
430
+ dom . html ( self . returns . description ) ;
431
+ dom . html ( '</td>' ) ;
432
+ dom . html ( '</tr>' ) ;
433
+ dom . html ( '</table>' ) ;
395
434
}
396
435
} ,
397
436
0 commit comments