drawio_dsl 0.5.6 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (215) hide show
  1. checksums.yaml +4 -4
  2. data/.builders/.data/shapes.json +44 -26
  3. data/.builders/.templates/basic/dom_builder_shapes.rb +2 -2
  4. data/.builders/.templates/basic/drawio_extensions.rb +57 -0
  5. data/.builders/.templates/basic/drawio_shapes.rb +2 -2
  6. data/.builders/.templates/basic/schema_require.rb +3 -1
  7. data/.builders/blueprint/shapes.rb +9 -5
  8. data/.builders/generators/10-transform-drawio-js.rb +195 -0
  9. data/.builders/generators/20-drawio-extensions.rb +41 -0
  10. data/.builders/generators/project_plans/drawio_dsl.rb +11 -5
  11. data/.builders/generators/project_plans/k_doc.rb +39 -0
  12. data/.builders/generators/sample_diagrams/15-grid-direction.rb +0 -8
  13. data/.builders/generators/sample_diagrams/20-styles.rb +1 -2
  14. data/.builders/generators/sample_diagrams/30-html-shapes.rb +68 -0
  15. data/.rubocop.yml +4 -1
  16. data/CHANGELOG.md +27 -0
  17. data/docs/extensions/analyti_cs.svg +3 -0
  18. data/docs/extensions/android_inputs.svg +3 -0
  19. data/docs/extensions/app_services.svg +3 -0
  20. data/docs/extensions/appliances.svg +3 -0
  21. data/docs/extensions/arrows.svg +3 -0
  22. data/docs/extensions/aws_17___analyti_cs.svg +3 -0
  23. data/docs/extensions/aws_17___application_services.svg +3 -0
  24. data/docs/extensions/aws_17___artificial_intelligence.svg +3 -0
  25. data/docs/extensions/aws_17___business_productivity.svg +3 -0
  26. data/docs/extensions/aws_17___compute.svg +3 -0
  27. data/docs/extensions/aws_17___contact_center.svg +3 -0
  28. data/docs/extensions/aws_17___containers.svg +3 -0
  29. data/docs/extensions/aws_17___database.svg +3 -0
  30. data/docs/extensions/aws_17___desktop_app_straning.svg +3 -0
  31. data/docs/extensions/aws_17___developer_tools.svg +3 -0
  32. data/docs/extensions/aws_17___game_development.svg +3 -0
  33. data/docs/extensions/aws_17___general.svg +3 -0
  34. data/docs/extensions/aws_17___io_t.svg +3 -0
  35. data/docs/extensions/aws_17___management.svg +3 -0
  36. data/docs/extensions/aws_17___messaging.svg +3 -0
  37. data/docs/extensions/aws_17___migration.svg +3 -0
  38. data/docs/extensions/aws_17___mobile_services.svg +3 -0
  39. data/docs/extensions/aws_17___networking_content_delivery.svg +3 -0
  40. data/docs/extensions/aws_17___on_demand_workforce.svg +3 -0
  41. data/docs/extensions/aws_17___sdks.svg +3 -0
  42. data/docs/extensions/aws_17___serurity_identity_and_compliance.svg +3 -0
  43. data/docs/extensions/aws_17___storage.svg +3 -0
  44. data/docs/extensions/aws_19___application_integration.svg +3 -0
  45. data/docs/extensions/aws_19___ar_vr.svg +3 -0
  46. data/docs/extensions/aws_19___blockchain.svg +3 -0
  47. data/docs/extensions/aws_19___business_applications.svg +3 -0
  48. data/docs/extensions/aws_19___compute.svg +3 -0
  49. data/docs/extensions/aws_19___cost_management.svg +3 -0
  50. data/docs/extensions/aws_19___customer_engagement.svg +3 -0
  51. data/docs/extensions/aws_19___database.svg +3 -0
  52. data/docs/extensions/aws_19___desktop_app_streaming.svg +3 -0
  53. data/docs/extensions/aws_19___developer_tools.svg +3 -0
  54. data/docs/extensions/aws_19___ec2_instance_types.svg +3 -0
  55. data/docs/extensions/aws_19___game_tech.svg +3 -0
  56. data/docs/extensions/aws_19___general.svg +3 -0
  57. data/docs/extensions/aws_19___groups_note_repeated_below_without_v2.svg +3 -0
  58. data/docs/extensions/aws_19___internet_of_things.svg +3 -0
  59. data/docs/extensions/aws_19___machine_learning.svg +3 -0
  60. data/docs/extensions/aws_19___management_governance.svg +3 -0
  61. data/docs/extensions/aws_19___media_services.svg +3 -0
  62. data/docs/extensions/aws_19___migration_transfer.svg +3 -0
  63. data/docs/extensions/aws_19___mobile.svg +3 -0
  64. data/docs/extensions/aws_19___networking_content_delivery.svg +3 -0
  65. data/docs/extensions/aws_19___roboti_cs.svg +3 -0
  66. data/docs/extensions/aws_19___satellite.svg +3 -0
  67. data/docs/extensions/aws_19___security_identity_compliance.svg +3 -0
  68. data/docs/extensions/aws_19___storage.svg +3 -0
  69. data/docs/extensions/aws_19_analyti_cs.svg +3 -0
  70. data/docs/extensions/aws_general.svg +3 -0
  71. data/docs/extensions/azure2019.svg +3 -0
  72. data/docs/extensions/azure_cloud.svg +3 -0
  73. data/docs/extensions/azure_enterprise.svg +3 -0
  74. data/docs/extensions/azure_vms.svg +3 -0
  75. data/docs/extensions/basic_network_shapes.svg +3 -0
  76. data/docs/extensions/beds.svg +3 -0
  77. data/docs/extensions/bpmn_2_0.svg +3 -0
  78. data/docs/extensions/cisco_basic.svg +3 -0
  79. data/docs/extensions/cisco_extended.svg +3 -0
  80. data/docs/extensions/common_elements.svg +3 -0
  81. data/docs/extensions/computers_and_monitors.svg +3 -0
  82. data/docs/extensions/containers.svg +3 -0
  83. data/docs/extensions/content_delivery.svg +3 -0
  84. data/docs/extensions/couches.svg +3 -0
  85. data/docs/extensions/cubicle_walls.svg +3 -0
  86. data/docs/extensions/data_flow.svg +3 -0
  87. data/docs/extensions/database.svg +3 -0
  88. data/docs/extensions/deployment.svg +3 -0
  89. data/docs/extensions/desks.svg +3 -0
  90. data/docs/extensions/detailed_network_diagrams.svg +3 -0
  91. data/docs/extensions/developer_tools.svg +3 -0
  92. data/docs/extensions/doors_windows.svg +3 -0
  93. data/docs/extensions/ec2.svg +3 -0
  94. data/docs/extensions/electrical.svg +3 -0
  95. data/docs/extensions/electroni_cs.svg +3 -0
  96. data/docs/extensions/enterprise_application.svg +3 -0
  97. data/docs/extensions/equipment.svg +3 -0
  98. data/docs/extensions/ext_shapes.svg +3 -0
  99. data/docs/extensions/flowchart.svg +3 -0
  100. data/docs/extensions/geometric_shapes.svg +3 -0
  101. data/docs/extensions/google_cloud_platform.svg +3 -0
  102. data/docs/extensions/heat_exchangers.svg +3 -0
  103. data/docs/extensions/i_os_6_i_pad_controls.svg +3 -0
  104. data/docs/extensions/i_os_6_i_pad_elements.svg +3 -0
  105. data/docs/extensions/i_os_6_i_pad_icons.svg +3 -0
  106. data/docs/extensions/i_os_6_i_phone_controls.svg +3 -0
  107. data/docs/extensions/i_os_6_i_phone_elements.svg +3 -0
  108. data/docs/extensions/i_os_6_i_phone_icons.svg +3 -0
  109. data/docs/extensions/i_os_devices.svg +3 -0
  110. data/docs/extensions/i_os_icons.svg +3 -0
  111. data/docs/extensions/i_os_mockups.svg +3 -0
  112. data/docs/extensions/i_os_ui_components.svg +3 -0
  113. data/docs/extensions/i_pad_elements.svg +3 -0
  114. data/docs/extensions/i_phone_elements.svg +3 -0
  115. data/docs/extensions/information.svg +3 -0
  116. data/docs/extensions/instruments.svg +3 -0
  117. data/docs/extensions/internet_of_things.svg +3 -0
  118. data/docs/extensions/kanban.svg +3 -0
  119. data/docs/extensions/kitchen.svg +3 -0
  120. data/docs/extensions/kubernetes_icons.svg +3 -0
  121. data/docs/extensions/logic_gates.svg +3 -0
  122. data/docs/extensions/materials.svg +3 -0
  123. data/docs/extensions/message_routing.svg +3 -0
  124. data/docs/extensions/message_transformation.svg +3 -0
  125. data/docs/extensions/messaging_channels.svg +3 -0
  126. data/docs/extensions/messaging_endpoints.svg +3 -0
  127. data/docs/extensions/messaging_systems.svg +3 -0
  128. data/docs/extensions/mind_map.svg +3 -0
  129. data/docs/extensions/misc.svg +3 -0
  130. data/docs/extensions/misc_floorplan.svg +3 -0
  131. data/docs/extensions/miscellaneous.svg +3 -0
  132. data/docs/extensions/mobile_services.svg +3 -0
  133. data/docs/extensions/network.svg +3 -0
  134. data/docs/extensions/networking.svg +3 -0
  135. data/docs/extensions/on_demand.svg +3 -0
  136. data/docs/extensions/piping.svg +3 -0
  137. data/docs/extensions/power_sources.svg +3 -0
  138. data/docs/extensions/processes.svg +3 -0
  139. data/docs/extensions/pumps.svg +3 -0
  140. data/docs/extensions/repeated_from_the_above.svg +3 -0
  141. data/docs/extensions/restroom.svg +3 -0
  142. data/docs/extensions/s3.svg +3 -0
  143. data/docs/extensions/sdks.svg +3 -0
  144. data/docs/extensions/security_identity.svg +3 -0
  145. data/docs/extensions/server_racks.svg +3 -0
  146. data/docs/extensions/shipments.svg +3 -0
  147. data/docs/extensions/site_map.svg +3 -0
  148. data/docs/extensions/stairs.svg +3 -0
  149. data/docs/extensions/standard.svg +3 -0
  150. data/docs/extensions/system_management.svg +3 -0
  151. data/docs/extensions/tables_chairs.svg +3 -0
  152. data/docs/extensions/technology.svg +3 -0
  153. data/docs/extensions/transistors.svg +3 -0
  154. data/docs/extensions/ui_containers.svg +3 -0
  155. data/docs/extensions/ui_input.svg +3 -0
  156. data/docs/extensions/ui_menus.svg +3 -0
  157. data/docs/extensions/ui_misc.svg +3 -0
  158. data/docs/extensions/ui_widgets.svg +3 -0
  159. data/docs/extensions/uml_class_diagram.svg +3 -0
  160. data/docs/extensions/uml_component.svg +3 -0
  161. data/docs/extensions/uml_entity_relationship.svg +3 -0
  162. data/docs/extensions/uml_sequence.svg +3 -0
  163. data/docs/extensions/uml_state_activity.svg +3 -0
  164. data/docs/extensions/uml_use_case.svg +3 -0
  165. data/docs/extensions/value_stream_mapping.svg +3 -0
  166. data/docs/extensions/valves.svg +3 -0
  167. data/docs/extensions/venn_gradient.svg +3 -0
  168. data/docs/extensions/venn_plain.svg +3 -0
  169. data/docs/extensions/vessels.svg +3 -0
  170. data/docs/extensions.md +614 -0
  171. data/docs/project_done.svg +1 -1
  172. data/docs/project_in_progress.svg +1 -1
  173. data/docs/project_todo.svg +1 -1
  174. data/docs/samples/grid-direction-horizontal.svg +1 -1
  175. data/docs/samples/grid-direction-vertical.svg +1 -1
  176. data/docs/samples/samples.svg +1 -1
  177. data/docs/samples/styles-glass.svg +1 -1
  178. data/docs/samples/styles-plain.svg +1 -1
  179. data/docs/samples/styles-rounded.svg +1 -1
  180. data/docs/samples/styles-shadow.svg +1 -1
  181. data/docs/samples/styles-sketch.svg +1 -1
  182. data/docs/samples/themes-random.svg +1 -1
  183. data/lib/drawio_dsl/configuration_shapes.rb +12 -8
  184. data/lib/drawio_dsl/dom_builder.rb +23 -8
  185. data/lib/drawio_dsl/dom_builder_shapes.rb +92 -82
  186. data/lib/drawio_dsl/drawio_extensions.json +14024 -0
  187. data/lib/drawio_dsl/drawio_extensions.rb +4599 -0
  188. data/lib/drawio_dsl/drawio_extensions_active.rb +32 -0
  189. data/lib/drawio_dsl/drawio_shapes.rb +108 -96
  190. data/lib/drawio_dsl/formatters/_.rb +8 -0
  191. data/lib/drawio_dsl/formatters/base_formatter.rb +24 -0
  192. data/lib/drawio_dsl/formatters/factory.rb +32 -0
  193. data/lib/drawio_dsl/formatters/html_builder.rb +84 -0
  194. data/lib/drawio_dsl/formatters/interface_formatter.rb +53 -0
  195. data/lib/drawio_dsl/formatters/klass_formatter.rb +52 -0
  196. data/lib/drawio_dsl/formatters/style_builder.rb +63 -0
  197. data/lib/drawio_dsl/layout_engine.rb +17 -7
  198. data/lib/drawio_dsl/schema/_.rb +8 -4
  199. data/lib/drawio_dsl/schema/diagram.rb +1 -1
  200. data/lib/drawio_dsl/schema/layouts/flex_layout.rb +1 -2
  201. data/lib/drawio_dsl/schema/layouts/grid_layout.rb +1 -2
  202. data/lib/drawio_dsl/schema/layouts/layout.rb +0 -3
  203. data/lib/drawio_dsl/schema/node.rb +21 -2
  204. data/lib/drawio_dsl/schema/node_list.rb +20 -1
  205. data/lib/drawio_dsl/schema/page.rb +14 -3
  206. data/lib/drawio_dsl/schema/shapes/interface.rb +9 -0
  207. data/lib/drawio_dsl/schema/shapes/klass.rb +9 -0
  208. data/lib/drawio_dsl/schema/shapes/shape.rb +14 -5
  209. data/lib/drawio_dsl/schema/virtual/anchor.rb +26 -0
  210. data/lib/drawio_dsl/version.rb +1 -1
  211. data/lib/drawio_dsl/xml_builder.rb +4 -8
  212. data/lib/drawio_dsl.rb +3 -0
  213. data/package-lock.json +2 -2
  214. data/package.json +1 -1
  215. metadata +174 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 35811da8138e65733de38529db78e785306a329c7a4f8b0cfb6c0317e647150c
