Expand description
Parser module for analyzing Rust source code.
This module provides functionality to walk directories, parse Rust source files, and extract structured information about code elements including:
- Enums: With variants, documentation, and attributes
- Structs: With fields, documentation, and attributes
- Methods: As implemented on structs, with parameters and documentation
§Example
use herolib_code::parser::{CodebaseParser, WalkerConfig};
// Parse a directory with default settings
let parser = CodebaseParser::new();
let codebase = parser.parse_directory("./src").unwrap();
// Print all discovered structs
for struct_info in &codebase.structs {
println!("Struct: {}", struct_info.name);
if let Some(doc) = &struct_info.doc_comment {
println!(" Doc: {}", doc);
}
for method in &struct_info.methods {
println!(" Method: {}", method.name);
}
}Structs§
- Code
Base - Represents a parsed Rust codebase containing all discovered code elements.
- Codebase
Parser - High-level codebase parser that combines directory walking with Rust parsing.
- Directory
Walker - Walks a directory tree and discovers Rust source files.
- Enum
Info - Represents a parsed Rust enum with its variants and documentation.
- Enum
Variant - Represents a single variant of an enum.
- Field
Info - Represents a field in a struct or enum variant.
- File
Info - Information about a parsed source file.
- Method
Info - Represents a method implemented on a struct.
- Parameter
Info - Represents a method parameter.
- Rust
Parser - Parses Rust source files and extracts code structure information.
- Struct
Info - Represents a parsed Rust struct with its fields and documentation.
- Walker
Config - Configuration options for the directory walker.
Enums§
- Parse
Error - Errors that can occur during code parsing.
- Receiver
- Represents the receiver of a method (self parameter).
- Visibility
- Represents the visibility of a Rust item.
Type Aliases§
- Parse
Result - Result type alias for parser operations.