From c23c590330af83afb6e146bcd9b0a274b3689d22 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Mon, 17 Aug 2026 03:27:46 +0800 Subject: refactor!: remove Node type and simplify dispatcher macro syntax The `dispatcher!` macro no longer requires a `CMD*` dispatcher type argument; the dispatcher struct is now generated internally as `__Dispatcher{Pascal}`. The `Node` type, `node!` macro, and `Dispatcher::node()` / `clone_dispatcher()` methods are removed. --- docs/pages/other/features.md | 2 +- docs/pages/other/naming_rule.md | 28 +++++++++++++--------------- 2 files changed, 14 insertions(+), 16 deletions(-) (limited to 'docs/pages/other') diff --git a/docs/pages/other/features.md b/docs/pages/other/features.md index 7615118..4552d30 100644 --- a/docs/pages/other/features.md +++ b/docs/pages/other/features.md @@ -158,7 +158,7 @@ For example, allows the shorthand form `dispatcher!("greet")`, which auto-genera | `group!(Type)` | Register external types as group members without modifying them | | `pack_err!(ErrorType)` / `pack_err!(ErrorType = Inner)` | Create error types with an automatic `name` field | | `#[program_setup]` | Declare a program initialization function | -| `dispatcher!("cmd.path")` **shorthand** | Omit `CMDStruct => EntryStruct`, names are auto-derived | +| `dispatcher!("cmd.path")` **shorthand** | Omit `EntryStruct`, the entry name is auto-derived |
Details diff --git a/docs/pages/other/naming_rule.md b/docs/pages/other/naming_rule.md index 1175ae0..770fd10 100644 --- a/docs/pages/other/naming_rule.md +++ b/docs/pages/other/naming_rule.md @@ -40,19 +40,17 @@ Name + Setup ### Dispatcher -Dispatchers are the entry points of commands, corresponding one-to-one with `Node` names. Node names use `.` to separate levels, dispatcher names use the `CMD` prefix with PascalCase. +Dispatchers are the entry points of commands. The command name uses `.` to separate hierarchy levels and matches the arguments typed by the user. ``` -CMD + Command Hierarchy +command name ``` -| Node | Dispatcher | -| ------------ | ----------------- | -| `greet` | `CMDGreet` | -| `remote.add` | `CMDRemoteAdd` | -| `remote.rm` | `CMDRemoteRemove` | - -Even if a node is an abbreviation, the dispatcher name should use the full name. For example, the node is `remote.rm`, but the dispatcher is `CMDRemoteRemove`, not `CMDRemoteRm`. +| Command | +| ------------ | +| `greet` | +| `remote.add` | +| `remote.rm` | ### Entry @@ -62,11 +60,11 @@ Entries are the pipeline starting types created by dispatchers, wrapping `Vec EntryRemoteAdd); +dispatcher!("remote.add", EntryRemoteAdd); // Entry → State #[chain] -- cgit