4
- data.tar.gz: 7604913a71121114897631cd5ee74666a9443a379119248e8e724d4c1edd4284
3
+ metadata.gz: 0ca0ef8325e3ca9e3eeb032142a12c57bc12b5bf0f0e564fe162d2da70a06136
4
+ data.tar.gz: 17d39e80687f5fa5778a9e48011b4073fea363082b3ce490dff3f90d06747c94
5
5
  SHA512:
6
- metadata.gz: 23b027e1219e74a55ebb2ce56973d7b32c389f712e0f15d60571020bf7d182d2e360c54e043213e5dc360fcbb244b18b314da2f0df5109212b42a3b69f147c29
7
- data.tar.gz: 4add99537c8e7e7a93fae23bb3d55634f0b8471c59a201f49cdc577e64a98e738763e98d1efbb82e601009d9847b77d7d9bc990b835317b130e7399e06d4222e
6
+ metadata.gz: c938d044a019af58cd694619dc5de2e78760f13a3626e06deb9470e0cb3066c2d4841066fb69bed1e921c2955a5849ae350e916e07c3eae31440779907057403
7
+ data.tar.gz: c37d85e61f581533d6803541fbbe3e6ed1aedc58cdafd48ef20834ac4c9361f81e96890f8514bc68c21b8bd0e58a415a5960e901774968f802f16bbe50b5965f
@@ -134,6 +134,42 @@
134
134
  "h": 160,
