Module parser

Module parser 

Source
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§

CodeBase
Represents a parsed Rust codebase containing all discovered code elements.
CodebaseParser
High-level codebase parser that combines directory walking with Rust parsing.
DirectoryWalker
Walks a directory tree and discovers Rust source files.
EnumInfo
Represents a parsed Rust enum with its variants and documentation.
EnumVariant
Represents a single variant of an enum.
FieldInfo
Represents a field in a struct or enum variant.
FileInfo
Information about a parsed source file.
MethodInfo
Represents a method implemented on a struct.
ParameterInfo
Represents a method parameter.
RustParser
Parses Rust source files and extracts code structure information.
StructInfo
Represents a parsed Rust struct with its fields and documentation.
WalkerConfig
Configuration options for the directory walker.

Enums§

ParseError
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§

ParseResult
Result type alias for parser operations.