1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//! crawk - Rust module dependency analyzer
//!
//! This library provides tools for analyzing module dependencies in Rust codebases.
//! It parses Rust source code to identify all internal crate references including
//! `use` statements, type annotations, trait bounds, struct literals, and macro invocations.
//!
//! # Quick Start
//!
//! ```no_run
//! # use crawk::{Analyzer, AnalysisOptions};
//! # use std::path::Path;
//! # fn main() -> Result<(), crawk::AnalysisError> {
//! let mut analyzer = Analyzer::new(Path::new("/path/to/crate"))?;
//! let options = AnalysisOptions::default();
//! let result = analyzer.analyze_module("utils::parser", &options)?;
//!
//! for (module, refs) in result.dependencies() {
//! println!("{module}");
//! for reference in refs {
//! println!(" {reference}");
//! }
//! }
//! # Ok(())
//! # }
//! ```
//!
//! # Key Concepts
//!
//! ## Module path
//!
//! A **module path** is the `::` separated path to a module within the crate, mirroring
//! the file layout under `src/`. For example:
//!
//! | File | Module path |
//! |----------------------------|---------------------|
//! | `src/lib.rs` | *(empty string)* |
//! | `src/utils.rs` | `"utils"` |
//! | `src/utils/parser.rs` | `"utils::parser"` |
//! | `src/utils/parser/lexer.rs`| `"utils::parser::lexer"` |
//!
//! Inline modules (declared with `mod foo { … }` inside a file) are addressed by their
//! full path too, e.g. `"utils::parser::tests"` for a `mod tests` block inside
//! `src/utils/parser.rs`.
//!
//! ## Internal crate references
//!
//! crawk reports **internal crate references** — paths that point to items defined inside
//! the analyzed crate itself, not to `std` or external dependencies. A path is considered
//! internal if it starts with `crate::`, `self::`, `super::`, or the crate's own name.
//! All such paths are normalized to their canonical form before being returned.
//!
//! ## Relationship between `Analyzer::new` and `analyze_module`
//!
//! [`Analyzer::new`](Analyzer::new) takes the **crate root directory** (the one containing
//! `Cargo.toml`) and initializes internal state. [`Analyzer::analyze_module`](Analyzer::analyze_module)
//! then takes a **module path** (see above) relative to that crate and returns its dependencies.
//! The same `Analyzer` instance can be reused to analyze multiple modules; it caches parsed
//! files internally to avoid redundant I/O.
//!
//! # MSRV
//!
//! Requires Rust **1.88** or later (`edition = "2024"`).
//!
//! # Features
//!
//! - **Comprehensive dependency detection**: Captures not just `use` statements but also
//! type annotations, trait bounds, struct patterns/literals, impl blocks, and macro invocations
//! - **Path expansion**: Resolves `self::` and `super::` to absolute `crate::` paths
//! - **Glob expansion**: Optionally expands `use crate::foo::*` to explicit items
//! - **Test module filtering**: Optionally include or exclude `#[cfg(test)]` modules
//! - **Depth limiting**: Truncate [`TypeReference`] paths via [`TypeReference::truncate_to_depth`]
pub use crateAnalyzer;
pub use crate;
pub use crateAnalysisError;
pub use crate;
pub use crate;
pub use crate;