@@ -18,6 +18,9 @@ var TypeScriptDocGenerator = (function () {
1818 this . sourceUnit = this . tree . sourceUnit ( ) ;
1919 this . lineMap = this . tree . lineMap ( ) ;
2020 }
21+ TypeScriptDocGenerator . prototype . cleanEndLine = function ( str ) {
22+ return str . replace ( new RegExp ( '[' + "\r\n" + ']' , 'g' ) , "\n" ) . replace ( new RegExp ( '[' + "\r" + ']' , 'g' ) , "\n" ) ;
23+ } ;
2124 TypeScriptDocGenerator . prototype . completePrefix = function ( oldPrefix , appendedPrefix ) {
2225 if ( oldPrefix === "" ) {
2326 return appendedPrefix ;
@@ -54,11 +57,11 @@ var TypeScriptDocGenerator = (function () {
5457 var lc = this . lineMap . getLineAndCharacterFromPosition ( position ) ;
5558 var nbSpaces = lc . character ( ) ;
5659 var startLinePosition = this . lineMap . getLineStartPosition ( lc . line ( ) ) ;
57- var comment = "\n" + this . repeatSpaces ( nbSpaces ) + "/**\n" ;
60+ var comment = "\r\ n" + this . repeatSpaces ( nbSpaces ) + "/**\r \n" ;
5861 for ( var j = 0 ; j < commentLines . length ; j ++ ) {
59- comment += this . repeatSpaces ( nbSpaces ) + "* " + commentLines [ j ] + "\n" ;
62+ comment += this . repeatSpaces ( nbSpaces ) + "* " + commentLines [ j ] . trim ( ) + "\r \n" ;
6063 }
61- comment += this . repeatSpaces ( nbSpaces ) + "*/\n" ;
64+ comment += this . repeatSpaces ( nbSpaces ) + "*/\r\ n" ;
6265 this . tsDefFileContent = this . tsDefFileContent . substr ( 0 , startLinePosition + this . nbCharsAdded ) + comment + this . tsDefFileContent . substr ( startLinePosition + this . nbCharsAdded ) ;
6366 this . nbCharsAdded += comment . length ;
6467 }
@@ -80,7 +83,7 @@ var TypeScriptDocGenerator = (function () {
8083 if ( c . members [ i ] . name === memberName ) {
8184 var m = c . members [ i ] ;
8285 var comments = [ ] ;
83- comments = comments . concat ( m . description . split ( "\n" ) ) ;
86+ comments = comments . concat ( this . cleanEndLine ( m . description ) . split ( "\n" ) ) ;
8487 if ( ( m . default != null ) && ( m . default !== "" ) ) {
8588 comments . push ( "Default: " + m . default ) ;
8689 }
@@ -96,7 +99,7 @@ var TypeScriptDocGenerator = (function () {
9699 var c = this . findClass ( className ) ;
97100 if ( c != null ) {
98101 var comments = [ ] ;
99- comments = comments . concat ( c . description . split ( "\n" ) ) ;
102+ comments = comments . concat ( this . cleanEndLine ( c . description ) . split ( "\n" ) ) ;
100103 return comments ;
101104 }
102105 else {
@@ -108,7 +111,7 @@ var TypeScriptDocGenerator = (function () {
108111 if ( c != null ) {
109112 var con = c . constructor ;
110113 var comments = [ ] ;
111- comments = comments . concat ( con . description . split ( "\n" ) ) ;
114+ comments = comments . concat ( this . cleanEndLine ( con . description ) . split ( "\n" ) ) ;
112115 if ( con . parameters . length > 0 ) {
113116 comments . push ( "" ) ;
114117 }
@@ -121,7 +124,7 @@ var TypeScriptDocGenerator = (function () {
121124 if ( ( p . default != null ) && ( p . default !== "" ) ) {
122125 def = " - Default: " + p . default ;
123126 }
124- var paramComments = p . description . split ( "\n" ) ;
127+ var paramComments = this . cleanEndLine ( p . description ) . split ( "\n" ) ;
125128 for ( var k = 0 ; k < paramComments . length ; k ++ ) {
126129 if ( k === 0 ) {
127130 comments . push ( "@param " + p . name + " " + paramComments [ k ] . trim ( ) + ( ( k === paramComments . length - 1 ) ? def : "" ) ) ;
@@ -144,7 +147,7 @@ var TypeScriptDocGenerator = (function () {
144147 if ( c . functions [ i ] . name === functionName ) {
145148 var f = c . functions [ i ] ;
146149 var comments = [ ] ;
147- comments = comments . concat ( f . description . split ( "\n" ) ) ;
150+ comments = comments . concat ( this . cleanEndLine ( f . description ) . split ( "\n" ) ) ;
148151 if ( f . parameters . length > 0 ) {
149152 comments . push ( "" ) ;
150153 }
@@ -158,7 +161,7 @@ var TypeScriptDocGenerator = (function () {
158161 def = " - Default: " + p . default ;
159162 }
160163
161- var paramComments = p . description . split ( "\n" ) ;
164+ var paramComments = this . cleanEndLine ( p . description ) . split ( "\n" ) ;
162165 for ( var k = 0 ; k < paramComments . length ; k ++ )
163166 {
164167 if ( k === 0 )
@@ -173,7 +176,16 @@ var TypeScriptDocGenerator = (function () {
173176
174177 }
175178 if ( f . returns != null ) {
176- comments . push ( "@return " + f . returns . description ) ;
179+ var returnComments = this . cleanEndLine ( f . returns . description ) . split ( "\n" ) ;
180+ for ( var l = 0 ; l < returnComments . length ; l ++ ) {
181+ if ( l === 0 ) {
182+ comments . push ( "@return " + returnComments [ l ] . trim ( ) ) ;
183+ }
184+ else
185+ {
186+ comments . push ( this . repeatSpaces ( ( "@return " ) . length ) + returnComments [ l ] . trim ( ) ) ;
187+ }
188+ }
177189 }
178190 return comments ;
179191 }
0 commit comments