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
//! Control flow graph extraction and rendering.
//!
//! Builds CFGs from parsed AST nodes, representing the control flow
//! structure of functions including branches, loops, and exception handling.
//!
//! # Modules
//!
//! - [`types`]: Core CFG data structures (blocks, edges, graph)
//! - [`builder`]: CFG construction from source code
//! - [`render`]: Output formats (Mermaid, DOT, ASCII, JSON)
//!
//! # Example
//!
//! ```ignore
//! use go_brrr::cfg::{extract, render};
//!
//! let cfg = extract("src/main.rs", "process_data")?;
//! println!("{}", render::to_mermaid(&cfg));
//! println!("{}", render::to_dot(&cfg));
//! ```
// Re-exports for the crate's public API (used by lib.rs)
pub use ;
// Re-export builder
pub use CfgBuilder;
// Re-export render functions for convenience
pub use ;
use crateResult;
/// Extract CFG for a function in a file.
///
/// This is a convenience function that wraps [`CfgBuilder::extract_from_file`].
///
/// # Arguments
///
/// * `file` - Path to the source file
/// * `function` - Name of the function to extract CFG for
///
/// # Returns
///
/// The control flow graph for the specified function.
///
/// # Errors
///
/// Returns an error if:
/// - The file cannot be read
/// - The language is not supported
/// - The function is not found
/// - Parsing fails
/// Extract CFG for a function with explicit language specification.
///
/// This function allows overriding the language auto-detection, which is useful
/// for files without extensions or with non-standard extensions.
///
/// # Arguments
///
/// * `file` - Path to the source file
/// * `function` - Name of the function to extract CFG for
/// * `language` - Optional language override (e.g., "python", "typescript", "rust").
/// If `None`, language is auto-detected from file extension.
///
/// # Returns
///
/// The control flow graph for the specified function.
///
/// # Errors
///
/// Returns an error if:
/// - The file cannot be read
/// - The language is not supported
/// - The function is not found
/// - Parsing fails