@@ -29,6 +29,7 @@ const stringify = (
2929 jsdocSpaces,
3030 jsdocVerticalAlignment,
3131 jsdocDescriptionTag,
32+ tsdoc,
3233 useTabs,
3334 tabWidth,
3435 } = options ;
@@ -61,8 +62,22 @@ const stringify = (
6162 }
6263 if ( name ) tagString += `${ gap } ${ name } ${ " " . repeat ( tagNameGapAdj ) } ` ;
6364
64- // Add description (complicated because of text wrap)
65- if ( description && tag !== EXAMPLE ) {
65+ // Try to use prettier on @example tag description
66+ if ( tag === EXAMPLE && ! tsdoc ) {
67+ const exampleCaption = description . match ( / < c a p t i o n > ( [ \s \S ] * ?) < \/ c a p t i o n > / i) ;
68+
69+ if ( exampleCaption ) {
70+ description = description . replace ( exampleCaption [ 0 ] , "" ) ;
71+ tagString = `${ tagString } ${ exampleCaption [ 0 ] } ` ;
72+ }
73+
74+ const beginningSpace = useTabs ? "\t" : " " . repeat ( tabWidth ) ;
75+ const formattedExample = formatCode ( description , beginningSpace , options ) ;
76+ tagString += formattedExample . startsWith ( "\n" )
77+ ? formattedExample . trimEnd ( )
78+ : "\n" + formattedExample ;
79+ } // Add description (complicated because of text wrap)
80+ else if ( description ) {
6681 if ( useTagTitle ) tagString += gap + " " . repeat ( descGapAdj ) ;
6782 if (
6883 TAGS_PEV_FORMATE_DESCRIPTION . includes ( tag ) ||
@@ -85,22 +100,6 @@ const stringify = (
85100 }
86101 }
87102
88- // Try to use prettier on @example tag description
89- if ( tag === EXAMPLE ) {
90- const exampleCaption = description . match ( / < c a p t i o n > ( [ \s \S ] * ?) < \/ c a p t i o n > / i) ;
91-
92- if ( exampleCaption ) {
93- description = description . replace ( exampleCaption [ 0 ] , "" ) ;
94- tagString = `${ tagString } ${ exampleCaption [ 0 ] } ` ;
95- }
96-
97- const beginningSpace = useTabs ? "\t" : " " . repeat ( tabWidth ) ;
98- const formattedExample = formatCode ( description , beginningSpace , options ) ;
99- tagString += formattedExample . startsWith ( "\n" )
100- ? formattedExample . trimEnd ( )
101- : "\n" + formattedExample ;
102- }
103-
104103 // Add empty line after some tags if there is something below
105104 tagString += descriptionEndLine ( {
106105 description : tagString ,
0 commit comments