drawio_dsl 0.7.0 → 0.8.2

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 (44) hide show
  1. checksums.yaml +4 -4
  2. data/.builders/.data/shapes.json +415 -353
  3. data/.builders/.templates/basic/configuration_shapes.rb +3 -3
  4. data/.builders/.templates/basic/dom_builder_shapes.rb +2 -1
  5. data/.builders/.templates/basic/drawio_shapes.rb +2 -2
  6. data/.builders/blueprint/shapes.rb +64 -42
  7. data/.builders/generators/02-generate-app.rb +3 -1
  8. data/.builders/generators/project-plan.rb +74 -0
  9. data/.builders/generators/sample_diagrams/05-samples.rb +19 -6
  10. data/.builders/generators/sample_diagrams/30-html-shapes.rb +27 -47
  11. data/.builders/generators/sample_diagrams/35-ids-and-arrows.rb +20 -0
  12. data/CHANGELOG.md +22 -0
  13. data/docs/project-plan/project.drawio +134 -0
  14. data/docs/project-plan/project_done.svg +3 -0
  15. data/docs/project-plan/project_in_progress.svg +3 -0
  16. data/docs/project-plan/project_todo.svg +3 -0
  17. data/docs/project-plan.md +3 -3
  18. data/docs/samples/html-shapes.svg +3 -0
  19. data/docs/samples/samples.md +4 -0
  20. data/docs/samples/styles-glass.svg +1 -1
  21. data/docs/samples/styles-plain.svg +1 -1
  22. data/docs/samples/styles-rounded.svg +1 -1
  23. data/docs/samples/styles-shadow.svg +1 -1
  24. data/docs/samples/styles-sketch.svg +1 -1
  25. data/docs/samples/themes-random.svg +1 -1
  26. data/lib/drawio_dsl/configuration_shapes.rb +45 -41
  27. data/lib/drawio_dsl/dom_builder_shapes.rb +90 -39
  28. data/lib/drawio_dsl/drawio_shapes.rb +95 -83
  29. data/lib/drawio_dsl/formatters/factory.rb +3 -2
  30. data/lib/drawio_dsl/formatters/interface_formatter.rb +5 -3
  31. data/lib/drawio_dsl/formatters/klass_formatter.rb +4 -2
  32. data/lib/drawio_dsl/schema/_.rb +2 -0
  33. data/lib/drawio_dsl/schema/shapes/line.rb +9 -0
  34. data/lib/drawio_dsl/schema/shapes/shape.rb +16 -11
  35. data/lib/drawio_dsl/schema/shapes/todo.rb +9 -0
  36. data/lib/drawio_dsl/version.rb +1 -1
  37. data/package-lock.json +2 -2
  38. data/package.json +1 -1
  39. metadata +11 -7
  40. data/.builders/generators/project_plans/drawio_dsl.rb +0 -65
  41. data/.builders/generators/project_plans/k_doc.rb +0 -39
  42. data/docs/project_done.svg +0 -3
  43. data/docs/project_in_progress.svg +0 -3
  44. data/docs/project_todo.svg +0 -3
@@ -5,7 +5,7 @@
5
5
  module DrawioDsl
6
6
  # Used to attach configuration to KConfig module
7
7
  module ConfigurationShapes
