different behaviour include paths for !include and !includesub

0 votes
asked May 13 in Bug by pluyckx (120 points)

Hi,

I am trying to split my project in multiple files, but I encounter some problems with both, the old preprocessor (plantuml v1.2019.03) and the new one (plantuml v1.2019.06beta22).

I have the following setup:

project/
  + subdir/
  |    + component1.puml
  |    + container.puml
  + app.puml

If you give the file component1.puml the following code:

@startuml
!startsub COMP_CLASS

class CompPuml
!endsub
@enduml

The file container.puml

@startuml
!includesub component.puml!COMP_CLASS
class SubPuml
@enduml

And the file app.puml

@startuml
!include sub/inc.puml
@enduml

Then the stable plantuml version generates following output:

[From sub/sub.puml (line2)]

---------------------------

@startuml

!includesub comp.puml!COMP_CLASS

Cannot include comp.puml

The beta plantuml version results in the following output:

[From sub/sub.puml (line2)]

---------------------------

@startuml

!includesub comp.puml!COMP_CLASS

Sytanx Error?

If I use !include, then the stable plantuml will not trigger an error, while the beta version will generate the same output, but it seems plantuml returns an error code. Because when using the GUI of plantuml, the list shows there was an error, however, the generated png is correct.

When also removing the !startsub and !endsub lines in component.puml, both versions of plantuml work fine.

The issue is that !includesub behaves differently from which directories it tries to include the files. I expect the behaviour like !include, if file1 includes file2, and file2 includes (a part of) file3, the include to file3 in file2 is relative to file2. This seems not the case. I also tried to include relative from the working directory or the root file (app.puml in my example above), but nothing works.

Am I doing something wrong or is this a bug in plantuml?

ps: I made a zip which you can download through wetransfer: https://we.tl/t-dyIFu0ooWM. This zip contains some files which simulates the above issue. includesub.puml is the actual issue I want to report. include.puml is the issue that the beta version generates the correct png, but plantuml reports there is an error. The last version is the version that works like it should.

1 Answer

0 votes
answered May 13 by plantuml (198,100 points)

The issue is that !includesub behaves differently from which directories it tries to include the files. I expect the behaviour like !include, if file1 includes file2, and file2 includes (a part of) file3, the include to file3 in file2 is relative to file2.

This seems not the case.

You are not anything wrong. This looks like a bug in PlantUML

The !includesub is not widely used and not yet implemented in preprocessorV2.

We are going to investigate and we will post here a message when this will be fixed in preprocessorV2. (I don't think we are going to fix it in the old preprocessor since it will be removed in some future.)

Thanks for the feedback!

commented May 14 by pluyckx (120 points)
Thank you for the feedback. For now I am using a workaround by splitting the files in more files and just use !include. So it is not a showstopper, but it is nice to know this will work again somewhere in the future. It will improve reusability and readability of some diagrams.

I do not expect you fix it in the old preprocessor. I read about the new one and it has some nice features, so it's better to focus more on the new one :).
...