@@ -114,7 +114,7 @@ interface DocgenEventJson {
114114}
115115
116116interface DocgenParamJson {
117- default ?: string ;
117+ default ?: boolean | number | string ;
118118 description : string ;
119119 name : string ;
120120 nullable ?: boolean ;
@@ -155,7 +155,7 @@ interface DocgenMethodJson {
155155interface DocgenPropertyJson {
156156 abstract ?: boolean ;
157157 access ?: DocgenAccess ;
158- default ?: string ;
158+ default ?: boolean | number | string ;
159159 deprecated ?: DocgenDeprecated ;
160160 description : string ;
161161 meta : DocgenMetaJson ;
@@ -1264,7 +1264,7 @@ export class ApiModelGenerator {
12641264 const apiItemMetadata : ApiItemMetadata = this . _collector . fetchApiItemMetadata ( astDeclaration ) ;
12651265 const docComment : tsdoc . DocComment | undefined = jsDoc
12661266 ? this . _tsDocParser . parseString (
1267- `/**\n * ${ this . _fixLinkTags ( jsDoc . description ) ?? '' } ${ jsDoc . default === undefined ? '' : ` (default: ${ this . _escapeSpecialChars ( jsDoc . default ) } )` } \n${
1267+ `/**\n * ${ this . _fixLinkTags ( jsDoc . description ) ?? '' } ${ jsDoc . default ? ` (default: ${ this . _escapeSpecialChars ( jsDoc . default ) } )` : '' } \n${
12681268 'see' in jsDoc ? jsDoc . see . map ( ( see ) => ` * @see ${ see } \n` ) . join ( '' ) : ''
12691269 } ${ 'readonly' in jsDoc && jsDoc . readonly ? ' * @readonly\n' : '' } ${
12701270 'deprecated' in jsDoc && jsDoc . deprecated
@@ -1342,7 +1342,7 @@ export class ApiModelGenerator {
13421342 const apiItemMetadata : ApiItemMetadata = this . _collector . fetchApiItemMetadata ( astDeclaration ) ;
13431343 const docComment : tsdoc . DocComment | undefined = jsDoc
13441344 ? this . _tsDocParser . parseString (
1345- `/**\n * ${ this . _fixLinkTags ( jsDoc . description ) ?? '' } ${ jsDoc . default === undefined ? '' : `\n * @defaultValue ${ this . _escapeSpecialChars ( jsDoc . default ) } ` } \n${
1345+ `/**\n * ${ this . _fixLinkTags ( jsDoc . description ) ?? '' } ${ jsDoc . default ? ` (default: ${ this . _escapeSpecialChars ( jsDoc . default ) } )` : '' } \n${
13461346 'see' in jsDoc ? jsDoc . see . map ( ( see ) => ` * @see ${ see } \n` ) . join ( '' ) : ''
13471347 } ${ 'readonly' in jsDoc && jsDoc . readonly ? ' * @readonly\n' : '' } ${
13481348 'deprecated' in jsDoc && jsDoc . deprecated
@@ -1746,6 +1746,14 @@ export class ApiModelGenerator {
17461746 return sourceLocation ;
17471747 }
17481748
1749+ private _escapeSpecialChars ( input : boolean | number | string ) {
1750+ if ( typeof input !== 'string' ) {
1751+ return input ;
1752+ }
1753+
1754+ return input . replaceAll ( / (?< char > [ { } ] ) / g, '\\$<char>' ) ;
1755+ }
1756+
17491757 private _fixLinkTags ( input ?: string ) : string | undefined {
17501758 return input
17511759 ?. replaceAll ( linkRegEx , ( _match , _p1 , _p2 , _p3 , _p4 , _p5 , _offset , _string , groups ) => {
@@ -1823,7 +1831,7 @@ export class ApiModelGenerator {
18231831 isOptional : Boolean ( prop . nullable ) ,
18241832 isReadonly : Boolean ( prop . readonly ) ,
18251833 docComment : this . _tsDocParser . parseString (
1826- `/**\n * ${ this . _fixLinkTags ( prop . description ) ?? '' } \n${
1834+ `/**\n * ${ this . _fixLinkTags ( prop . description ) ?? '' } ${ prop . default ? ` (default: ${ this . _escapeSpecialChars ( prop . default ) } )` : '' } \n${
18271835 prop . see ?. map ( ( see ) => ` * @see ${ see } \n` ) . join ( '' ) ?? ''
18281836 } ${ prop . readonly ? ' * @readonly\n' : '' } */`,
18291837 ) . docComment ,
0 commit comments