Skip to content

palaniraja/swiftuml

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Swift to PlantUML

Using SourceKitten and PlantUML to generate UML class diagrams from swift source code.

Class diagram output without relationship

Usage

sh plantuml.sh demo.swift

If you want to run on multiple files at the moment, you can do some command line kung fu like below

ls -d "/directory/full/of/swift/files/"* | xargs -L 1 sh plantuml.sh | pbcopy

or if you list of files with fullpath

cat ~/Downloads/listOfFilesWithFullPath.txt | xargs -L 1 | xargs -L 1 sh plantuml.sh | pbcopy

once it copy everything to your clipboard (MacOS) you can paste it in your favorite text editor replace multiple @startuml and @enduml block and have just one startuml at top and enduml at the bottom


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

Dependencies

About

Script to generate plantuml class diagram from swift source code

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published