@@ -214,23 +214,25 @@ Doc.prototype = {
214
214
if ( atName ) {
215
215
var text = trim ( atText . join ( '\n' ) ) , match ;
216
216
if ( atName == 'param' ) {
217
- match = text . match ( / ^ \{ ( [ ^ } = ] + ) ( = ) ? \} \s + ( ( [ ^ \s = ] + ) | \[ ( \S + ) = ( [ ^ \] ] + ) \] ) \s + ( .* ) / ) ;
218
- // 1 12 2 34 4 5 5 6 6 3 7 7
217
+ match = text . match ( / ^ \{ ( [ ^ } ] + ) \} \s + ( ( [ ^ \s = ] + ) | \[ ( \S + ) = ( [ ^ \] ] + ) \] ) \s + ( .* ) / ) ;
218
+ // 1 1 23 3 4 4 5 5 2 6 6
219
219
if ( ! match ) {
220
- throw new Error ( "Not a valid 'param' format: " + text ) ;
220
+ throw new Error ( "Not a valid 'param' format: " + text + ' (found in: ' + self . file + ':' + self . line + ')' ) ;
221
221
}
222
+
223
+ var optional = ( match [ 1 ] . slice ( - 1 ) === '=' ) ;
222
224
var param = {
223
- name : match [ 5 ] || match [ 4 ] ,
224
- description :self . markdown ( text . replace ( match [ 0 ] , match [ 7 ] ) ) ,
225
- type : match [ 1 ] ,
226
- optional : ! ! match [ 2 ] ,
227
- 'default' :match [ 6 ]
225
+ name : match [ 4 ] || match [ 3 ] ,
226
+ description :self . markdown ( text . replace ( match [ 0 ] , match [ 6 ] ) ) ,
227
+ type : optional ? match [ 1 ] . substring ( 0 , match [ 1 ] . length - 1 ) : match [ 1 ] ,
228
+ optional : optional ,
229
+ 'default' :match [ 5 ]
228
230
} ;
229
231
self . param . push ( param ) ;
230
232
} else if ( atName == 'returns' || atName == 'return' ) {
231
- match = text . match ( / ^ \{ ( [ ^ } = ] + ) \} \s + ( .* ) / ) ;
233
+ match = text . match ( / ^ \{ ( [ ^ } ] + ) \} \s + ( .* ) / ) ;
232
234
if ( ! match ) {
233
- throw new Error ( "Not a valid 'returns' format: " + text + ' in ' + self . file + ':' + self . line ) ;
235
+ throw new Error ( "Not a valid 'returns' format: " + text + ' (found in: ' + self . file + ':' + self . line + ')' ) ;
234
236
}
235
237
self . returns = {
236
238
type : match [ 1 ] ,
@@ -245,7 +247,7 @@ Doc.prototype = {
245
247
} else if ( atName == 'property' ) {
246
248
match = text . match ( / ^ \{ ( \S + ) \} \s + ( \S + ) ( \s + ( .* ) ) ? / ) ;
247
249
if ( ! match ) {
248
- throw new Error ( "Not a valid 'property' format: " + text ) ;
250
+ throw new Error ( "Not a valid 'property' format: " + text + ' (found in: ' + self . file + ':' + self . line + ')' ) ;
249
251
}
250
252
var property = new Doc ( {
251
253
type : match [ 1 ] ,
@@ -383,40 +385,53 @@ Doc.prototype = {
383
385
var self = this ;
384
386
dom . h ( 'Usage' , function ( ) {
385
387
var restrict = self . restrict || 'AC' ;
388
+
386
389
if ( restrict . match ( / E / ) ) {
387
- dom . text ( 'as element (see ' ) ;
390
+ dom . text ( 'This directive can be used as custom element, but we aware of ' ) ;
388
391
dom . tag ( 'a' , { href :'guide/ie' } , 'IE restrictions' ) ;
389
- dom . text ( ')' ) ;
390
- dom . code ( function ( ) {
391
- dom . text ( '<' ) ;
392
- dom . text ( dashCase ( self . shortName ) ) ;
393
- renderParams ( '\n ' , '="' , '"' ) ;
394
- dom . text ( '>\n</' ) ;
395
- dom . text ( dashCase ( self . shortName ) ) ;
396
- dom . text ( '>' ) ;
397
- } ) ;
392
+ dom . text ( '.' ) ;
398
393
}
399
- if ( restrict . match ( / A / ) ) {
400
- var element = self . element || 'ANY' ;
401
- dom . text ( 'as attribute' ) ;
402
- dom . code ( function ( ) {
403
- dom . text ( '<' + element + ' ' ) ;
404
- dom . text ( dashCase ( self . shortName ) ) ;
405
- renderParams ( '\n ' , '="' , '"' , true ) ;
406
- dom . text ( '>\n ...\n' ) ;
407
- dom . text ( '</' + element + '>' ) ;
408
- } ) ;
409
- }
410
- if ( restrict . match ( / C / ) ) {
411
- dom . text ( 'as class' ) ;
412
- var element = self . element || 'ANY' ;
413
- dom . code ( function ( ) {
414
- dom . text ( '<' + element + ' class="' ) ;
415
- dom . text ( dashCase ( self . shortName ) ) ;
416
- renderParams ( ' ' , ': ' , ';' , true ) ;
417
- dom . text ( '">\n ...\n' ) ;
418
- dom . text ( '</' + element + '>' ) ;
394
+
395
+ if ( self . usage ) {
396
+ dom . tag ( 'pre' , function ( ) {
397
+ dom . tag ( 'code' , function ( ) {
398
+ dom . text ( self . usage ) ;
399
+ } ) ;
419
400
} ) ;
401
+ } else {
402
+ if ( restrict . match ( / E / ) ) {
403
+ dom . text ( 'as element:' ) ;
404
+ dom . code ( function ( ) {
405
+ dom . text ( '<' ) ;
406
+ dom . text ( dashCase ( self . shortName ) ) ;
407
+ renderParams ( '\n ' , '="' , '"' ) ;
408
+ dom . text ( '>\n</' ) ;
409
+ dom . text ( dashCase ( self . shortName ) ) ;
410
+ dom . text ( '>' ) ;
411
+ } ) ;
412
+ }
413
+ if ( restrict . match ( / A / ) ) {
414
+ var element = self . element || 'ANY' ;
415
+ dom . text ( 'as attribute' ) ;
416
+ dom . code ( function ( ) {
417
+ dom . text ( '<' + element + ' ' ) ;
418
+ dom . text ( dashCase ( self . shortName ) ) ;
419
+ renderParams ( '\n ' , '="' , '"' , true ) ;
420
+ dom . text ( '>\n ...\n' ) ;
421
+ dom . text ( '</' + element + '>' ) ;
422
+ } ) ;
423
+ }
424
+ if ( restrict . match ( / C / ) ) {
425
+ dom . text ( 'as class' ) ;
426
+ var element = self . element || 'ANY' ;
427
+ dom . code ( function ( ) {
428
+ dom . text ( '<' + element + ' class="' ) ;
429
+ dom . text ( dashCase ( self . shortName ) ) ;
430
+ renderParams ( ' ' , ': ' , ';' , true ) ;
431
+ dom . text ( '">\n ...\n' ) ;
432
+ dom . text ( '</' + element + '>' ) ;
433
+ } ) ;
434
+ }
420
435
}
421
436
self . html_usage_directiveInfo ( dom ) ;
422
437
self . html_usage_parameters ( dom ) ;
0 commit comments