From 903ef3aacc3d98d32d51b65aaf4bfbdc20d90bc5 Mon Sep 17 00:00:00 2001 From: Jake Wallin Date: Fri, 16 Oct 2026 16:44:47 +0000 Subject: [PATCH] uudoc: prefer Linux tldr pages over common pages --- src/bin/uudoc.rs | 58 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 50 insertions(+), 8 deletions(-) diff --git a/src/bin/uudoc.rs b/src/bin/uudoc.rs index 992526b2e1..14adcb5088 100644 --- a/src/bin/uudoc.rs +++ b/src/bin/uudoc.rs @@ -666,16 +666,22 @@ fn write_zip_examples( name: &str, output_markdown: bool, ) -> io::Result { - let content = if let Some(f) = get_zip_content(archive, &format!("pages/common/{name}.md")) { - f - } else if let Some(f) = get_zip_content(archive, &format!("pages/linux/{name}.md")) { - f + // Linux pages for these utilities can describe other implementations or shell builtins. + let platforms = if matches!(name, "hostname" | "kill" | "more" | "uptime") { + ["common", "linux"] } else { - return Err(io::Error::new( - io::ErrorKind::NotFound, - format!("Could not find tldr examples for {name}"), - )); + // Prefer GNU-specific examples over generic POSIX examples. + ["linux", "common"] }; + let content = platforms + .into_iter() + .find_map(|platform| get_zip_content(archive, &format!("pages/{platform}/{name}.md"))) + .ok_or_else(|| { + io::Error::new( + io::ErrorKind::NotFound, + format!("Could not find tldr examples for {name}"), + ) + })?; match format_examples(content, output_markdown) { Err(e) => Err(io::Error::other(format!( @@ -719,6 +725,42 @@ fn format_examples(content: String, output_markdown: bool) -> Result