uudoc: move tldr.zip warning to build.rs (#10039)

Move the tldr.zip missing warning from runtime (uudoc.rs) to compile
time (build.rs). This ensures the warning is printed only once during
the build, instead of 100+ times when make calls uudoc separately for
each utility.

Fixes #9940
This commit is contained in:
Ruiyang Wang
2026-01-18 18:54:50 +01:00
committed by GitHub
parent 3c55820f5e
commit eb482fb2ee
3 changed files with 25 additions and 26 deletions
-19
View File
@@ -133,19 +133,6 @@ fn gen_completions<T: Args>(args: impl Iterator<Item = OsString>, util_map: &Uti
process::exit(0);
}
/// print tldr error
fn print_tldr_error() {
eprintln!("Warning: No tldr archive found, so the documentation will not include examples.");
eprintln!(
"To include examples in the documentation, download the tldr archive and put it in the docs/ folder."
);
eprintln!();
eprintln!(
" curl -L https://github.com/tldr-pages/tldr/releases/latest/download/tldr.zip -o docs/tldr.zip"
);
eprintln!();
}
/// # Errors
/// Returns an error if the writer fails.
#[allow(clippy::too_many_lines)]
@@ -162,9 +149,6 @@ fn main() -> io::Result<()> {
match command {
"manpage" => {
let args_iter = args.into_iter().skip(2);
if tldr_zip.is_none() {
print_tldr_error();
}
gen_manpage(
&mut tldr_zip,
args_iter,
@@ -186,9 +170,6 @@ fn main() -> io::Result<()> {
}
}
}
if tldr_zip.is_none() {
print_tldr_error();
}
let utils = util_map::<Box<dyn Iterator<Item = OsString>>>();
match std::fs::create_dir("docs/src/utils/") {
Err(e) if e.kind() == std::io::ErrorKind::AlreadyExists => Ok(()),