@@ -126,6 +126,20 @@ export class MarkdownCommand extends MarkdownBase {
126126 }
127127 }
128128
129+ if ( parameters . length > 0 ) {
130+ lines . push ( '## Flags' ) ;
131+ lines . push ( '' ) ;
132+ lines . push ( '<!-- prettier-ignore-start -->' ) ;
133+ lines . push ( '| Flag Name (Long) | Flag Name (Short) | Description |' ) ;
134+ lines . push ( '|------------------|-------------------|-------------|' ) ;
135+ for ( const param of parameters ) {
136+ lines . push ( renderFlagRow ( param ) ) ;
137+ }
138+ lines . push ( '' ) ;
139+ lines . push ( '<!-- prettier-ignore-end -->' ) ;
140+ lines . push ( '' ) ;
141+ }
142+
129143 if ( this . examples . length > 0 ) {
130144 lines . push ( `## Examples for ${ this . commandName } ` ) ;
131145 lines . push ( '' ) ;
@@ -143,20 +157,6 @@ export class MarkdownCommand extends MarkdownBase {
143157 }
144158 }
145159
146- if ( parameters . length > 0 ) {
147- lines . push ( '## Flags' ) ;
148- lines . push ( '' ) ;
149- lines . push ( '<!-- prettier-ignore-start -->' ) ;
150- lines . push ( '| Flag | Description |' ) ;
151- lines . push ( '|----------------------------------------|-------------|' ) ;
152- for ( const param of parameters ) {
153- lines . push ( renderFlagRow ( param ) ) ;
154- }
155- lines . push ( '' ) ;
156- lines . push ( '<!-- prettier-ignore-end -->' ) ;
157- lines . push ( '' ) ;
158- }
159-
160160 return lines . join ( '\n' ) ;
161161 }
162162}
@@ -241,33 +241,32 @@ function resolveDisclaimer(
241241}
242242
243243function renderFlagRow ( param : CommandParameterData ) : string {
244- const flagLabel = renderFlagLabel ( param ) ;
244+ const longFlag = `\`--${ param . name } \`` ;
245+ const shortFlag = param . char ? `\`-${ param . char } \`` : 'N/A' ;
245246 const desc = renderFlagDescription ( param ) ;
246- return `| ${ flagLabel } | ${ desc } |` ;
247- }
248-
249- function renderFlagLabel ( param : CommandParameterData ) : string {
250- const parts : string [ ] = [ ] ;
251- if ( param . char ) parts . push ( `\`-${ param . char } \`` ) ;
252- const longFlag = param . hasValue ? `\`--${ param . name } ${ param . name . toUpperCase ( ) } \`` : `\`--${ param . name } \`` ;
253- parts . push ( longFlag ) ;
254- return parts . join ( ', ' ) ;
247+ return `| ${ longFlag } | ${ shortFlag } | ${ desc } |` ;
255248}
256249
257250function renderFlagDescription ( param : CommandParameterData ) : string {
258- const parts : string [ ] = [ ] ;
251+ const metadataParts : string [ ] = [ ] ;
259252 if ( param . deprecated ) {
260253 const toNote = param . deprecated . to ? ` Use \`--${ param . deprecated . to } \` instead.` : '' ;
261- parts . push ( `**This flag is deprecated.${ toNote } **` ) ;
254+ metadataParts . push ( `**This flag is deprecated.${ toNote } **` ) ;
262255 }
263- if ( ! param . optional ) parts . push ( '**Required**' ) ;
256+ const flagType = param . hasValue ? 'Value' : 'Boolean' ;
257+ metadataParts . push ( `**Type:** ${ flagType } ` ) ;
258+ if ( ! param . optional ) metadataParts . push ( '**Required**' ) ;
264259 if ( param . options ?. length ) {
265- parts . push ( `**Valid Values:** ${ param . options . map ( ( o ) => `\`${ o } \`` ) . join ( ', ' ) } ` ) ;
260+ metadataParts . push ( `**Valid Values:** ${ param . options . map ( ( o ) => `\`${ o } \`` ) . join ( ', ' ) } ` ) ;
266261 }
267- if ( param . defaultFlagValue ) parts . push ( `**Default value:** \`${ param . defaultFlagValue } \`` ) ;
262+ if ( param . defaultFlagValue ) metadataParts . push ( `**Default value:** \`${ param . defaultFlagValue } \`` ) ;
263+
268264 const desc = convertHyphenListsToMarkdown (
269265 param . description . map ( ( p ) => applyCodeFormatting ( escapeAngleBrackets ( p . replace ( / \| / g, '|' ) ) ) )
270266 ) . join ( '<br><br>' ) ;
267+
268+ const parts : string [ ] = [ metadataParts . join ( '<br>' ) ] ;
271269 if ( desc ) parts . push ( desc ) ;
272- return parts . join ( '<br>' ) . replace ( / \n / g, ' ' ) ;
270+
271+ return parts . join ( '<br><br>' ) . replace ( / \n / g, ' ' ) ;
273272}
0 commit comments