aboutsummaryrefslogtreecommitdiff
path: root/mingling_core/src/build/comp.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-08-14 02:57:39 +0800
committer魏曹先生 <1992414357@qq.com>2026-08-14 02:57:39 +0800
commita14b9bbb96e025a60abeb492ba043b0db806289a (patch)
treef764b1d9dae63e4dabcdc9dcf4fb135b9788255d /mingling_core/src/build/comp.rs
parent9dde70fc4fb85a5be14a9429ba52fffe529317d3 (diff)
docs: enable running doctests in comp and pathf build modules
Diffstat (limited to 'mingling_core/src/build/comp.rs')
-rw-r--r--mingling_core/src/build/comp.rs38
1 files changed, 26 insertions, 12 deletions
diff --git a/mingling_core/src/build/comp.rs b/mingling_core/src/build/comp.rs
index be53463..d6bb34f 100644
--- a/mingling_core/src/build/comp.rs
+++ b/mingling_core/src/build/comp.rs
@@ -1,4 +1,3 @@
-// Doc Not Optimize
use std::path::PathBuf;
use just_template::tmpl;
@@ -17,15 +16,18 @@ const TMPL_COMP_PWSH: &str = include_str!("../../tmpls/comps/pwsh.ps1");
/// Scripts are written to the `OUT_DIR` (or `target/` if `OUT_DIR` is not set).
///
/// # Example
-/// ```rust,ignore
-/// # use mingling_core::comp::ShellFlag;
+/// ```
+/// # #[cfg(all(feature = "build", feature = "comp"))] {
+/// # temp_env::with_var("OUT_DIR", Some(".temp/target/test/out/"), || {
+/// # use mingling_core::ShellFlag;
/// # use mingling_core::build::build_comp_scripts;
-///
/// // Generate completion scripts for "myapp"
/// build_comp_scripts("myapp").unwrap();
///
/// // Generate completion scripts for current package
/// build_comp_scripts(env!("CARGO_PKG_NAME")).unwrap();
+/// # });
+/// # }
/// ```
pub fn build_comp_scripts(name: &str) -> Result<(), std::io::Error> {
#[cfg(target_os = "windows")]
@@ -58,10 +60,14 @@ pub fn build_comp_scripts(name: &str) -> Result<(), std::io::Error> {
/// resulting completion script to the target directory (typically `target/`).
///
/// # Example
-/// ```rust,ignore
-/// # use mingling_core::comp::ShellFlag;
+/// ```
+/// # #[cfg(all(feature = "build", feature = "comp"))] {
+/// # temp_env::with_var("OUT_DIR", Some(".temp/target/test/out/"), || {
+/// # use mingling_core::ShellFlag;
/// # use mingling_core::build::build_comp_script;
/// build_comp_script(&ShellFlag::Bash, "myapp").unwrap();
+/// # });
+/// # }
/// ```
pub fn build_comp_script(shell_flag: &ShellFlag, bin_name: &str) -> Result<(), std::io::Error> {
let out_dir = std::path::PathBuf::from(std::env::var("OUT_DIR").unwrap());
@@ -76,10 +82,14 @@ pub fn build_comp_script(shell_flag: &ShellFlag, bin_name: &str) -> Result<(), s
/// and writes the resulting completion script to the specified directory.
///
/// # Example
-/// ```rust,ignore
-/// # use mingling_core::comp::ShellFlag;
+/// ```
+/// # #[cfg(all(feature = "build", feature = "comp"))] {
+/// # temp_env::with_var("OUT_DIR", Some(".temp/target/test/out/"), || {
+/// # use mingling_core::ShellFlag;
/// # use mingling_core::build::build_comp_script_to;
-/// build_comp_script_to(&ShellFlag::Bash, "myapp", "target/completions").unwrap();
+/// build_comp_script_to(&ShellFlag::Bash, "myapp", ".temp/target/test/out/").unwrap();
+/// # });
+/// # }
/// ```
pub fn build_comp_script_to(
shell_flag: &ShellFlag,
@@ -102,10 +112,14 @@ pub fn build_comp_script_to(
/// and writes the resulting completion script directly to the specified file path.
///
/// # Example
-/// ```rust,ignore
-/// # use mingling_core::comp::ShellFlag;
+/// ```
+/// # #[cfg(all(feature = "build", feature = "comp"))] {
+/// # temp_env::with_var("OUT_DIR", Some(".temp/target/test/out/"), || {
+/// # use mingling_core::ShellFlag;
/// # use mingling_core::build::build_comp_script_to_file;
-/// build_comp_script_to_file(&ShellFlag::Bash, "myapp", "target/completions/myapp_comp.sh").unwrap();
+/// build_comp_script_to_file(&ShellFlag::Bash, "myapp", ".temp/target/test/out/myapp.comp.sh").unwrap();
+/// # });
+/// # }
/// ```
pub fn build_comp_script_to_file(
shell_flag: &ShellFlag,