1- use std:: borrow:: Cow ;
2-
31use crate :: {
4- dot:: { font_tag, DotGraph } ,
2+ dot:: { font_tag, html_escape , DotGraph } ,
53 utils,
64} ;
75use bevy:: render:: render_graph:: { Edge , NodeId , RenderGraph } ;
86use itertools:: { EitherOrBoth , Itertools } ;
97
10- /// Escape tags in such a way that it is suitable for inclusion in a
11- /// Graphviz HTML label.
12- pub fn escape_html < ' a , S > ( s : S ) -> Cow < ' a , str >
13- where
14- S : Into < Cow < ' a , str > > ,
15- {
16- s. into ( )
17- . replace ( "&" , "&" )
18- . replace ( "\" " , """ )
19- . replace ( "<" , "<" )
20- . replace ( ">" , ">" )
21- . into ( )
22- }
23-
248pub fn render_graph_dot ( graph : & RenderGraph ) -> String {
259 let options = [ ( "rankdir" , "LR" ) , ( "ranksep" , "1.0" ) ] ;
2610 let mut dot = DotGraph :: new ( "RenderGraph" , & options) ;
@@ -47,9 +31,9 @@ pub fn render_graph_dot(graph: &RenderGraph) -> String {
4731 . map ( |( index, slot) | {
4832 format ! (
4933 "<TD PORT=\" {}\" >{}: {}</TD>" ,
50- escape_html ( format!( "{}" , index) ) ,
51- escape_html ( slot. info. name. clone ( ) ) ,
52- escape_html ( format!( "{:?}" , slot. info. resource_type) )
34+ html_escape ( & format!( "{}" , index) ) ,
35+ html_escape ( & slot. info. name) ,
36+ html_escape ( & format!( "{:?}" , slot. info. resource_type) )
5337 )
5438 } )
5539 . collect :: < Vec < _ > > ( ) ;
@@ -60,10 +44,10 @@ pub fn render_graph_dot(graph: &RenderGraph) -> String {
6044 . enumerate ( )
6145 . map ( |( index, slot) | {
6246 format ! (
63- "<TD PORT=\" {}\" >{}: {:? }</TD>" ,
64- escape_html ( format!( "{}" , index) ) ,
65- escape_html ( slot. info. name. clone ( ) ) ,
66- escape_html ( format!( "{:?}" , slot. info. resource_type) )
47+ "<TD PORT=\" {}\" >{}: {}</TD>" ,
48+ html_escape ( & format!( "{}" , index) ) ,
49+ html_escape ( & slot. info. name) ,
50+ html_escape ( & format!( "{:?}" , slot. info. resource_type) )
6751 )
6852 } )
6953 . collect :: < Vec < _ > > ( ) ;
@@ -83,9 +67,9 @@ pub fn render_graph_dot(graph: &RenderGraph) -> String {
8367 . collect :: < String > ( ) ;
8468
8569 let label = format ! (
86- "<<TABLE><TR><TD PORT=\" title\" BORDER=\" 0\" COLSPAN=\" 2\" >{}<BR/>{}</TD></TR>{}</TABLE>>" ,
87- escape_html ( name) ,
88- font_tag( & escape_html ( & type_name) , "red" , 10 ) ,
70+ "<<TABLE STYLE= \" rounded \" ><TR><TD PORT=\" title\" BORDER=\" 0\" COLSPAN=\" 2\" >{}<BR/>{}</TD></TR>{}</TABLE>>" ,
71+ html_escape ( name) ,
72+ font_tag( & type_name, "red" , 10 ) ,
8973 slots,
9074 ) ;
9175
@@ -101,9 +85,6 @@ pub fn render_graph_dot(graph: &RenderGraph) -> String {
10185 output_node,
10286 output_index,
10387 } => {
104- let input = graph. get_node_state ( * input_node) . unwrap ( ) ;
105- let input_slot = & input. input_slots . iter ( ) . nth ( * input_index) . unwrap ( ) . info ;
106-
10788 dot. add_edge (
10889 & node_id ( output_node) ,
10990 Some ( & format ! ( "{}:e" , output_index) ) ,
@@ -121,7 +102,7 @@ pub fn render_graph_dot(graph: &RenderGraph) -> String {
121102 Some ( "title:e" ) ,
122103 & node_id ( input_node) ,
123104 Some ( "title:w" ) ,
124- & [ ( "style" , "dashed" ) ] ,
105+ & [ ] ,
125106 ) ;
126107 }
127108 }
0 commit comments