pytransitions / transitions

A lightweight, object-oriented finite state machine implementation in Python with many extensions
MIT License
5.73k stars 530 forks source link

state diagrams #4

Closed tyarkoni closed 8 years ago

tyarkoni commented 9 years ago

At some point we should add the ability to generate state diagrams via GraphViz or NetworkX.

ExpandOcean commented 9 years ago

Agree! I use plantuml, and I think it's better to me:) By the way, your work is just what I want for a long time, thank you!

bibi21000 commented 9 years ago

Yep ... it should be a good idea. Don't know if you know blockdiag ant its friends (http://blockdiag.com/en/index.html). Maybe the can help you as they can be embeded in many documents (http://blockdiag.com/en/blockdiag/embed_diagram.html) By the way, thank you very much for transitions ... your statefull machine save hours of dev Thanks again

svdgraaf commented 8 years ago

I actually have code laying around which does just this, rendering the graph using pygraphviz, I'm not too satistisfied with the pygraphviz output though:

asset

You can find a quick gist here: https://gist.github.com/svdgraaf/198e2c0cf4cf0a031c84

tyarkoni commented 8 years ago

This would be a great start, @svdgraaf! I agree that the result could be improved aesthetically, but for now it would be great to have even rudimentary diagramming capabilities. Do you want to open a PR for this? I suggest putting your code in a separate 'diagrams' module and refactoring slightly so that the graphing call takes a Machine instance as the first argument. We can also maybe add a diagram() method to the Machine class for convenience.

svdgraaf commented 8 years ago

Sure, I'll try to make some time this week to create a PR..!

On 3 dec. 2015, at 16:33, Tal Yarkoni notifications@github.com wrote:

This would be a great start, @svdgraaf! I agree that the result could be improved aesthetically, but for now it would be great to have even rudimentary diagramming capabilities. Do you want to open a PR for this? I suggest putting your code in a separate 'diagrams' module and refactoring slightly so that the graphing call takes a Machine instance as the first argument. We can also maybe add a diagram() method to the Machine class for convenience.

— Reply to this email directly or view it on GitHub.

svdgraaf commented 8 years ago

I created a PR, let me know of any feedback: https://github.com/tyarkoni/transitions/pull/47

e3krisztian commented 8 years ago

I like this feature, however I think the current implementation requires pygraphviz. I'd prefer if it would be optional - when the feature is not needed it need not be installed.

svdgraaf commented 8 years ago

@krisztianfekete it's optional (you can provide your own diagram class), do you have a suggestion for other tools?

tyarkoni commented 8 years ago

Thanks! This is great; will add feedback in the PR conversation. I agree with @krisztianfekete that we probably want to avoid making pygraphviz a hard requirement.

tyarkoni commented 8 years ago

Closed in #47. Thanks @svdgraaf! We'll probably want to revisit this and add more features in future, but we can open more specific issues for that.

e3krisztian commented 8 years ago

@svdgraaf I have no suggestion, pygraphviz is fine, and I like as it is now - good work! :)