Expand description
§dgmod
Generates Mermaid diagrams of Rust module dependencies.
§Installation
cargo install --path dgmodOr run directly from the workspace:
cargo run -p dgmod -- /path/to/crate§Usage
dgmod [OPTIONS] [PATH]§Arguments
PATH— Path to the Rust crate or workspace to analyze (default: current directory)
§Options
--exclude-tests— Excludetestsmodules from the output
§Examples
# Analyze current directory
dgmod
# Analyze a specific crate
dgmod /path/to/my-crate
# Save output to a file
dgmod /path/to/my-crate > deps.md
# Exclude test modules
dgmod --exclude-tests§Example
Given a crate with this structure:
src/
├── lib.rs # pub mod alpha; pub mod beta;
├── alpha/
│ ├── mod.rs # pub mod delta;
│ └── delta.rs
└── beta.rs # use crate::alpha::delta;Running dgmod produces:
## my-crate
```mermaid
flowchart TD
crate["crate"]
alpha["alpha"]
alpha_delta["alpha::delta"]
beta["beta"]
crate --> alpha
crate --> beta
alpha --> alpha_delta
beta -.-> alpha_delta
```Which renders as:
flowchart TD
crate["crate"]
alpha["alpha"]
alpha_delta["alpha::delta"]
beta["beta"]
crate --> alpha
crate --> beta
alpha --> alpha_delta
beta -.-> alpha_delta§Edge Types
- Solid arrows (
-->) —moddeclarations (parent declares child module) - Dashed arrows (
-.->) —useimports (module imports from another)
§Workspace Support
When pointed at a Cargo workspace, dgmod generates a separate diagram for each member crate.
Modules§
- graph
- Graph data structures for module dependencies
- mermaid
- Mermaid diagram output formatting
- parser
- Rust source file parsing using syn
- resolver
- Module path resolution
- workspace
- Cargo workspace detection
Enums§
- Analyze
Error - Errors that can occur during crate analysis
- Parse
Error - Errors that can occur during parsing
- Resolve
Error - Errors that can occur during module resolution
Functions§
- analyze_
crate - Analyze a crate and build its module dependency graph