A cargo plugin for showing an overview of a crate's modules.
With time, as your Rust projects grow bigger and bigger, it gets more and more important to properly structure your code. Fortunately Rust provides us with a quite sophisticated module system, allowing us to neatly split up our crates into arbitrarily small sub-modules of types and functions. While this helps to avoid monolithic and unstructured chunks of code, it can also make it hard at times to still mentally stay on top of the over-all high-level structure of the project at hand.
This is where cargo-modules
comes into play:
Install cargo-modules
via:
bash
cargo install cargo-modules
bash
cargo modules generate tree <OPTIONS>
```terminal USAGE: cargo-modules generate tree [FLAGS] [OPTIONS]
FLAGS:
--all-features Activate all available features
-h, --help Prints help information
--lib Process only this package's library
--no-default-features Do not activate the default
feature
-V, --version Prints version information
--verbose Enable verbose messages during command execution
--with-orphans Include orphaned modules (i.e. unused files in /src)
--with-tests Include tests (e.g. #[cfg(test)] mod tests { … }
)
--with-types Include types (e.g. structs, enums)
OPTIONS:
--bin --cargo-all-features
is provided
--focus-on cargo help pkgid
)
--target
bash
cargo modules generate graph <OPTIONS>
```terminal USAGE: cargo-modules generate graph [FLAGS] [OPTIONS]
FLAGS:
--all-features Activate all available features
-h, --help Prints help information
--lib Process only this package's library
--no-default-features Do not activate the default
feature
-V, --version Prints version information
--verbose Enable verbose messages during command execution
--with-externs Include used modules and types from extern crates
--with-orphans Include orphaned modules (i.e. unused files in /src)
--with-tests Include tests (e.g. #[cfg(test)] mod tests { … }
)
--with-types Include types (e.g. structs, enums)
--with-uses Include used modules and types
OPTIONS:
--bin --cargo-all-features
is provided
--focus-on cargo help pkgid
)
--target
If you have xdot installed on your system, you can run this using:
`cargo modules generate dependencies | xdot -`
```
cargo-modules checks for the presence of a NO_COLOR
environment variable that, when present (regardless of its value), prevents the addition of color to the console output.
Please read CONTRIBUTING.md for details on our code of conduct,
and the process for submitting pull requests to us.
We use SemVer for versioning. For the versions available, see the tags on this repository.
This project is licensed under the MPL-2.0 – see the LICENSE.md file for details.