135
135
  "style_modifiers": "shape=cloud"
136
136
  },
137
+ {
138
+ "type": "container",
139
+ "text_only": false,
140
+ "x": 0,
141
+ "y": 0,
142
+ "w": 160,
143
+ "h": 160,
144
+ "style_modifiers": "swimlane"
145
+ },
146
+ {
147
+ "type": "container2",
148
+ "text_only": false,
149
+ "x": 0,
150
+ "y": 0,
151
+ "w": 160,
152
+ "h": 160,
153
+ "style_modifiers": "swimlane;horizontal=0"
154
+ },
155
+ {
156
+ "type": "container3",
157
+ "text_only": false,
158
+ "x": 0,
159
+ "y": 0,
160
+ "w": 160,
161
+ "h": 160,
162
+ "style_modifiers": "swimlane;startSize=50"
163
+ },
164
+ {
165
+ "type": "container4",
166
+ "text_only": false,
167
+ "x": 0,
168
+ "y": 0,
169
+ "w": 160,
170
+ "h": 160,
171
+ "style_modifiers": "swimlane;resizable=0"
172
+ },
137
173
  {
138
174
  "type": "cross",
139
175
  "text_only": false,
@@ -189,40 +225,22 @@
189
225
  "style_modifiers": "shape=hexagon"
190
226
  },
