Function flowclib::dumper::functions_to_dot::dump_functions
source · pub fn dump_functions(
flow: &FlowDefinition,
tables: &CompilerTables,
output_dir: &Path
) -> Result<()>Expand description
Create a directed graph named after the flow, showing all the functions of the flow after it has been compiled down, grouped in sub-clusters
Example
use std::env;
use url::Url;
use flowcore::provider::Provider;
use flowcore::meta_provider::MetaProvider;
use flowcore::errors::Result;
use flowcore::model::process::Process::FlowProcess;
use tempdir::TempDir;
use std::collections::BTreeSet;
use simpath::Simpath;
use std::path::Path;
use std::path::PathBuf;
// Create a lib_search_path including 'context' which is in flowr/src
let mut lib_search_path = Simpath::new("TEST_LIBS");
let root_str = Path::new(env!("CARGO_MANIFEST_DIR")).parent().unwrap();
let runtime_parent = root_str.join("flowr/src");
lib_search_path.add_directory(runtime_parent.to_str().unwrap());
let provider = MetaProvider::new(lib_search_path, PathBuf::from("/"));
let mut url = Url::from_file_path(env::current_dir().unwrap()).unwrap();
url = url.join("flowc/tests/test-flows/hello-world/hello-world.toml").unwrap();
let mut source_urls = BTreeSet::<(Url, Url)>::new();
let output_dir = TempDir::new("flow-test").expect("A temp dir").into_path();
if let Ok(FlowProcess(mut flow)) = flowclib::compiler::parser::parse(&url,
&provider,
&mut source_urls) {
let tables = flowclib::compiler::compile::compile(&flow, &output_dir, false, false,
#[cfg(feature = "debugger")] &mut source_urls
).unwrap();
// strip off filename so output_dir is where the root.toml file resides
let output_dir = TempDir::new("flow").unwrap().into_path();
// create a .dot format directed graph of all the functions after compiling down the flow
flowclib::dumper::functions_to_dot::dump_functions(&flow, &tables, &output_dir).unwrap();
}