From e214d07f6783009869c93bbab1e4bec9829584ee Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Mon, 15 Jun 2026 00:36:34 +0800 Subject: Add Introduction, Getting Started, and Features docs --- docs/pages/other/features.md | 246 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 246 insertions(+) create mode 100644 docs/pages/other/features.md (limited to 'docs/pages/other') diff --git a/docs/pages/other/features.md b/docs/pages/other/features.md new file mode 100644 index 0000000..8f458af --- /dev/null +++ b/docs/pages/other/features.md @@ -0,0 +1,246 @@ +
+ Mingling's complete feature list +
+ +## Feature `all_serde_fmt` + +**Description:** + +Enables serde formatting support for all serialization formats (JSON, RON, TOML, YAML) in `general_renderer`. + +Enabling this feature will automatically enable the four sub-features: `json_serde_fmt`, `ron_serde_fmt`, `toml_serde_fmt`, `yaml_serde_fmt`. + +## Feature `async` + +**Description:** + +Enables async runtime support, allowing `#[chain]` to bind `async` functions, e.g.: + +```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` + +**Description:** + +Enables scripts needed for use in `build.rs`, currently including: + +1. Completion script generation under the `comp` feature: + +```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:** + +Enables integration with the [clap](https://crates.io/crates/clap) command-line argument parsing library, making it easy to build CLI apps. + +With this feature enabled, you can use the `#[dispatcher_clap]` attribute macro to generate a dispatcher from a `clap::Parser` struct. + +See [example](https://mingling-rs.github.io/mingling/docs/example-viewer.html?name=example-clap-binding) + +## Feature `comp` + +**Description:** + +Enables code completion functionality, providing auto-completion support for interactive environments. + +When enabled, you can use the `#[completion]` attribute macro to define dynamic completion logic, and generate completion scripts for shells such as bash, zsh, fish, and pwsh. + +See [example](https://mingling-rs.github.io/mingling/docs/example-viewer.html?name=example-completion) + +## Feature `debug` + +**Description:** + +Enables debugging-related features, providing more detailed error info and diagnostic output. + +## Feature `dispatch_tree` + +**Description:** + +Enables the dispatch tree mechanism, supporting conditional dispatch and routing. + +When enabled, Mingling **at compile time** hard-codes the subcommand structure as a prefix tree (Trie), achieving extremely fast subcommand lookup. Lookup complexity is **O(n)**, where _n_ is the input length, not the number of commands. + +See [example](https://mingling-rs.github.io/mingling/docs/example-viewer.html?name=example-dispatch-tree) + +## Feature `extra_macros` + +**Description:** + +Enables an additional set of macros, providing more convenient syntactic sugar and metaprogramming capabilities. + +For example, allows the shorthand form `dispatcher!("greet")`, which auto-generates `CMDGreet` / `EntryGreet`. + +| Macro | Description | +|---|---| +| `empty_result!()` | Shorthand for returning an empty result early in a chain | +| `entry!(Type, ["a", "b"])` | Construct test data for an entry type | +| `#[program_setup]` | Declare a program initialization function | +| `dispatcher!("cmd.path")` **shorthand** | Omit `CMDStruct => EntryStruct`, names are auto-derived | + ++ Written by @Weicao-CatilGrass +
-- cgit