-
Notifications
You must be signed in to change notification settings - Fork 1.2k
add Automaton.toMermaid() for emitting mermaid state charts #14360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Mermaid is state chart supported within fenced codeblocks by github. For some reason it doesn't support dotty but instead the latest js tool. I'm sure in 2 months it will be a different tool. Beautification of any sort can happen at any time, this just makes it work correctly. Mermaid state diagram really isn't the best for this, just look at how start/end state works there. So we just define a "class" that makes accept states blue. I'd rather have double-circle but I'm not a CSS guy. Closes apache#14351
Here's the same Automaton, but via But maybe we can improve the styling here to make this more useful and save you that step. |
Mermaid definitely doesn't handle infinite automata very well at all: stateDiagram
direction LR
classDef accept border-width:5px;stroke-width:5px,stroke:#00FFFF
class 0 accept
0 --> 0:K
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, thanks for implementing this! I bookmarked the issue because sometimes it'd be more convenient to copy-paste automaton ascii rather than insert screenshots.
I agree graphviz has a clearer output but maybe we should keep what you've written as an alternative? It adds little code and may be useful for simpler automata.
I've looked at the docs of mermaid and toyed around a bit. I agree that infinite loops are so ugly that one's eyes start to bleed. Maybe we should stick to graphviz. |
i'll keep the PR up here. Actually as a first step, I'd rather improve existing toDot() and regex toString(). It would help the logic here, too. There's no need to escape codepoints as If I want to make them look pretty, i edit the .dot file and fix some of these things. We can definitely try to help remove that step. For mermaid, it does allow accessible descriptions via "hover" with the mouse. It would be nice to be "aggressive" about displaying characters but at the same time provide the ability to see the unicode range if you want. I'll see what the possibilities are with dot here too. |
This PR has not had activity in the past 2 weeks, labeling it as stale. If the PR is waiting for review, notify the dev@lucene.apache.org list. Thank you for your contribution! |
Mermaid is state chart supported within fenced codeblocks by github. For some reason it doesn't support dotty but instead the latest js tool. I'm sure in 2 months it will be a different tool.
Beautification of any sort can happen at any time, this just makes it work correctly. Mermaid state diagram really isn't the best for this, just look at how start/end state works there. So we just define a "class" that makes accept states blue. I'd rather have double-circle but I'm not a CSS guy.
Closes #14351