-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/sequence diagrams improvements #1365
Feature/sequence diagrams improvements #1365
Conversation
This commit fixes some outdated docstrings, replacing the description and @params where necessary.
This commit extract the commonly used /br\s*\/?>/gi regex to common.js, in order to keep the code more DRY.
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.
Hi! Good stuff!
This looks neat and we should add this to mermaid. One issue is that by bypassing the template this causes extra administration and increasing the risk that this is missed in the release notes. Could you please add that? This should not take to long.
Next thing, could you also add those diagrams you mentioned to rendering tests? Its quite easy, look in cypress/integration/rendering/sequenceDiagram.spec.js
Here is a sample test:
it('should render autonumber when autonumber keyword is used', () => {
imgSnapshotTest(
`
sequenceDiagram
autonumber
Alice->>John: Hello John, how are you?
loop Healthcheck
John->>John: Fight against hypochondria
end
Note right of John: Rational thoughts!
John-->>Alice: Great!
John->>Bob: How about you?
Bob-->>John: Jolly good!
`,
{}
);
});
Just add new ones with diagram showing this new feature.
This helps testing, making sure it wont brea by some other change in the future.
Looking forward to merging this.
This commit fixes some bugs, and I believe, improves upon the current implementation. In no particular order, it adds: 1. Control over note font size, family and alignment (now defaults to center) 2. Dynamic actor resizing - actor's width will now scale if its description is bigger than the static configured width 3. Dynamic actor margins - the margin between actors will now be dynamically calculated by taking into account the width of connecting messages or notes 4. Fixed a small visual annoyance where a loop arrow would intersect with the text it loops on 5. Fixed a bug where if global config -> fontFamily wasn't defined, it would override the actorFontFamily with an undefined 6. Removed some stale / commented out code 7. Added missing config variables to the global config object in mermaidAPI.js 8. Added messageFontSize, messageFontFamily to control message (non-note) font settings 9. Memoized the actor widths in a pre-calculation that takes notes and signals lengths into account 10. Removed redundant console.log lines 11. Extracted out actor width & margin calculation to getMaxMessageWidthPerActor, and calculateActorMargins
60d78ec
to
5f6887b
Compare
This commits adds e2e tests for the suggested improvements. I've went over the generated screenshots and they look good to me.
This commit adds documentation to new config variables that were introduced as part of this PR, namely, the font settings for actors, messages and notes. I've also linted the markdown document.
Hey hey @knsv - thanks for the feedback, I've revisit the PR, added e2e tests Feel free to go over it (For a quick diff, you can add a Let me know what you think, |
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.
Thanks! The extra effort is much appreciated!
馃搼 Summary
This commit fixes some bugs, and I believe, improves upon the current
implementation.
Resolves #494
馃搹 Design Decisions
Mermaid is awesome - I use it a lot (it's even more awesome w/ emacs & ob-mermaid);
and that's why I think that we should make a few improvements to the sequence diagram rendering.
I think that it falls short, compared to other diagram types, in that it renders rectangles with a fixed size, as opposed to dynamically scaling them when, for instance, the text is larger than the container.
There are workaround, of course - one can set a larger width for the rectangles - that yield an awkward result though, b/c all rectangles are rendered with the same width;
and we'd probably like to have the ability to have a sole rectangle that should be bigger, and others that should be smaller.
The following is a list of proposed fixes that I believe would make the usage of sequence diagrams better:
center)
description is bigger than the static configured width
dynamically calculated by taking into account the width of connecting
messages or notes
with the text it loops on
would override the actorFontFamily with an undefined
All tests pass - and looking at the generated
dist/index.html
, with some additional use cases, looks pretty good.馃搵 Tasks
Make sure you
develop
branch