项目作者: palaniraja

项目描述 :
Script to generate plantuml class diagram from swift source code
高级语言: Swift
项目地址: git://github.com/palaniraja/swiftuml.git
创建时间: 2019-07-07T23:11:23Z
项目社区:https://github.com/palaniraja/swiftuml

开源协议:

下载


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

  1. @startuml
  2. ' STYLE START
  3. hide empty members
  4. skinparam shadowing false
  5. ' STYLE END
  6. class "Vehicle" as Vehicle {
  7. +makeNoise()
  8. }
  9. class "Bicycle" as Bicycle {
  10. }
  11. class "Tandem" as Tandem {
  12. }
  13. class "Train" as Train {
  14. +makeNoise()
  15. }
  16. class "Car" as Car {
  17. }
  18. class "AutomaticCar" as AutomaticCar {
  19. }
  20. class "Double" as Double << (E,orchid) extension >> {
  21. }
  22. class "Rect" as Rect << (S, SkyBlue) struct >> {
  23. }
  24. class "Rect" as Rect8 << (E,orchid) extension >> {
  25. +init(center:size:)
  26. }
  27. class "FullyNamed" as FullyNamed << (P,GoldenRod) protocol >> {
  28. }
  29. class "Person" as Person << (S, SkyBlue) struct >> {
  30. }
  31. class "Starship" as Starship {
  32. +init(name:prefix:)
  33. }
  34. class "Togglable" as Togglable << (P,GoldenRod) protocol >> {
  35. +toggle()
  36. }
  37. class "OnOffSwitch" as OnOffSwitch << (E,LightSteelBlue) enum >> {
  38. +toggle()
  39. }
  40. class "Named" as Named << (P,GoldenRod) protocol >> {
  41. }
  42. class "Aged" as Aged << (P,GoldenRod) protocol >> {
  43. }
  44. class "Person2" as Person2 << (S, SkyBlue) struct >> {
  45. }
  46. class "CounterDataSource" as CounterDataSource << (P,GoldenRod) protocol >> {
  47. +increment(forCount:)
  48. }
  49. class "Counter" as Counter {
  50. +increment()
  51. }
  52. class "ThreeSource" as ThreeSource {
  53. }
  54. class "TowardsZeroSource" as TowardsZeroSource {
  55. +increment(forCount:)
  56. }
  57. class "IntStack" as IntStack << (S, SkyBlue) struct >> {
  58. +push(_:)
  59. +pop()
  60. }
  61. class "Stack" as Stack << (S, SkyBlue) struct >> {
  62. +push(_:)
  63. +pop()
  64. }
  65. class "Stack" as Stack23 << (E,orchid) extension >> {
  66. }
  67. class "AnotherPublicClass" as AnotherPublicClass {
  68. -somePrivateMethod()
  69. }
  70. class "AnotherInternalClass" as AnotherInternalClass {
  71. -somePrivateMethod()
  72. }
  73. class "AnotherFilePrivateClass" as AnotherFilePrivateClass {
  74. +someFilePrivateMethod()
  75. -somePrivateMethod()
  76. }
  77. class "AnotherPrivateClass" as AnotherPrivateClass {
  78. +somePrivateMethod()
  79. }
  80. Bicycle --|> Vehicle : inherits
  81. Tandem --|> Bicycle : inherits
  82. Train --|> Vehicle : inherits
  83. Car --|> Vehicle : inherits
  84. AutomaticCar --|> Car : inherits
  85. Person ..|> FullyNamed : confirms to
  86. Starship ..|> FullyNamed : confirms to
  87. OnOffSwitch ..|> Togglable : confirms to
  88. Person2 ..|> Named : confirms to
  89. Person2 ..|> Aged : confirms to
  90. ThreeSource --|> NSObject
  91. ThreeSource ..|> CounterDataSource : confirms to
  92. TowardsZeroSource --|> NSObject
  93. TowardsZeroSource ..|> CounterDataSource : confirms to
  94. Rect <.. Rect8 : ext
  95. Stack <.. Stack23 : ext
  96. @enduml

Dependencies