Skip to content

hypernetix/codematrix-rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

codematrix-rust

codematrix-rust is a Rust CLI tool that scans a Rust crate and produces a code matrix model as JSON, Mermaid, or Graphviz DOT. The generated JSON model can be visualized with the Code Matrix viewer (hypernetix/codematrix).

Installation

  • From source (this repository):
cargo build --release

This will build the codematrix-rust binary in target/release/.

Alternatively install it globally for your user:

cargo install --path .
codematrix-rust --help

Basic usage

The CLI expects the path to the crate root (the folder containing Cargo.toml) as the first positional argument. Other options can appear before or after the path.

codematrix_rust <PATH_TO_CRATE_ROOT> [--out <OUTPUT_JSON>] [--format <json|mermaid|dot>] [--include-private]
  • PATH_TO_CRATE_ROOT: required positional argument; path to the Rust crate to scan.
  • --out: output file path for the generated JSON model (only used when --format json, default: codematrix_rust.json).
  • --format: output format: json (default), mermaid, or dot.
  • --include-private: include non-public items on a best-effort basis; by default only public items are modeled.

Examples:

# Generate a JSON code matrix for the current crate (see `codematrix_rust.json`)
codematrix-rust .

# Generate a JSON code matrix for another crate and write to a custom file
codematrix-rust /path/to/other/crate --out my_code_matrix.json

# Generate Mermaid class diagram to stdout
codematrix-rust . --format mermaid

# Generate Graphviz DOT to stdout including private items
codematrix-rust . --format dot --include-private

Generating the Code Matrix JSON file

To produce the JSON file that can be consumed by external tools:

  1. Build the CLI (from this repo):

    cargo build --release
  2. Run the scanner against your crate (from anywhere):

    /path/to/codematrix-rust/target/release/codematrix-rust <PATH_TO_CRATE_ROOT> --out codematrix_rust.json --format json

    This creates codematrix_rust.json in the current working directory.

Viewing the Code Matrix

The generated JSON model is designed to be consumed by the Code Matrix viewer. You can use the viewer from the hypernetix/codematrix project to explore the graph:

Follow the instructions in that repository to load the codematrix_rust.json file and visualize your Rust codebase.

Roadmap

  • Add official codematrix format extension and specification
  • Add unit tests

About

Rust parser for the Hypernetix CodeMatrix tool

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages