diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-06-29 13:06:34 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-06-29 13:06:34 +0800 |
| commit | 18b734d36bf07fb797556e264c91e1d7c64f9051 (patch) | |
| tree | c4b0c805aa5dbf5b5e7afc3a962b3cbb5695cf77 /docs | |
| parent | 2d2eef2770025b5fe7db3f1e36e2dc7daede16ca (diff) | |
style(docs): trim trailing whitespace in code blocks
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/_zh_CN/pages/other/features.md | 50 | ||||
| -rw-r--r-- | docs/pages/other/features.md | 50 |
2 files changed, 50 insertions, 50 deletions
diff --git a/docs/_zh_CN/pages/other/features.md b/docs/_zh_CN/pages/other/features.md index 04aa0ab..8b19b31 100644 --- a/docs/_zh_CN/pages/other/features.md +++ b/docs/_zh_CN/pages/other/features.md @@ -19,15 +19,15 @@ ```rust // Features: ["async"] - + pack!(StateFoo = ()); - + #[chain] async fn handle_state_foo(foo: StateFoo) -> Next { StateFoo::new(()) } ``` - + 详见 [示例](https://mingling-rs.github.io/mingling/docs/example-viewer.html?name=example-async-support) ## 特性 `builds` @@ -41,13 +41,13 @@ async fn handle_state_foo(foo: StateFoo) -> Next { ```rust // Features: ["builds", "comp"] use mingling::build::build_comp_scripts; - + fn main() { // 为 `myprogram` 生成补全脚本 build_comp_scripts("myprogram").unwrap(); } ``` - + ## 特性 `clap` **介绍:** @@ -108,17 +108,17 @@ fn main() { ```rust // Features: ["extra_macros"] - + pack!(StatePrev1 = ()); pack!(StatePrev2 = ()); - + pack!(StateNext = ()); - + #[chain] fn handle_state_prev2(_p: StatePrev2) { // 无 Next 的 #[chain] 可以直接不返回值 } - + #[chain] fn handle_state_prev1(_p: StatePrev1) -> Next { let foo = 1; @@ -131,19 +131,19 @@ fn handle_state_prev1(_p: StatePrev1) -> Next { } } ``` - + ### `#[program_setup]` ```rust // Features: ["extra_macros"] use mingling::{macros::program_setup, Program}; - + fn main() { let mut program = ThisProgram::new(); program.with_setup(NoErrorSetup); program.exec_and_exit(); } - + #[program_setup] fn no_error_setup(program: &mut Program<ThisProgram>) { program.global_flag(["--no-error"], |program| { @@ -151,24 +151,24 @@ fn no_error_setup(program: &mut Program<ThisProgram>) { }); } ``` - + ### `entry!` ```rust // Features: ["extra_macros"] use mingling::macros::entry; - + pack!(EntryHello = Vec<String>); - + fn main() { let result = handle_hello(entry!("--name", "Bob")).into(); // ... 此处为断言逻辑 } - + #[chain] fn handle_hello(args: EntryHello) {} ``` - + ### `group!` 将外部类型注册为程序组成员,无需修改原始类型的定义。 @@ -178,12 +178,12 @@ fn handle_hello(args: EntryHello) {} // Features: ["extra_macros"] use mingling::macros::group; use std::num::ParseIntError; - + // 将 std::num::ParseIntError 注册为组成员。 // 注册后,ParseIntError 可用于 #[chain] 和 #[renderer] 函数中。 group!(std::num::ParseIntError); ``` - + ### `pack_err!` 创建带自动 `name: String` 字段的错误结构体,字段值自动设为结构体名的蛇形命名。 @@ -192,20 +192,20 @@ group!(std::num::ParseIntError); ```rust // Features: ["extra_macros"] use std::path::PathBuf; - + // 简单形式——仅包含 name 字段: pack_err!(ErrorNotFound); // 生成: // struct ErrorNotFound { pub name: String } // impl Default for ErrorNotFound { ... } - + // 带类型的形式——包含额外的 info 字段: pack_err!(ErrorNotDir = PathBuf); // 生成: // struct ErrorNotDir { pub name: String, pub info: PathBuf } // impl ErrorNotDir { pub fn new(info: PathBuf) -> Self { ... } } ``` - + </details> ## 特性 `structural_renderer` @@ -258,17 +258,17 @@ pack_err!(ErrorNotDir = PathBuf); # Cargo.toml [dependencies.mingling] features = ["pathf"] - + [build-dependencies.mingling] features = ["builds", "pathf"] ``` - + ```rust // BUILD TIME // Features: ["pathf"] analyze_and_build_type_mapping().unwrap(); ``` - + 详见 [示例](https://mingling-rs.github.io/mingling/docs/example-viewer.html?name=example-pathfinder) ## 特性 `parser` diff --git a/docs/pages/other/features.md b/docs/pages/other/features.md index 58373a2..891083d 100644 --- a/docs/pages/other/features.md +++ b/docs/pages/other/features.md @@ -19,15 +19,15 @@ Enables async runtime support, allowing `#[chain]` to bind `async` functions, e. ```rust // Features: ["async"] - + pack!(StateFoo = ()); - + #[chain] async fn handle_state_foo(foo: StateFoo) -> Next { StateFoo::new(()) } ``` - + See [example](https://mingling-rs.github.io/mingling/docs/example-viewer.html?name=example-async-support) ## Feature `builds` @@ -41,13 +41,13 @@ Enables scripts needed for use in `build.rs`, currently including: ```rust // Features: ["builds", "comp"] use mingling::build::build_comp_scripts; - + fn main() { // Generate completion scripts for `myprogram` build_comp_scripts("myprogram").unwrap(); } ``` - + ## Feature `clap` **Description:** @@ -108,17 +108,17 @@ For example, allows the shorthand form `dispatcher!("greet")`, which auto-genera ```rust // Features: ["extra_macros"] - + pack!(StatePrev1 = ()); pack!(StatePrev2 = ()); - + pack!(StateNext = ()); - + #[chain] fn handle_state_prev2(_p: StatePrev2) { // A #[chain] with no return type can simply omit the return value } - + #[chain] fn handle_state_prev1(_p: StatePrev1) -> Next { let foo = 1; @@ -131,19 +131,19 @@ fn handle_state_prev1(_p: StatePrev1) -> Next { } } ``` - + ### `#[program_setup]` ```rust // Features: ["extra_macros"] use mingling::{macros::program_setup, Program}; - + fn main() { let mut program = ThisProgram::new(); program.with_setup(NoErrorSetup); program.exec_and_exit(); } - + #[program_setup] fn no_error_setup(program: &mut Program<ThisProgram>) { program.global_flag(["--no-error"], |program| { @@ -151,24 +151,24 @@ fn no_error_setup(program: &mut Program<ThisProgram>) { }); } ``` - + ### `entry!` ```rust // Features: ["extra_macros"] use mingling::macros::entry; - + pack!(EntryHello = Vec<String>); - + fn main() { let result = handle_hello(entry!("--name", "Bob")).into(); // ... assertion logic here } - + #[chain] fn handle_hello(args: EntryHello) {} ``` - + ### `group!` Registers an external type as a member of the program group without modifying its definition. @@ -178,12 +178,12 @@ The type's simple name is used as the enum variant, just like `pack!` or `#[deri // Features: ["extra_macros"] use mingling::macros::group; use std::num::ParseIntError; - + // Register std::num::ParseIntError as a group member. // After this, ParseIntError can be used in #[chain] and #[renderer] functions. group!(std::num::ParseIntError); ``` - + ### `pack_err!` Creates an error struct with an automatic `name: String` field set to the snake_case @@ -192,20 +192,20 @@ of the struct name. Optionally wraps an inner type for additional context. ```rust // Features: ["extra_macros"] use std::path::PathBuf; - + // Simple form — only a name field: pack_err!(ErrorNotFound); // Generates: // struct ErrorNotFound { pub name: String } // impl Default for ErrorNotFound { ... } - + // Typed form — with additional info field: pack_err!(ErrorNotDir = PathBuf); // Generates: // struct ErrorNotDir { pub name: String, pub info: PathBuf } // impl ErrorNotDir { pub fn new(info: PathBuf) -> Self { ... } } ``` - + </details> ## Feature `structural_renderer` @@ -258,17 +258,17 @@ When enabled, types can be defined in any submodule, and `gen_program!()` can au # Cargo.toml [dependencies.mingling] features = ["pathf"] - + [build-dependencies.mingling] features = ["builds", "pathf"] ``` - + ```rust // BUILD TIME // Features: ["pathf"] analyze_and_build_type_mapping().unwrap(); ``` - + See [example](https://mingling-rs.github.io/mingling/docs/example-viewer.html?name=example-pathfinder) ## Feature `parser` |
