4个版本 (2个重大更新)
0.3.0 | 2023年7月12日 |
---|---|
0.2.0 | 2022年5月28日 |
0.1.2 | 2022年3月28日 |
0.1.1 | 2022年3月28日 |
#522 in 过程宏
58KB
980 代码行
syn-file-expand
额外功能:CLI工具
syn-file-expand-cli
工具扩展Rust源代码,如 cargo expand
,但不进行宏展开,仅针对模块。不涉及 rustc
。建议使用 rustfmt
进行调试。
$ syn-file-expand-cli -fTp src/lib.rs
#![doc = include_str!("../README.md")]
#![forbid(unsafe_code)]
...
mod attrs {
use proc_macro2;
...
}
mod expand_impl {
use std::path::PathBuf;
...
}
$ syn-file-expand-cli --help
Usage: syn-file-expand-cli [OPTIONS]
Use `syn-file-expand-cli -fTp src/lib.rs` as a starting point.
Reads rust source file, including referred modules and expands them into a single source with all modules inline
Apart from respective dedicated command line arguments, conditional paths like
`#[cfg_attr(feature="qqq"),path=...)` are resolved using
environment variables like SYN_FILE_EXPAND_FEATURE_QQQ=1
Other influential envvars: SYN_FILE_EXPAND_DEBUGVARS=1 SYN_FILE_EXPAND_DEFAULTTRUE=1
Positional arguments:
input_file Input Rust source file to start crawling from
Optional arguments:
-h, --help
-l, --loopify Convert all blocks and expressions to `loop{}`s.
Note that inner items within blocks get lost in the process.
-D, --undoc Strip all documentation attributes. Note that inner items within blocks are not processed and may retain their attributes.
-T, --cfg-true-by-default Assume all `#[cfg]`s and `#[cfg_attr]`s are true. May lead to errors unless `-f` is also used.
-f, --full-crate-tree Allow duplicate modules, also preserve/transform some `cfg` attributes.
-c, --cfg CFG Set this cfg check result to true.
Note that `all` or `any` are not handled.
You need to set all needed expression results one by one.
Strings required for --cfg are not the same as for environment variables-
-based version of this feature.
-u, --unset-cfg UNSET-CFG In `--cfg-true-by-default` mode, explicitly unset given cfg expression outcome.
-d, --debug-cfg Print each encountered cfg check to stderr, in form suitable for `--cfg` parameter
Note that the format is different from the one used by `SYN_FILE_EXPAND_DEBUGVARS=1` environment variable.
-o, --output OUTPUT Use given file for output instead of stdout
-p, --pretty Use `prettyplease` to format the output
该工具在Github发行版中为各种平台预构建。
您也可以使用 cargo install syn-file-expand-cli
命令安装该工具。
依赖项
~2.5MB
~57K SLoC