@@ -10,12 +10,12 @@ import { TypeScriptHelpers } from '../analyzer/TypeScriptHelpers';
1010import { Span } from '../analyzer/Span' ;
1111import { CollectorEntity } from '../collector/CollectorEntity' ;
1212import { AstDeclaration } from '../analyzer/AstDeclaration' ;
13- import { StringBuilder } from '@microsoft/tsdoc' ;
1413import { DeclarationMetadata } from '../collector/DeclarationMetadata' ;
1514import { SymbolMetadata } from '../collector/SymbolMetadata' ;
1615import { AstImport } from '../analyzer/AstImport' ;
1716import { AstSymbol } from '../analyzer/AstSymbol' ;
1817import { ExtractorMessage } from '../api/ExtractorMessage' ;
18+ import { StringWriter } from './StringWriter' ;
1919
2020export class ReviewFileGenerator {
2121 /**
@@ -33,30 +33,30 @@ export class ReviewFileGenerator {
3333 }
3434
3535 public static generateReviewFileContent ( collector : Collector ) : string {
36- const output : StringBuilder = new StringBuilder ( ) ;
36+ const stringWriter : StringWriter = new StringWriter ( ) ;
3737
38- output . append ( [
38+ stringWriter . writeLine ( [
3939 `## API Review File for "${ collector . workingPackage . name } "` ,
4040 `` ,
4141 `> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).` ,
4242 ``
4343 ] . join ( '\n' ) ) ;
4444
4545 // Write the opening delimiter for the Markdown code fence
46- output . append ( '\n ```ts\n \n') ;
46+ stringWriter . writeLine ( ' ```ts\n') ;
4747
4848 for ( const entity of collector . entities ) {
4949 if ( entity . exported ) {
5050 if ( entity . astEntity instanceof AstSymbol ) {
5151 // Emit all the declarations for this entry
5252 for ( const astDeclaration of entity . astEntity . astDeclarations || [ ] ) {
5353
54- output . append ( ReviewFileGenerator . _getAedocSynopsis ( collector , astDeclaration ) ) ;
54+ stringWriter . write ( ReviewFileGenerator . _getAedocSynopsis ( collector , astDeclaration ) ) ;
5555
5656 const span : Span = new Span ( astDeclaration . declaration ) ;
5757 ReviewFileGenerator . _modifySpan ( collector , span , entity , astDeclaration , false ) ;
58- span . writeModifiedText ( output ) ;
59- output . append ( '\n \n') ;
58+ span . writeModifiedText ( stringWriter . stringBuilder ) ;
59+ stringWriter . writeLine ( ' \n') ;
6060 }
6161 } else {
6262 // This definition is reexported from another package, so write it as an "export" line
@@ -65,47 +65,47 @@ export class ReviewFileGenerator {
6565 const astImport : AstImport = entity . astEntity ;
6666
6767 if ( astImport . exportName === '*' ) {
68- output . append ( `export * as ${ entity . nameForEmit } ` ) ;
68+ stringWriter . write ( `export * as ${ entity . nameForEmit } ` ) ;
6969 } else if ( entity . nameForEmit !== astImport . exportName ) {
70- output . append ( `export { ${ astImport . exportName } as ${ entity . nameForEmit } }` ) ;
70+ stringWriter . write ( `export { ${ astImport . exportName } as ${ entity . nameForEmit } }` ) ;
7171 } else {
72- output . append ( `export { ${ astImport . exportName } }` ) ;
72+ stringWriter . write ( `export { ${ astImport . exportName } }` ) ;
7373 }
74- output . append ( ` from '${ astImport . modulePath } ';\n ` ) ;
74+ stringWriter . writeLine ( ` from '${ astImport . modulePath } ';` ) ;
7575 }
7676 }
7777 }
7878
7979 if ( collector . starExportedExternalModulePaths . length > 0 ) {
80- output . append ( '\n' ) ;
80+ stringWriter . writeLine ( ) ;
8181 for ( const starExportedExternalModulePath of collector . starExportedExternalModulePaths ) {
82- output . append ( `export * from "${ starExportedExternalModulePath } ";\n ` ) ;
82+ stringWriter . writeLine ( `export * from "${ starExportedExternalModulePath } ";` ) ;
8383 }
8484 }
8585
8686 // Write the unassociated warnings at the bottom of the file
8787 const unassociatedMessages : ExtractorMessage [ ] = collector . messageRouter
8888 . fetchUnassociatedMessagesForReviewFile ( ) ;
8989 if ( unassociatedMessages . length > 0 ) {
90- output . append ( '\n' ) ;
91- ReviewFileGenerator . _writeLineAsComments ( output , 'Warnings were encountered during analysis:' ) ;
92- ReviewFileGenerator . _writeLineAsComments ( output , '' ) ;
90+ stringWriter . writeLine ( ) ;
91+ ReviewFileGenerator . _writeLineAsComments ( stringWriter , 'Warnings were encountered during analysis:' ) ;
92+ ReviewFileGenerator . _writeLineAsComments ( stringWriter , '' ) ;
9393 for ( const unassociatedMessage of unassociatedMessages ) {
94- ReviewFileGenerator . _writeLineAsComments ( output , unassociatedMessage . formatMessageWithLocation (
94+ ReviewFileGenerator . _writeLineAsComments ( stringWriter , unassociatedMessage . formatMessageWithLocation (
9595 collector . workingPackage . packageFolder
9696 ) ) ;
9797 }
9898 }
9999
100100 if ( collector . workingPackage . tsdocComment === undefined ) {
101- output . append ( '\n' ) ;
102- ReviewFileGenerator . _writeLineAsComments ( output , '(No @packageDocumentation comment for this package)' ) ;
101+ stringWriter . writeLine ( ) ;
102+ ReviewFileGenerator . _writeLineAsComments ( stringWriter , '(No @packageDocumentation comment for this package)' ) ;
103103 }
104104
105105 // Write the closing delimiter for the Markdown code fence
106- output . append ( '\n```\n ' ) ;
106+ stringWriter . writeLine ( '\n```' ) ;
107107
108- return output . toString ( ) ;
108+ return stringWriter . toString ( ) ;
109109 }
110110
111111 /**
@@ -230,7 +230,7 @@ export class ReviewFileGenerator {
230230 * by the analysis.
231231 */
232232 private static _getAedocSynopsis ( collector : Collector , astDeclaration : AstDeclaration ) : string {
233- const output : StringBuilder = new StringBuilder ( ) ;
233+ const output : StringWriter = new StringWriter ( ) ;
234234
235235 const messagesToReport : ExtractorMessage [ ] = collector . messageRouter
236236 . fetchAssociatedMessagesForReviewFile ( astDeclaration ) ;
@@ -287,12 +287,12 @@ export class ReviewFileGenerator {
287287 return output . toString ( ) ;
288288 }
289289
290- private static _writeLineAsComments ( output : StringBuilder , line : string ) : void {
290+ private static _writeLineAsComments ( stringWriter : StringWriter , line : string ) : void {
291291 const lines : string [ ] = Text . convertToLf ( line ) . split ( '\n' ) ;
292292 for ( const realLine of lines ) {
293- output . append ( '// ' ) ;
294- output . append ( realLine ) ;
295- output . append ( '\n' ) ;
293+ stringWriter . write ( '// ' ) ;
294+ stringWriter . write ( realLine ) ;
295+ stringWriter . writeLine ( ) ;
296296 }
297297 }
298298
0 commit comments