aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWeicao-CatilGrass <1992414357@qq.com>2026-04-12 21:27:34 +0800
committerWeicao-CatilGrass <1992414357@qq.com>2026-04-12 21:27:34 +0800
commitb33c2f991fa835049dfd8aa6d9ef621ac36d55d3 (patch)
tree9a67e409135ec25f904fcc1e61d4c7c00c428905
parent0e0423ec631371c04e8e8afa18aa57886f7de53b (diff)
Trim trailing whitespace in generated examples file
-rw-r--r--dev_tools/src/bin/refresh-examples.rs9
-rw-r--r--examples/example-general-renderer/src/main.rs2
-rw-r--r--mingling/src/example_docs.rs2
-rw-r--r--run-tools.ps126
4 files changed, 36 insertions, 3 deletions
diff --git a/dev_tools/src/bin/refresh-examples.rs b/dev_tools/src/bin/refresh-examples.rs
index c341bc4..be5da82 100644
--- a/dev_tools/src/bin/refresh-examples.rs
+++ b/dev_tools/src/bin/refresh-examples.rs
@@ -118,7 +118,14 @@ fn main() {
});
}
- std::fs::write(repo_root.join(OUTPUT_PATH), template.to_string()).unwrap();
+ let template_str = template.to_string();
+ let template_str = template_str
+ .lines()
+ .map(|line| line.trim_end())
+ .collect::<Vec<_>>()
+ .join("\n")
+ + "\n";
+ std::fs::write(repo_root.join(OUTPUT_PATH), template_str).unwrap();
}
fn find_git_repo() -> Option<std::path::PathBuf> {
diff --git a/examples/example-general-renderer/src/main.rs b/examples/example-general-renderer/src/main.rs
index 18cbe58..c405c74 100644
--- a/examples/example-general-renderer/src/main.rs
+++ b/examples/example-general-renderer/src/main.rs
@@ -17,7 +17,7 @@
//! ## Step3 - Write Code
//! Write the following content into `main.rs`
//!
-//! ## Step3 - Build and Run
+//! ## Step4 - Build and Run
//! ```bash
//! cargo run --manifest-path ./examples/example-general-renderer/Cargo.toml -- render Bob 22
//! cargo run --manifest-path ./examples/example-general-renderer/Cargo.toml -- render Bob 22 --json
diff --git a/mingling/src/example_docs.rs b/mingling/src/example_docs.rs
index 95aee93..1260509 100644
--- a/mingling/src/example_docs.rs
+++ b/mingling/src/example_docs.rs
@@ -223,7 +223,7 @@ pub mod example_completion {}
/// ## Step3 - Write Code
/// Write the following content into `main.rs`
///
-/// ## Step3 - Build and Run
+/// ## Step4 - Build and Run
/// ```bash
/// cargo run --manifest-path ./examples/example-general-renderer/Cargo.toml -- render Bob 22
/// cargo run --manifest-path ./examples/example-general-renderer/Cargo.toml -- render Bob 22 --json
diff --git a/run-tools.ps1 b/run-tools.ps1
new file mode 100644
index 0000000..fa06ecd
--- /dev/null
+++ b/run-tools.ps1
@@ -0,0 +1,26 @@
+Set-Location -Path (Split-Path -Parent $MyInvocation.MyCommand.Path) -ErrorAction Stop
+
+if ($args.Count -eq 0) {
+ Write-Host "Available:"
+ if (Test-Path "dev_tools/src/bin") {
+ $files = Get-ChildItem -Path "dev_tools/src/bin/*.rs"
+ foreach ($file in $files) {
+ if ($file -is [System.IO.FileInfo]) {
+ Write-Host $file.BaseName
+ }
+ }
+ } else {
+ Write-Host "Warning: dev_tools/src/bin directory does not exist"
+ }
+ exit 1
+}
+
+$target_bin = $args[0]
+$target_file = "dev_tools/src/bin/${target_bin}.rs"
+
+if (-not (Test-Path $target_file)) {
+ Write-Host "Error: target file '$target_file' does not exist"
+ exit 1
+}
+
+cargo run --manifest-path dev_tools/Cargo.toml --bin $args[0]