Skip to content

[Workflow] Add PlantUML dumper to workflow:dump command #24705

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
Feb 7, 2018
Merged

[Workflow] Add PlantUML dumper to workflow:dump command #24705

merged 1 commit into from
Feb 7, 2018

Conversation

Plopix
Copy link
Contributor

@Plopix Plopix commented Oct 27, 2017

Q A
Branch 4.1
Bug fix no
New feature yes
BC breaks? no
Deprecations? no
Tests pass? yes
License MIT
Doc PR symfony/symfony-docs#9220

Hello,

workflow:dump exports workflows in dot format. To me, this format is not the easiest and not the simplest to use. Styles and logic are mixed together which makes it hard to read.

PlantUML is a tool based on Graphviz like Dot but that
generates nicer diagrams, more readable and most of all easier to adapt to your
documentation. Just copy and paste the PUML on the website you will see the rendering live.

Also, there is a PHPStorm Plugin and plenty of integration of this format.

This PR adds 2 options

  • a --dump-format=puml option to the workflow:dump command to generate the workflows in PlantUML.

The conversion requires the PlantUML JAR, and can be used like that:

php bin/console workflow:dump pull_request --dump-format=puml | java -jar plantuml.jar -p  > workflow.png

don't forget the -p to enable the "piping"

Here is an example with pull_request workflow of the documentation (with no style and no marking):

@startuml
title pull_request
state start <<initial>>
state coding
state travis
state review
state merged
state closed
start --> travis: submit
coding --> travis: update
travis --> travis: update
review --> travis: update
travis --> review: wait_for_review
review --> coding: request_change
review --> merged: accept
review --> closed: reject
closed --> review: reopen
@enduml

As PlantUML let us define styles, I have provided some by default that the user can override.
Adding some marking:

php bin/console workflow:dump pull_request travis review --dump-format=puml

will give us:

@startuml
sprite $sf_logo [81x20/16z] {
hPNRaYiX24K1xwBo_tyx6-qaCtDEJ-KXLYMTLbp0HWcHZr3KRDJ8z94HG3jZn4_mijbQ2ryJoFePtXLWA_qxyGy19DpdY_10z11ZAbGjFHRwcEbcKx5-wqsV
yIMo8StMCHKh8ZUxnEwrZiwRAUOvy1lLcPQF4lEFAjhzMd5WOAqvKflS0Enx8PbihiSYXM8ClGVAseIWTAjCgVSAcnYbQG79xKFsZ0VnDCNc7AVBoPSMcTsX
UnrujbYjjz0NnsObkTgnmolqJD4QgGUYTQiNe8eIjtx4b6Vv8nPGpncn3NJ8Geo9W9VW2wGACm_JzgIO8A8KXr2jUBCVGEAAJSZ6JUlsNnmOzmIYti9G7bjL
8InaHM9G40NkwTG7OxrggvNIejA8AZuqyWjOzTIKi-wwYvjeHYesSWuPiTGDN5THzkYLU4MD5r2_0PDhG7LIUG33z5HtM6CP3icyWEVOS61sD_2ZsBfJdbVA
qM53XHDUwhY0TAwPug3OG9NonRFhO8ynF3I4unuAMDHmSrXH57V1RGvl9jafuZF9ZhqjWOEh98y0tUYGsUxkBSllIyBdT2oM5Fn2-ut-fzsq_cQNuL6Uvwqr
knh4RrvOKzxZfLV3s0rs_R_1SdYt3VxeQ1_y2_W2
}
title pull_request
skinparam titleBorderRoundCorner 15
skinparam titleBorderThickness 2
skinparam state {
    BackgroundColor<<initial>> #87b741
    BackgroundColor<<marked>> #3887C6
    BorderColor #3887C6
    BorderColor<<marked>> Black
    FontColor<<marked>> White
}
state start <<initial>>
state coding
state travis <<marked>>
state review <<marked>>
state merged
state closed
start --> travis: submit
coding --> travis: update
travis --> travis: update
review --> travis: update
travis --> review: wait_for_review
review --> coding: request_change
review --> merged: accept
review --> closed: reject
closed --> review: reopen
footer \nGenerated by <$sf_logo> **Workflow Component** and **PlantUML**
@enduml

