@@ -69,7 +69,7 @@ export function extractJsDoc(entity: AnnotatedApiEntity | boolean): JsDocBlock {
69
69
result . tags . push ( { name : 'deprecated' } ) ;
70
70
}
71
71
if ( entity . example !== undefined ) {
72
- result . tags . push ( { name : 'example' , value : exampleToString ( entity . example ) } ) ;
72
+ result . tags . push ( { name : 'example' , value : '\n' + exampleToString ( entity . example ) . trim ( ) } ) ;
73
73
}
74
74
if ( entity . examples !== undefined ) {
75
75
for ( const [ exampleName , example ] of Object . entries ( entity . examples ) ) {
@@ -79,7 +79,7 @@ export function extractJsDoc(entity: AnnotatedApiEntity | boolean): JsDocBlock {
79
79
}
80
80
result . tags . push ( {
81
81
name : 'example' ,
82
- value : `${ exampleInfo . length > 0 ? ` ${ exampleInfo . join ( '. ' ) } ` : '' } ${ exampleToString ( example . value ) } `
82
+ value : `${ exampleInfo . length > 0 ? ` ${ exampleInfo . join ( '. ' ) } ` : '' } \n ${ exampleToString ( example . value ) } `
83
83
} ) ;
84
84
}
85
85
}
@@ -113,6 +113,19 @@ const defaultWordWrapLineWidth = 80;
113
113
114
114
export type JsDocRenderConfig = OpenApiClientGeneratorConfig [ 'jsDoc' ] ;
115
115
116
+ function renderJsDocTag ( tag : JsDocBlockTag ) : string {
117
+ let result = `@${ tag . name } ` ;
118
+
119
+ if ( tag . value ) {
120
+ if ( ! tag . value . match ( / ^ [ \n \r \t ] / ) ) {
121
+ result += ' ' ;
122
+ }
123
+ result += tag . value ;
124
+ }
125
+
126
+ return result ;
127
+ }
128
+
116
129
export function renderJsDoc ( jsdoc : JsDocBlock , config : JsDocRenderConfig = { } ) : string | null {
117
130
function processText ( text : string ) {
118
131
if ( config ?. wordWrap !== false ) {
@@ -131,9 +144,7 @@ export function renderJsDoc(jsdoc: JsDocBlock, config: JsDocRenderConfig = {}):
131
144
jsdocParts . push ( processText ( description ) ) ;
132
145
}
133
146
if ( jsdoc . tags . length > 0 ) {
134
- jsdocParts . push (
135
- jsdoc . tags . map ( ( { name, value} ) => `@${ name } ${ value ? ` ${ processText ( value . trim ( ) ) } ` : '' } ` ) . join ( '\n' )
136
- ) ;
147
+ jsdocParts . push ( jsdoc . tags . map ( renderJsDocTag ) . join ( '\n' ) ) ;
137
148
}
138
149
if ( jsdocParts . length === 0 ) {
139
150
return null ;
0 commit comments