mdeloof / statig

Hierarchical state machines for designing event-driven systems
https://crates.io/crates/statig
MIT License
559 stars 18 forks source link

Diagram representation of the state machine #26

Open GyulyVGC opened 1 week ago

GyulyVGC commented 1 week ago

Hey, thanks for the cool library!

It'd be nice to add the possibility of creating a .dot file (or similar) for a defined state machine.

This would enable deriving a graphical representation of the states and all the possible transitions via tools like Graphviz.

GyulyVGC commented 1 week ago

I've noticed there already is a similar issue open (#11), although I think that producing a .dot file is simpler than an ASCII representation.

mdeloof commented 1 week ago

Hi, thanks for trying out statig!

Having some sort of visualisation of state machines has been on my todo list for some time now. The major issue I don't really have a solution for is how to deduce the transitions between states. That logic is fully defined within the state handler so it can't be reliably understood by a macro. I've been considering the option to allow users to manually add the possible transitions with some sort of attribute, but then you could run into situations where code and documentation are out of sync, so it's not ideal. 😕