Using SourceKitten and PlantUML to generate UML class diagrams from swift source code.
sh plantuml.sh demo.swift
will produce this diagram Full Image
Generates the below content, which you can copy and paste it in PlantText
@startuml
' STYLE START
hide empty members
skinparam shadowing false
' STYLE END
class "Vehicle" as Vehicle {
+makeNoise()
}
class "Bicycle" as Bicycle {
}
class "Tandem" as Tandem {
}
class "Train" as Train {
+makeNoise()
}
class "Car" as Car {
}
class "AutomaticCar" as AutomaticCar {
}
class "Double" as Double << (E,orchid) extension >> {
}
class "Rect" as Rect << (S, SkyBlue) struct >> {
}
class "Rect" as Rect8 << (E,orchid) extension >> {
+init(center:size:)
}
class "FullyNamed" as FullyNamed << (P,GoldenRod) protocol >> {
}
class "Person" as Person << (S, SkyBlue) struct >> {
}
class "Starship" as Starship {
+init(name:prefix:)
}
class "Togglable" as Togglable << (P,GoldenRod) protocol >> {
+toggle()
}
class "OnOffSwitch" as OnOffSwitch << (E,LightSteelBlue) enum >> {
+toggle()
}
class "Named" as Named << (P,GoldenRod) protocol >> {
}
class "Aged" as Aged << (P,GoldenRod) protocol >> {
}
class "Person2" as Person2 << (S, SkyBlue) struct >> {
}
class "CounterDataSource" as CounterDataSource << (P,GoldenRod) protocol >> {
+increment(forCount:)
}
class "Counter" as Counter {
+increment()
}
class "ThreeSource" as ThreeSource {
}
class "TowardsZeroSource" as TowardsZeroSource {
+increment(forCount:)
}
class "IntStack" as IntStack << (S, SkyBlue) struct >> {
+push(_:)
+pop()
}
class "Stack" as Stack << (S, SkyBlue) struct >> {
+push(_:)
+pop()
}
class "Stack" as Stack23 << (E,orchid) extension >> {
}
class "AnotherPublicClass" as AnotherPublicClass {
-somePrivateMethod()
}
class "AnotherInternalClass" as AnotherInternalClass {
-somePrivateMethod()
}
class "AnotherFilePrivateClass" as AnotherFilePrivateClass {
+someFilePrivateMethod()
-somePrivateMethod()
}
class "AnotherPrivateClass" as AnotherPrivateClass {
+somePrivateMethod()
}
Bicycle --|> Vehicle : inherits
Tandem --|> Bicycle : inherits
Train --|> Vehicle : inherits
Car --|> Vehicle : inherits
AutomaticCar --|> Car : inherits
Person ..|> FullyNamed : confirms to
Starship ..|> FullyNamed : confirms to
OnOffSwitch ..|> Togglable : confirms to
Person2 ..|> Named : confirms to
Person2 ..|> Aged : confirms to
ThreeSource --|> NSObject
ThreeSource ..|> CounterDataSource : confirms to
TowardsZeroSource --|> NSObject
TowardsZeroSource ..|> CounterDataSource : confirms to
Rect <.. Rect8 : ext
Stack <.. Stack23 : ext
@enduml
-
Generates output for PlantText*