@@ -143,7 +143,7 @@ var keepTags = [
143
143
144
144
// parses a comment into text and tags
145
145
function parseComment ( comment ) {
146
- var lines = comment . replace ( / ^ * \/ \* \* * | ^ * \* \/ | * \* \/ * $ | ^ * \* * / mg, "" ) . trim ( ) . split ( / \r ? \n / g) ;
146
+ var lines = comment . replace ( / ^ * \/ \* \* * | ^ * \* \/ | * \* \/ * $ | ^ * \* * / mg, "" ) . trim ( ) . split ( / \r ? \n | \r / g) ; // property.description has just "\r" ?!
147
147
var desc ;
148
148
var text = [ ] ;
149
149
var tags = null ;
@@ -174,7 +174,6 @@ function writeComment(comment, otherwiseNewline) {
174
174
writeln ( ) ;
175
175
return ;
176
176
}
177
-
178
177
if ( typeof comment !== "object" )
179
178
comment = parseComment ( comment ) ;
180
179
comment . tags = comment . tags . filter ( function ( tag ) {
@@ -187,7 +186,10 @@ function writeComment(comment, otherwiseNewline) {
187
186
}
188
187
writeln ( "/**" ) ;
189
188
comment . text . forEach ( function ( line ) {
190
- writeln ( " * " , line ) ;
189
+ if ( line . length )
190
+ writeln ( " * " , line ) ;
191
+ else
192
+ writeln ( " *" ) ;
191
193
} ) ;
192
194
comment . tags . forEach ( function ( tag ) {
193
195
var started = false ;
@@ -393,8 +395,12 @@ function writeInterfaceBody(element) {
393
395
write ( "}" ) ;
394
396
}
395
397
396
- function writeProperty ( property ) {
397
- writeComment ( property . comment ) ;
398
+ function writeProperty ( property , withLet ) {
399
+ writeComment ( property . description ) ;
400
+ if ( ! / ^ [ \w $ ] + $ / . test ( property . name ) ) // incompatible
401
+ write ( "// " ) ;
402
+ if ( withLet )
403
+ write ( "let " ) ;
398
404
write ( property . name ) ;
399
405
if ( property . optional )
400
406
write ( "?" ) ;
@@ -454,6 +460,16 @@ function handleNamespace(element/*, parent*/) {
454
460
if ( ! children . length )
455
461
return ;
456
462
var first = true ;
463
+ if ( element . properties )
464
+ element . properties . forEach ( function ( property ) {
465
+ if ( first ) {
466
+ begin ( element ) ;
467
+ writeln ( "namespace " , element . name , " {" ) ;
468
+ ++ indent ;
469
+ first = false ;
470
+ }
471
+ writeProperty ( property , true ) ;
472
+ } ) ;
457
473
children . forEach ( function ( child ) {
458
474
if ( child . scope === "inner" || seen [ child . longname ] )
459
475
return ;
@@ -521,7 +537,9 @@ function handleClass(element, parent) {
521
537
522
538
// properties
523
539
if ( is_interface && element . properties )
524
- element . properties . forEach ( writeProperty ) ;
540
+ element . properties . forEach ( function ( property ) {
541
+ writeProperty ( property ) ;
542
+ } ) ;
525
543
526
544
// class-compatible members
527
545
var incompatible = [ ] ;
0 commit comments