191
227
  {
192
- "type": "container",
228
+ "type": "interface",
193
229
  "text_only": false,
194
230
  "x": 0,
195
231
  "y": 0,
196
- "w": 160,
197
- "h": 160,
198
- "style_modifiers": "swimlane"
199
- },
200
- {
201
- "type": "container2",
202
- "text_only": false,
203
- "x": 0,
204
- "y": 0,
205
- "w": 160,
206
- "h": 160,
207
- "style_modifiers": "swimlane;horizontal=0"
208
- },
209
- {
210
- "type": "container3",
211
- "text_only": false,
212
- "x": 0,
213
- "y": 0,
214
- "w": 160,
215
- "h": 160,
216
- "style_modifiers": "swimlane;startSize=50"
232
+ "w": 200,
233
+ "h": 120,
234
+ "style_modifiers": "align=left;overflow=fill;fontSize=12;fontFamily=Helvetica"
217
235
  },
218
236
  {
219
- "type": "container4",
237
+ "type": "klass",
220
238
  "text_only": false,
221
239
  "x": 0,
222
240
  "y": 0,
223
- "w": 160,
224
- "h": 160,
225
- "style_modifiers": "swimlane;resizable=0"
241
+ "w": 200,
242
+ "h": 120,
243
+ "style_modifiers": "align=left;overflow=fill;fontSize=12;fontFamily=Helvetica"
226
244
  },
