@@ -401,10 +401,7 @@ pub fn run(workspace_root: &Path, check: bool) -> Result<()> {
401401 Ok ( ( ) )
402402}
403403
404- /// Run `auths <args> -h` and render a description + HTML flag table.
405- ///
406- /// The first 5 flags are shown immediately. If more exist, an expandable
407- /// `<details>` section exposes the rest.
404+ /// Run `auths <args> -h` and render a description + markdown flag table.
408405fn generate_table ( binary : & Path , args : & [ & str ] ) -> Result < String > {
409406 let mut full_args: Vec < & str > = args. to_vec ( ) ;
410407 full_args. push ( "-h" ) ;
@@ -421,84 +418,29 @@ fn generate_table(binary: &Path, args: &[&str]) -> Result<String> {
421418 let description = extract_description ( & text) ;
422419 let rows = parse_help_rows ( & text) ?;
423420
424- let mut html = String :: new ( ) ;
421+ let mut out = String :: new ( ) ;
425422 if !description. is_empty ( ) {
426- html . push_str ( & description) ;
427- html . push_str ( "\n \n " ) ;
423+ out . push_str ( & description) ;
424+ out . push_str ( "\n \n " ) ;
428425 }
429426
430427 if rows. is_empty ( ) {
431- html. push_str ( "_No options._" ) ;
432- return Ok ( html) ;
433- }
434-
435- const VISIBLE : usize = 5 ;
436- let has_overflow = rows. len ( ) > VISIBLE ;
437-
438- // Each expandable section needs a unique id so multiple sections on the
439- // same page don't conflict. We derive it from the first flag name.
440- let section_id = rows
441- . first ( )
442- . map ( |( f, _, _) | {
443- f. chars ( )
444- . filter ( |c| c. is_ascii_alphanumeric ( ) || * c == '-' )
445- . collect :: < String > ( )
446- } )
447- . unwrap_or_default ( ) ;
448-
449- if has_overflow {
450- html. push_str ( & format ! (
451- "<div class=\" flags-container\" >\n \
452- <input type=\" checkbox\" id=\" flags-{section_id}\" class=\" flags-state\" >\n "
453- ) ) ;
454- }
455-
456- html. push_str ( "<table>\n <thead><tr>" ) ;
457- html. push_str ( "<th>Flag</th><th>Default</th><th>Description</th>" ) ;
458- html. push_str ( "</tr></thead>\n <tbody>\n " ) ;
459-
460- for ( i, ( flag, default, desc) ) in rows. iter ( ) . enumerate ( ) {
461- if i == VISIBLE && has_overflow {
462- html. push_str ( "</tbody>\n <tbody class=\" flags-overflow\" >\n " ) ;
463- }
464- write_html_row ( & mut html, flag, default, desc) ;
428+ out. push_str ( "_No options._" ) ;
429+ return Ok ( out) ;
465430 }
466431
467- html. push_str ( "</tbody>\n </table>\n " ) ;
468-
469- if has_overflow {
470- html. push_str ( & format ! (
471- "<label for=\" flags-{section_id}\" class=\" flags-toggle\" >\
472- <span class=\" flags-show\" >Show all flags</span>\
473- <span class=\" flags-hide\" >Show less</span>\
474- </label>\n </div>\n "
475- ) ) ;
432+ out. push_str ( "| Flag | Default | Description |\n " ) ;
433+ out. push_str ( "|------|---------|-------------|\n " ) ;
434+ for ( flag, default, desc) in rows {
435+ let d = if default. is_empty ( ) {
436+ "—" . to_string ( )
437+ } else {
438+ format ! ( "`{default}`" )
439+ } ;
440+ let desc = desc. replace ( '|' , "\\ |" ) ;
441+ out. push_str ( & format ! ( "| `{flag}` | {d} | {desc} |\n " ) ) ;
476442 }
477-
478- Ok ( html)
479- }
480-
481- /// Write a single `<tr>` for the flag table.
482- fn write_html_row ( html : & mut String , flag : & str , default : & str , desc : & str ) {
483- let d = if default. is_empty ( ) {
484- "—" . to_string ( )
485- } else {
486- format ! ( "<code>{}</code>" , escape_html( default ) )
487- } ;
488- html. push_str ( & format ! (
489- "<tr><td><code>{}</code></td><td>{}</td><td>{}</td></tr>\n " ,
490- escape_html( flag) ,
491- d,
492- escape_html( desc) ,
493- ) ) ;
494- }
495-
496- /// Minimal HTML escaping for table cell content.
497- fn escape_html ( s : & str ) -> String {
498- s. replace ( '&' , "&" )
499- . replace ( '<' , "<" )
500- . replace ( '>' , ">" )
501- . replace ( '"' , """ )
443+ Ok ( out)
502444}
503445
504446/// Extract the command description from clap's help output.
0 commit comments