pub struct Extractor { /* private fields */ }Expand description
The main entry point for annotation extraction.
Construct with Extractor::new (auto-discovers ast-grep on PATH) or
Extractor::with_binary (explicit binary path).
Implementations§
Source§impl Extractor
impl Extractor
Sourcepub fn new() -> Result<Self, ExtractorError>
pub fn new() -> Result<Self, ExtractorError>
Construct an Extractor using the bundled (compile-time embedded) rules
and ast-grep from PATH.
Returns ExtractorError::BinaryNotFound if ast-grep cannot be located.
Sourcepub fn with_rules(rules_path: PathBuf) -> Result<Self, ExtractorError>
pub fn with_rules(rules_path: PathBuf) -> Result<Self, ExtractorError>
Construct using a custom rules YAML path and ast-grep from PATH.
Sourcepub fn with_binary(
rules_path: PathBuf,
ast_grep_bin: PathBuf,
) -> Result<Self, ExtractorError>
pub fn with_binary( rules_path: PathBuf, ast_grep_bin: PathBuf, ) -> Result<Self, ExtractorError>
Construct using explicit paths for both the rules file and the binary.
Sourcepub fn scan_dir(&self, root: &Path) -> Result<ScanResult, ExtractorError>
pub fn scan_dir(&self, root: &Path) -> Result<ScanResult, ExtractorError>
Scan an entire directory tree for G8 annotations.
Uses the ignore crate to walk the tree (respects .gitignore).
Source files are processed via ast-grep; Markdown sidecars are processed
by the native section scanner.
The file .g8/INTENT_SUMMARY.md is excluded from extraction to avoid
a feedback loop (per ARCHITECTURE.md §3.2).
Sourcepub fn scan_file(&self, file: &Path) -> Result<Vec<Annotation>, ExtractorError>
pub fn scan_file(&self, file: &Path) -> Result<Vec<Annotation>, ExtractorError>
Scan a single source file for magic-comment annotations.
For Markdown sidecars, delegates to the native section parser.
For other file types, invokes ast-grep restricted to that one file.