8
- ShapeDefaults = Struct.new(:type, :text_only, :x, :y, :w, :h, :style_modifiers, keyword_init: true)
8
+ ShapeDefaults = Struct.new(:type, :category, :x, :y, :w, :h, :style_modifiers, keyword_init: true)
9
9
  Shapes = Struct.new(
10
10
  :shape,
11
11
  {{#each shapes}}
@@ -16,9 +16,9 @@ module DrawioDsl
16
16
 
17
17
  def add_shapes
18
18
  @shapes = Shapes.new(
19
- shape: ShapeDefaults.new(type: :shape, text_only: false, x: 0, y: 0, w: 20, h: 20, style_modifiers: ''),
19
+ shape: ShapeDefaults.new(type: :shape, category: :element, x: 0, y: 0, w: 20, h: 20, style_modifiers: ''),
20
20
  {{#each shapes}}
21
- {{snake ./type}}: ShapeDefaults.new(type: :{{snake ./type}}, x: {{./x}}, text_only: {{./text_only}}, y: {{./y}}, w: {{./w}}, h: {{./h}}, style_modifiers: '{{{./style_modifiers}}}'){{#if @last}}{{^}},{{/if}}
21
+ {{snake ./type}}: ShapeDefaults.new(type: :{{snake ./type}}, x: {{./x}}, category: :{{./category}}, y: {{./y}}, w: {{./w}}, h: {{./h}}, style_modifiers: '{{{./style_modifiers}}}'){{#if @last}}{{^}},{{/if}}
22
22
  {{/each}}
23
23
  )
24
24
  end
@@ -6,7 +6,8 @@ module DrawioDsl
6
6
  module DomBuilderShapes
7
7
  {{#each shapes}}
8
8
 
9
- def add_{{snake ./type}}(**opts, &block)
9
+ def add_{{snake ./type}}(id = nil, **opts, &block)
10
+ opts = { id: id }.merge(opts) if id
10
11
  {{snake ./type}} = DrawioDsl::Schema::{{camel ./type}}.new(current_page, **opts, &block)
11
12
  add_shape({{snake ./type}})
12
13
  end
@@ -14,8 +14,8 @@ module DrawioDsl
14
14
  end
15
15
  {{#each shapes}}
16
16
 
17
- def {{snake ./type}}(**opts, &block)
18
- builder.add_{{snake ./type}}(**opts, &block)
17
+ def {{snake ./type}}(id = nil, **opts, &block)
18
+ builder.add_{{snake ./type}}(id, **opts, &block)
19
19
  end
20
20
  {{/each}}
21
21
  end
@@ -1,65 +1,87 @@
1
1
  m = KManager.model :shapes, namespace: %i[domain] do
2
2
  # microapp = import(:handlebars_helpers, :microapp)
3
3
 
4
+ table :strokes do
5
+ fields [:name, :style]
6
+
7
+ row :dashed , 'dashed=1;fixDash=1'
8
+ row :dotted , 'dashed=1;fixDash=1;dashPattern=1 4'
9
+ row :dashdot , 'dashed=1;fixDash=1;dashPattern=10 5 1 5'
10
+ row :dashdotdot , 'dashed=1;fixDash=1;dashPattern=10 5 1 5 1 5'
11
+ row :dotdotdot , 'dashed=1;fixDash=1;dashPattern=1 2'
12
+ row :longdash , 'dashed=1;fixDash=1;dashPattern=16 6'
13
+ row :dashlongdash , 'dashed=1;fixDash=1;dashPattern=10 6 16 6'
14
+ row :dashed24 , 'dashed=1;fixDash=1;dashPattern=3 8'
15
+ row :dashed32 , 'dashed=1;fixDash=1;dashPattern=6 5'
16
+ row :dashed44 , 'dashed=1;fixDash=1;dashPattern=8 8'
17
+ end
18
+
4
19
  table :shapes do
5
- fields [:type, :text_only, :x, :y, :w, :h, :style_modifiers]
20
+ fields [:type, :category, :x, :y, :w, :h, :style_modifiers]
6
21
 
7
22
  # shape is a custom object
8
23
  # row :shape , 0, 0, 20, 20, ''
9
24
 
10
25
  # configuration for general purpose shapes
11
- row :h1 , true, 0, 0, 100, 50, 'text;fontSize=89;fontColor=#ffffff;fontStyle=1;fillColor=none'
12
- row :h2 , true, 0, 0, 100, 50, 'text;fontSize=67;fontColor=#ffffff;fontStyle=1;fillColor=none'
13
- row :h3 , true, 0, 0, 100, 50, 'text;fontSize=50;fontColor=#ffffff;fontStyle=1;fillColor=none'
14
- row :h4 , true, 0, 0, 100, 50, 'text;fontSize=37;fontColor=#ffffff;fontStyle=1;fillColor=none'
15
- row :h5 , true, 0, 0, 100, 50, 'text;fontSize=28;fontColor=#ffffff;fontStyle=1;fillColor=none'
16
- row :h6 , true, 0, 0, 100, 50, 'text;fontSize=21;fontColor=#ffffff;fontStyle=1;fillColor=none'
17
- row :p , true, 0, 0, 100, 50, 'text;fontSize=16;fontColor=#ffffff;fontStyle=1;fillColor=none'
26
+ row :h1 , :text , 0, 0, 100, 50, 'text;fontSize=89;fontColor=#ffffff;fontStyle=1;fillColor=none'
27
+ row :h2 , :text , 0, 0, 100, 50, 'text;fontSize=67;fontColor=#ffffff;fontStyle=1;fillColor=none'
28
+ row :h3 , :text , 0, 0, 100, 50, 'text;fontSize=50;fontColor=#ffffff;fontStyle=1;fillColor=none'
29
+ row :h4 , :text , 0, 0, 100, 50, 'text;fontSize=37;fontColor=#ffffff;fontStyle=1;fillColor=none'
30
+ row :h5 , :text , 0, 0, 100, 50, 'text;fontSize=28;fontColor=#ffffff;fontStyle=1;fillColor=none'
31
+ row :h6 , :text , 0, 0, 100, 50, 'text;fontSize=21;fontColor=#ffffff;fontStyle=1;fillColor=none'
32
+ row :p , :text , 0, 0, 100, 50, 'text;fontSize=16;fontColor=#ffffff;fontStyle=1;fillColor=none'
33
+
34
+ row :actor , :element, 0, 0, 40, 50, 'shape=actor'
35
+ row :actor2 , :element, 0, 0, 30, 50, 'shape=umlActor;verticalLabelPosition=bottom;outlineConnect=1'
36
+ row :callout , :element, 0, 0, 160, 120, 'shape=callout'
37
+ row :callout2 , :element, 0, 0, 160, 160, 'shape=mxgraph.basic.oval_callout'
38
+ row :callout3 , :element, 0, 0, 160, 160, 'shape=mxgraph.basic.cloud_callout'
39
+ row :callout4 , :element, 0, 0, 160, 120, 'shape=mxgraph.basic.roundRectCallout;dx=30;dy=15;size=5;boundedLbl=1;'
40
+ row :circle , :element, 0, 0, 160, 160, 'ellipse'
41
+ row :cloud , :element, 0, 0, 160, 160, 'shape=cloud'
42
+ row :container , :element, 0, 0, 160, 160, 'swimlane'
43
+ row :container2 , :element, 0, 0, 160, 160, 'swimlane;horizontal=0'
44
+ row :container3 , :element, 0, 0, 160, 160, 'swimlane;startSize=50'
45
+ row :container4 , :element, 0, 0, 160, 160, 'swimlane;resizable=0'
46
+ row :cross , :element, 0, 0, 50, 50, 'verticalLabelPosition=bottom;verticalAlign=top;html=1;shape=mxgraph.basic.x'
47
+ row :envelop , :element, 0, 0, 160, 100, 'shape=message'
48
+ row :diamond , :element, 0, 0, 100, 100, 'rhombus'
49
+ row :document , :element, 0, 0, 160, 160, 'shape=mxgraph.basic.document'
50
+ row :ellipse , :element, 0, 0, 200, 120, 'ellipse'
51
+ row :hexagon , :element, 0, 0, 200, 120, 'shape=hexagon'
52
+ row :interface , :element, 0, 0, 160, 160, 'align=left;overflow=fill;fontSize=12;fontFamily=Helvetica'
53
+ row :klass , :element, 0, 0, 160, 160, 'align=left;overflow=fill;fontSize=12;fontFamily=Helvetica'
54
+ row :note , :element, 0, 0, 160, 160, 'shape=note'
55
+ row :process , :element, 0, 0, 200, 120, 'shape=process'
56
+ row :rectangle , :element, 0, 0, 200, 120, ''
57
+ row :rectangle2 , :element, 0, 0, 200, 120, 'shape=mxgraph.basic.cloud_rect'
58
+ row :square , :element, 0, 0, 160, 160, ''
59
+ row :step , :element, 0, 0, 120, 80, 'shape=step;perimeter=stepPerimeter;fixedSize=1'
60
+ row :tick , :element, 0, 0, 50, 50, 'verticalLabelPosition=bottom;verticalAlign=top;shape=mxgraph.basic.tick'
61
+ row :todo , :element, 0, 0, 300, 60, ''
62
+ row :face , :element, 0, 0, 100, 100, 'verticalLabelPosition=bottom;verticalAlign=top;shape=mxgraph.basic.smiley'
63
+ row :triangle , :element, 0, 0, 100, 100, 'triangle'
18
64
 
19
- row :actor , false, 0, 0, 40, 50, 'shape=actor'
20
- row :actor2 , false, 0, 0, 30, 50, 'shape=umlActor;verticalLabelPosition=bottom;outlineConnect=1'
21
- row :callout , false, 0, 0, 160, 120, 'shape=callout'
22
- row :callout2 , false, 0, 0, 160, 160, 'shape=mxgraph.basic.oval_callout'
23
- row :callout3 , false, 0, 0, 160, 160, 'shape=mxgraph.basic.cloud_callout'
24
- row :callout4 , false, 0, 0, 160, 120, 'shape=mxgraph.basic.roundRectCallout;dx=30;dy=15;size=5;boundedLbl=1;'
25
- row :circle , false, 0, 0, 160, 160, 'ellipse'
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'
31
- row :cross , false, 0, 0, 50, 50, 'verticalLabelPosition=bottom;verticalAlign=top;html=1;shape=mxgraph.basic.x'
32
- row :envelop , false, 0, 0, 160, 100, 'shape=message'
33
- row :diamond , false, 0, 0, 100, 100, 'rhombus'
34
- row :document , false, 0, 0, 160, 160, 'shape=mxgraph.basic.document'
35
- row :ellipse , false, 0, 0, 200, 120, 'ellipse'
36
- row :hexagon , false, 0, 0, 200, 120, 'shape=hexagon'
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'
39
- row :note , false, 0, 0, 160, 160, 'shape=note'
40
- row :process , false, 0, 0, 200, 120, 'shape=process'
41
- row :rectangle , false, 0, 0, 200, 120, ''
42
- row :rectangle2 , false, 0, 0, 200, 120, 'shape=mxgraph.basic.cloud_rect'
43
- row :square , false, 0, 0, 160, 160, ''
44
- row :step , false, 0, 0, 120, 80, 'shape=step;perimeter=stepPerimeter;fixedSize=1'
45
- row :tick , false, 0, 0, 50, 50, 'verticalLabelPosition=bottom;verticalAlign=top;shape=mxgraph.basic.tick'
46
- row :face , false, 0, 0, 100, 100, 'verticalLabelPosition=bottom;verticalAlign=top;shape=mxgraph.basic.smiley'
47
- row :triangle , false, 0, 0, 100, 100, 'triangle'
65
+ row :line , :line , 0, 0, 50, 50, 'edgeStyle=entityRelationEdgeStyle;strokeWidth=1;elbow=vertical;startArrow=none;startFill=0;endArrow=block;endFill=0;targetPerimeterSpacing=0;shape=flexArrow;endSize=6;fillStyle=zigzag;'
66
+ # edge="1" parent="node_root_2T8" source="b" target="c"
48
67
 
49
68
  # configuration for embedded element shape
50
69
  # note that the width / height probably should be driven of parent shape
51
- row :embed_row , false, 0, 0, 200, 40, 'shape=partialRectangle;collapsible=0;dropTarget=0;pointerEvents=0;top=0;left=0;bottom=1;right=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest'
52
- row :embed_col50 , false, 0, 0, 50, 40, 'shape=partialRectangle;connectable=0;top=0;left=0;bottom=0;right=0;fontStyle=1;overflow=hidden'
53
- row :embed_col200 , false, 0, 0, 150, 40, 'shape=partialRectangle;connectable=0;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;overflow=hidden'
70
+ row :embed_row , :element, 0, 0, 200, 40, 'shape=partialRectangle;collapsible=0;dropTarget=0;pointerEvents=0;top=0;left=0;bottom=1;right=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest'
71
+ row :embed_col50 , :element, 0, 0, 50, 40, 'shape=partialRectangle;connectable=0;top=0;left=0;bottom=0;right=0;fontStyle=1;overflow=hidden'
72
+ row :embed_col200 , :element, 0, 0, 150, 40, 'shape=partialRectangle;connectable=0;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;overflow=hidden'
54
73
  end
55
74
 
56
75
  action do
57
76
  data = self.raw_data
58
- shapes = JSON.pretty_generate(data['shapes'])
77
+ content = {
78
+ strokes: data['strokes'],
79
+ shapes: data['shapes']
80
+ }
59
81
 
60
82
  k_builder
61
83
  .cd(:data)
62
- .add_file('shapes.json', content: shapes, on_exist: :write)
84
+ .add_file('shapes.json', content: JSON.pretty_generate(content), on_exist: :write)
63
85
  end
64
86
  end
65
87
 
@@ -2,7 +2,9 @@ KManager.action :requires do
2
2
 
3
3
  action do
4
4
  shapes_file = k_builder.target_folders.get_filename(:data, 'shapes.json')
5
- shapes = JSON.parse(File.read(shapes_file))
5
+ shapes_configuration = JSON.parse(File.read(shapes_file))
6
+ shapes = shapes_configuration['shapes']
7
+ # strokes = shapes_configuration['strokes']
6
8
 
7
9
  KDirector::Dsls::BasicDsl
8
10
  .init(k_builder,
@@ -0,0 +1,74 @@
1
+ KManager.action :project_plan 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
+ todo(title: 'refactor the shape->text_only (boolean) to category (symbol)')
15
+ todo(title: 'build configuration for line strokes (eg. dashed, dotted)')
16
+ todo(title: 'add new shapes related to line connectors')
17
+ todo(title: 'line connectors need to support autolinking using ids')
18
+ end
19
+ .page('To Do', theme: :style_02, margin_left: 0, margin_top: 0) do
20
+
21
+ # h5(x: 300, y: 0, w: 400, h: 80, title: 'DrawIO DSL')
22
+ # p(x: 350, y: 40, w: 400, h: 80, title: 'Project plan')
23
+
24
+ grid_layout(y:90, direction: :horizontal, grid_h: 80, grid_w: 320, wrap_at: 3, grid: 0)
25
+
26
+ todo(title: 'add page background to theme, use it whenever the theme is set at a diagram/page level')
27
+ todo(title: 'move DrawioDsl::Formatters::Factory::FORMATTERS to resource file')
28
+ todo(title: 'move DrawioDsl::Formatters::StyleBuilder::MAPPINGS to resource file')
29
+ todo(title: 'need to setup new project plans')
30
+ todo(title: 'settings style attributes need to de-duplicate, might be best to utilize the new StyleBuilder class')
31
+ todo(title: 'write SVG directly into other projects')
32
+ todo(title: 'add :shape and :text-only to random shape generator')
33
+ todo(title: 'Nodes need to support child nodes')
34
+ todo(title: 'Grid layout does not position itself in relation to the last element')
35
+ todo(title: 'Dynamic sized shapes that expand to the size of their text')
36
+ todo(title: 'Control of text padding left, right, top and bottom')
37
+ todo(title: 'Improve the theme control over text-only shapes')
38
+ todo(title: 'x,y settings do not work for shapes within a grid layout')
39
+ todo(title: 'page layout so that you drop elements on and they are positioned correctly, e.g centered, left, right, etc, maybe a grid layout with a wrap of 1 and a width of the page is sufficient')
40
+ end
41
+ .page('Done', theme: :style_06, margin_left: 0, margin_top: 0) do
42
+
43
+ # h5(x: 300, y: 0, w: 400, h: 80, title: 'DrawIO DSL')
44
+ # p(x: 350, y: 40, w: 400, h: 80, title: 'Done')
45
+
46
+ grid_layout(y:90, direction: :horizontal, grid_h: 80, grid_w: 320, wrap_at: 3, grid: 0)
47
+
48
+ todo(title: 'ensure that ids are working as expected')
49
+ todo(title: 'alter the initial parameter of all shapes so that it can be an ID, without named attribute')
50
+ todo(title: 'move project-plan files')
51
+ todo(title: 'alter configure_shape so it sets the default shape key and use that for selecting the default HTML formatter')
52
+ todo(title: 'add todo shape to simplify project plan drawing')
53
+ todo(title: 'introduce .value property to shape and let it use either formatted HTML or plain text title')
54
+ todo(title: 'formatter DSL that can render HTML directly into the value property')
55
+ todo(title: 'formatter DSL for class and interface generation')
56
+ todo(title: 'generate extension based graphics based on drawio extensions.js')
57
+ todo(title: 'active? flag on page defaulting to true. set to false to exclude page from diagram.')
58
+ todo(title: 'first level child nodes need to hang of node 1')
59
+ todo(title: 'node has child nodes and add_node will set a nodes parent')
60
+ todo(title: 'nodes can belong to a parent node, the top level node responds with truthy to root?')
61
+ todo(title: 'add sample diagram for the github readme file')
62
+ todo(title: 'write samples into docs folder and display in readme')
63
+ todo(title: 'add export as .PNG, needs to take a page number as the PNG will not support multiple pages')
64
+ todo(title: 'add export as .SVG, needs to take a page number as the SVG will not support multiple pages')
65
+ todo(title: 'add save as .drawio')
66
+
67
+ end
68
+ .cd(:docs)
69
+ .save('project-plan/project.drawio')
70
+ .export_svg('project-plan/project_in_progress', page: 1)
71
+ .export_svg('project-plan/project_todo' , page: 2)
72
+ .export_svg('project-plan/project_done' , page: 3)
73
+ end
74
+ end
@@ -9,15 +9,28 @@ KManager.action :bootstrap do
9
9
  .page('Samples') do
10
10
  grid_layout(wrap_at: 5)
11
11
 
12
- KConfig.configuration.drawio.shapes.select { |shape| shape.type != :shape && !shape.text_only }.each do |shape|
13
- # print random number between 0 and 1
14
- send(shape.type, theme: KConfig.configuration.drawio.random_theme, title: shape.type.to_s, shape: shape, rounded: rnd(2), gloss: rnd(2), sketch: rnd(8))
12
+ # KConfig.configuration.drawio.shapes.select { |shape| shape.type != :shape && !shape.text_only }.each do |shape|
13
+ # # print random number between 0 and 1
14
+ # send(shape.type, theme: KConfig.configuration.drawio.random_theme, title: shape.type.to_s, shape: shape, rounded: rnd(2), gloss: rnd(2), sketch: rnd(8))
15
+ # end
16
+
17
+ for jersy_number in 67..112
18
+ team_color = :style_02
19
+ team_color = :style_03 if jersy_number % 3 == 0
20
+ team_color = :style_04 if jersy_number % 12 == 0
21
+
22
+ if jersy_number % 20 == 0
23
+ cloud(title: jersy_number, theme: team_color)
24
+ else
25
+ actor(title: jersy_number, theme: team_color)
26
+ end
15
27
  end
28
+
16
29
 
17
30
  end
18
31
  .cd(:spec)
19
- .save('.samples/05-samples.drawio')
20
- .cd(:docs)
21
- .export_svg('samples/samples', page: 1)
32
+ .osave('.samples/05-samples.drawio')
33
+ # .cd(:docs)
34
+ # .export_svg('samples/samples', page: 1)
22
35
  end
23
36
  end
@@ -8,61 +8,41 @@ KManager.action :html_shapes do
8
8
  .page('Style-Plain', margin_left: 0, margin_top: 0, rounded: 0, background: '#FFEADB') do
9
9
  grid_layout(wrap_at: 8)
10
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)
11
+ # html = DrawioDsl::Formatters::KlassFormatter.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
+ # .method(:sean)
19
+ # .as_html
20
+
21
+ # square(title: html,
22
+ # style_modifiers: 'align=left;overflow=fill;fontSize=12;fontFamily=Helvetica'
23
+ # )
24
+
25
+ interface(theme: :style_07) do
26
+ format
27
27
  .header('IPerson')
28
28
  .field(:field1, type: :string)
29
29
  .field(:field2, type: :string)
30
30
  .method(:full_name, type: :string)
31
31
  end
32
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
-
33
+ klass do
34
+ format(:class)
35
+ .header('Person')
36
+ .field(:field1, type: :string)
37
+ .field(:field2, type: :string)
38
+ .field(:age, type: :integer)
39
+ .field(:birthday, type: :date)
40
+ .method(:full_name, type: :string)
41
+ end
61
42
  end
62
43
  .cd(:spec)
63
- .save('.samples/30-html-shapes.drawio')
44
+ .osave('.samples/30-html-shapes.drawio')
64
45
  # .cd(:docs)
65
- # .export_svg('samples/themes-square', page: 1)
66
-
46
+ # .export_svg('samples/html-shapes', page: 1)
67
47
  end
68
48
  end
@@ -0,0 +1,20 @@
1
+ KManager.action :bootstrap do
2
+ action do
3
+
4
+ DrawioDsl::Drawio
5
+ .init(k_builder, on_exist: :write, on_action: :execute)
6
+ .diagram(theme: :style_06)
7
+ .page('Style-Plain', margin_left: 0, margin_top: 0) do
8
+ grid_layout(wrap_at: 2)
9
+
10
+ square(:a, title: '01')
11
+ circle(:b, title: '02')
12
+ rectangle(:c, title: '03')
13
+ ellipse(:d, title: '04')
14
+ end
15
+ .cd(:spec)
16
+ .osave('.samples/35-ids-and-arrows.drawio')
17
+ # .cd(:docs)
18
+ # .export_svg('samples/styles-plain', page: 1)
19
+ end
20
+ end
data/CHANGELOG.md CHANGED
@@ -1,3 +1,25 @@
1
+ ## [0.8.1](https://github.com/klueless-io/drawio_dsl/compare/v0.8.0...v0.8.1) (2022-03-16)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * alter the initial parameter of all shapes so that it can be an ID, without named attribute ([9c00a63](https://github.com/klueless-io/drawio_dsl/commit/9c00a634f818d25b92042a9cdb81749dbe994cf5))
7
+
8
+ # [0.8.0](https://github.com/klueless-io/drawio_dsl/compare/v0.7.0...v0.8.0) (2022-03-15)
9
+
10
+
11
+ ### Features
12
+
13
+ * alter configure_shape so it sets the default shape key and use that for selecting the default HTML formatter ([f0cde77](https://github.com/klueless-io/drawio_dsl/commit/f0cde7719c7b230147f10e269cbb9f02584b542b))
14
+
15
+ # [0.7.0](https://github.com/klueless-io/drawio_dsl/compare/v0.6.0...v0.7.0) (2022-03-14)
16
+
17
+
18
+ ### Features
19
+
20
+ * add support for HTML formatters to shapes ([14b05e2](https://github.com/klueless-io/drawio_dsl/commit/14b05e2c55ea61ad8f275d678ca4fcff8a43b466))
21
+ * add support for html shapes ([d2d0e72](https://github.com/klueless-io/drawio_dsl/commit/d2d0e72bef8f44c244dd209d191ab29aea0091c1))
22
+
1
23
  # [0.6.0](https://github.com/klueless-io/drawio_dsl/compare/v0.5.7...v0.6.0) (2022-03-13)
2
24
 
3
25
 
@@ -0,0 +1,134 @@
1
+ <mxfile host="GEP">
2
+ <diagram id="OQJ" name="In progress">
3
+ <mxGraphModel dx="0" dy="0" background="#FFFACD" grid="0" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1169" pageHeight="827" math="0" shadow="0">
4
+ <root>
5
+ <mxCell id="page_root_OQJ" parent="OQJ"/>
6
+ <mxCell id="node_root_OQJ" parent="page_root_OQJ"/>
7
+ <mxCell id="OQJ-2" value="refactor the shape-&gt;text_only (boolean) to category (symbol)" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#d5e8d4;strokeColor=#82b366;fontColor=#333333" vertex="1" parent="node_root_OQJ">
8
+ <mxGeometry x="10" y="10" width="300" height="60" as="geometry"/>
9
+ </mxCell>
10
+ <mxCell id="OQJ-3" value="build configuration for line strokes (eg. dashed, dotted)" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#d5e8d4;strokeColor=#82b366;fontColor=#333333" vertex="1" parent="node_root_OQJ">
11
+ <mxGeometry x="330" y="10" width="300" height="60" as="geometry"/>
12
+ </mxCell>
13
+ <mxCell id="OQJ-4" value="add new shapes related to line connectors" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#d5e8d4;strokeColor=#82b366;fontColor=#333333" vertex="1" parent="node_root_OQJ">
14
+ <mxGeometry x="650" y="10" width="300" height="60" as="geometry"/>
15
+ </mxCell>
16
+ <mxCell id="OQJ-5" value="line connectors need to support autolinking using ids" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#d5e8d4;strokeColor=#82b366;fontColor=#333333" vertex="1" parent="node_root_OQJ">
17
+ <mxGeometry x="10" y="90" width="300" height="60" as="geometry"/>
18
+ </mxCell>
19
+ </root>
20
+ </mxGraphModel>
21
+ </diagram>
22
+ <diagram id="QfI" name="To Do">
23
+ <mxGraphModel dx="0" dy="0" background="#FFFACD" grid="0" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1169" pageHeight="827" math="0" shadow="0">
24
+ <root>
25
+ <mxCell id="page_root_QfI" parent="QfI"/>
26
+ <mxCell id="node_root_QfI" parent="page_root_QfI"/>
27
+ <mxCell id="QfI-2" value="add page background to theme, use it whenever the theme is set at a diagram/page level" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontColor=#333333" vertex="1" parent="node_root_QfI">
28
+ <mxGeometry x="10" y="10" width="300" height="60" as="geometry"/>
29
+ </mxCell>
30
+ <mxCell id="QfI-3" value="move DrawioDsl::Formatters::Factory::FORMATTERS to resource file" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontColor=#333333" vertex="1" parent="node_root_QfI">
31
+ <mxGeometry x="330" y="10" width="300" height="60" as="geometry"/>
32
+ </mxCell>
33
+ <mxCell id="QfI-4" value="move DrawioDsl::Formatters::StyleBuilder::MAPPINGS to resource file" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontColor=#333333" vertex="1" parent="node_root_QfI">
34
+ <mxGeometry x="650" y="10" width="300" height="60" as="geometry"/>
35
+ </mxCell>
36
+ <mxCell id="QfI-5" value="need to setup new project plans" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontColor=#333333" vertex="1" parent="node_root_QfI">
37
+ <mxGeometry x="10" y="90" width="300" height="60" as="geometry"/>
38
+ </mxCell>
39
+ <mxCell id="QfI-6" value="settings style attributes need to de-duplicate, might be best to utilize the new StyleBuilder class" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontColor=#333333" vertex="1" parent="node_root_QfI">
40
+ <mxGeometry x="330" y="90" width="300" height="60" as="geometry"/>
41
+ </mxCell>
42
+ <mxCell id="QfI-7" value="write SVG directly into other projects" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontColor=#333333" vertex="1" parent="node_root_QfI">
43
+ <mxGeometry x="650" y="90" width="300" height="60" as="geometry"/>
44
+ </mxCell>
45
+ <mxCell id="QfI-8" value="add :shape and :text-only to random shape generator" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontColor=#333333" vertex="1" parent="node_root_QfI">
46
+ <mxGeometry x="10" y="170" width="300" height="60" as="geometry"/>
47
+ </mxCell>
48
+ <mxCell id="QfI-9" value="Nodes need to support child nodes" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontColor=#333333" vertex="1" parent="node_root_QfI">
49
+ <mxGeometry x="330" y="170" width="300" height="60" as="geometry"/>
50
+ </mxCell>
51
+ <mxCell id="QfI-10" value="Grid layout does not position itself in relation to the last element" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontColor=#333333" vertex="1" parent="node_root_QfI">
52
+ <mxGeometry x="650" y="170" width="300" height="60" as="geometry"/>
53
+ </mxCell>
54
+ <mxCell id="QfI-11" value="Dynamic sized shapes that expand to the size of their text" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontColor=#333333" vertex="1" parent="node_root_QfI">
55
+ <mxGeometry x="10" y="250" width="300" height="60" as="geometry"/>
56
+ </mxCell>
57
+ <mxCell id="QfI-12" value="Control of text padding left, right, top and bottom" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontColor=#333333" vertex="1" parent="node_root_QfI">
58
+ <mxGeometry x="330" y="250" width="300" height="60" as="geometry"/>
59
+ </mxCell>
60
+ <mxCell id="QfI-13" value="Improve the theme control over text-only shapes" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontColor=#333333" vertex="1" parent="node_root_QfI">
61
+ <mxGeometry x="650" y="250" width="300" height="60" as="geometry"/>
62
+ </mxCell>
63
+ <mxCell id="QfI-14" value="x,y settings do not work for shapes within a grid layout" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontColor=#333333" vertex="1" parent="node_root_QfI">
64
+ <mxGeometry x="10" y="330" width="300" height="60" as="geometry"/>
65
+ </mxCell>
66
+ <mxCell id="QfI-15" value="page layout so that you drop elements on and they are positioned correctly, e.g centered, left, right, etc, maybe a grid layout with a wrap of 1 and a width of the page is sufficient" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontColor=#333333" vertex="1" parent="node_root_QfI">
67
+ <mxGeometry x="330" y="330" width="300" height="60" as="geometry"/>
68
+ </mxCell>
69
+ </root>
70
+ </mxGraphModel>
71
+ </diagram>
72
+ <diagram id="TcB" name="Done">
73
+ <mxGraphModel dx="0" dy="0" background="#FFFACD" grid="0" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1169" pageHeight="827" math="0" shadow="0">
74
+ <root>
75
+ <mxCell id="page_root_TcB" parent="TcB"/>
76
+ <mxCell id="node_root_TcB" parent="page_root_TcB"/>
77
+ <mxCell id="TcB-2" value="ensure that ids are working as expected" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#f8cecc;strokeColor=#b85450;fontColor=#333333" vertex="1" parent="node_root_TcB">
78
+ <mxGeometry x="10" y="10" width="300" height="60" as="geometry"/>
79
+ </mxCell>
80
+ <mxCell id="TcB-3" value="alter the initial parameter of all shapes so that it can be an ID, without named attribute" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#f8cecc;strokeColor=#b85450;fontColor=#333333" vertex="1" parent="node_root_TcB">
81
+ <mxGeometry x="330" y="10" width="300" height="60" as="geometry"/>
82
+ </mxCell>
83
+ <mxCell id="TcB-4" value="move project-plan files" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#f8cecc;strokeColor=#b85450;fontColor=#333333" vertex="1" parent="node_root_TcB">
84
+ <mxGeometry x="650" y="10" width="300" height="60" as="geometry"/>
85
+ </mxCell>
86
+ <mxCell id="TcB-5" value="alter configure_shape so it sets the default shape key and use that for selecting the default HTML formatter" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#f8cecc;strokeColor=#b85450;fontColor=#333333" vertex="1" parent="node_root_TcB">
87
+ <mxGeometry x="10" y="90" width="300" height="60" as="geometry"/>
88
+ </mxCell>
89
+ <mxCell id="TcB-6" value="add todo shape to simplify project plan drawing" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#f8cecc;strokeColor=#b85450;fontColor=#333333" vertex="1" parent="node_root_TcB">
90
+ <mxGeometry x="330" y="90" width="300" height="60" as="geometry"/>
91
+ </mxCell>
92
+ <mxCell id="TcB-7" value="introduce .value property to shape and let it use either formatted HTML or plain text title" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#f8cecc;strokeColor=#b85450;fontColor=#333333" vertex="1" parent="node_root_TcB">
93
+ <mxGeometry x="650" y="90" width="300" height="60" as="geometry"/>
94
+ </mxCell>
95
+ <mxCell id="TcB-8" value="formatter DSL that can render HTML directly into the value property" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#f8cecc;strokeColor=#b85450;fontColor=#333333" vertex="1" parent="node_root_TcB">
96
+ <mxGeometry x="10" y="170" width="300" height="60" as="geometry"/>
97
+ </mxCell>
98
+ <mxCell id="TcB-9" value="formatter DSL for class and interface generation" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#f8cecc;strokeColor=#b85450;fontColor=#333333" vertex="1" parent="node_root_TcB">
99
+ <mxGeometry x="330" y="170" width="300" height="60" as="geometry"/>
100
+ </mxCell>
101
+ <mxCell id="TcB-10" value="generate extension based graphics based on drawio extensions.js" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#f8cecc;strokeColor=#b85450;fontColor=#333333" vertex="1" parent="node_root_TcB">
102
+ <mxGeometry x="650" y="170" width="300" height="60" as="geometry"/>
103
+ </mxCell>
104
+ <mxCell id="TcB-11" value="active? flag on page defaulting to true. set to false to exclude page from diagram." style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#f8cecc;strokeColor=#b85450;fontColor=#333333" vertex="1" parent="node_root_TcB">
105
+ <mxGeometry x="10" y="250" width="300" height="60" as="geometry"/>
106
+ </mxCell>
107
+ <mxCell id="TcB-12" value="first level child nodes need to hang of node 1" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#f8cecc;strokeColor=#b85450;fontColor=#333333" vertex="1" parent="node_root_TcB">
108
+ <mxGeometry x="330" y="250" width="300" height="60" as="geometry"/>
109
+ </mxCell>
110
+ <mxCell id="TcB-13" value="node has child nodes and add_node will set a nodes parent" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#f8cecc;strokeColor=#b85450;fontColor=#333333" vertex="1" parent="node_root_TcB">
111
+ <mxGeometry x="650" y="250" width="300" height="60" as="geometry"/>
112
+ </mxCell>
113
+ <mxCell id="TcB-14" value="nodes can belong to a parent node, the top level node responds with truthy to root?" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#f8cecc;strokeColor=#b85450;fontColor=#333333" vertex="1" parent="node_root_TcB">
114
+ <mxGeometry x="10" y="330" width="300" height="60" as="geometry"/>
115
+ </mxCell>
116
+ <mxCell id="TcB-15" value="add sample diagram for the github readme file" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#f8cecc;strokeColor=#b85450;fontColor=#333333" vertex="1" parent="node_root_TcB">
117
+ <mxGeometry x="330" y="330" width="300" height="60" as="geometry"/>
118
+ </mxCell>
119
+ <mxCell id="TcB-16" value="write samples into docs folder and display in readme" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#f8cecc;strokeColor=#b85450;fontColor=#333333" vertex="1" parent="node_root_TcB">
120
+ <mxGeometry x="650" y="330" width="300" height="60" as="geometry"/>
121
+ </mxCell>
122
+ <mxCell id="TcB-17" value="add export as .PNG, needs to take a page number as the PNG will not support multiple pages" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#f8cecc;strokeColor=#b85450;fontColor=#333333" vertex="1" parent="node_root_TcB">
123
+ <mxGeometry x="10" y="410" width="300" height="60" as="geometry"/>
124
+ </mxCell>
125
+ <mxCell id="TcB-18" value="add export as .SVG, needs to take a page number as the SVG will not support multiple pages" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#f8cecc;strokeColor=#b85450;fontColor=#333333" vertex="1" parent="node_root_TcB">
126
+ <mxGeometry x="330" y="410" width="300" height="60" as="geometry"/>
127
+ </mxCell>
128
+ <mxCell id="TcB-19" value="add save as .drawio" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#f8cecc;strokeColor=#b85450;fontColor=#333333" vertex="1" parent="node_root_TcB">
129
+ <mxGeometry x="650" y="410" width="300" height="60" as="geometry"/>
130
+ </mxCell>
131
+ </root>
132
+ </mxGraphModel>
133
+ </diagram>
134
+ </mxfile>