Macro for processing collections

0 votes
asked Jan 25 in Wanted features by MR

Dear plantuml,

Do you reckon it would be possible to implement support for macros that can handle collection on the input?

My use case for this is the ability to enter a collection into the macro without knowing how many elements will be input, in order to build up some shared macros that can be used by multiple people and potentially updated to make global changes in formatting/styling that would affect our whole repository of specifications.

An example of what's possible:

@startuml

!define descHeader(element) element : <size:10>**Some formatting headline...**</size>
!define descRow(element,text) element : <size:10> text</size>

state A
state B

descHeader(A)
descHeader(B)

descRow(A,some quality of A)
descRow(A,another quality of A)
descRow(B,some quality of B)
descRow(B,some flaw of B)

@enduml

Now here I know that I have two states, A and B, so I could do this:

@startuml

!definelong descHeaders(e1,e2)
descHeader(e1)
descHeader(e2)
!enddefinelong
!define descHeader(element) element : <size:10>**Some formatting headline...**</size>
!define descRow(element,text) element : <size:10> text</size>

state A
state B

descHeaders(A,B)

descRow(A,some quality of A)
descRow(A,another quality of A)
descRow(B,some quality of B)
descRow(B,some flaw of B)

@enduml

But what I would like to be able to achieve is something like this:

@startuml

!defineloop descHeaders(elements) element : <size:10>**Some formatting headline...**</size>
!define descRow(element,text) element : <size:10> text</size>

state A
state B

descHeaders(A,B)

descRow(A,some quality of A)
descRow(A,another quality of A)
descRow(B,some quality of B)
descRow(B,some flaw of B)

@enduml

Without having to worry how many elements I enter, so if the situation demanded it, I could do for instance descHeaders(A,B,C,D,E,F,G,H,I,J,K,L,M,N), which would totally beat the readability out of having to write descHeader(A), descHeader(B), ... that would be spread over many lines (14 in this particular example) which would only compromise readability and maintainability.

Obviously the syntax above is just first thing that came to mind and it might need to be a bit more complicated to enable more elaborate loops, but in fact just this would be quite a leap ahead for me.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.
...