diff options
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/_zh_CN/pages/14-testing.md | 4 | ||||
| -rw-r--r-- | docs/_zh_CN/pages/2-define-a-dispatcher.md | 4 | ||||
| -rw-r--r-- | docs/_zh_CN/pages/6-argument-parse-picker.md | 10 | ||||
| -rw-r--r-- | docs/_zh_CN/pages/8-setup-and-resources.md | 6 | ||||
| -rw-r--r-- | docs/_zh_CN/pages/9-error-handling.md | 4 | ||||
| -rw-r--r-- | docs/_zh_CN/pages/other/features.md | 12 | ||||
| -rw-r--r-- | docs/dev/pages/issues/_the-mod-pathfinder.md | 2 | ||||
| -rw-r--r-- | docs/dev/pages/issues/the-command-macro.md | 6 | ||||
| -rw-r--r-- | docs/example-pages/examples.json | 12 | ||||
| -rw-r--r-- | docs/pages/14-testing.md | 4 | ||||
| -rw-r--r-- | docs/pages/2-define-a-dispatcher.md | 4 | ||||
| -rw-r--r-- | docs/pages/6-argument-parse-picker.md | 10 | ||||
| -rw-r--r-- | docs/pages/8-setup-and-resources.md | 6 | ||||
| -rw-r--r-- | docs/pages/9-error-handling.md | 4 | ||||
| -rw-r--r-- | docs/pages/other/features.md | 12 |
15 files changed, 50 insertions, 50 deletions
diff --git a/docs/_zh_CN/pages/14-testing.md b/docs/_zh_CN/pages/14-testing.md index 031be59..3567aef 100644 --- a/docs/_zh_CN/pages/14-testing.md +++ b/docs/_zh_CN/pages/14-testing.md @@ -70,10 +70,10 @@ fn test_handle_hello_with_name() { ## 用 entry! 宏构造数据 -如果启用了 `extra_macros`,可以用 `entry!` 快速构造 Entry: +如果启用了 `extras`,可以用 `entry!` 快速构造 Entry: ```rust -// Features: ["extra_macros"] +// Features: ["extras"] @@@use mingling::{assert_member_id, unpack_chain_process}; @@@use mingling::macros::entry; diff --git a/docs/_zh_CN/pages/2-define-a-dispatcher.md b/docs/_zh_CN/pages/2-define-a-dispatcher.md index 0afd911..b238d9f 100644 --- a/docs/_zh_CN/pages/2-define-a-dispatcher.md +++ b/docs/_zh_CN/pages/2-define-a-dispatcher.md @@ -79,10 +79,10 @@ pub struct EntryGreet { ## 进阶:隐式声明 -以上是标准写法。如果你启用了 `extra_macros` 特性,还可以更简洁: +以上是标准写法。如果你启用了 `extras` 特性,还可以更简洁: ```rust -// Features: ["extra_macros"] +// Features: ["extras"] // 省略 CMDType 和 EntryType,名字自动推导 dispatcher!("greet"); // dispatcher!("greet", CMDGreet => EntryGreet); diff --git a/docs/_zh_CN/pages/6-argument-parse-picker.md b/docs/_zh_CN/pages/6-argument-parse-picker.md index f0609ed..462a912 100644 --- a/docs/_zh_CN/pages/6-argument-parse-picker.md +++ b/docs/_zh_CN/pages/6-argument-parse-picker.md @@ -138,7 +138,7 @@ fn handle_test_entry(prev: EntryTest) -> Next { 先来看一个简单示例 ```rust -// Features: ["parser", "extra_macros"] +// Features: ["parser", "extras"] @@@use mingling::macros::buffer; @@@use mingling::macros::route; @@@dispatcher!("greet", CMDGreet => EntryGreet); @@ -164,10 +164,10 @@ fn render_greet(result: ResultName) { 若使用 `pick_or_route`,写法会变得相对复杂:因为 `.unpack()` 不再直接返回参数,而是 `Result<Value, Route>`。 -不过 **Mingling** 的 `extra_macros` 特性提供了简化展开的宏 `route!`,它不复杂,只是省略了一部分样板代码: +不过 **Mingling** 的 `extras` 特性提供了简化展开的宏 `route!`,它不复杂,只是省略了一部分样板代码: ```rust -// Features: ["parser", "extra_macros"] +// Features: ["parser", "extras"] @@@ pack!(ErrorFail = ()); @@@ use mingling::macros::route; @@@ fn func() -> mingling::ChainProcess<ThisProgram> { @@ -181,7 +181,7 @@ let name = route!(pick_result); 它展开为: ```rust -// Features: ["parser", "extra_macros"] +// Features: ["parser", "extras"] @@@ pack!(ErrorFail = ()); @@@ fn func() -> mingling::ChainProcess<ThisProgram> { @@@ let args: Vec<String> = vec![]; @@ -223,7 +223,7 @@ fn handle_greet_entry(prev: EntryGreet) -> Next { 同样,你可以使用 `after_or_route` 来处理输入参数的格式错误 ```rust -// Features: ["parser", "extra_macros"] +// Features: ["parser", "extras"] @@@use mingling::macros::buffer; @@@use mingling::macros::route; @@@dispatcher!("greet", CMDGreet => EntryGreet); diff --git a/docs/_zh_CN/pages/8-setup-and-resources.md b/docs/_zh_CN/pages/8-setup-and-resources.md index d38e69d..9ed9894 100644 --- a/docs/_zh_CN/pages/8-setup-and-resources.md +++ b/docs/_zh_CN/pages/8-setup-and-resources.md @@ -8,7 +8,7 @@ ## 用 Setup 做初始化 ```rust -// Features: ["extra_macros"] +// Features: ["extras"] @@@use mingling::macros::program_setup; @@@use mingling::Program; #[program_setup] @@ -32,14 +32,14 @@ fn my_setup(program: &mut Program<ThisProgram>) { 在 `main` 里通过 `program.with_setup(...)` 注册即可使用。 > [!NOTE] -> `#[program_setup]` 需要 `extra_macros` 特性。没有此特性时,可以手动实现 `ProgramSetup` trait。 +> `#[program_setup]` 需要 `extras` 特性。没有此特性时,可以手动实现 `ProgramSetup` trait。 ## 提取全局参数 Setup 里最常用的操作就是提取全局参数。Mingling 提供了几个辅助方法: ```rust -// Features: ["extra_macros"] +// Features: ["extras"] @@@use mingling::macros::program_setup; @@@use mingling::Program; #[program_setup] diff --git a/docs/_zh_CN/pages/9-error-handling.md b/docs/_zh_CN/pages/9-error-handling.md index 4ce61ab..f5055b8 100644 --- a/docs/_zh_CN/pages/9-error-handling.md +++ b/docs/_zh_CN/pages/9-error-handling.md @@ -107,10 +107,10 @@ Error: name is required ## 关于 `pack_err!` -如果你启用了 `extra_macros`,还可以用 `pack_err!` 快速声明带有自动 `name` 字段的错误类型: +如果你启用了 `extras`,还可以用 `pack_err!` 快速声明带有自动 `name` 字段的错误类型: ```rust -// Features: ["extra_macros"] +// Features: ["extras"] pack_err!(ErrorNotFound); // 生成: struct ErrorNotFound { pub name: String } ``` diff --git a/docs/_zh_CN/pages/other/features.md b/docs/_zh_CN/pages/other/features.md index 8bd386c..84010c4 100644 --- a/docs/_zh_CN/pages/other/features.md +++ b/docs/_zh_CN/pages/other/features.md @@ -83,7 +83,7 @@ build_comp_scripts("myprogram").unwrap(); 详见 [示例](https://mingling-rs.github.io/mingling/docs/example-viewer.html?name=example-dispatch-tree) -## 特性 `extra_macros` +## 特性 `extras` **介绍:** @@ -106,7 +106,7 @@ build_comp_scripts("myprogram").unwrap(); ### `empty_result!()` ```rust -// Features: ["extra_macros"] +// Features: ["extras"] pack!(StatePrev1 = ()); pack!(StatePrev2 = ()); @@ -134,7 +134,7 @@ fn handle_state_prev1(_p: StatePrev1) -> Next { ### `#[program_setup]` ```rust -// Features: ["extra_macros"] +// Features: ["extras"] use mingling::{macros::program_setup, Program}; fn main() { @@ -154,7 +154,7 @@ fn no_error_setup(program: &mut Program<ThisProgram>) { ### `entry!` ```rust -// Features: ["extra_macros"] +// Features: ["extras"] use mingling::macros::entry; pack!(EntryHello = Vec<String>); @@ -174,7 +174,7 @@ fn handle_hello(args: EntryHello) {} 类型名会直接作为枚举变体,与 `pack!` 或 `#[derive(Grouped)]` 一致。 ```rust -// Features: ["extra_macros"] +// Features: ["extras"] use mingling::macros::group; use std::num::ParseIntError; @@ -189,7 +189,7 @@ group!(std::num::ParseIntError); 可选择包裹一个内部类型以携带额外上下文。 ```rust -// Features: ["extra_macros"] +// Features: ["extras"] use std::path::PathBuf; // 简单形式——仅包含 name 字段: diff --git a/docs/dev/pages/issues/_the-mod-pathfinder.md b/docs/dev/pages/issues/_the-mod-pathfinder.md index 8869beb..92cdb5f 100644 --- a/docs/dev/pages/issues/_the-mod-pathfinder.md +++ b/docs/dev/pages/issues/_the-mod-pathfinder.md @@ -32,7 +32,7 @@ mod sub { } ``` -There are a few exceptions, such as the implicit Dispatcher provided by `extra_macros`, but these can be inferred from the node name: +There are a few exceptions, such as the implicit Dispatcher provided by `extras`, but these can be inferred from the node name: ```rust dispatcher!("remote.add"); // although the type is unknown, we can infer CMDRemoteAdd and EntryRemoteAdd diff --git a/docs/dev/pages/issues/the-command-macro.md b/docs/dev/pages/issues/the-command-macro.md index 2f4a80a..82d733c 100644 --- a/docs/dev/pages/issues/the-command-macro.md +++ b/docs/dev/pages/issues/the-command-macro.md @@ -16,7 +16,7 @@ For a long time, creating a command in Mingling required the following steps: dispatcher!("greet", CMDGreet => EntryGreet); ``` -Or use the implicit syntax provided by `extra_macros` (automatically deriving `CMDGreet` and `EntryGreet`): +Or use the implicit syntax provided by `extras` (automatically deriving `CMDGreet` and `EntryGreet`): ```rust dispatcher!("greet"); @@ -151,11 +151,11 @@ In Mingling, there is no concept called `Command` — all behavior is the result ## Enabling -This macro requires the `extra_macros` feature. Enable it in your `Cargo.toml`: +This macro requires the `extras` feature. Enable it in your `Cargo.toml`: ```toml [dependencies] -mingling = { version = "...", features = ["extra_macros"] } +mingling = { version = "...", features = ["extras"] } ``` ## Caveats diff --git a/docs/example-pages/examples.json b/docs/example-pages/examples.json index 349248e..bde9d35 100644 --- a/docs/example-pages/examples.json +++ b/docs/example-pages/examples.json @@ -84,7 +84,7 @@ "tags": [ "pathf", "dispatch_tree", - "extra_macros", + "extras", "build.rs" ], "files": [ @@ -230,7 +230,7 @@ "name": "Implicit Dispatcher", "icon": "🫥", "category": "dispatch", - "desc": "Shows the abbreviated `dispatcher!(\"cmd.path\")` syntax from `extra_macros` that auto-derives struct names from the command path.\n", + "desc": "Shows the abbreviated `dispatcher!(\"cmd.path\")` syntax from `extras` that auto-derives struct names from the command path.\n", "tags": [ "implicit" ], @@ -261,7 +261,7 @@ "desc": "Demonstrates how to use the `group!()` macro to convert an external type into a type recognizable by Mingling\n", "tags": [ "group!", - "extra_macros" + "extras" ], "files": [ "src/main.rs", @@ -276,7 +276,7 @@ "desc": "Demonstrates how to use the `pack_err!` macro to define error types with automatic `name` field (snake_case at compile time) and optional `info` field. Also shows `--json` serialization when `structural_renderer` is enabled.\n", "tags": [ "pack_err!", - "extra_macros", + "extras", "structural_renderer", "--json" ], @@ -354,7 +354,7 @@ "desc": "Demonstrates how to build a custom `ProgramSetup` with `#[program_setup]` for modular configuration of program behaviour.\n", "tags": [ "#[setup]", - "extra_macros" + "extras" ], "files": [ "src/main.rs", @@ -385,7 +385,7 @@ "desc": "Shows how to write unit tests for Chain and Renderer functions using the `entry!` macro and assertion helpers.\n", "tags": [ "testing", - "extra_macros" + "extras" ], "files": [ "src/main.rs", diff --git a/docs/pages/14-testing.md b/docs/pages/14-testing.md index 65fedc9..86171bf 100644 --- a/docs/pages/14-testing.md +++ b/docs/pages/14-testing.md @@ -70,10 +70,10 @@ What the three test macros do: ## Constructing Data with the entry! Macro -If `extra_macros` is enabled, you can use `entry!` to quickly construct an Entry: +If `extras` is enabled, you can use `entry!` to quickly construct an Entry: ```rust -// Features: ["extra_macros"] +// Features: ["extras"] @@@use mingling::{assert_member_id, unpack_chain_process}; @@@use mingling::macros::entry; diff --git a/docs/pages/2-define-a-dispatcher.md b/docs/pages/2-define-a-dispatcher.md index 804ad1b..1208e64 100644 --- a/docs/pages/2-define-a-dispatcher.md +++ b/docs/pages/2-define-a-dispatcher.md @@ -79,10 +79,10 @@ When the user types `greet Alice Bob` on the command line, `EntryGreet.inner` be ## Advanced: Implicit Declaration -The above is the standard syntax. If you enable the `extra_macros` feature, you can be more concise: +The above is the standard syntax. If you enable the `extras` feature, you can be more concise: ```rust -// Features: ["extra_macros"] +// Features: ["extras"] // Omit CMDType and EntryType, names are auto-derived dispatcher!("greet"); // dispatcher!("greet", CMDGreet => EntryGreet); diff --git a/docs/pages/6-argument-parse-picker.md b/docs/pages/6-argument-parse-picker.md index 01f1c37..d7d38af 100644 --- a/docs/pages/6-argument-parse-picker.md +++ b/docs/pages/6-argument-parse-picker.md @@ -138,7 +138,7 @@ As the saying goes: "never trust your users." To handle missing required params, Here's a simple example: ```rust -// Features: ["parser", "extra_macros"] +// Features: ["parser", "extras"] @@@use mingling::macros::buffer; @@@use mingling::macros::route; @@@dispatcher!("greet", CMDGreet => EntryGreet); @@ -164,10 +164,10 @@ fn render_greet(result: ResultName) { With `pick_or_route`, the code becomes more involved: `.unpack()` no longer returns the value directly, but `Result<Value, Route>`. -However, **Mingling**'s `extra_macros` feature provides the `route!` macro for simplified expansion. It's not complex — it just reduces boilerplate: +However, **Mingling**'s `extras` feature provides the `route!` macro for simplified expansion. It's not complex — it just reduces boilerplate: ```rust -// Features: ["parser", "extra_macros"] +// Features: ["parser", "extras"] @@@ pack!(ErrorFail = ()); @@@ use mingling::macros::route; @@@ fn func() -> mingling::ChainProcess<ThisProgram> { @@ -181,7 +181,7 @@ let name = route!(pick_result); It expands to: ```rust -// Features: ["parser", "extra_macros"] +// Features: ["parser", "extras"] @@@ pack!(ErrorFail = ()); @@@ fn func() -> mingling::ChainProcess<ThisProgram> { @@@ let args: Vec<String> = vec![]; @@ -223,7 +223,7 @@ fn handle_greet_entry(prev: EntryGreet) -> Next { Similarly, you can use `after_or_route` to handle input format errors: ```rust -// Features: ["parser", "extra_macros"] +// Features: ["parser", "extras"] @@@use mingling::macros::buffer; @@@use mingling::macros::route; @@@dispatcher!("greet", CMDGreet => EntryGreet); diff --git a/docs/pages/8-setup-and-resources.md b/docs/pages/8-setup-and-resources.md index 3858e99..12c7610 100644 --- a/docs/pages/8-setup-and-resources.md +++ b/docs/pages/8-setup-and-resources.md @@ -8,7 +8,7 @@ When a program needs to do some init work at startup—like parsing global args ## Initialize with Setup ```rust -// Features: ["extra_macros"] +// Features: ["extras"] @@@use mingling::macros::program_setup; @@@use mingling::Program; #[program_setup] @@ -32,14 +32,14 @@ A function annotated with `#[program_setup]` receives `&mut Program<ThisProgram> Register it in `main` via `program.with_setup(...)` to use it. > [!NOTE] -> `#[program_setup]` requires the `extra_macros` feature. Without it, you can manually implement the `ProgramSetup` trait. +> `#[program_setup]` requires the `extras` feature. Without it, you can manually implement the `ProgramSetup` trait. ## Extract Global Args The most common use of Setup is extracting global args. Mingling provides a few helper methods: ```rust -// Features: ["extra_macros"] +// Features: ["extras"] @@@use mingling::macros::program_setup; @@@use mingling::Program; #[program_setup] diff --git a/docs/pages/9-error-handling.md b/docs/pages/9-error-handling.md index f6e05e3..680328c 100644 --- a/docs/pages/9-error-handling.md +++ b/docs/pages/9-error-handling.md @@ -107,10 +107,10 @@ Error: name is required ## About `pack_err!` -If you've enabled `extra_macros`, you can use `pack_err!` to quickly declare an error type with an auto-generated `name` field: +If you've enabled `extras`, you can use `pack_err!` to quickly declare an error type with an auto-generated `name` field: ```rust -// Features: ["extra_macros"] +// Features: ["extras"] pack_err!(ErrorNotFound); // Generates: struct ErrorNotFound { pub name: String } ``` diff --git a/docs/pages/other/features.md b/docs/pages/other/features.md index 7994d4c..465c290 100644 --- a/docs/pages/other/features.md +++ b/docs/pages/other/features.md @@ -83,7 +83,7 @@ When enabled, Mingling **at compile time** hard-codes the subcommand structure a See [example](https://mingling-rs.github.io/mingling/docs/example-viewer.html?name=example-dispatch-tree) -## Feature `extra_macros` +## Feature `extras` **Description:** @@ -106,7 +106,7 @@ For example, allows the shorthand form `dispatcher!("greet")`, which auto-genera ### `empty_result!()` ```rust -// Features: ["extra_macros"] +// Features: ["extras"] pack!(StatePrev1 = ()); pack!(StatePrev2 = ()); @@ -134,7 +134,7 @@ fn handle_state_prev1(_p: StatePrev1) -> Next { ### `#[program_setup]` ```rust -// Features: ["extra_macros"] +// Features: ["extras"] use mingling::{macros::program_setup, Program}; fn main() { @@ -154,7 +154,7 @@ fn no_error_setup(program: &mut Program<ThisProgram>) { ### `entry!` ```rust -// Features: ["extra_macros"] +// Features: ["extras"] use mingling::macros::entry; pack!(EntryHello = Vec<String>); @@ -174,7 +174,7 @@ Registers an external type as a member of the program group without modifying it The type's simple name is used as the enum variant, just like `pack!` or `#[derive(Grouped)]`. ```rust -// Features: ["extra_macros"] +// Features: ["extras"] use mingling::macros::group; use std::num::ParseIntError; @@ -189,7 +189,7 @@ Creates an error struct with an automatic `name: String` field set to the snake_ of the struct name. Optionally wraps an inner type for additional context. ```rust -// Features: ["extra_macros"] +// Features: ["extras"] use std::path::PathBuf; // Simple form — only a name field: |