Which gives you that:
workflow

With square as transition, it gives you that:
workflow

Hope you will find that interesting!

@Plopix
Copy link
Contributor Author

Plopix commented Oct 27, 2017

That is failing on Windows, but I don't really know why, probably a weird Windows specificity, or the END OF LINE?
You might have an idea?

Thanks!

@@ -1,6 +1,10 @@
CHANGELOG
=========

3.5.0
Copy link
Contributor

Choose a reason for hiding this comment

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

It will be 4.1.0 not 3.5.0 (which never will be released)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

}

return
'@startuml'.PHP_EOL.static::SYMFONY_LOGO.PHP_EOL;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be in previous line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok


const MARKED = 'marked';

const SYMFONY_LOGO = 'sprite $sf_logo [81x20/16z] {
Copy link
Contributor

Choose a reason for hiding this comment

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

Better & probably safer than string comparison would be to save them as fixtures & compare results with pregenerated fixture.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure I understand here what you are proposing. Can you tell me more and I will be happy to change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I got it and I made changes accordingly.

@nicolas-grekas nicolas-grekas added this to the 4.1 milestone Oct 27, 2017
@nicolas-grekas nicolas-grekas changed the base branch from 3.4 to master October 27, 2017 08:55
@Plopix
Copy link
Contributor Author

Plopix commented Oct 28, 2017

  • I fixed the comment 9 (cc @stloyd)
  • appveyor build is passing now
  • travis-ci build fails because of VarDumper (that is not related to this PR cc @nicolas-grekas)

@Nyholm or @lyrixx
Question/Note: The current workflow:dump does not generate the same way workflow and state machine. Is that a standard? I feel that it is so much more readable with transition names on the arrows. Is that something you want me to add on the PR? I am not a graph expert and it might be a convention or something.

@nicolas-grekas
Copy link
Member

DST time, transient failure will be fixed tomorrow hopefully :)

@lyrixx
Copy link
Member

lyrixx commented Nov 7, 2017

Question/Note: The current workflow:dump does not generate the same way workflow and state machine. Is that a standard?

Oups Sorry I forgot to reply.

Yes it's wanted. As a state machine can have many transition with the same name, the graph could be very ugly. that's why we did this.

} else {
throw new \InvalidArgumentException(sprintf('No service found for "workflow.%1$s" nor "state_machine.%1$s".', $serviceId));
}

/** @var \Symfony\Component\Workflow\Workflow $workflow */
Copy link
Member

Choose a reason for hiding this comment

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

Looks like it's useless

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not for PHPStorm ;) but I can remove it

@Plopix
Copy link
Contributor Author

Plopix commented Nov 8, 2017

@lyrixx I have added an option to let the user decide which transition he wants.
I hope that is fine for you! Because to me, the square as transition kind of complexify sometimes too. It is great to have the option.

@lyrixx
Copy link
Member

lyrixx commented Nov 8, 2017

Thanks. I will try your PR as soon as possible ;)

@nicolas-grekas
Copy link
Member

@lyrixx time to review? :)