227
245
  {
228
246
  "type": "note",
@@ -6,8 +6,8 @@ module DrawioDsl
6
6
  module DomBuilderShapes
7
7
  {{#each shapes}}
8
8
 
9
- def add_{{snake ./type}}(**opts)
10
- {{snake ./type}} = DrawioDsl::Schema::{{camel ./type}}.new(current_page, **opts)
9
+ def add_{{snake ./type}}(**opts, &block)
10
+ {{snake ./type}} = DrawioDsl::Schema::{{camel ./type}}.new(current_page, **opts, &block)
11
11
  add_shape({{snake ./type}})
12
12
  end
13
13
  {{/each}}
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DrawioDsl
4
+ # :nocov:
5
+ class DrawIoExtensions
6
+
7
+ attr_reader :sections
8
+ attr_reader :current_section
9
+
10
+ def initialize
11
+ @sections = []
12
+ end
13
+
14
+ def section(name)
15
+ @current_section = {
16
+ name: name,
17
+ shapes: []
18
+ }
19
+ @sections << current_section
20
+
21
+ yield if block_given?
22
+ end
23
+
24
+ def shape(name, style, original_name)
25
+ shape = {
26
+ name: name,
27
+ style: style,
28
+ original_name: original_name
29
+ }
30
+ current_section[:shapes] << shape
31
+ shape
32
+ end
33
+
34
+ def to_h
35
+ {
36
+ sections: @sections.map(&:to_h)
37
+ }
38
+ end
39
+
40
+ # This methods was generated using Extensions.js
41
+ # This generation can be improved over time and the code to do the generation
42
+ # can be found in the .builders/generators/10-transform-drawio-js.rb.
43
+ # original source: ~/dev/tools/drawio-desktop/drawio/src/main/webapp/js/diagramly/Extensions.js
44
+ def build_extensions
45
+ # Constants
46
+ {{{constants}}}
47
+ {{#each sections}}
48
+ section :{{snake ./name}} do
49
+ {{#each ./shapes}}
50
+ shape :{{padr (snake ./name) 60}}, "{{{./style}}}", "{{./name}}"
51
+ {{/each}}
52
+ end
53
+ {{/each}}
54
+ end
55
+ end
56
+ # :nocov:
57
+ end
@@ -14,8 +14,8 @@ module DrawioDsl
14
14
  end
15
15
  {{#each shapes}}
16
16
 
17
- def {{snake ./type}}(**opts)
18
- builder.add_{{snake ./type}}(**opts)
17
+ def {{snake ./type}}(**opts, &block)
18
+ builder.add_{{snake ./type}}(**opts, &block)
19
19
  end
20
20
  {{/each}}
21
21
  end
@@ -14,4 +14,6 @@ require_relative 'layouts/grid_layout'
14
14
  require_relative 'shapes/shape'
15
15
  {{#each shapes}}
16
16
  require_relative 'shapes/{{snake ./type}}'
17
- {{/each}}
17
+ {{/each}}
18
+
19
+ require_relative 'virtual/anchor'
@@ -1,4 +1,4 @@
1
- KManager.model :shapes, namespace: %i[domain] do
1
+ m = KManager.model :shapes, namespace: %i[domain] do
2
2
  # microapp = import(:handlebars_helpers, :microapp)
3
3
 
4
4
  table :shapes do
@@ -24,16 +24,18 @@ KManager.model :shapes, namespace: %i[domain] do
24
24
  row :callout4 , false, 0, 0, 160, 120, 'shape=mxgraph.basic.roundRectCallout;dx=30;dy=15;size=5;boundedLbl=1;'
25
25
  row :circle , false, 0, 0, 160, 160, 'ellipse'
26
26
  row :cloud , false, 0, 0, 160, 160, 'shape=cloud'
27
+ row :container , false, 0, 0, 160, 160, 'swimlane'
28
+ row :container2 , false, 0, 0, 160, 160, 'swimlane;horizontal=0'
29
+ row :container3 , false, 0, 0, 160, 160, 'swimlane;startSize=50'
30
+ row :container4 , false, 0, 0, 160, 160, 'swimlane;resizable=0'
27
31
  row :cross , false, 0, 0, 50, 50, 'verticalLabelPosition=bottom;verticalAlign=top;html=1;shape=mxgraph.basic.x'
28
32
  row :envelop , false, 0, 0, 160, 100, 'shape=message'
29
33
  row :diamond , false, 0, 0, 100, 100, 'rhombus'
30
34
  row :document , false, 0, 0, 160, 160, 'shape=mxgraph.basic.document'
31
35
  row :ellipse , false, 0, 0, 200, 120, 'ellipse'
32
36
  row :hexagon , false, 0, 0, 200, 120, 'shape=hexagon'
33
- row :container , false, 0, 0, 160, 160, 'swimlane'
34
- row :container2 , false, 0, 0, 160, 160, 'swimlane;horizontal=0'
35
- row :container3 , false, 0, 0, 160, 160, 'swimlane;startSize=50'
36
- row :container4 , false, 0, 0, 160, 160, 'swimlane;resizable=0'
37
+ row :interface , false, 0, 0, 200, 120, 'align=left;overflow=fill;fontSize=12;fontFamily=Helvetica'
38
+ row :klass , false, 0, 0, 200, 120, 'align=left;overflow=fill;fontSize=12;fontFamily=Helvetica'
37
39
  row :note , false, 0, 0, 160, 160, 'shape=note'
38
40
  row :process , false, 0, 0, 200, 120, 'shape=process'
39
41
  row :rectangle , false, 0, 0, 200, 120, ''
@@ -60,3 +62,5 @@ KManager.model :shapes, namespace: %i[domain] do
60
62
  .add_file('shapes.json', content: shapes, on_exist: :write)
61
63
  end
62
64
  end
65
+
66
+
@@ -0,0 +1,195 @@
1
+ KManager.action :transform_drawio_js do
2
+
3
+ action do
4
+ director = KDirector::Dsls::BasicDsl
5
+ .init(k_builder,
6
+ on_exist: :write, # %i[skip write compare]
7
+ on_action: :execute # %i[queue execute]
8
+ )
9
+ .blueprint do
10
+ cd(:data)
11
+
12
+ source_file = '/Users/davidcruwys/dev/tools/drawio-desktop/drawio/src/main/webapp/js/diagramly/Extensions.js'
13
+ target_file = k_builder.target_folders.get_filename(:data, 'extensions.js')
14
+
15
+ clean = CleanExtensionsJs.new(source_file, target_file)
16
+
17
+ cd(:lib)
18
+
19
+ clean.parse
20
+
21
+ add_file('drawio_extensions.json', content: clean.build_json)
22
+ add('drawio_extensions.rb', constants: clean.constants, sections: clean.sections)
23
+ end
24
+ end
25
+ end
26
+
27
+ class CleanExtensionsJs
28
+ def initialize(source_file, target_file)
29
+ @source_file = source_file
30
+ @target_file = target_file
31
+ @source = File.read(@source_file)
32
+ @constants = []
33
+ @builder = ExtensionJsBuilder.new
34
+ end
35
+
36
+ def parse
37
+ split_source
38
+ end
39
+
40
+ def build_json
41
+ @builder.build_json
42
+ end
43
+
44
+ def build_ruby
45
+ @builder.build_ruby
46
+ end
47
+
48
+ def constants
49
+ @builder.constants.join("\n")
50
+ end
51
+
52
+ def sections
53
+ @builder.sections.select { |s| s[:shapes].length > 0 }
54
+ end
55
+
56
+ private
57
+
58
+ def split_source
59
+ source_lines = @source.split("\n")
60
+ section = :unknown
61
+
62
+ source_lines.each do |line|
63
+ if line.include?('// Global import transformation')
64
+ section = :constants
65
+ next
66
+ elsif line.include?('var styleMap = {') && !line.include?('var styleMap = {};')
67
+ puts '-----------------------------------'
68
+ section = :style_map
69
+ next
70
+ elsif line.include?('};') ||
71
+ line.include?('//Instead of doing a massive code refactoring, thees ugly global variables are used')
72
+ section = :unknown
73
+ end
74
+
75
+ if section == :constants
76
+ @builder.process_constant(line)
77
+ end
78
+
79
+ if section == :style_map
80
+ @builder.process_style_map(line)
81
+ end
82
+ end
83
+ end
84
+
85
+ def process_style_map(line)
86
+ line
87
+ end
88
+ end
89
+
90
+ class ExtensionJsBuilder
91
+ attr_accessor :constants
92
+ attr_accessor :shapes
93
+ attr_accessor :sections
94
+ attr_accessor :current_section
95
+
96
+ def initialize
97
+ @constants = []
98
+ @shapes = []
99
+ @sections = []
100
+ @current_section = nil
101
+ end
102
+
103
+ def process_constant(line)
104
+ line = line.gsub(' ', '').gsub('var ', '').gsub(/;$/, '')
105
+ @constants << " #{line}"
106
+ end
107
+
108
+ def process_style_map(line)
109
+ line = clean_line(line)
110
+
111
+ return if kill_line(line)
112
+
113
+ if line.start_with?('#')
114
+ set_section(line)
115
+ return
116
+ end
117
+
118
+ return unless current_section
119
+
120
+ parts = process_line(line)
121
+
122
+ if parts.length == 2
123
+ name = parts[0]
124
+ style = parts[1]
125
+ current_section[:shapes] << { name: name, style: style }
126
+ shapes << line
127
+ else
128
+ puts 'length not 2'
129
+ puts line
130
+ end
131
+ end
132
+
133
+ def process_line(line)
134
+ line.split(':').map { |s| s.strip.gsub('"', '') }
135
+ end
136
+
137
+ def clean_line(line)
138
+ line
139
+ .strip
140
+ .gsub(' ', ' ')
141
+ .gsub(' ', ' ')
142
+ .gsub(' :', ':')
143
+ .gsub("don't", 'do not')
144
+ .gsub('//TODO', '')
145
+ .gsub(/(\/\/)([^ ])/) do |_|
146
+ match = Regexp.last_match
147
+ "// #{match[2]}"
148
+ end
149
+ .gsub("'", '"')
150
+ .gsub('not all variants covered', '')
151
+ .gsub('Timeline shape', '')
152
+ .gsub('# not all variants covered', '')
153
+ .gsub('not all versions supported', '')
154
+ .gsub('ss + "', '"#{ss}')
155
+ .gsub('s + "', '"#{s}')
156
+ .gsub('cs,', '#{cs}')
157
+ .gsub(/cs$/, '#{cs}')
158
+ .gsub('" + containerStyle', '#{containerStyle}"')
159
+ .gsub('kupIcon + "', '"#{kupIcon}')
160
+ .gsub('gcpIcon + "', '"#{gcpIcon}')
161
+ .gsub('azur19 + "', '"#{azur19}')
162
+ .gsub('ssAzure + "', '"#{ssAzure}')
163
+ .gsub('" + arcSize + "', '#{arcSize}')
164
+ .gsub('//', '#')
165
+ .gsub(' ', ' ')
166
+ .gsub(', #', '')
167
+ .strip
168
+ .gsub(/,$/, '')
169
+ .strip
170
+ end
171
+
172
+ def kill_line(line)
173
+ line.end_with?('NA') ||
174
+ line.end_with?('not working properly, needs specific code)') ||
175
+ line.start_with?('Timeline shapes are postponed, this code is a work-in-progress') ||
176
+ line.start_with?('# *******') ||
177
+ line.start_with?('# 2019 mapping') ||
178
+ line.include?('# "') ||
179
+ line.include?('# "') ||
180
+ line.empty?
181
+ end
182
+
183
+ def set_section(line)
184
+ section = line.gsub('#', '').strip
185
+ @current_section = {
186
+ name: section,
187
+ shapes: []
188
+ }
189
+ @sections << current_section
190
+ end
191
+
192
+ def build_json
193
+ JSON.pretty_generate(@sections)
194
+ end
195
+ end
@@ -0,0 +1,41 @@
1
+ KManager.action :transform_drawio_js do
2
+
3
+ action do
4
+ director = DrawioDsl::Drawio
5
+ .init(k_builder, on_exist: :write, on_action: :execute)
6
+ .diagram(theme: :style_10)
7
+
8
+ ext = DrawioDsl::DrawIoExtensions.new
9
+ ext.build_extensions
10
+ puts ext.sections.length
11
+
12
+ ext.sections.select { |s| s[:active] }.each do |section|
13
+ director.page(section[:name]) do
14
+ grid_layout(wrap_at: 5)
15
+ puts section[:name]
16
+ puts section[:shapes]
17
+ section[:shapes].select { |s| s[:active] }.each do |shape|
18
+ square(title: shape[:name], style_modifiers: shape[:style])
19
+ log.kv(:title, shape[:name])
20
+ log.kv(:style, shape[:style])
21
+ end
22
+ end
23
+ end
24
+ director
25
+ .cd(:spec)
26
+ .save('.samples/20-extensions.drawio')
27
+ .cd(:docs)
28
+
29
+ markdown = "# Extensions\n\n"
30
+
31
+ director.builder.diagram.pages.each_with_index do |page, index|
32
+ page_no = index+1
33
+ puts "Page #{page_no}, #{page.name}"
34
+ # director.export_svg("extensions/#{page.name}", page: page_no)
35
+ markdown += "## #{page.name}\n\n![](./extensions/#{page.name}.svg)\n\n"
36
+ end
37
+
38
+ director
39
+ .add('extensions.md', content: markdown)
40
+ end
41
+ end
@@ -11,8 +11,9 @@ KManager.action :todo_drawio_dsl do
11
11
 
12
12
  grid_layout(y:90, direction: :horizontal, grid_h: 80, grid_w: 320, wrap_at: 3, grid: 0)
13
13
 
14
- square(w: 300, h: 60, title: 'add :shape and :text-only to random shape generator')
15
- square(w: 300, h: 60, title: 'write SVG directly into other projects')
14
+ square(w: 300, h: 60, title: 'formatter DSL that can render HTML directly into the title property')
15
+ square(w: 300, h: 60, title: 'formatter DSL for class and interface generation')
16
+ square(w: 300, h: 60, title: 'Add page background to theme, use it whenever the theme is set at a diagram/page level')
16
17
  end
17
18
  .page('To Do', theme: :style_02, margin_left: 0, margin_top: 0) do
18
19
 
@@ -21,10 +22,10 @@ KManager.action :todo_drawio_dsl do
21
22
 
22
23
  grid_layout(y:90, direction: :horizontal, grid_h: 80, grid_w: 320, wrap_at: 3, grid: 0)
23
24
 
24
- square(w: 300, h: 60, title: 'First level child nodes need to hang of node 1')
25
- square(w: 300, h: 60, title: 'Add page background to theme, use it whenever the theme is set at a diagram/page level')
25
+ square(w: 300, h: 60, title: 'write SVG directly into other projects')
26
+ square(w: 300, h: 60, title: 'add :shape and :text-only to random shape generator')
26
27
  square(w: 300, h: 60, title: 'Nodes need to support child nodes')
27
- square(w: 300, h: 60, title: 'Grid layout does no position itself in relation to the last element')
28
+ square(w: 300, h: 60, title: 'Grid layout does not position itself in relation to the last element')
28
29
  square(w: 300, h: 60, title: 'Dynamic sized shapes that expand to the size of their text')
29
30
  square(w: 300, h: 60, title: 'Control of text padding left, right, top and bottom')
30
31
  square(w: 300, h: 60, title: 'Improve the theme control over text-only shapes')
@@ -42,6 +43,11 @@ KManager.action :todo_drawio_dsl do
42
43
 
43
44
  grid_layout(y:90, direction: :horizontal, grid_h: 80, grid_w: 320, wrap_at: 3, grid: 0)
44
45
 
46
+ square(w: 300, h: 60, title: 'generate extension based graphics based on drawio extensions.js')
47
+ square(w: 300, h: 60, title: 'active? flag on page defaulting to true. set to false to exclude page from diagram.')
48
+ square(w: 300, h: 60, title: 'first level child nodes need to hang of node 1')
49
+ square(w: 300, h: 60, title: 'node has child nodes and add_node will set a nodes parent')
50
+ square(w: 300, h: 60, title: 'nodes can belong to a parent node, the top level node responds with truthy to root?')
45
51
  square(w: 300, h: 60, title: 'add sample diagram for the github readme file')
46
52
  square(w: 300, h: 60, title: 'write samples into docs folder and display in readme')
47
53
  square(w: 300, h: 60, title: 'add export as .PNG, needs to take a page number as the PNG will not support multiple pages')
@@ -0,0 +1,39 @@
1
+ KManager.action :todo_drawio_dsl do
2
+ action do
3
+
4
+ DrawioDsl::Drawio
5
+ .init(k_builder, on_exist: :write, on_action: :execute)
6
+ .diagram(rounded: 1, glass: 1)
7
+ .page('In progress', theme: :style_03, margin_left: 0, margin_top: 0) do
8
+
9
+ # h5(x: 300, y: 0, w: 400, h: 80, title: 'DrawIO DSL')
10
+ # p(x: 350, y: 40, w: 400, h: 80, title: 'Project plan - In progress')
11
+
12
+ grid_layout(y:90, direction: :horizontal, grid_h: 80, grid_w: 320, wrap_at: 3, grid: 0)
13
+
14
+ square(w: 300, h: 60, title: '')
15
+ end
16
+ .page('To Do', theme: :style_02, margin_left: 0, margin_top: 0) do
17
+
18
+ # h5(x: 300, y: 0, w: 400, h: 80, title: 'DrawIO DSL')
19
+ # p(x: 350, y: 40, w: 400, h: 80, title: 'Project plan')
20
+
21
+ grid_layout(y:90, direction: :horizontal, grid_h: 80, grid_w: 320, wrap_at: 3, grid: 0)
22
+
23
+ end
24
+ .page('Done', theme: :style_06, margin_left: 0, margin_top: 0) do
25
+
26
+ # h5(x: 300, y: 0, w: 400, h: 80, title: 'DrawIO DSL')
27
+ # p(x: 350, y: 40, w: 400, h: 80, title: 'Done')
28
+
29
+ grid_layout(y:90, direction: :horizontal, grid_h: 80, grid_w: 320, wrap_at: 3, grid: 0)
30
+
31
+ end
32
+ .cd(:spec)
33
+ .save('project-plans/k_doc.drawio')
34
+ # .cd(:k_doc_docs)
35
+ # .export_svg('project_in_progress', page: 1)
36
+ # .export_svg('project_todo' , page: 2)
37
+ # .export_svg('project_done' , page: 3)
38
+ end
39
+ end
@@ -1,13 +1,5 @@
1
1
  KManager.action :bootstrap do
2
2
  action do
3
-
4
- # KConfig.configuration.drawio.square.w = KConfig.configuration.drawio.square.w / 4
5
- # KConfig.configuration.drawio.square.h = KConfig.configuration.drawio.square.h / 4
6
- # KConfig.configuration.drawio.circle.w = KConfig.configuration.drawio.circle.w / 4
7
- # KConfig.configuration.drawio.circle.h = KConfig.configuration.drawio.circle.h / 4
8
- # KConfig.configuration.drawio.rectangle.w = KConfig.configuration.drawio.rectangle.w / 4
9
- # KConfig.configuration.drawio.rectangle.h = KConfig.configuration.drawio.rectangle.h / 4
10
-
11
3
  DrawioDsl::Drawio
12
4
  .init(k_builder, on_exist: :write, on_action: :execute)
13
5
  .diagram(theme: :style_01)
@@ -1,8 +1,7 @@
1
1
  KManager.action :bootstrap do
2
2
  action do
3
3
 
4
- # :rounded, :shadow, :sketch, :glass
5
- director = DrawioDsl::Drawio
4
+ DrawioDsl::Drawio
6
5
  .init(k_builder, on_exist: :write, on_action: :execute)
7
6
  .diagram(theme: :style_06)
8
7
  .page('Style-Plain', margin_left: 0, margin_top: 0) do
@@ -0,0 +1,68 @@
1
+ KManager.action :html_shapes do
2
+ action do
3
+
4
+ # :rounded, :shadow, :sketch, :glass
5
+ DrawioDsl::Drawio
6
+ .init(k_builder, on_exist: :write, on_action: :execute)
7
+ .diagram(theme: :style_11)
8
+ .page('Style-Plain', margin_left: 0, margin_top: 0, rounded: 0, background: '#FFEADB') do
9
+ grid_layout(wrap_at: 8)
10
+
11
+ html = DrawioDsl::Formatters::InterfaceFormatter.new
12
+ .header('IPerson')
13
+ .field(:first_name, type: :string)
14
+ .field(:last_name, type: :string)
15
+ .field(:age, type: :integer)
16
+ .field(:birthday, type: :date)
17
+ .method(:full_name)
18
+ .as_html
19
+
20
+ square(
21
+ title: html,
22
+ style_modifiers: 'align=left;overflow=fill;fontSize=12;fontFamily=Helvetica'
23
+ )
24
+
25
+ square(title: 'xxx', style_modifiers: 'align=left;overflow=fill;fontSize=12;fontFamily=Helvetica') do
26
+ format(:interface)
27
+ .header('IPerson')
28
+ .field(:field1, type: :string)
29
+ .field(:field2, type: :string)
30
+ .method(:full_name, type: :string)
31
+ end
32
+
33
+ html = DrawioDsl::Formatters::KlassFormatter.new
34
+ .header('Person')
35
+ .field(:first_name, type: :string)
36
+ .field(:last_name, type: :string)
37
+ .field(:age, type: :integer)
38
+ .method(:full_name)
39
+ .as_html
40
+
41
+ square(
42
+ title: html,
43
+ style_modifiers: 'align=left;overflow=fill;fontSize=12;fontFamily=Helvetica'
44
+ )
45
+
46
+ # square do
47
+ # formatter(:class)
48
+ # .name('Person')
49
+ # .field(:field1, type: :string)
50
+ # .field(:field2, type: :string)
51
+ # .method(:full_name, type: :string)
52
+ # end
53
+
54
+ # dg_interface('IContract') do
55
+ # field('first_name', type: 'String')
56
+ # field('last_name', type: 'String')
57
+ # field('age', type: 'int')
58
+ # method('full_name', type: 'String', params: 'String first_name, String last_name')
59
+ # end
60
+
61
+ end
62
+ .cd(:spec)
63
+ .save('.samples/30-html-shapes.drawio')
64
+ # .cd(:docs)
65
+ # .export_svg('samples/themes-square', page: 1)
66
+
67
+ end
68
+ end
data/.rubocop.yml CHANGED
@@ -10,7 +10,7 @@ AllCops:
10
10
  Exclude:
11
11
  - ".builders/**/*"
12
12
  - "spec/samples/**/*"
13
-
13
+ - "lib/drawio_dsl/drawio_extensions.rb"
14
14
 
15
15
  Metrics/BlockLength:
16
16
  Exclude:
@@ -52,6 +52,9 @@ Style/BlockComments:
52
52
  Include:
53
53
  - "**/spec/*"
54
54
 
55
+ Style/RegexpLiteral:
56
+ Enabled: false
57
+
55
58
  # My Preferences - Start
56
59
  Metrics/ClassLength:
57
60
  Enabled: false