aboutsummaryrefslogtreecommitdiff
path: root/dev_tools/src
diff options
context:
space:
mode:
Diffstat (limited to 'dev_tools/src')
-rw-r--r--dev_tools/src/bin/test-all-markdown-code.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/dev_tools/src/bin/test-all-markdown-code.rs b/dev_tools/src/bin/test-all-markdown-code.rs
index 500e66a..e43053e 100644
--- a/dev_tools/src/bin/test-all-markdown-code.rs
+++ b/dev_tools/src/bin/test-all-markdown-code.rs
@@ -1,4 +1,5 @@
use std::collections::HashMap;
+use std::env;
use std::path::{Path, PathBuf};
use colored::Colorize;
@@ -44,6 +45,22 @@ fn main() {
})
};
+ // Parse optional path argument from env args
+ let single_file: Option<PathBuf> = {
+ let args: Vec<String> = env::args().collect();
+ if args.len() > 1 {
+ let p = PathBuf::from(&args[1]);
+ if p.exists() {
+ Some(p)
+ } else {
+ eprintln_cargo_style!("error: specified file '{}' does not exist", args[1]);
+ std::process::exit(1);
+ }
+ } else {
+ None
+ }
+ };
+
// Collect all markdown files from config
let mut files: Vec<(String, PathBuf)> = Vec::new();
@@ -74,6 +91,25 @@ fn main() {
}
}
+ // If a single file was specified, filter the list to only that file
+ if let Some(ref target) = single_file {
+ // Canonicalize to compare paths reliably
+ let target_canon = std::fs::canonicalize(target).unwrap_or_else(|_| target.clone());
+ files.retain(|(_, path)| {
+ std::fs::canonicalize(path)
+ .map(|p| p == target_canon)
+ .unwrap_or(false)
+ });
+ if files.is_empty() {
+ eprintln_cargo_style!(
+ "error: specified file '{}' is not among the configured documentation files",
+ target.display()
+ );
+ std::process::exit(1);
+ }
+ println_cargo_style!("Source: testing only file '{}'", target.display());
+ }
+
if files.is_empty() {
eprintln_cargo_style!("No markdown files found to verify");
std::process::exit(1);