@@ -68,10 +68,12 @@ def get_graph(self, title=None, roi_state=None):
68
68
title = title if title else self .machine .title
69
69
70
70
fsm_graph = ['---' , title , '---' , 'stateDiagram-v2' ]
71
+ fsm_graph .extend (_to_mermaid (self .machine .machine_attributes , " " ))
72
+
71
73
for style_name , style_attrs in self .machine .style_attributes ["node" ].items ():
72
74
if style_name :
73
75
fsm_graph .append ("classDef s_{} {}" .format (
74
- style_name , _to_css ( style_attrs )))
76
+ style_name , ',' . join ( _to_mermaid ( style_attrs , ":" ) )))
75
77
fsm_graph .append ("" )
76
78
states , transitions = self ._get_elements ()
77
79
if roi_state :
@@ -250,16 +252,16 @@ def draw(self, filename, format=None, prog="dot", args=""):
250
252
return None
251
253
252
254
253
- invalid = {"style" , "shape" , "peripheries" }
254
- convertible = {"fillcolor" : "fill" }
255
+ invalid = {"style" , "shape" , "peripheries" , "strict" , "directed" }
256
+ convertible = {"fillcolor" : "fill" , "rankdir" : "direction" }
255
257
256
258
257
- def _to_css (style_attrs ):
259
+ def _to_mermaid (style_attrs , sep ):
258
260
params = []
259
261
for k , v in style_attrs .items ():
260
262
if k in invalid :
261
263
continue
262
264
if k in convertible :
263
265
k = convertible [k ]
264
- params .append ("{}:{} " .format (k , v ))
265
- return ',' . join ( params )
266
+ params .append ("{}{}{} " .format (k , sep , v ))
267
+ return params
0 commit comments