Include NodePath in artifact graph mermaid charts as comments (#6884)
* Display NodePath in artifact graph mermaid charts * Update output * Change node path display to be only comments * Update output * Update output after rebase
This commit is contained in:
@ -298,40 +298,48 @@ impl ArtifactGraph {
|
||||
let range = code_ref.range;
|
||||
[range.start(), range.end(), range.module_id().as_usize()]
|
||||
}
|
||||
fn node_path_display<W: Write>(output: &mut W, prefix: &str, code_ref: &CodeRef) -> std::fmt::Result {
|
||||
// %% is a mermaid comment. Prefix is increased one level since it's
|
||||
// a child of the line above it.
|
||||
if code_ref.node_path.is_empty() {
|
||||
return writeln!(output, "{prefix} %% Missing NodePath");
|
||||
}
|
||||
writeln!(output, "{prefix} %% {:?}", code_ref.node_path.steps)
|
||||
}
|
||||
|
||||
match artifact {
|
||||
Artifact::CompositeSolid(composite_solid) => {
|
||||
writeln!(
|
||||
output,
|
||||
"{prefix}{}[\"CompositeSolid {:?}<br>{:?}\"]",
|
||||
id,
|
||||
"{prefix}{id}[\"CompositeSolid {:?}<br>{:?}\"]",
|
||||
composite_solid.sub_type,
|
||||
code_ref_display(&composite_solid.code_ref)
|
||||
)?;
|
||||
node_path_display(output, prefix, &composite_solid.code_ref)?;
|
||||
}
|
||||
Artifact::Plane(plane) => {
|
||||
writeln!(
|
||||
output,
|
||||
"{prefix}{}[\"Plane<br>{:?}\"]",
|
||||
id,
|
||||
"{prefix}{id}[\"Plane<br>{:?}\"]",
|
||||
code_ref_display(&plane.code_ref)
|
||||
)?;
|
||||
node_path_display(output, prefix, &plane.code_ref)?;
|
||||
}
|
||||
Artifact::Path(path) => {
|
||||
writeln!(
|
||||
output,
|
||||
"{prefix}{}[\"Path<br>{:?}\"]",
|
||||
id,
|
||||
"{prefix}{id}[\"Path<br>{:?}\"]",
|
||||
code_ref_display(&path.code_ref)
|
||||
)?;
|
||||
node_path_display(output, prefix, &path.code_ref)?;
|
||||
}
|
||||
Artifact::Segment(segment) => {
|
||||
writeln!(
|
||||
output,
|
||||
"{prefix}{}[\"Segment<br>{:?}\"]",
|
||||
id,
|
||||
"{prefix}{id}[\"Segment<br>{:?}\"]",
|
||||
code_ref_display(&segment.code_ref)
|
||||
)?;
|
||||
node_path_display(output, prefix, &segment.code_ref)?;
|
||||
}
|
||||
Artifact::Solid2d(_solid2d) => {
|
||||
writeln!(output, "{prefix}{}[Solid2d]", id)?;
|
||||
@ -339,56 +347,56 @@ impl ArtifactGraph {
|
||||
Artifact::StartSketchOnFace(StartSketchOnFace { code_ref, .. }) => {
|
||||
writeln!(
|
||||
output,
|
||||
"{prefix}{}[\"StartSketchOnFace<br>{:?}\"]",
|
||||
id,
|
||||
"{prefix}{id}[\"StartSketchOnFace<br>{:?}\"]",
|
||||
code_ref_display(code_ref)
|
||||
)?;
|
||||
node_path_display(output, prefix, code_ref)?;
|
||||
}
|
||||
Artifact::StartSketchOnPlane(StartSketchOnPlane { code_ref, .. }) => {
|
||||
writeln!(
|
||||
output,
|
||||
"{prefix}{}[\"StartSketchOnPlane<br>{:?}\"]",
|
||||
id,
|
||||
"{prefix}{id}[\"StartSketchOnPlane<br>{:?}\"]",
|
||||
code_ref_display(code_ref)
|
||||
)?;
|
||||
node_path_display(output, prefix, code_ref)?;
|
||||
}
|
||||
Artifact::Sweep(sweep) => {
|
||||
writeln!(
|
||||
output,
|
||||
"{prefix}{}[\"Sweep {:?}<br>{:?}\"]",
|
||||
id,
|
||||
"{prefix}{id}[\"Sweep {:?}<br>{:?}\"]",
|
||||
sweep.sub_type,
|
||||
code_ref_display(&sweep.code_ref)
|
||||
)?;
|
||||
node_path_display(output, prefix, &sweep.code_ref)?;
|
||||
}
|
||||
Artifact::Wall(_wall) => {
|
||||
writeln!(output, "{prefix}{}[Wall]", id)?;
|
||||
writeln!(output, "{prefix}{id}[Wall]")?;
|
||||
}
|
||||
Artifact::Cap(cap) => {
|
||||
writeln!(output, "{prefix}{}[\"Cap {:?}\"]", id, cap.sub_type)?;
|
||||
writeln!(output, "{prefix}{id}[\"Cap {:?}\"]", cap.sub_type)?;
|
||||
}
|
||||
Artifact::SweepEdge(sweep_edge) => {
|
||||
writeln!(output, "{prefix}{}[\"SweepEdge {:?}\"]", id, sweep_edge.sub_type,)?;
|
||||
writeln!(output, "{prefix}{id}[\"SweepEdge {:?}\"]", sweep_edge.sub_type)?;
|
||||
}
|
||||
Artifact::EdgeCut(edge_cut) => {
|
||||
writeln!(
|
||||
output,
|
||||
"{prefix}{}[\"EdgeCut {:?}<br>{:?}\"]",
|
||||
id,
|
||||
"{prefix}{id}[\"EdgeCut {:?}<br>{:?}\"]",
|
||||
edge_cut.sub_type,
|
||||
code_ref_display(&edge_cut.code_ref)
|
||||
)?;
|
||||
node_path_display(output, prefix, &edge_cut.code_ref)?;
|
||||
}
|
||||
Artifact::EdgeCutEdge(_edge_cut_edge) => {
|
||||
writeln!(output, "{prefix}{}[EdgeCutEdge]", id)?;
|
||||
writeln!(output, "{prefix}{id}[EdgeCutEdge]")?;
|
||||
}
|
||||
Artifact::Helix(helix) => {
|
||||
writeln!(
|
||||
output,
|
||||
"{prefix}{}[\"Helix<br>{:?}\"]",
|
||||
id,
|
||||
"{prefix}{id}[\"Helix<br>{:?}\"]",
|
||||
code_ref_display(&helix.code_ref)
|
||||
)?;
|
||||
node_path_display(output, prefix, &helix.code_ref)?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
Reference in New Issue
Block a user