One-line declaration in state diagram

0 votes
asked Mar 25, 2014 in Wanted features by rmric (2,140 points)

Hi,

Along with the shiny new @append keyword, I'd like to be able to create a new state on only one line, but it looks like current PlantUML v7995 is limited with that regard. The following syntaxes are rejected:

@startuml

state aaaa : blah
state "aaaa_bis" : blah

state bbbb as BB
' however it works surrounded with double-quotes:  state "bbbb_bis" as BB_bis

state cccc as CC : blah
state "dddd" as DD : blah

' The following abbreviated syntaxes are also rejected, but we can live without them smiley

eeee as EE
"ffff" as FF
gggg as GG : blah
"hhhh" as HH : blah

@enduml

 

Best regards

related to an answer for: @pauseuml for splitting uml code

1 Answer

0 votes
answered Mar 27, 2014 by plantuml (295,800 points)
selected Apr 7, 2014 by rmric
 
Best answer

Good idea!
In the latest beta https://dl.dropboxusercontent.com/u/13064071/plantuml.jar , we have enabled:

@startuml
state "bbbb_label0" as BB0
state BB1 as "bbbb_label1"
state BB2 as "bbbb_label2" : blah
state AA0 : blah
state "AA1" as AA1 : blah
@enduml


Hopes it helps!
Do not hesitate to feedback.
 

commented Mar 27, 2014 by rmric (2,140 points)
Indeed, it helps for aaaa & "dddd", thanks.

Could it be possible to have these ones? bbbb and cccc will be quite common.

@startuml
state "aaaa bis" : blah
state bbbb as BB
state cccc as CC : blah
@enduml

Thanks!
commented Mar 27, 2014 by plantuml (295,800 points)
There is a slight issue with the following syntax:

state bbbb as BB

It's not obvious to know if BB is the ident and bbbb the label, or bbbb being the ident and BB the label.

That's the only reason why we impose quotes, so that users could use either:

state ident as "label"

or

state "label" as ident

Both syntax are actually working.
I know this may sound odd.
Are quotes an issue for you ?
commented Mar 31, 2014 by rmric (2,140 points)
Thank you for your response.

To me it was clear (consistent with other diagrams) that bbbb is the label (=description), and BB is the ident (=alias). Thus, only bbbb would require double-quotes because it may contain spaces. It does not seem appropriate to put space in an ident, after all. IMHO, label/ident role should be determined by syntaxic position, and not double-quote decoration.

  state "My long state name" as BB

In the end, mandatory quotes are not an issue for me as long as the rule is known. It might be an issue for newcomers who won't be aware of it, and can be frustrating.

One last question, when there's no ident (alias), why this syntax can not be possible?

@startuml
state "aaaa bis" : blah
@enduml

Best Regards
commented Mar 31, 2014 by plantuml (295,800 points)
Since the syntax has been defined in some fuzzy way, we have sometimes inconsistencies in the parser.
Sorry about that and thanks for pointing it out!

We have solved the following issue:
state "aaaa bis" : blah

in this current version: https://dl.dropboxusercontent.com/u/13064071/plantuml.jar

Happy testings :-)
commented Mar 31, 2014 by rmric (2,140 points)
Besides this plantuml.jar spewing plenty of "ug=class net.sourceforge.plantuml.ugraphic.UGraphicStencil"  (beta's debug message?), it works like a charm!

Many thanks :-)
...