@@ -44,7 +44,13 @@ export class MarkdownCommand extends MarkdownBase {
4444 outputDir : string
4545 ) {
4646 const commandWithUnderscores = ensureString ( command . id ) . replace ( / : / g, '_' ) ;
47- const filename = MarkdownBase . file ( `cli_reference_${ commandWithUnderscores } ` ) ;
47+ // If the command ID has no subtopic (e.g. "doctor"), its filename would collide with the topic
48+ // index file (cli_reference_doctor.md), so append _command to disambiguate.
49+ const isTopicLevelCommand = ! ensureString ( command . id ) . includes ( ':' ) ;
50+ const baseName = isTopicLevelCommand
51+ ? `cli_reference_${ commandWithUnderscores } _command`
52+ : `cli_reference_${ commandWithUnderscores } ` ;
53+ const filename = MarkdownBase . file ( baseName ) ;
4854 super ( filename , outputDir ) ;
4955 this . destination = join ( outputDir , topic , filename ) ;
5056
@@ -112,8 +118,10 @@ export class MarkdownCommand extends MarkdownBase {
112118 if ( this . help . length > 0 ) {
113119 lines . push ( `## Description for ${ this . commandName } ` ) ;
114120 lines . push ( '' ) ;
115- for ( const paragraph of this . help ) {
116- lines . push ( applyCodeFormatting ( escapeAngleBrackets ( paragraph ) ) ) ;
121+ for ( const paragraph of convertHyphenListsToMarkdown (
122+ this . help . map ( ( p ) => applyCodeFormatting ( escapeAngleBrackets ( p ) ) )
123+ ) ) {
124+ lines . push ( paragraph ) ;
117125 lines . push ( '' ) ;
118126 }
119127 }
@@ -162,12 +170,37 @@ function applyCodeFormatting(text: string): string {
162170 let result = text . replace ( / (?< ! ` ) - - ( [ \w - ] + ) (? ! ` ) / g, '`--$1`' ) ;
163171 // Wrap glob patterns like *.cls, *.trigger (not already in backticks)
164172 result = result . replace ( / (?< ! ` ) \* ( \. \w + ) (? ! ` ) / g, '`*$1`' ) ;
173+ // Wrap filenames/extensions with known doc-related extensions (not already in backticks)
174+ // Must run compound extensions (.sarif.json) before simple ones (.sarif, .json)
175+ result = result . replace ( / (?< ! [ \w ` ] ) ( \. s a r i f \. j s o n ) (? ! [ \w ` ] ) / g, '`$1`' ) ;
176+ result = result . replace ( / (?< ! [ \w ` ] ) ( \w [ \w . - ] * \. (?: x m l | h t m l ? | j s o n | s a r i f | c s v ) ) (? ! [ \w ` ] ) / g, '`$1`' ) ;
177+ result = result . replace ( / (?< ! [ \w ` ] ) ( \. (?: x m l | h t m l ? | j s o n | s a r i f | c s v ) ) (? ! [ \w ` ] ) / g, '`$1`' ) ;
165178 // Wrap file/directory paths: must be preceded by whitespace or opening punctuation (not part of a URL)
166179 // Matches: ./foo/bar, ../foo, foo/bar/baz — but not https://foo/bar
167180 result = result . replace ( / ( ^ | (?< = [ \s ( [ " ] ) ) (? ! h t t p s ? : \/ \/ ) ( (?: \. { 1 , 2 } \/ | [ \w ] [ \w - ] * \/ ) [ \w . / - ] + ) / g, '$1`$2`' ) ;
168181 return result ;
169182}
170183
184+ function convertHyphenListsToMarkdown ( paragraphs : string [ ] ) : string [ ] {
185+ const result : string [ ] = [ ] ;
186+ let i = 0 ;
187+ while ( i < paragraphs . length ) {
188+ if ( paragraphs [ i ] . startsWith ( '- ' ) ) {
189+ // Collect consecutive list items and join with <br> for table cell rendering
190+ const items : string [ ] = [ ] ;
191+ while ( i < paragraphs . length && paragraphs [ i ] . startsWith ( '- ' ) ) {
192+ items . push ( paragraphs [ i ] ) ;
193+ i ++ ;
194+ }
195+ result . push ( items . join ( '<br>' ) ) ;
196+ } else {
197+ result . push ( paragraphs [ i ] ) ;
198+ i ++ ;
199+ }
200+ }
201+ return result ;
202+ }
203+
171204function resolveStateLabel ( state : unknown , deprecated : boolean ) : string | null {
172205 if ( deprecated ) return 'Deprecated' ;
173206 if ( state === 'beta' ) return 'Beta' ;
@@ -232,9 +265,9 @@ function renderFlagDescription(param: CommandParameterData): string {
232265 parts . push ( `**Valid Values:** ${ param . options . map ( ( o ) => `\`${ o } \`` ) . join ( ', ' ) } ` ) ;
233266 }
234267 if ( param . defaultFlagValue ) parts . push ( `**Default value:** \`${ param . defaultFlagValue } \`` ) ;
235- const desc = param . description
236- . map ( ( p ) => applyCodeFormatting ( escapeAngleBrackets ( p . replace ( / \| / g, '|' ) ) ) )
237- . join ( '<br><br>' ) ;
268+ const desc = convertHyphenListsToMarkdown (
269+ param . description . map ( ( p ) => applyCodeFormatting ( escapeAngleBrackets ( p . replace ( / \| / g, '|' ) ) ) )
270+ ) . join ( '<br><br>' ) ;
238271 if ( desc ) parts . push ( desc ) ;
239272 return parts . join ( '<br>' ) . replace ( / \n / g, ' ' ) ;
240273}
0 commit comments