{"id":15373042,"url":"https://github.com/vi/syn-file-expand","last_synced_at":"2025-04-15T12:31:28.181Z","repository":{"id":41243654,"uuid":"473712566","full_name":"vi/syn-file-expand","owner":"vi","description":"Rust library to scan files and expand (make modules inline) multi-file crates source code as a single tree. ","archived":false,"fork":false,"pushed_at":"2024-01-10T11:18:31.000Z","size":106,"stargazers_count":17,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-28T21:02:57.019Z","etag":null,"topics":["ast","modules","proc-macro","rust"],"latest_commit_sha":null,"homepage":"https://docs.rs/syn-file-expand/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-24T17:43:29.000Z","updated_at":"2025-03-19T22:52:45.000Z","dependencies_parsed_at":"2024-10-16T13:01:13.586Z","dependency_job_id":null,"html_url":"https://github.com/vi/syn-file-expand","commit_stats":{"total_commits":42,"total_committers":1,"mean_commits":42.0,"dds":0.0,"last_synced_commit":"44f029629f2d0d1418b20428d593d529d764ae18"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vi%2Fsyn-file-expand","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vi%2Fsyn-file-expand/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vi%2Fsyn-file-expand/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vi%2Fsyn-file-expand/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vi","download_url":"https://codeload.github.com/vi/syn-file-expand/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249072206,"owners_count":21208138,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ast","modules","proc-macro","rust"],"created_at":"2024-10-01T13:54:09.095Z","updated_at":"2025-04-15T12:31:27.903Z","avatar_url":"https://github.com/vi.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# syn-file-expand\n\nThis library allows you to load full source code of multi-file crates into a single [`syn::File`](https://docs.rs/syn/latest/syn/struct.File.html).\n\nFeatures:\n\n* Based on `syn` crate.\n* Handling `#[path]` attributes\n* Handling `#[cfg]` where it affects modules to filesystem mapping\n* There is both a lower-level IO-less function and a simpler one that just loads crate from a `std::fs::Path`.\n\nLimitation:\n\n* `cfg_if` [like this](https://github.com/Amanieu/parking_lot/blob/a75875b0bf904287a9749e8eabea919b5e9dd8a9/core/src/thread_parker/mod.rs#L53-L83) is not handled.\n* `include!` / `include_str!` / `include_bytes!` is not handled.\n\nStart exploring the library from the [`read_crate`](https://docs.rs/syn-file-expand/latest/syn_file_expand/fn.read_crate.html) function.\n\n# Bonus: CLI tool \n\n`syn-file-expand-cli` tool expands Rust sources, like `cargo expand`, but without macro expansion, only for modules.\n`rustc` is not involved. Filtering through `rustfmt` is adviced for debugging use case. \n\n```text\n$ syn-file-expand-cli -fTp src/lib.rs\n#![doc = include_str!(\"../README.md\")]\n#![forbid(unsafe_code)]\n...\nmod attrs {\n    use proc_macro2;\n    ...\n}\nmod expand_impl {\n    use std::path::PathBuf;\n    ...\n}\n\n$ syn-file-expand-cli --help\nUsage: syn-file-expand-cli [OPTIONS]\n\nUse `syn-file-expand-cli -fTp src/lib.rs` as a starting point.\n\nReads rust source file, including referred modules and expands them into a single source with all modules inline\nApart from respective dedicated command line arguments, conditional paths like\n`#[cfg_attr(feature=\"qqq\"),path=...)` are resolved using\nenvironment variables like SYN_FILE_EXPAND_FEATURE_QQQ=1\nOther influential envvars: SYN_FILE_EXPAND_DEBUGVARS=1 SYN_FILE_EXPAND_DEFAULTTRUE=1\n\nPositional arguments:\n  input_file                 Input Rust source file to start crawling from\n\nOptional arguments:\n  -h, --help\n  -l, --loopify              Convert all blocks and expressions to `loop{}`s.\n                      Note that inner items within blocks get lost in the process.\n  -D, --undoc                Strip all documentation attributes. Note that inner items within blocks are not processed and may retain their attributes.\n  -T, --cfg-true-by-default  Assume all `#[cfg]`s and `#[cfg_attr]`s are true. May lead to errors unless `-f` is also used.\n  -f, --full-crate-tree      Allow duplicate modules, also preserve/transform some `cfg` attributes.\n  -c, --cfg CFG              Set this cfg check result to true.\n                                Note that `all` or `any` are not handled.\n                                You need to set all needed expression results one by one.\n                                Strings required for --cfg are not the same as for environment variables-\n                                -based version of this feature.\n  -u, --unset-cfg UNSET-CFG  In `--cfg-true-by-default` mode, explicitly unset given cfg expression outcome.\n  -d, --debug-cfg            Print each encountered cfg check to stderr, in form suitable for `--cfg` parameter\n                   Note that the format is different from the one used by `SYN_FILE_EXPAND_DEBUGVARS=1` environment variable.\n  -o, --output OUTPUT        Use given file for output instead of stdout\n  -p, --pretty               Use `prettyplease` to format the output\n\n```\n\nThere is [a Github release](https://github.com/vi/syn-file-expand/releases/) with the tool pre-built for various platforms.  \nYou can also install the tool using `cargo install syn-file-expand-cli`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvi%2Fsyn-file-expand","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvi%2Fsyn-file-expand","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvi%2Fsyn-file-expand/lists"}