I showed you my source code, pls respond
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

179 lines
3.6 KiB

4 years ago
  1. +++
  2. title = "PlantUML"
  3. author = ["Christopher James Hayward"]
  4. lastmod = 2021-02-04T14:39:22-05:00
  5. draft = false
  6. +++
  7. As described by the webiste[^fn:1]:
  8. > **PlantUML** is a component that allows you to quickly write UML and other data diagrams, using a simple and intuitive language.
  9. ## Display JSON data {#display-json-data}
  10. You can use the JSON format with PlantUML to visualize your data, to activate the feature the diagram must use the `@startjson` and `@endjson` tags, respectively[^fn:2].
  11. ```plantuml
  12. @startjson
  13. "Hello world!"
  14. @endjson
  15. ```
  16. {{< figure src="/ox-hugo/plantuml-display-json-data.png" >}}
  17. ### Simple example {#simple-example}
  18. Here's an example of a `user` object, with an accompanying `address` and list of `phone` numbers:
  19. ```plantuml
  20. @startjson
  21. {
  22. "name": "Bob",
  23. "email": "bob@bob.com",
  24. "phone": [
  25. { "type": "work", "number": "555-1234" },
  26. { "type": "mobile", "number": "555-4321" }
  27. ],
  28. "address": {
  29. }
  30. }
  31. @endjson
  32. ```
  33. {{< figure src="/ox-hugo/plantuml-display-json-data-simple-example.png" >}}
  34. ### Complex example {#complex-example}
  35. Here is the example of a complex data structure[^fn:2], which comes from the Wikipedia page for JSON[^fn:3]:
  36. ```plantuml
  37. @startjson
  38. {
  39. "firstName": "John",
  40. "lastName": "Smith",
  41. "isAlive": true,
  42. "age": 27,
  43. "address": {
  44. "streetAddress": "21 2nd Street",
  45. "city": "New York",
  46. "state": "NY",
  47. "postalCode": "10021-3100"
  48. },
  49. "phoneNumbers": [
  50. {
  51. "type": "home",
  52. "number": "212 555-1234"
  53. },
  54. {
  55. "type": "office",
  56. "number": "646 555-4567"
  57. }
  58. ],
  59. "children": [],
  60. "spouse": null
  61. }
  62. @endjson
  63. ```
  64. {{< figure src="/ox-hugo/plantuml-display-json-data-complex-example.png" >}}
  65. ## Display YAML data {#display-yaml-data}
  66. Much like JSON, PlantUML can visualize YAML data using the `@startyaml`, and `@endyaml` keywords[^fn:4]:
  67. ```plantuml
  68. @startyaml
  69. fruit: Apple
  70. size: Large
  71. @endyaml
  72. ```
  73. {{< figure src="/ox-hugo/plantuml-display-yaml-data.png" >}}
  74. ### Docker example {#docker-example}
  75. Here's an example docker compose file running with a simple application structure[^fn:5]:
  76. ```plantuml
  77. @startyaml
  78. version: "3.9"
  79. services:
  80. db:
  81. image: postgres
  82. environment:
  83. - POSTGRES_DB=postgres
  84. - POSTGRES_USER=postgres
  85. - POSTGRES_PASSWORD=postgres
  86. web:
  87. build: .
  88. command: python manage.py runserver 0.0.0.0:8000
  89. volumes:
  90. - .:/code
  91. ports:
  92. - "8000:8000"
  93. depends_on:
  94. - db
  95. @endyaml
  96. ```
  97. {{< figure src="/ox-hugo/plantuml-display-yaml-data-docker-example.png" >}}
  98. ## Sequence Diagram {#sequence-diagram}
  99. Here's the complete example[^fn:6] showing many participants.
  100. ```plantuml
  101. @startuml
  102. /'
  103. ' Define the participant(s).
  104. '/
  105. participant participant as 1
  106. actor actor as 2
  107. boundary boundary as 3
  108. control control as 4
  109. entity entity as 5
  110. database database as 6
  111. collections collections as 7
  112. queue queue as 8
  113. /'
  114. ' Draw a line to each participant(s).
  115. '/
  116. 1 -> 2 : To actor
  117. 1 -> 3 : To boundary
  118. 1 -> 4 : To control
  119. 1 -> 5 : To entity
  120. 1 -> 6 : To database
  121. 1 -> 7 : To collection
  122. 1 -> 8 : To queue
  123. @enduml
  124. ```
  125. {{< figure src="/ox-hugo/plantuml-sequence-diagram.png" >}}
  126. Here's a list of all the available keywords:
  127. - actor
  128. - boundary
  129. - control
  130. - entity
  131. - database
  132. - collections
  133. - queue
  134. ## Resources {#resources}
  135. [^fn:1]: PlantUML Website <https://plantuml.com>
  136. [^fn:2]: PlantUML JSON Data <https://plantuml.com/json>
  137. [^fn:3]: Wikipedia entry for JSON <https://en.wikipedia.org/wiki/JSON>
  138. [^fn:4]: PlantUML YAML Data <https://plantuml.com/yaml>
  139. [^fn:5]: Docker compose documentation <https://docs.docker.com/compose/django/>
  140. [^fn:6]: PlantUML Sequence Diagrams <https://plantuml.com/sequence-diagram>