aboutsummaryrefslogtreecommitdiff
path: root/mingling_core/src/docs/build.md
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-08-03 01:12:50 +0800
committer魏曹先生 <1992414357@qq.com>2026-08-03 01:12:50 +0800
commit7ded2fd8b3b3dc10800d72ff69aa369432428cf2 (patch)
tree3d8bcfb384ba6f2a68e9ff2fe00ecd92d3e3c6c0 /mingling_core/src/docs/build.md
parent0fbd748cd01ab530253ddbc5b810dc665d02acb8 (diff)
docs(build): update build feature documentation
Document build-time features, feature pairing, and add a `build.rs` template for easily setting up `comp` and `pathf`.
Diffstat (limited to 'mingling_core/src/docs/build.md')
-rw-r--r--mingling_core/src/docs/build.md55
1 files changed, 49 insertions, 6 deletions
diff --git a/mingling_core/src/docs/build.md b/mingling_core/src/docs/build.md
index dac3778..6f9285a 100644
--- a/mingling_core/src/docs/build.md
+++ b/mingling_core/src/docs/build.md
@@ -1,14 +1,57 @@
-Provides Mingling's build script module, used in `build.rs` to provide build-time behavior for certain features.
+Provide Mingling's build script module for build-time behavior of specific features in `build.rs`.
-To use it, add the following to your `Cargo.toml` under `[build-dependencies]`, and enable the features
-that require build-time behavior from the crate:
+To use it, add a dependency on mingling under `[build-dependencies]` in `Cargo.toml`, and enable the relevant features:
+
+## Build-Time Related Features
+
+| Name | Purpose |
+| ---------------- | ------------------------------------------------------------------------------------------------- |
+| `build` | Master switch for build-time features |
+| `build_advanced` | Master switch for build-time features, paired with the `advanced` feature |
+| `build_full` | Master switch for build-time features, paired with the `full` feature |
+| `comp` | Completion script builder; both sides must enable it, generates cross-platform completion scripts |
+| `pathf` | Type path analyzer; both sides must enable it, generates type mapping tables |
+| `dispatch_tree` | Compile-time dispatch tree; when `pathf` is a build-time dependency, |
+| | and `dispatch_tree` (included in `advanced` or `full`) is enabled, both sides should enable it |
```toml
# Cargo.toml
+[dependencies.mingling]
+features = [
+ "advanced", # Enable `advanced` if using it
+]
+
[build-dependencies.mingling]
-version = "0.3.0"
features = [
- "build", # Enable it
- "comp", # If you need completion-related build-time behavior, enable this as well
+ "build_advanced" # This side should enable `build_advanced`
]
```
+
+## `build.rs` Templates
+
+You can use the following template to write `build.rs` to quickly gain the build-time capabilities of `comp` and `pathf`:
+
+```rust,ignore
+// build.rs
+fn main() {
+ build_scripts();
+ build_pathf_mapping();
+}
+
+/// Generate completion scripts
+fn build_scripts() {
+ // `env!("CARGO_PKG_NAME")` equals the crate name, which matches the binary name.
+ // If your binary name differs from the crate name, specify it explicitly.
+ mingling::build::build_comp_scripts(
+ // Your binary name:
+ env!("CARGO_PKG_NAME"),
+ )
+ .unwrap();
+}
+
+fn build_pathf_mapping() {
+ // Build pathf type mapping to ensure that the enabled `pathf` feature
+ // can correctly scan macros in the project
+ mingling::build::analyze_and_build_type_mapping().unwrap();
+}
+```