SwiftPlantUML icon indicating copy to clipboard operation
SwiftPlantUML copied to clipboard

Is there a option that draws 'Composition' as uml?

Open kickbell opened this issue 2 years ago • 5 comments

Is there a option that draws 'Composition' as uml?

kickbell avatar Dec 01 '22 23:12 kickbell

You can modify the output of this command-line tool to add compositions as PlantUML supports this notation.

@startuml
Foo *-- Bar
@enduml

would result in

SoWkIImgAStDuNBBprVGqjLLS4eiud98pKi1YW40

But SwiftPlantUML will not auto-generate this for you because I did not implement the composition (or association) detection in Swift code.

This Swift code

public class Foo {
    private Bar bar = new Bar(); 
}

would result in the following PlantUML script generated by SwiftPlantUML command-line tool

@startuml
' STYLE START
hide empty members
skinparam shadowing false
' STYLE END

class "Foo" as Foo << (C, DarkSeaGreen) >> { 
  -Bar() 
}
class "Bar" as Bar << (C, DarkSeaGreen) >> {  
}

@enduml

And you want

@startuml
' STYLE START
hide empty members
skinparam shadowing false
' STYLE END

class "Foo" as Foo << (C, DarkSeaGreen) >> { 
  -Bar() 
}
class "Bar" as Bar << (C, DarkSeaGreen) >> {  
}

Foo *-- Bar

@enduml

Does this answer your question?

MarcoEidinger avatar Dec 02 '22 00:12 MarcoEidinger

yes, that's a really good answer. I'll try it out! 👍🏻

kickbell avatar Dec 02 '22 10:12 kickbell

Hi, are you planning on adding an option to detect Composition automatically? It'd be great to get insights regarding the coupling of the system, too

AlexPerathoner avatar Mar 25 '23 20:03 AlexPerathoner

Hi @AlexPerathoner, it's not on my short-term list as I am worried about performance & cluttering the diagram. If you wanna take a shot and prepare a PR then I am happy to reviewing it

MarcoEidinger avatar Mar 25 '23 21:03 MarcoEidinger