1
- use std:: borrow:: Cow ;
2
-
3
1
use crate :: {
4
- dot:: { font_tag, DotGraph } ,
2
+ dot:: { font_tag, html_escape , DotGraph } ,
5
3
utils,
6
4
} ;
7
5
use bevy:: render:: render_graph:: { Edge , NodeId , RenderGraph } ;
8
6
use itertools:: { EitherOrBoth , Itertools } ;
9
7
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
-
24
8
pub fn render_graph_dot ( graph : & RenderGraph ) -> String {
25
9
let options = [ ( "rankdir" , "LR" ) , ( "ranksep" , "1.0" ) ] ;
26
10
let mut dot = DotGraph :: new ( "RenderGraph" , & options) ;
@@ -47,9 +31,9 @@ pub fn render_graph_dot(graph: &RenderGraph) -> String {
47
31
. map ( |( index, slot) | {
48
32
format ! (
49
33
"<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) )
53
37
)
54
38
} )
55
39
. collect :: < Vec < _ > > ( ) ;
@@ -60,10 +44,10 @@ pub fn render_graph_dot(graph: &RenderGraph) -> String {
60
44
. enumerate ( )
61
45
. map ( |( index, slot) | {
62
46
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) )
67
51
)
68
52
} )
69
53
. collect :: < Vec < _ > > ( ) ;
@@ -83,9 +67,9 @@ pub fn render_graph_dot(graph: &RenderGraph) -> String {
83
67
. collect :: < String > ( ) ;
84
68
85
69
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 ) ,
89
73
slots,
90
74
) ;
91
75
@@ -101,9 +85,6 @@ pub fn render_graph_dot(graph: &RenderGraph) -> String {
101
85
output_node,
102
86
output_index,
103
87
} => {
104
- let input = graph. get_node_state ( * input_node) . unwrap ( ) ;
105
- let input_slot = & input. input_slots . iter ( ) . nth ( * input_index) . unwrap ( ) . info ;
106
-
107
88
dot. add_edge (
108
89
& node_id ( output_node) ,
109
90
Some ( & format ! ( "{}:e" , output_index) ) ,
@@ -121,7 +102,7 @@ pub fn render_graph_dot(graph: &RenderGraph) -> String {
121
102
Some ( "title:e" ) ,
122
103
& node_id ( input_node) ,
123
104
Some ( "title:w" ) ,
124
- & [ ( "style" , "dashed" ) ] ,
105
+ & [ ] ,
125
106
) ;
126
107
}
127
108
}
0 commit comments