#cargo #plugin #module #mod #tree

bin+lib cargo-modules

A cargo plugin for showing a tree-like overview of a crate’s modules

23 releases

new 0.5.0-beta.2 Feb 21, 2021
0.4.10 Dec 9, 2020
0.4.9 Aug 14, 2020
0.4.8 Jul 6, 2020
0.2.2 Jun 30, 2016

#46 in Cargo plugins

Download history 34/week @ 2020-11-03 14/week @ 2020-11-10 15/week @ 2020-11-17 41/week @ 2020-11-24 19/week @ 2020-12-01 115/week @ 2020-12-08 34/week @ 2020-12-15 16/week @ 2020-12-22 43/week @ 2020-12-29 26/week @ 2021-01-05 17/week @ 2021-01-12 48/week @ 2021-01-19 11/week @ 2021-01-26 19/week @ 2021-02-02 64/week @ 2021-02-09 127/week @ 2021-02-16

186 downloads per month

MPL-2.0 license

84KB
2K SLoC

cargo-modules

Build Status Downloads Version License

Synopsis

A cargo plugin for showing an overview of a crate's modules.

Motivation

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:

Installation

Install cargo-modules via:

cargo install cargo-modules

Usage

Print crate as a tree

cargo modules generate tree <OPTIONS>
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 <bin>                        Process only the specified binary
        --features <features>...           List of features to activate. This will be ignored if `--cargo-all-features`
                                           is provided
        --focus-on <focus-on>              Focus the graph on a particular path's environment
        --manifest-path <manifest-path>     [default: ./Cargo.toml]
        --max-depth <max-depth>            The maximum depth of the generated graph relative to the node selected by
                                           '--focus-on'
    -p, --package <package>                Package to process (see `cargo help pkgid`)
        --target <target>                  rustc target

Print crate as a graph

cargo modules generate graph <OPTIONS>
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 <bin>                        Process only the specified binary
        --features <features>...           List of features to activate. This will be ignored if `--cargo-all-features`
                                           is provided
        --focus-on <focus-on>              Focus the graph on a particular path's environment
        --layout <layout>                  The graph layout algorithm to use (e.g. dot, neato, twopi, circo, fdp, sfdp)
                                           [default: neato]
        --manifest-path <manifest-path>     [default: ./Cargo.toml]
        --max-depth <max-depth>            The maximum depth of the generated graph relative to the node selected by
                                           '--focus-on'
    -p, --package <package>                Package to process (see `cargo help pkgid`)
        --target <target>                  rustc target


        If you have xdot installed on your system, you can run this using:
        `cargo modules generate dependencies | xdot -`

No-Color Mode

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.

Contributing

Please read CONTRIBUTING.md for details on our code of conduct,
and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

License

This project is licensed under the MPL-2.0 – see the LICENSE.md file for details.

Dependencies

~11MB
~236K SLoC