!include file.wsd!MY_ID does include the whole file.wsd

0 votes
asked Aug 16, 2021 in Question / help by apercu

I have the following code:

AB.wsd:

@startuml (id=A)
component A
@enduml

@startuml (id=B)
component B
@enduml

C.wsd:

@startuml C
!include AB.wsd!A
component C
@enduml

I would expect to see a diagram containing the components A and C, but actually I get a diagram with A, B and C. All contents of AB.wsd are included, no matter if I import only id A or B.

What am I doing wrong?

I use the latest plantUML extension in VS code and run the docker PlantUML renderer on jetty on another PC.

Cheers.

1 Answer

0 votes
answered Aug 17, 2021 by The-Lu (64,340 points)

Hello A.,

It is not an issue on PlantUML core, but more on PlantUML extension in VS code:

With latest PlantUML extension (V 2.15.1) in VS code and embedded PlantUML jar (local Render) it is OK.

It seems that is an issue on the extension with the docker PlantUML jetty webserver (PlantUMLServer Render).

Perhaps ask the author/maintainer of the extension to know if 'include' with 'id' is available with the PlantUMLServer Render mode.

See related fixed issue about 'include' here:

Regards,
Th.

commented Aug 17, 2021 by apercu
Thanks a lot, the Local renderer fits my need!

(It was my first touch with docker, so I'm unsure how to provide feedback there.)

Cheers!
commented Aug 17, 2021 by apercu

Me again - my other issue which now appears again (and which was the reason I used the docker PlantUML renderer before) is multiple includes.

I'm actually creating an bigger ancestry tree using components and interfaces, and it works totally well as long as everything is defined in one file. But the tree can get big, and as soon as you want to split in different trees but at the same time make things reusable, it's getting difficult.

Let's say I have this:

[Parent_A]  [Parent_B]
        \    /
         \  /
          \/
          () A_B
          /\
         /  \
[Child_1]    [Child_2]  
The persons are components, the connections are interfaces, And I try to define them as follows:
@startuml (id=A_B)
() A_B
!include ancestry.wsd!Parent_A
!include ancestry.wsd!Parent_B
Parent_A --> A_B
Parent_B --> A_B
A_B --> Child_1
A_B --> Child_2
@enduml

@startuml (id=Parent_1)
component Parent_1 [
  Parent 1 details
]
!include ancestry.wsd!A_B
@enduml

.. and so on...

To generate a complete tree for a specific person (e.g. Child_1), I'd like to have a wsd file which includes Child_1 (and Child_2 for completeness of data). From here on, the includes should be automatic as they are defined alwas from childs to interfaces, and from interfaces to parents: the Child_1 should itself include A_B (as well as Child_2). A_B would include the parents objects.

This works fine, UNTIL I start to add a sibling of a Parent_A (to add it's data, as the component definition itself is not included by the strict upwards include chain) - then I receive the error "This element (Parent_A) is already defined", because the sibling is first referenced first by the interface between the grand-parents from the Parent_A chain, and then again by the sinbling's chain (or the other way round).

---

It's a bit hard to explain - but I think the multiple includes problem is known, and it was not an issue with the docker renderer. But with the renderer I cannot refer to a single ID, but always get the whole file.

For me it would be important to understand if this behavior is by design, or if it is a bug, because my workarounds might look different in each case. I surely hope it would be bug which could be fixed :-)

Cheers!

commented Aug 18, 2021 by The-Lu (64,340 points)

Hello A.,

For include (!include, !include_many, !include_once), you can see documentation here:

Then: I have a little trouble understanding how the PlantUMLServer Render mode would solve the problem, perhaps it is more the implementation of the VS Code PlantUML extension... (according include).

If that can help,
Regards.

commented Aug 19, 2021 by apercu
You're surely right, it might all be more related to the VS plugin, I somehow have the impression it does not support the include_many anymore, as I tried this before without success.

Anyways, I could work around my problem, thank you!
commented Aug 19, 2021 by The-Lu (64,340 points)

OK, great.

And, FYI, here is a link to the code of the PlantUML VS Code extension that mimics the 'include' (natively on PlantUML) functionality:

...