以这个小例子来说明我的问题。
common.puml
@startuml common
!startsub COMMON
abstract Common {
id : uuid
}
!endsub
@enduml
myclass1.puml
@startuml myclass1
!includesub common.puml!COMMON
class MyClass1 extends Common {
text: string
}
@enduml
myclass2.puml
@startuml myclass1
!includesub common.puml!COMMON
class MyClass2 extends Common {
value: int
}
@enduml
all.puml
@startuml all
!include ./sub/common.puml
!include ./sub/myclass1.puml
!include ./sub/myclass2.puml
@enduml
在重新绘制all.puml图时,公共部分有一个奇怪的结果。属性呈现3次!
知道吗?
发布于 2022-08-24 03:53:46
这要么是个特征要么是个bug。包含文件,只需将文件中的代码放在另一个文件中。由于common.puml
最终被包含了三次(一次在all
中,一次在myclass1
中,一次在myclass2
中),所以您或多或少地使用了:
abstract Common {
id : uuid
}
abstract Common {
id : uuid
}
abstract Common {
id : uuid
}
它将产生
也许您可以通过定义一个变量来防止这种情况发生,例如,在不想重复的!$common = 1
中定义一个变量,并在执行!includesub
之前进行检查。
...
!if (%not($common == 1))
!includesub common.puml!COMMON
!endif
...
(注意-我没有测试这个!)
https://stackoverflow.com/questions/63227378
复制相似问题