@@ -36,7 +36,6 @@ import {
36
36
Navigation ,
37
37
} from '@discordjs/api-extractor-model' ;
38
38
import type * as tsdoc from '@microsoft/tsdoc' ;
39
- import { TSDocParser } from '@microsoft/tsdoc' ;
40
39
import { DeclarationReference } from '@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference.js' ;
41
40
import { JsonFile , Path } from '@rushstack/node-core-library' ;
42
41
import * as ts from 'typescript' ;
@@ -220,12 +219,16 @@ export class ApiModelGenerator {
220
219
221
220
private readonly _apiModel : ApiModel ;
222
221
222
+ private readonly _tsDocParser : tsdoc . TSDocParser ;
223
+
223
224
private readonly _referenceGenerator : DeclarationReferenceGenerator ;
224
225
225
226
public constructor ( collector : Collector ) {
226
227
this . _collector = collector ;
227
228
this . _apiModel = new ApiModel ( ) ;
228
229
this . _referenceGenerator = new DeclarationReferenceGenerator ( collector ) ;
230
+ // @ts -expect-error we reuse the private tsdocParser from collector here
231
+ this . _tsDocParser = collector . _tsdocParser ;
229
232
}
230
233
231
234
public get apiModel ( ) : ApiModel {
@@ -500,7 +503,7 @@ export class ApiModelGenerator {
500
503
const excerptTokens : IExcerptToken [ ] = this . _buildExcerptTokens ( astDeclaration , nodesToCapture ) ;
501
504
const apiItemMetadata : ApiItemMetadata = this . _collector . fetchApiItemMetadata ( astDeclaration ) ;
502
505
const docComment : tsdoc . DocComment | undefined = parent ?. construct
503
- ? new TSDocParser ( ) . parseString (
506
+ ? this . _tsDocParser . parseString (
504
507
`/*+\n * ${ fixLinkTags ( parent . construct . description ) } \n${
505
508
parent . construct . params
506
509
?. map ( ( param ) => ` * @param ${ param . name } - ${ fixLinkTags ( param . description ) } \n` )
@@ -586,7 +589,7 @@ export class ApiModelGenerator {
586
589
const excerptTokens : IExcerptToken [ ] = this . _buildExcerptTokens ( astDeclaration , nodesToCapture ) ;
587
590
const apiItemMetadata : ApiItemMetadata = this . _collector . fetchApiItemMetadata ( astDeclaration ) ;
588
591
const docComment : tsdoc . DocComment | undefined = jsDoc
589
- ? new TSDocParser ( ) . parseString (
592
+ ? this . _tsDocParser . parseString (
590
593
`/**\n * ${ fixLinkTags ( jsDoc . description ) } \n${ jsDoc . see ?. map ( ( see ) => ` * @see ${ see } \n` ) . join ( '' ) ?? '' } ${
591
594
jsDoc . deprecated
592
595
? ` * @deprecated ${
@@ -658,7 +661,7 @@ export class ApiModelGenerator {
658
661
const excerptTokens : IExcerptToken [ ] = this . _buildExcerptTokens ( astDeclaration , nodesToCapture ) ;
659
662
const apiItemMetadata : ApiItemMetadata = this . _collector . fetchApiItemMetadata ( astDeclaration ) ;
660
663
const docComment : tsdoc . DocComment | undefined = parent ?. construct
661
- ? new TSDocParser ( ) . parseString (
664
+ ? this . _tsDocParser . parseString (
662
665
`/*+\n * ${ fixLinkTags ( parent . construct . description ) } \n${
663
666
parent . construct . params
664
667
?. map ( ( param ) => ` * @param ${ param . name } - ${ fixLinkTags ( param . description ) } \n` )
@@ -789,7 +792,7 @@ export class ApiModelGenerator {
789
792
const excerptTokens : IExcerptToken [ ] = this . _buildExcerptTokens ( astDeclaration , nodesToCapture ) ;
790
793
const apiItemMetadata : ApiItemMetadata = this . _collector . fetchApiItemMetadata ( astDeclaration ) ;
791
794
const docComment : tsdoc . DocComment | undefined = jsDoc
792
- ? new TSDocParser ( ) . parseString (
795
+ ? this . _tsDocParser . parseString (
793
796
`/**\n * ${ fixLinkTags ( jsDoc . description ) } \n${
794
797
jsDoc . params ?. map ( ( param ) => ` * @param ${ param . name } - ${ fixLinkTags ( param . description ) } \n` ) . join ( '' ) ??
795
798
''
@@ -916,7 +919,7 @@ export class ApiModelGenerator {
916
919
const excerptTokens : IExcerptToken [ ] = this . _buildExcerptTokens ( astDeclaration , nodesToCapture ) ;
917
920
const apiItemMetadata : ApiItemMetadata = this . _collector . fetchApiItemMetadata ( astDeclaration ) ;
918
921
const docComment : tsdoc . DocComment | undefined = jsDoc
919
- ? new TSDocParser ( ) . parseString (
922
+ ? this . _tsDocParser . parseString (
920
923
`/**\n * ${ fixLinkTags ( jsDoc . description ) } \n${ jsDoc . see ?. map ( ( see ) => ` * @see ${ see } \n` ) . join ( '' ) ?? '' } ${
921
924
jsDoc . deprecated
922
925
? ` * @deprecated ${
@@ -980,7 +983,7 @@ export class ApiModelGenerator {
980
983
const excerptTokens : IExcerptToken [ ] = this . _buildExcerptTokens ( astDeclaration , nodesToCapture ) ;
981
984
const apiItemMetadata : ApiItemMetadata = this . _collector . fetchApiItemMetadata ( astDeclaration ) ;
982
985
const docComment : tsdoc . DocComment | undefined = jsDoc
983
- ? new TSDocParser ( ) . parseString (
986
+ ? this . _tsDocParser . parseString (
984
987
`/**\n * ${ fixLinkTags ( jsDoc . description ) } \n${
985
988
jsDoc . params ?. map ( ( param ) => ` * @param ${ param . name } - ${ fixLinkTags ( param . description ) } \n` ) . join ( '' ) ??
986
989
''
@@ -1058,7 +1061,7 @@ export class ApiModelGenerator {
1058
1061
const excerptTokens : IExcerptToken [ ] = this . _buildExcerptTokens ( astDeclaration , nodesToCapture ) ;
1059
1062
const apiItemMetadata : ApiItemMetadata = this . _collector . fetchApiItemMetadata ( astDeclaration ) ;
1060
1063
const docComment : tsdoc . DocComment | undefined = jsDoc
1061
- ? new TSDocParser ( ) . parseString (
1064
+ ? this . _tsDocParser . parseString (
1062
1065
`/**\n * ${ fixLinkTags ( jsDoc . description ) } \n${
1063
1066
jsDoc . params ?. map ( ( param ) => ` * @param ${ param . name } - ${ fixLinkTags ( param . description ) } \n` ) . join ( '' ) ??
1064
1067
''
@@ -1166,7 +1169,7 @@ export class ApiModelGenerator {
1166
1169
const excerptTokens : IExcerptToken [ ] = this . _buildExcerptTokens ( astDeclaration , nodesToCapture ) ;
1167
1170
const apiItemMetadata : ApiItemMetadata = this . _collector . fetchApiItemMetadata ( astDeclaration ) ;
1168
1171
const docComment : tsdoc . DocComment | undefined = jsDoc
1169
- ? new TSDocParser ( ) . parseString (
1172
+ ? this . _tsDocParser . parseString (
1170
1173
`/**\n * ${ fixLinkTags ( jsDoc . description ) } \n${
1171
1174
'see' in jsDoc ? jsDoc . see . map ( ( see ) => ` * @see ${ see } \n` ) . join ( '' ) : ''
1172
1175
} ${ 'readonly' in jsDoc && jsDoc . readonly ? ' * @readonly\n' : '' } ${
@@ -1229,7 +1232,7 @@ export class ApiModelGenerator {
1229
1232
const excerptTokens : IExcerptToken [ ] = this . _buildExcerptTokens ( astDeclaration , nodesToCapture ) ;
1230
1233
const apiItemMetadata : ApiItemMetadata = this . _collector . fetchApiItemMetadata ( astDeclaration ) ;
1231
1234
const docComment : tsdoc . DocComment | undefined = jsDoc
1232
- ? new TSDocParser ( ) . parseString (
1235
+ ? this . _tsDocParser . parseString (
1233
1236
`/**\n * ${ fixLinkTags ( jsDoc . description ) } \n${
1234
1237
'see' in jsDoc ? jsDoc . see . map ( ( see ) => ` * @see ${ see } \n` ) . join ( '' ) : ''
1235
1238
} ${ 'readonly' in jsDoc && jsDoc . readonly ? ' * @readonly\n' : '' } ${
@@ -1290,7 +1293,7 @@ export class ApiModelGenerator {
1290
1293
const excerptTokens : IExcerptToken [ ] = this . _buildExcerptTokens ( astDeclaration , nodesToCapture ) ;
1291
1294
const apiItemMetadata : ApiItemMetadata = this . _collector . fetchApiItemMetadata ( astDeclaration ) ;
1292
1295
const docComment : tsdoc . DocComment | undefined = jsDoc
1293
- ? new TSDocParser ( ) . parseString (
1296
+ ? this . _tsDocParser . parseString (
1294
1297
`/**\n * ${ fixLinkTags ( jsDoc . description ) ?? '' } \n${
1295
1298
'params' in jsDoc
1296
1299
? jsDoc . params . map ( ( param ) => ` * @param ${ param . name } - ${ fixLinkTags ( param . description ) } \n` ) . join ( '' )
@@ -1425,7 +1428,7 @@ export class ApiModelGenerator {
1425
1428
} ) ;
1426
1429
}
1427
1430
1428
- const docComment : tsdoc . DocComment | undefined = new TSDocParser ( ) . parseString (
1431
+ const docComment : tsdoc . DocComment | undefined = this . _tsDocParser . parseString (
1429
1432
`/**\n * ${ fixLinkTags ( jsDoc . description ) } \n${
1430
1433
jsDoc . params ?. map ( ( param ) => ` * @param ${ param . name } - ${ fixLinkTags ( param . description ) } \n` ) . join ( '' ) ?? ''
1431
1434
} ${ 'see' in jsDoc ? jsDoc . see . map ( ( see ) => ` * @see ${ see } \n` ) . join ( '' ) : '' } ${
0 commit comments