Use d3-graphviz for rendering crates graph on the extension side

This commit is contained in:
André Oliveira
2021-08-10 13:34:30 +00:00
parent e1dcec0e02
commit f4f68e62c2
3 changed files with 33 additions and 15 deletions

View File

@@ -133,18 +133,9 @@ pub(crate) fn handle_view_crate_graph(
let _p = profile::span("handle_view_crate_graph");
let dot = snap.analysis.view_crate_graph(params.full)??;
// We shell out to `dot` to render to SVG, as there does not seem to be a pure-Rust renderer.
let child = Command::new("dot")
.arg("-Tsvg")
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.spawn()
.map_err(|err| format!("failed to spawn `dot`: {}", err))?;
child.stdin.unwrap().write_all(dot.as_bytes())?;
eprintln!("{}", dot);
let mut svg = String::new();
child.stdout.unwrap().read_to_string(&mut svg)?;
Ok(svg)
Ok(dot)
}
pub(crate) fn handle_expand_macro(