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
mod ast;
pub mod cli;
mod display;
pub mod error;
pub mod dump;
mod graph;
mod parser;
use display::{dot::Dot, tikz::Tikz, GraphDisplay, GraphDisplayBackend};
use error::Result;
pub fn generate(
    content: &[u8],
    file_name: &str,
    function_name: Option<String>,
    curly: bool,
    tikz: bool,
) -> Result<String> {
    let ast = parser::parse(content, file_name, function_name)?;
    // dbg!(&ast);
    let graph = graph::from_ast(ast, &String::from_utf8(content.to_vec())?, file_name)?;
    // dbg!(&graph);
    let display: GraphDisplayBackend = if tikz {
        Tikz::new().into()
    } else {
        Dot::new(curly).into()
    };
    display.generate_from_graph(&graph)
}