public function __construct($transitionType)
{
$this->transitionType = static::DEFAULT_TRANSITION_TYPE;
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need to do this since it's already defaulted when you do $input->getOption('transition')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree but this class could be used differently and without the command then I think it is correct to initialize it. no?

Copy link
Contributor

Choose a reason for hiding this comment

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

Why not using

protected $transitionType = self::DEFAULT_TRANSITION_TYPE;

instead ?
I may be missing something but it feels better to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No that is me, I don't know I wanted to avoid that because of php versions but now for 4.x it is php 7 then we are all good to do that. And I think we were good before too...I was wrong. It is better now ;)

public function __construct($transitionType)
{
$this->transitionType = static::DEFAULT_TRANSITION_TYPE;
if ($transitionType == static::SQUARE_TRANSITION_TYPE) {
Copy link
Contributor

Choose a reason for hiding this comment

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

if (static::SQUARE_TRANSITION_TYPE === $transitionType)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

same as above comment


protected function isSquareTransitionType()
{
return $this->transitionType == static::SQUARE_TRANSITION_TYPE;
Copy link
Contributor

Choose a reason for hiding this comment

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

why not === ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok will change

$code[] = "agent {$transition->getName()}";
}
}
foreach ($definition->getTransitions() as $transition) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It feels like alot of complexity comparing to the GraphvizDumper, isn't in the class something you could re-use to get arrays and then transform them directly ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really sure I get what you want me to do. I agree it is not really straightforward but it is an efficient way to manage both TransitionType, GraphvizDumper as 2 classes to do that. I did not see the value for the PlantUML one, and I still don't see it. (but I would love to have your opinion)

I could do that in another method and then merge arrays... is it what you would like?.

Let me know!

Thank you!

Copy link
Contributor

Choose a reason for hiding this comment

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

I was just thinking on how much this adds complexity. I guess if merging the arrays cost more in performance than what you are doing here let's keep this. (I think it will be anyway).

I just wanted to know more about this ;).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

@Plopix
Copy link
Contributor Author

Plopix commented Dec 12, 2017

I have updated the PR and rebased. Not sure why the tests are failing I think it is not related to this code, master code is failing too.


public function __construct($transitionType = null)
{
if ($transitionType === static::SQUARE_TRANSITION_TYPE) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You should use yoda style, btw I don't know if it's really needed to do this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • yoda style done.
  • it is a way to kind of enforcing the 2 types and those 2 type only the default one or square
    It would work without, but the value of transitionType could be inconsistent. Let me know your thoughts


protected function isSquareTransitionType()
{
return $this->transitionType === static::SQUARE_TRANSITION_TYPE;
Copy link
Contributor

Choose a reason for hiding this comment

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

yoda style please.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

if (isset($options['name'])) {
$code[] = "title {$options['name']}";
}
if (isset($options['skinparams']) && count($options['skinparams']) > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think you need to count here

Copy link
Contributor Author

@Plopix Plopix Dec 12, 2017

Choose a reason for hiding this comment

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

correct I replaced with is_array to ensure the foreach won't fail if someone send something else

Copy link
Contributor

@Simperfit Simperfit left a comment

Choose a reason for hiding this comment

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

Some minor comments, but great improvment thanks !

@Plopix
Copy link
Contributor Author

Plopix commented Dec 12, 2017

updated @Simperfit (we are almost there ;) )

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.

I let few comments on the Command Class. It seems you did not test it on real
project :/

And I followed you doc and it does not work. the program open a dialog windows
where I'm supposed to select a folder. I'm a bit lost.

Finally, I'm not sure if plantuml is really mainstream. By default the website
is in French :/ http://plantuml.com/

So for now I'm not sure we want this support in the Core. What do others think?

ping @xabbuh @Nyholm

@@ -19,6 +19,8 @@
use Symfony\Component\Workflow\Dumper\GraphvizDumper;
use Symfony\Component\Workflow\Dumper\StateMachineGraphvizDumper;
use Symfony\Component\Workflow\Marking;
use Symfony\Component\Console\Input\InputOption;
Copy link
Member

Choose a reason for hiding this comment

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

Input Option Is already imported.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed.

@@ -19,6 +19,8 @@
use Symfony\Component\Workflow\Dumper\GraphvizDumper;
use Symfony\Component\Workflow\Dumper\StateMachineGraphvizDumper;
use Symfony\Component\Workflow\Marking;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Workflow\Dumper\PlantUmlDumper;
Copy link
Member

Choose a reason for hiding this comment

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

Could you sort all uses?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

@@ -39,13 +41,23 @@ protected function configure()
new InputArgument('name', InputArgument::REQUIRED, 'A workflow name'),
new InputArgument('marking', InputArgument::IS_ARRAY, 'A marking (a list of places)'),
new InputOption('label', 'l', InputArgument::OPTIONAL, 'Labels a graph'),
new InputOption('format', null, InputArgument::OPTIONAL, 'The dump format', 'dot'),
new InputOption(
Copy link
Member

Choose a reason for hiding this comment

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

We don't do that in Symfony. All arguments should be on one line..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

alright, that is fixed.

@@ -39,13 +41,23 @@ protected function configure()
new InputArgument('name', InputArgument::REQUIRED, 'A workflow name'),
new InputArgument('marking', InputArgument::IS_ARRAY, 'A marking (a list of places)'),
new InputOption('label', 'l', InputArgument::OPTIONAL, 'Labels a graph'),
new InputOption('format', null, InputArgument::OPTIONAL, 'The dump format', 'dot'),
new InputOption(
'transition',
Copy link
Member

Choose a reason for hiding this comment

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

puml_transition_format

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed.

new InputOption(
'transition',
null,
InputArgument::OPTIONAL,
Copy link
Member

Choose a reason for hiding this comment

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

This is wrong:

  • It's an option, not an arguement
  • The value is required

Copy link
Contributor Author

Choose a reason for hiding this comment

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

correct, fixed.


%command.full_name% <workflow name> | dot -Tpng > workflow.png
<info>DOT</info>: %command.full_name% <workflow name> | dot -Tpng > workflow.png
<info>PUML</info>: %command.full_name% <workflow name> --format=puml -p | java -jar plantuml.jar > workflow.png
Copy link
Member

Choose a reason for hiding this comment

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

What is -p ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is a typo (not present in the PR doc) the -p, as mentioned in the PR doc is for piping. But it is for plantuml.jar... not for the command. I have fixed that too.

@@ -39,13 +41,23 @@ protected function configure()
new InputArgument('name', InputArgument::REQUIRED, 'A workflow name'),
new InputArgument('marking', InputArgument::IS_ARRAY, 'A marking (a list of places)'),
new InputOption('label', 'l', InputArgument::OPTIONAL, 'Labels a graph'),
new InputOption('format', null, InputArgument::OPTIONAL, 'The dump format', 'dot'),
Copy link
Member

Choose a reason for hiding this comment

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

"The dump format [dot|puml]"

Copy link
Member

Choose a reason for hiding this comment

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

format is a bad name because it's already used in the --help command.
So bin/console workflow:dump article --format=puml -h do not work anymore

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch I have renamed by dump_format

} else {
throw new \InvalidArgumentException(sprintf('No service found for "workflow.%1$s" nor "state_machine.%1$s".', $serviceId));
}

if ('puml' === $format) {
$dumper = new PlantUmlDumper($transitionType);
} else {
Copy link
Member

Choose a reason for hiding this comment

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

use an else if here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok done.

/**
* PlantUmlDumper dumps a workflow as a PlantUML file.
*
* You can convert the generated dot file with the plantuml.jar utility (http://plantuml.com/):
Copy link
Member

Choose a reason for hiding this comment

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

I suppose it does not generate a dot file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that is correct, I have pushed the correction. thx!

knh4RrvOKzxZfLV3s0rs_R_1SdYt3VxeQ1_y2_W2
}';
const INITIAL = 'initial';
const MARKED = 'marked';
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't some of these be private constants ?


private function isSquareTransitionType(): bool
{
return static::SQUARE_TRANSITION_TYPE === $this->transitionType;
Copy link
Member

Choose a reason for hiding this comment

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

use self:: to access constant. There is no reason to make them an extension point by allowing changing their values (and the code would not work anyway in such case, due to other places)

return $start;
}

return $start.static::SYMFONY_LOGO.PHP_EOL;
Copy link
Member

Choose a reason for hiding this comment

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

self: here as well

return $end;
}

return PHP_EOL.'footer \nGenerated by <$sf_logo> **Workflow Component** and **PlantUML**'.$end;
Copy link
Member

Choose a reason for hiding this comment

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

Are you sure about the \n here, which is not a newline char ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes I think so, the \n is working as expected.

@stof
Copy link
Member

stof commented Jan 23, 2018

The dump of the workflow in #24705 (comment) looks confusing to me. It looks like there are 2 independant publish transitions, allowing to go one path or the other, while it is actually a single transition with 2 inputs (meaning that it is a AND between both paths, not a OR). This is exactly the reason why the dot dumper uses boxes to represent transitions, not arrows (to allow having multiple inputs and multiple outputs for each of them).
This is the main difference between a generic workflow and a state machine (the state machine has only one input and one output for each transition)

@lyrixx
Copy link
Member

lyrixx commented Jan 23, 2018

Oh @stof Is totally right. This PR could not be merged in this state.

@stof
Copy link
Member

stof commented Jan 23, 2018

The current dumper is fine for the case of state machines though

@Plopix
Copy link
Contributor Author

Plopix commented Jan 23, 2018

@stof thank you I have updated the code.
About the confusion, well as I said before, I am not an expert on workflow/state_machine, I was just trying to provide a better dump.

From my point of view, I don't find it that confusing as I know that I can have only one transition with the same name, then it must be the same.

You said:

This is the main difference between a generic workflow and a state machine (the state machine has only one input and one output for each transition)

But here: https://symfony.com/doc/current/workflow/state-machines.html
update gets multiple 'from'

The PR is aiming to let the choice to the user to dump it with arrow or square transition.
I have compared closely the dumps with Dot and PlantUML

On the cases provided in the doc and on the article workflow of @lyrixx :
(for each I dumped with Dot, PlantUML square and arrow transition)

Pull Request: https://symfony.com/doc/current/workflow/state-machines.html
screen shot 2018-01-23 at 1 46 31 pm

Blog Publishing: https://symfony.com/doc/current/workflow/usage.html
screen shot 2018-01-23 at 1 49 20 pm

Article: https://github.com/lyrixx/SFLive-Paris2016-Workflow/blob/master/config/packages/workflow.yaml#L3
screen shot 2018-01-23 at 1 51 03 pm

I think that is working, I am not sure what you are expecting, I see at least 3 options in which we could go:

  • 1/ we could force square for workflow and arrow for state_machine
  • 2/ we could put by default square for workflow and arrow for state_machine
  • 3/ don't do change anything as the user has the choice already

Let me know

@lyrixx
Copy link
Member

lyrixx commented Jan 24, 2018

1/ we could force square for workflow and arrow for state_machine

It's definitively the way to go ;)

@Plopix
Copy link
Contributor Author

Plopix commented Jan 25, 2018

hey @lyrixx @stof I have done the option 1/

For the sake of my understanding, I would love if you could you explain why "arrows" are not valid sometimes?
screen shot 2018-01-25 at 12 07 02 am

In this example, for instance, it feels simpler to have arrows. But I would understand if the reason is to force a kind of consistency for each type.

Let me know!

@lyrixx
Copy link
Member

lyrixx commented Jan 26, 2018

2018-01-26 10 38 57

As you can see on the previous schema, If you don't draw the transition (square), you have no way to know how many transition there are. And of course the 2 workflows (line 1 and line 2) are totally different.

@Plopix
Copy link
Contributor Author

Plopix commented Jan 26, 2018

ok makes sense ;-) all good to merge then maybe ;-)

@fabpot
Copy link
Member

fabpot commented Feb 7, 2018

Thank you @Plopix.

@fabpot fabpot merged commit 1497d36 into symfony:master Feb 7, 2018
fabpot added a commit that referenced this pull request Feb 7, 2018
…d (Plopix)

This PR was merged into the 4.1-dev branch.

Discussion
----------

[Workflow] Add PlantUML dumper to workflow:dump command

| Q             | A
| ------------- | ---
| Branch        | 4.1
| Bug fix       | no
| New feature   | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| License       | MIT
| Doc PR        | Will do depending on the comments about that PR

Hello,

`workflow:dump` exports workflows in `dot` format. To me, this format is not the easiest and not the simplest to use. Styles and logic are mixed together which makes it hard to read.

[PlantUML](http://plantuml.com/) is a tool based on Graphviz like Dot but that
generates nicer diagrams, more readable and most of all easier to adapt to your
documentation. Just copy and paste the PUML on the website you will see the rendering live.

Also, there is a [PHPStorm Plugin](https://plugins.jetbrains.com/plugin/7017-plantuml-integration) and [plenty of integration](http://plantuml.com/running) of this format.

This PR adds 2 options

* a `--dump-format=puml` option to the `workflow:dump` command to generate the workflows in PlantUML.

* a `--puml-transition-format=square|arrow` option to the `workflow:dump` command to generate the workflows in PlantUML using a square shape or arrow for the transition. (see below)

The conversion requires the PlantUML JAR, and can be used like that:
```bash
php bin/console workflow:dump pull_request --dump-format=puml | java -jar plantuml.jar -p  > workflow.png
```
> don't forget the `-p` to enable the "piping"

Here is an example with `pull_request` workflow of the documentation (with no style and no marking):
```
@startuml
title pull_request
state start <<initial>>
state coding
state travis
state review
state merged
state closed
start --> travis: submit
coding --> travis: update
travis --> travis: update
review --> travis: update
travis --> review: wait_for_review
review --> coding: request_change
review --> merged: accept
review --> closed: reject
closed --> review: reopen
@enduml
```

As PlantUML let us define styles, I have provided some by default that the user can override.
Adding some marking:
```bash
php bin/console workflow:dump pull_request travis review --dump-format=puml
```
will give us:

```
@startuml
sprite $sf_logo [81x20/16z] {
hPNRaYiX24K1xwBo_tyx6-qaCtDEJ-KXLYMTLbp0HWcHZr3KRDJ8z94HG3jZn4_mijbQ2ryJoFePtXLWA_qxyGy19DpdY_10z11ZAbGjFHRwcEbcKx5-wqsV
yIMo8StMCHKh8ZUxnEwrZiwRAUOvy1lLcPQF4lEFAjhzMd5WOAqvKflS0Enx8PbihiSYXM8ClGVAseIWTAjCgVSAcnYbQG79xKFsZ0VnDCNc7AVBoPSMcTsX
UnrujbYjjz0NnsObkTgnmolqJD4QgGUYTQiNe8eIjtx4b6Vv8nPGpncn3NJ8Geo9W9VW2wGACm_JzgIO8A8KXr2jUBCVGEAAJSZ6JUlsNnmOzmIYti9G7bjL
8InaHM9G40NkwTG7OxrggvNIejA8AZuqyWjOzTIKi-wwYvjeHYesSWuPiTGDN5THzkYLU4MD5r2_0PDhG7LIUG33z5HtM6CP3icyWEVOS61sD_2ZsBfJdbVA
qM53XHDUwhY0TAwPug3OG9NonRFhO8ynF3I4unuAMDHmSrXH57V1RGvl9jafuZF9ZhqjWOEh98y0tUYGsUxkBSllIyBdT2oM5Fn2-ut-fzsq_cQNuL6Uvwqr
knh4RrvOKzxZfLV3s0rs_R_1SdYt3VxeQ1_y2_W2
}
title pull_request
skinparam titleBorderRoundCorner 15
skinparam titleBorderThickness 2
skinparam state {
    BackgroundColor<<initial>> #87b741
    BackgroundColor<<marked>> #3887C6
    BorderColor #3887C6
    BorderColor<<marked>> Black
    FontColor<<marked>> White
}
state start <<initial>>
state coding
state travis <<marked>>
state review <<marked>>
state merged
state closed
start --> travis: submit
coding --> travis: update
travis --> travis: update
review --> travis: update
travis --> review: wait_for_review
review --> coding: request_change
review --> merged: accept
review --> closed: reject
closed --> review: reopen
footer \nGenerated by <$sf_logo> **Workflow Component** and **PlantUML**
@enduml
```

Which gives you that:
![workflow](https://user-images.githubusercontent.com/313532/32086584-253e39c0-ba8b-11e7-82c7-fa24309dbcd6.png)

With `square` as transition, it gives you that:
![workflow](https://user-images.githubusercontent.com/313532/32533123-a8ea4530-c403-11e7-8f88-4f18d5e23a28.png)

Hope you will find that interesting!

Commits
-------

1497d36 Add option to the workflow:dump command to allow PlantUML format dump
@Plopix Plopix deleted the 3.4 branch February 7, 2018 07:28
@lyrixx
Copy link
Member

lyrixx commented Feb 7, 2018

👏 Thanks for your hard work on this feature. I just tested it and it works very well.

javiereguiluz added a commit to symfony/symfony-docs that referenced this pull request Feb 7, 2018
This PR was submitted for the 4.0 branch but it was merged into the master branch instead (closes #9220).

Discussion
----------

[Workflow] PlantUML Dump documentation

Documentation related to symfony/symfony#24705
This PR aims to explain that the PlantUML dump format is available.

Platform.sh URL: http://pr-9220-x7nzdnq-6qmocelev2lwe.eu.platform.sh/workflow/dumping-workflows.html

Commits
-------

b62d961 [Workflow] PlantUML Dump documentation
@fabpot fabpot mentioned this pull request May 7, 2018
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.

9 participants