Commands inside comments

0 votes
asked Nov 14, 2013 in Wanted features by surlac (120 points)

Is it possible to use PlantUML commands inside of existing source code (SQL) in comments? (So SQL compiler will skip PlantUML commands because it's in comment block and PlantUML will use only it's own commands).

Example of code:

CREATE PROCEDURE test() BEGIN

 -- @startuml

  -- (*) --> "First activity"
SELECT * FROM table_1;
  -- (*) --> "second activity"
SELECT * FROM table_2;
-- --> (*)
-- @enduml

END;

 

Currently PlantUML shows this error:

SELECT * FROM table_1;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Syntax Error?

 

1 Answer

0 votes
answered Nov 14, 2013 by plantuml (295,000 points)

Well, this is weird, we have never though about doing something like this, but here what you can do:

First, you have to choose between two syntaxes : the legacy http://plantuml.sourceforge.net/activity.html  and the new http://plantuml.sourceforge.net/activity2.html

If you choose the new activity syntax, you can do:

-- @startuml
-- start
-- :SELECT * FROM table_1;
-- :second activity;
-- :SELECT * FROM table_2;
-- end
-- @enduml


Note that an activity has to start with : and ends with ;
The : will be an issue for SQL command, but luckily, you can put an activity on two lines.
And remove the header -- for real SQL command, PlantUML will be OK with that:

-- @startuml
-- start
-- :
SELECT * FROM table_1;
-- :second activity;
-- :
SELECT * FROM table_2;
-- end
-- @enduml



For the legacy activity syntax, you have to use --> and quotes "


-- @startuml
-- (*) --> "First activity"
-- --> "SELECT * FROM table_1;"
-- (*) --> "second activity"
-- --> "SELECT * FROM table_2;"
-- --> (*)
-- @enduml


Which can be changed into:

-- @startuml
-- (*) --> "First activity"
-- --> "
SELECT * FROM table_1;
-- "
-- --> "second activity"
-- --> "
SELECT * FROM table_2;
-- "
-- --> (*)
-- @enduml


It's also working, but the new activity syntax is probably simplier.

Hope this helps!
 

...