Can I "extend" PlantUML diagram?

0 votes
asked May 22, 2021 in Question / help by nvcnvn (120 points)
PlantUML can include another file, now imagine I have a simplified class diagram for business team to understand the project,
then I want to "extend" the same diagram but with more details for engineers.

For example:
```
' simplified.plantuml
@startuml (id=simplified)

class Foo {}
@enduml
```

in another file, something like:
```
include simplified.plantuml
@startuml
class Foo extended simplified.Foo {
    datal
}
@enduml
```

Or you have better idea? I am trying to hard to make the issue complicated? or better I just copy/paste?

2 Answers

0 votes
answered May 30, 2021 by The-Lu (64,760 points)
selected Jun 4, 2021 by nvcnvn
 
Best answer

Hello N.,

Or depends of what you want, you can just extend a simple diagram, named simplified.puml:

@startuml
title Simplified diagram
hide empty members

class Foo {}
class C {}
class D {
data_simpl
}
class E

Foo --> C
C -> D
@enduml

with another file named full.puml:

@startuml
!include simplified.puml
title Full: extended diagram
hide empty members

class Foo {
    data1
}
class C {
data_full
}
class D {
data_full
}
class F {
data_full
}
C --> F
@enduml

If that can help,
Regards,
Th. 

0 votes
answered May 23, 2021 by kirchsth (4,980 points)

1) You could write a complete diagram and show/hide the details via preprocessor !if
2) Set the $details variable (indirect) via command line argument; or in a second *.puml
like below

@startuml
' 1) use preprocessor !if and show details if $details==true
'    details see https://plantuml.com/de/preprocessing

' !$details=true
' include ....

!if %variable_exists("WITH_DETAILS")
  !$details=true
!endif

Alice -> Bob : call
!if ($details==true)
Bob -> C : internal call
!endif


' =======================
' 2a) define variable in a "details file" before you !include the file
' !$details=true
' !include ....

' =======================
' 2b) or define it with additional command line argument -DWITH_DETAILS="1" then no additional file is required
@enduml

 

...