@@ -143,7 +143,7 @@ var keepTags = [
143143
144144// parses a comment into text and tags
145145function 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" ?!
147147 var desc ;
148148 var text = [ ] ;
149149 var tags = null ;
@@ -174,7 +174,6 @@ function writeComment(comment, otherwiseNewline) {
174174 writeln ( ) ;
175175 return ;
176176 }
177-
178177 if ( typeof comment !== "object" )
179178 comment = parseComment ( comment ) ;
180179 comment . tags = comment . tags . filter ( function ( tag ) {
@@ -187,7 +186,10 @@ function writeComment(comment, otherwiseNewline) {
187186 }
188187 writeln ( "/**" ) ;
189188 comment . text . forEach ( function ( line ) {
190- writeln ( " * " , line ) ;
189+ if ( line . length )
190+ writeln ( " * " , line ) ;
191+ else
192+ writeln ( " *" ) ;
191193 } ) ;
192194 comment . tags . forEach ( function ( tag ) {
193195 var started = false ;
@@ -393,8 +395,12 @@ function writeInterfaceBody(element) {
393395 write ( "}" ) ;
394396}
395397
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 " ) ;
398404 write ( property . name ) ;
399405 if ( property . optional )
400406 write ( "?" ) ;
@@ -454,6 +460,16 @@ function handleNamespace(element/*, parent*/) {
454460 if ( ! children . length )
455461 return ;
456462 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+ } ) ;
457473 children . forEach ( function ( child ) {
458474 if ( child . scope === "inner" || seen [ child . longname ] )
459475 return ;
@@ -521,7 +537,9 @@ function handleClass(element, parent) {
521537
522538 // properties
523539 if ( is_interface && element . properties )
524- element . properties . forEach ( writeProperty ) ;
540+ element . properties . forEach ( function ( property ) {
541+ writeProperty ( property ) ;
542+ } ) ;
525543
526544 // class-compatible members
527545 var incompatible = [ ] ;
0 commit comments