Skip to content

[Workflow] Add Mermaid.js dumper #40171

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

Merged
merged 1 commit into from
Apr 13, 2021

Conversation

eFrane
Copy link
Contributor

@eFrane eFrane commented Feb 12, 2021

Q A
Branch? 5.x
Bug fix? no
New feature? yes
Deprecations? no
Tickets #40165
License MIT
Doc PR symfony/symfony-docs#15102

Mermaid is - next to PlantUML - one of the most popular simple graphing solutions. This workflow dumper mirrors the feature set of the PlantUML dumper except that Mermaid does not currently support colored transitions.

Things I need help with:

  • I basically tried to copy the code style of the surrounding files and hope everything is conforming. Please let me know if I missed something. I see, that's the magic of fabbot. Nice. ❤️
  • There are currently no tests for the different graph direction constants, I can add those, just did not see value in doing so yet.
  • I am unsure how to integrate this with the current documentation. This however is likely better discussed in the corresponding issue (see above).

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has a contribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (see https://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (see https://symfony.com/releases)
  • Features and deprecations must be submitted against the 5.x branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

Copy link
Member

@stof stof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the WorkflowDumpCommand should also be updated to add the new output format.

@stof
Copy link
Member

stof commented Feb 12, 2021

There is a single dumper output here, while other dumpers have different output for the state machine vs workflow cases, because the behavior of transitions is different. In full-fledged workflows, each transition can have multiple from and multiple to. Representing them as separate arrows would not reflect the actual workflow.

}

$placeNodeFormat = '%s'.$labelShape;
$placeNode = sprintf($placeNodeFormat, $placeName, $placeLabel);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to apply proper escaping on labels, to ensure the generated graph is valid, because labels can be anything: https://mermaid-js.github.io/mermaid/#/flowchart?id=special-characters-that-break-syntax

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, be careful than the lowercase end identifier is reserved and cannot be used as a node identifier.

@eFrane
Copy link
Contributor Author

eFrane commented Feb 13, 2021

@stof There is an explicit diagram syntax for state machines in Mermaid. However, that does not support styling the same way the flowchart syntax does. I can see two ways forward here: Either go the same route as the PlantUML Dumper and just use a different line style for state machines or choose the Graphviz strategy of having another class handling the specifics of state machines. I currently favour the latter, am however unsure because of the styling restrictions.

EDIT: I had to push my current state, but it is not ready for review yet (in my opinion), just may have to switch machines.

@stof
Copy link
Member

stof commented Feb 15, 2021

@eFrane actually, I would say that the work you did at the time of my previous review was actually more appropriate for the dumping of state machines (look at the graphviz and PlantUML outputs for both cases). so I think the dumper should keep using flowchart in both cases.

Regarding 1 class vs 2 classes for the dumping, I would say that it depends how much code depends on the cases and how much is shared between them.

@nicolas-grekas nicolas-grekas added this to the 5.x milestone Feb 16, 2021
@lyrixx
Copy link
Member

lyrixx commented Mar 4, 2021

Hello @eFrane ; Thanks for your first contribution 💛

Could you take care of @stof comments? I would be very happy to merge your PR.

@eFrane eFrane force-pushed the f_workflows_add_mermaid_dumper branch from 1d9a488 to 0b830c0 Compare March 7, 2021 16:51
@eFrane eFrane requested a review from stof March 7, 2021 16:56
@eFrane
Copy link
Contributor Author

eFrane commented Mar 7, 2021

@stof After having an embarrassingly long stare at the existing dumpers and the documentation, I finally understood your point about the differing dumping styles for workflows and state machines. As there was quite a bit of added code, there may be new non-symfony ways I did things.

Apart from that, I also added support for markings. I am not sure if it is okay to go the metadata route for that, but that would be an easy fix.

In the meantime, I will (finally) start on the documentation update PR for this.

@eFrane
Copy link
Contributor Author

eFrane commented Mar 25, 2021

From my end, this feels done. Is there anything I can do to move this along? @lyrixx @stof

Copy link
Member

@lyrixx lyrixx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼

@lyrixx lyrixx force-pushed the f_workflows_add_mermaid_dumper branch from bae73e2 to ada6f7d Compare April 13, 2021 08:42
@lyrixx
Copy link
Member

lyrixx commented Apr 13, 2021

Thanks @eFrane for working on this feature, this is much appreciated.

@lyrixx lyrixx merged commit 02704e9 into symfony:5.x Apr 13, 2021
wouterj added a commit to symfony/symfony-docs that referenced this pull request Apr 13, 2021
This PR was merged into the 5.3-dev branch.

Discussion
----------

[Workflow] Add info about MermaidDumper

<!--

If your pull request fixes a BUG, use the oldest maintained branch that contains
the bug (see https://symfony.com/releases for the list of maintained branches).

If your pull request documents a NEW FEATURE, use the same Symfony branch where
the feature was introduced (and `5.x` for features of unreleased versions).

-->

This updates the documentation for symfony/symfony#40171.

Commits
-------

b7340c7 [Workflow] Add info about MermaidDumper
@eFrane eFrane deleted the f_workflows_add_mermaid_dumper branch April 13, 2021 16:47
@fabpot fabpot mentioned this pull request Apr 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants