File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -90,6 +90,28 @@ export function renderJsDocList(items: string[]): string {
90
90
return items . map ( ( item ) => ` * ${ item . trim ( ) . replace ( / \n / g, '\n ' ) } ` ) . join ( '\n\n' ) ;
91
91
}
92
92
93
+ function renderJsDocTagAsPlainText ( tag : JsDocBlockTag ) : string {
94
+ let result = `${ tag . name } ` ;
95
+
96
+ if ( tag . value ) {
97
+ if ( tag . name === 'example' ) {
98
+ if ( tag . value . match ( / ^ [ \n \r \t ] / ) ) {
99
+ result += `:${ tag . value } ` ;
100
+ } else {
101
+ result += `:${ tag . value . replace ( / ^ ( [ ^ \n ] + ) \n / , ' "$1":\n```' ) } \`\`\`` ;
102
+ }
103
+ } else {
104
+ result += ':' ;
105
+ if ( ! tag . value . match ( / ^ [ \n \r \t ] / ) ) {
106
+ result += ' ' ;
107
+ }
108
+ result += tag . value ;
109
+ }
110
+ }
111
+
112
+ return result ;
113
+ }
114
+
93
115
export function renderJsDocAsPlainText ( jsdoc : JsDocBlock ) : string | null {
94
116
const bits : string [ ] = [ ] ;
95
117
const title = jsdoc . title && jsdoc . title . trim ( ) ;
@@ -101,7 +123,7 @@ export function renderJsDocAsPlainText(jsdoc: JsDocBlock): string | null {
101
123
bits . push ( description ) ;
102
124
}
103
125
if ( jsdoc . tags . length > 0 ) {
104
- bits . push ( jsdoc . tags . map ( ( { name , value } ) => ` ${ name } ${ value ? `: ${ value . trim ( ) } ` : '' } ` ) . join ( '\n' ) ) ;
126
+ bits . push ( jsdoc . tags . map ( renderJsDocTagAsPlainText ) . join ( '\n' ) ) ;
105
127
}
106
128
if ( bits . length === 0 ) {
107
129
return null ;
You can’t perform that action at this time.
0 commit comments