aboutsummaryrefslogtreecommitdiff
path: root/mingling_macros/src/lib.rs
Commit message (Collapse)AuthorAgeFilesLines
* feat: add dispatch strategy features with auto-selection and benchmark魏曹先生17 hours1-4/+38
| | | | | | | | | | | | | | | | | | support Add `dispatch_linear`, `dispatch_tree`, and `dispatch_phf` as mutually exclusive features for selecting the command dispatch strategy. When no strategy feature is enabled, an auto-selection heuristic picks the optimal strategy based on command table characteristics (size, name length, nesting depth). Add the `bench_support` feature to compile all three generators for the benchmark harness, and introduce `bench_cell!` to generate benchmark cells comparing strategies. The PHF generator uses a CHD minimal perfect hash for O(1) lookup independent of table size, while the trie generator was refactored to use a shared fallback method, keeping code size linear in table size.
* refactor!: replace build.rs with compile-time macro build steps魏曹先生3 days1-0/+47
| | | | | | | | | | | | | BREAKING CHANGE: Replace the `build`/`builds` feature system with compile-time macro-driven generation. `gen_program!()` now automatically invokes `build_comp!()` and `build_pathf!()` when the `comp`/`pathf` features are enabled, eliminating the need for `build.rs` and `[build-dependencies]` blocks. This removes the `build` feature, the `mingling::build` module, and all related build-time API functions. Completion scripts are now written to `{target_directory}/mingling/` instead of `target/release/`. The `mingling_cli` uses `build_comp!("mling")` for its custom binary name.
* feat(macros)!: change completion context parameter to owned type魏曹先生4 days1-19/+21
| | | | | | BREAKING CHANGE: `#[completion]` functions must now take `ShellContext` by value instead of `&ShellContext`. Reference parameters are reserved for resource injection.
* feat(macros): relax completion attribute signature魏曹先生4 days1-13/+28
| | | | | | | Allow completion functions to omit the context parameter, accept owned ShellContext or any From<&ShellContext> type, and return any type implementing Into<Suggest>. Add From<&str> for SuggestItem and derive Clone for ShellContext.
* refactor!: replace pack! macros with derive-based pipeline types魏曹先生4 days1-192/+46
| | | | | | | | | Remove the `pack!`, `pack_err!`, `pack_structural!`, and `pack_err_structural!` macros, replacing all pipeline type definitions with `#[derive(Grouped)]` and `#[derive(Grouped, Wrap)]` attributes. This changes the generated struct shape from named-field structs with an `inner` field to tuple structs accessed via `.0`, and removes the auto-generated `name` and `info` fields from error types.
* feat(macros): add Wrap derive macro魏曹先生4 days1-1/+46
| | | | | | Add `#[derive(Wrap)]` to treat a struct as its inner type, generating `From`, `Deref`, and `DerefMut` implementations. Supports single-field structs or multi-field structs with a `#[wrap]`-marked field.
* refactor!: remove Node type and simplify dispatcher macro syntax魏曹先生4 days1-47/+2
| | | | | | | 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.
* refactor!: remove dynamic dispatcher registration API魏曹先生4 days1-149/+13
| | | | | | | Dispatchers are now always registered at compile time, removing the `with_dispatcher` / `with_dispatchers` methods and the `PathfinderConfig` API. The `dispatch_tree` feature now only controls the matching strategy (trie vs linear list).
* chore: add "Doc Not Optimize" comments to source files魏曹先生7 days1-0/+1
| | | | | Mark all source files with a comment indicating they are not optimized for documentation purposes.
* refactor: simplify macro parsing code and fix clippy warnings魏曹先生10 days1-2/+2
|
* refactor(macros): clean up clippy lints and simplify code魏曹先生10 days1-5/+8
|
* feat: add entry metadata system with compile-time typed values魏曹先生2026-08-041-1/+61
| | | | | | | | | | | Add `Metadata<B>` trait and `#[metadata(Entry)]` attribute macro to attach arbitrary, compile-time-typed metadata to entries. Implement `ProgramCollect::get_metadata<T>()` for runtime retrieval, backed by a global registry populated by `register_metadata!`. Extend `pathf` with `MetadataPattern` to resolve metadata types across modules at build time. Add two examples demonstrating metadata usage with and without pathf integration.
* chore!: rename ErrorDispatcherNotFound to EntryFallback魏曹先生2026-08-031-6/+6
| | | | | | | | Rename the internal fallback type and its associated `ProgramCollect` plumbing from `ErrorDispatcherNotFound`/`build_dispatcher_not_found` to `EntryFallback`/`build_entry_fallback`, along with the generated enum variant and pack type. Update all documentation, examples, and tests accordingly.
* refactor!: rename `extra_macros` feature to `extras`feat/new-pipeline-model魏曹先生2026-08-011-25/+25
| | | | | Update all references across docs, examples, and configuration files to use the shorter `extras` feature name.
* feat(mingling_macros, mingling_pathf): add `#[command]` attribute macro魏曹先生2026-07-281-0/+87
| | | | | | | | | | | | | Add a new `#[command]` attribute macro (feature-gated behind `extra_macros`) that converts a plain function with a `Vec<String>` parameter into a fully wired Mingling command. The macro generates a `dispatcher!` call, a `#[chain]` wrapper, and a hidden module re-exporting all generated types. Also add `CommandPattern` to the pathf pattern analyzer to recognize `#[command]`-annotated functions and track their generated hidden modules.
* feat(macros): split monolith into one-macro-per-file modules魏曹先生2026-07-261-49/+23
|
* fix: qualify `render` call as `ProgramCollect::render` in error path魏曹先生2026-07-211-1/+1
|
* feat(macros): add `#[mlint(...)]` marker attribute macro魏曹先生2026-07-211-0/+19
|
* feat(macros): add render_route macro and renderify attribute for render魏曹先生2026-07-211-0/+76
| | | | pipeline error routing
* feat(core, macros): add r_append! macro and RenderResult::append_other魏曹先生2026-07-211-0/+30
| | | | | | | Implement `RenderResult::append_other()` to merge buffered content and immediate output behavior from one result into another. Add the `r_append!` macro with both explicit buffer (`dst, src`) and implicit buffer (`src`) usage forms, re-exported from `mingling::prelude`.
* feat(core)!: replace RenderResult with buffered output model魏曹先生2026-07-211-0/+66
| | | | | | | | | | Remove `Deref<Target=str>` and `render_text:String` in favor of `render_buffer:Vec<(String, RenderResultMode)>` and an `immediate_output` flag. Add `RenderResultMode` enum, `r_eprint!`/`r_eprintln!` macros, and new buffer manipulation methods (`append_to_buffer`, `eprint`, etc.). Update `Display` to trim output and remove trailing newline. Migrate all callers and tests away from `Deref` usage.
* chore: add missing docs lint and document public API魏曹先生2026-07-201-0/+85
| | | | | | | Add `#![deny(missing_docs)]` across multiple crates and fill in documentation for all public items, including struct fields, enum variants, trait methods, and proc macros. Also mark two shell scripts as executable.
* feat(macros): add `#[buffer]` attribute and re-export `r_print!(ln)`魏曹先生2026-07-201-0/+98
| | | | | | | | | | | macros Reintroduce `r_print!` and `r_println!` macros as public exports, now supporting both explicit buffer argument and implicit `#[buffer]` attr. Add `#[buffer]` attribute macro that wraps unit-returning functions to produce a `RenderResult` with an automatically injected buffer variable. Relax `RenderResult::print()` and `println()` to accept `impl AsRef<str>`.
* feat(core)!: remove `to_chain` and `to_render` from `Grouped` trait魏曹先生2026-07-201-1/+1
| | | | | Move routing methods exclusively to the `Routable` trait and update all macro-generated code to reference `Routable` instead of `Grouped`
* feat(routeify): map `?` span to `route!` for tooling support魏曹先生2026-07-201-0/+22
| | | | | | Use the span of the `?` token when generating the macro invocation in the `#[routeify]` transformation, so that rust-analyzer resolves hover and go-to-definition on `?` to the `route!` macro's documentation
* feat(extensions): add routeify extension macro for error routing魏曹先生2026-07-201-0/+21
|
* chore(macros): reorganize module hierarchy in mingling_macros魏曹先生2026-07-201-708/+42
| | | | | | Restructure flat module layout into logical directories (attr/, derive/, func/, systems/, extensions/, utils.rs). Tighten internal function visibility to pub(crate). All public API signatures remain unchanged.
* feat(macros): add extension point mechanism for attribute macros魏曹先生2026-07-201-1/+19
| | | | | | | Implement an `extensions` module in `mingling_macros` that allows attribute macros to accept extension identifiers (e.g., `routeify`) which are re-dispatched as outer attributes before the core macro logic runs, enabling extensibility without modifying existing macros
* feat(macros): add Routable trait and update route! macro魏曹先生2026-07-191-8/+35
| | | | | | Introduce a `Routable` trait with `to_chain` and `to_render` methods, replacing direct `Grouped` usage in the `route!` macro so error branches correctly route through the rendering pipeline
* fix!: rename `Groupped` to `Grouped` across the codebase魏曹先生2026-07-191-40/+40
|
* feat(macros): relax `#[help]` return type to accept `Into<RenderResult>`魏曹先生2026-07-181-1/+1
|
* ix(macros)!: require explicit `.into()` on chain function return values魏曹先生2026-07-181-1/+2
|
* docs: add module-level documentation and improve doc comments魏曹先生2026-07-171-40/+40
|
* fix(docs): correct RenderResult usage examples to use mut binding and魏曹先生2026-07-111-7/+10
| | | | add Write import
* feat: require renderers to return RenderResult instead of mutating one魏曹先生2026-07-111-143/+66
| | | | | | | BREAKING CHANGE: The `render` method on `Renderer`, `HelpRequest`, and `ProgramCollect` now returns `RenderResult` instead of taking `&mut RenderResult`. The `r_print!` and `r_println!` macros have been removed in favor of using `std::io::Write` directly on `RenderResult`.
* fix(macros): fix false positives in entry_has_variant substring matching魏曹先生2026-07-021-4/+21
|
* fix(macros): pass pathf_map into dispatch tree generators魏曹先生2026-06-291-3/+3
|
* feat(macros): add pathf type resolution for downcasts魏曹先生2026-06-291-29/+81
|
* refactor(macros): reorganize module structure and parse pathf include魏曹先生2026-06-291-6/+25
| | | | | | | inline Instead of using `include!` with generated paths, read the file at compile time and parse it into a token stream during macro expansion.
* feat(pathf): add build-time type path resolution system魏曹先生2026-06-281-0/+10
| | | | | | | Add `mingling_pathf` sub-crate and `pathf` feature for automatic resolution of Mingling type module paths at build time. Scans source files, identifies macro invocations via pattern matchers, and generates mapping files consumed by `gen_program!()`.
* feat(macros): add async mutable resource injection for `#[chain]`魏曹先生2026-06-271-2/+16
| | | | | | | Support `&mut T` resource parameters in async chain functions by using an extract-store pattern that avoids holding mutable borrows across await points. Remove the previous compile-time rejection of this combination.
* feat(macros, docs): register structural macros and update feature table魏曹先生2026-06-261-2/+10
|
* feat(macros): Render ResultEmpty for non-structural types魏曹先生2026-06-261-1/+7
|
* feat(macros): simplify ResultEmpty to a unit struct魏曹先生2026-06-261-3/+15
|
* refactor(general_renderer): rename to structural_renderer魏曹先生2026-06-261-38/+38
|
* feat(core): decouple structured output from Groupped trait魏曹先生2026-06-261-0/+88
| | | | | | | Introduce `StructuralData` sealed trait and `pack_structural!` / `group_structural!` / `derive(StructuralData)` macros to control structured rendering separately from grouping. `Groupped` no longer requires `Serialize`.
* fix(dispatch_tree): use proper snake_case for dispatcher static names魏曹先生2026-06-251-1/+1
| | | | | | | | | Fix the static name generation for dispatch tree nodes to use a correct snake_case conversion instead of a simple `.` to `_` replacement. Also correct the `__comp` completion dispatcher name from triple underscore to double underscore, resolving a mismatch between `register_dispatcher!` and `program_comp_gen`
* Trim whitespace from variant string after removing trailing comma魏曹先生2026-06-231-1/+1
|
* Add entry-str dedup and registry cleanup in final gen魏曹先生2026-06-231-0/+22
|
* Add compile-time duplicate variant detection魏曹先生2026-06-231-0/+31
| | | | | | Add duplicate variant checks for chain, renderer, help, and completion registrations to produce a clear compile error instead of silently generating unreachable code