Class: Archsight::Import::Handlers::RustGrapher
- Inherits:
-
Grapher
- Object
- Archsight::Import::Handler
- Grapher
- Archsight::Import::Handlers::RustGrapher
- Defined in:
- lib/archsight/import/handlers/rust_grapher.rb
Overview
RustGrapher — analyses a Rust repository and generates a GraphViz DOT graph of its crate/module structure, stored as architecture/rust/modules on the TechnologyArtifact.
Supports single-crate projects (Cargo.toml at root) and Cargo workspaces
(root Cargo.toml with [workspace] members). Uses pure static regex analysis
of use crate:: and use <workspace_member>:: statements — no Rust
toolchain required.
File-to-package mapping follows Rust conventions:
src/lib.rs, src/main.rs → crate root package
src/foo.rs → crate/foo
src/foo/mod.rs → crate/foo (directory module)
src/foo/bar.rs → crate/foo/bar → capped to crate/foo
Configuration:
import/config/path - Path to the Rust repository root
import/config/ranksep - Horizontal gap between rank columns (default: 0.6)
import/config/nodesep - Vertical gap between nodes in a column (default: 0.15)
Constant Summary collapse
- SKIP_DIRS =
%w[target .git tests test benches examples].freeze
- MAX_PKG_DEPTH =
MAX_PKG_DEPTH = 2: crate/feature is the natural Rust module depth.
2- USE_CRATE_RE =
use crate::foo::bar::Baz — capture everything after crate::
/^\s*use\s+crate::((?:\w+::)*\w+)/- USE_PATH_RE =
use some_crate::path — capture full path for workspace dep resolution
/^\s*use\s+((?:\w+::)*\w+)/- BUILTIN_PREFIXES =
Identifiers that are never workspace crate names
%w[crate super self].freeze
Constants inherited from Grapher
Instance Attribute Summary
Attributes inherited from Archsight::Import::Handler
#database, #import_resource, #progress, #resources_dir, #shared_writer
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Grapher
#dot_graph, #execute, #safe_glob
Methods inherited from Archsight::Import::Handler
#compute_config_hash, #config, #config_all, #execute, #import_yaml, #initialize, #resource_yaml, #resources_to_yaml, #self_marker, #write_generates_meta, #write_yaml
Constructor Details
This class inherits a constructor from Archsight::Import::Handler
Class Method Details
.applicable?(path) ⇒ Boolean
28 29 30 31 |
# File 'lib/archsight/import/handlers/rust_grapher.rb', line 28 def self.applicable?(path) File.exist?(File.join(path, "Cargo.toml")) || Dir.glob(File.join(path, "*/Cargo.toml")).any? end |
.language_name ⇒ Object
26 |
# File 'lib/archsight/import/handlers/rust_grapher.rb', line 26 def self.language_name = "rust" |
Instance Method Details
#wrap_single_module? ⇒ Boolean
33 34 35 |
# File 'lib/archsight/import/handlers/rust_grapher.rb', line 33 def wrap_single_module? true end |