Skip to content

Commit 09372eb

Browse files
bordumbclaude
andcommitted
revert: drop expandable flag tables, use plain markdown tables
The pure-CSS checkbox hack for expandable flag containers didn't work reliably in mkdocs-material. Revert to plain full markdown tables with command descriptions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 6af0fd8 commit 09372eb

2 files changed

Lines changed: 17 additions & 154 deletions

File tree

crates/xtask/src/gen_docs.rs

Lines changed: 17 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
408405
fn 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('&', "&amp;")
499-
.replace('<', "&lt;")
500-
.replace('>', "&gt;")
501-
.replace('"', "&quot;")
443+
Ok(out)
502444
}
503445

504446
/// Extract the command description from clap's help output.

docs/stylesheets/extra.css

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -408,85 +408,6 @@ body {
408408
border-color: var(--md-default-fg-color--lightest);
409409
}
410410

411-
/* ----------------------------------------
412-
FLAGS TOGGLE (CLI docs)
413-
Pure-CSS expandable flag tables.
414-
A hidden checkbox + label controls overflow.
415-
---------------------------------------- */
416-
.flags-container {
417-
position: relative;
418-
border: 1px solid #e5e7eb;
419-
border-radius: 8px;
420-
overflow: hidden;
421-
margin-bottom: 1rem;
422-
}
423-
424-
[data-md-color-scheme="slate"] .flags-container {
425-
border-color: #2a2a3a;
426-
}
427-
428-
/* Remove default table border inside container */
429-
.flags-container table {
430-
margin: 0 !important;
431-
border: none !important;
432-
border-radius: 0 !important;
433-
width: 100%;
434-
}
435-
436-
/* Hidden checkbox drives the state — use offscreen positioning
437-
instead of display:none so label `for` always toggles it */
438-
.flags-state {
439-
position: absolute;
440-
opacity: 0;
441-
pointer-events: none;
442-
}
443-
444-
/* Overflow rows hidden by default */
445-
.flags-container .flags-overflow {
446-
display: none;
447-
}
448-
449-
/* When checked, show overflow rows — must beat the rule above */
450-
.flags-container .flags-state:checked ~ table .flags-overflow {
451-
display: table-row-group;
452-
}
453-
454-
.flags-state:checked ~ .flags-toggle .flags-show {
455-
display: none;
456-
}
457-
458-
.flags-state:not(:checked) ~ .flags-toggle .flags-hide {
459-
display: none;
460-
}
461-
462-
/* Toggle label — centered at container bottom */
463-
.flags-toggle {
464-
display: block;
465-
text-align: center;
466-
padding: 0.45em 0;
467-
font-size: 0.8rem;
468-
font-weight: 500;
469-
color: #5b21b6;
470-
background: #f8fafc;
471-
border-top: 1px solid #e5e7eb;
472-
cursor: pointer;
473-
user-select: none;
474-
transition: background 0.2s;
475-
}
476-
477-
.flags-toggle:hover {
478-
background: rgba(91, 33, 182, 0.06);
479-
}
480-
481-
[data-md-color-scheme="slate"] .flags-toggle {
482-
color: #a78bfa;
483-
background: #12121a;
484-
border-top-color: #2a2a3a;
485-
}
486-
487-
[data-md-color-scheme="slate"] .flags-toggle:hover {
488-
background: rgba(167, 139, 250, 0.1);
489-
}
490411

491412
/* ----------------------------------------
492413
RESPONSIVE

0 commit comments

Comments
 (0)