drawio_dsl 0.8.5 → 0.8.8
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.
- checksums.yaml +4 -4
- data/.builders/.data/shapes.json +9 -0
- data/.builders/blueprint/shapes.rb +1 -0
- data/.builders/generators/domain_diagram.rb +1 -0
- data/.builders/generators/project-plan.rb +8 -4
- data/.builders/generators/sample_diagrams/20-styles.rb +2 -2
- data/.builders/generators/sample_diagrams/30-html-shapes.rb +36 -14
- data/.builders/generators/sample_diagrams/35-ids-and-arrows.rb +0 -2
- data/.vscode/settings.json +2 -1
- data/CHANGELOG.md +22 -0
- data/README.md +0 -7
- data/docs/domain-modal/domain_model_custom.svg +1 -0
- data/docs/domain-modal.md +1 -1
- data/docs/domain_model.drawio +265 -0
- data/docs/domain_model.json +1038 -0
- data/docs/domain_model.svg +3 -0
- data/docs/project-plan/project.drawio +68 -56
- data/docs/project-plan/project_done.svg +1 -1
- data/docs/project-plan/project_in_progress.svg +1 -1
- data/docs/project-plan/project_todo.svg +1 -1
- data/docs/samples/styles-glass.svg +1 -1
- data/docs/samples/styles-plain.svg +1 -1
- data/docs/samples/styles-rounded.svg +1 -1
- data/docs/samples/styles-shadow.svg +1 -1
- data/docs/samples/styles-sketch.svg +1 -1
- data/lib/drawio_dsl/configuration_shapes.rb +3 -1
- data/lib/drawio_dsl/dom_builder_shapes.rb +7 -1
- data/lib/drawio_dsl/drawio.rb +16 -0
- data/lib/drawio_dsl/drawio_shapes.rb +22 -16
- data/lib/drawio_dsl/formatters/base_formatter.rb +120 -0
- data/lib/drawio_dsl/formatters/html_builder.rb +39 -0
- data/lib/drawio_dsl/formatters/interface_formatter.rb +13 -1
- data/lib/drawio_dsl/formatters/klass_formatter.rb +13 -1
- data/lib/drawio_dsl/schema/_.rb +1 -0
- data/lib/drawio_dsl/schema/shapes/group.rb +9 -0
- data/lib/drawio_dsl/version.rb +1 -1
- data/package-lock.json +2 -2
- data/package.json +1 -1
- metadata +7 -3
- data/docs/domain-modal/domain_model_custom.png +0 -0
@@ -3,7 +3,7 @@
|
|
3
3
|
# Attach configuration to the DrawIO DSL module
|
4
4
|
# :nocov:
|
5
5
|
module DrawioDsl
|
6
|
-
#
|
6
|
+
# Used to attach configuration to KConfig module
|
7
7
|
module ConfigurationShapes
|
8
8
|
ShapeDefaults = Struct.new(:type, :category, :x, :y, :w, :h, :style_modifiers, keyword_init: true)
|
9
9
|
Shapes = Struct.new(
|
@@ -35,6 +35,7 @@ module DrawioDsl
|
|
35
35
|
:diamond,
|
36
36
|
:document,
|
37
37
|
:ellipse,
|
38
|
+
:group,
|
38
39
|
:hexagon,
|
39
40
|
:interface,
|
40
41
|
:klass,
|
@@ -84,6 +85,7 @@ module DrawioDsl
|
|
84
85
|
diamond: ShapeDefaults.new(type: :diamond, x: 0, category: :element, y: 0, w: 100, h: 100, style_modifiers: 'rhombus'),
|
85
86
|
document: ShapeDefaults.new(type: :document, x: 0, category: :element, y: 0, w: 160, h: 160, style_modifiers: 'shape=mxgraph.basic.document'),
|
86
87
|
ellipse: ShapeDefaults.new(type: :ellipse, x: 0, category: :element, y: 0, w: 200, h: 120, style_modifiers: 'ellipse'),
|
88
|
+
group: ShapeDefaults.new(type: :group, x: 0, category: :element, y: 0, w: 210, h: 210, style_modifiers: 'fontSize=20;verticalAlign=top'),
|
87
89
|
hexagon: ShapeDefaults.new(type: :hexagon, x: 0, category: :element, y: 0, w: 200, h: 120, style_modifiers: 'shape=hexagon'),
|
88
90
|
interface: ShapeDefaults.new(type: :interface, x: 0, category: :element, y: 0, w: 160, h: 160, style_modifiers: 'align=left;overflow=fill;fontSize=12;fontFamily=Helvetica'),
|
89
91
|
klass: ShapeDefaults.new(type: :klass, x: 0, category: :element, y: 0, w: 160, h: 160, style_modifiers: 'align=left;overflow=fill;fontSize=12;fontFamily=Helvetica'),
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# :nocov:
|
4
4
|
module DrawioDsl
|
5
|
-
#
|
5
|
+
# DrawioDsl is a DSL for draw-io diagrams.
|
6
6
|
module DomBuilderShapes
|
7
7
|
def add_line(id = nil, **opts, &block)
|
8
8
|
opts = { id: id }.merge(opts) if id
|
@@ -166,6 +166,12 @@ module DrawioDsl
|
|
166
166
|
add_shape(ellipse)
|
167
167
|
end
|
168
168
|
|
169
|
+
def add_group(id = nil, **opts, &block)
|
170
|
+
opts = { id: id }.merge(opts) if id
|
171
|
+
group = DrawioDsl::Schema::Group.new(current_page, **opts, &block)
|
172
|
+
add_shape(group)
|
173
|
+
end
|
174
|
+
|
169
175
|
def add_hexagon(id = nil, **opts, &block)
|
170
176
|
opts = { id: id }.merge(opts) if id
|
171
177
|
hexagon = DrawioDsl::Schema::Hexagon.new(current_page, **opts, &block)
|
data/lib/drawio_dsl/drawio.rb
CHANGED
@@ -19,6 +19,7 @@ module DrawioDsl
|
|
19
19
|
|
20
20
|
layout = DrawioDsl::LayoutEngine.new(builder.current_page)
|
21
21
|
layout.call
|
22
|
+
|
22
23
|
self
|
23
24
|
end
|
24
25
|
|
@@ -37,6 +38,21 @@ module DrawioDsl
|
|
37
38
|
save(file_name, **{ open: :write }.merge(opts))
|
38
39
|
end
|
39
40
|
|
41
|
+
def save_json(file_name, **opts)
|
42
|
+
return unless last_save_file_name
|
43
|
+
return unless File.exist?(last_save_file_name)
|
44
|
+
|
45
|
+
file_name = "#{file_name}.json" unless file_name.end_with?('.json')
|
46
|
+
|
47
|
+
add(file_name, content: JSON.pretty_generate(builder.dom), **opts)
|
48
|
+
|
49
|
+
self
|
50
|
+
end
|
51
|
+
|
52
|
+
def osave_json(file_name, **opts)
|
53
|
+
save_json(file_name, **{ open: :write }.merge(opts))
|
54
|
+
end
|
55
|
+
|
40
56
|
def export_svg(output_file_name, page: 1)
|
41
57
|
return unless last_save_file_name
|
42
58
|
return unless File.exist?(last_save_file_name)
|
@@ -5,7 +5,7 @@ module DrawioDsl
|
|
5
5
|
# :nocov:
|
6
6
|
module DrawioShapes
|
7
7
|
def random(**opts)
|
8
|
-
case rand(
|
8
|
+
case rand(44)
|
9
9
|
when 0
|
10
10
|
line(**opts)
|
11
11
|
when 1
|
@@ -61,36 +61,38 @@ module DrawioDsl
|
|
61
61
|
when 26
|
62
62
|
ellipse(**opts)
|
63
63
|
when 27
|
64
|
-
|
64
|
+
group(**opts)
|
65
65
|
when 28
|
66
|
-
|
66
|
+
hexagon(**opts)
|
67
67
|
when 29
|
68
|
-
|
68
|
+
interface(**opts)
|
69
69
|
when 30
|
70
|
-
|
70
|
+
klass(**opts)
|
71
71
|
when 31
|
72
|
-
|
72
|
+
note(**opts)
|
73
73
|
when 32
|
74
|
-
|
74
|
+
process(**opts)
|
75
75
|
when 33
|
76
|
-
|
76
|
+
rectangle(**opts)
|
77
77
|
when 34
|
78
|
-
|
78
|
+
rectangle2(**opts)
|
79
79
|
when 35
|
80
|
-
|
80
|
+
square(**opts)
|
81
81
|
when 36
|
82
|
-
|
82
|
+
step(**opts)
|
83
83
|
when 37
|
84
|
-
|
84
|
+
tick(**opts)
|
85
85
|
when 38
|
86
|
-
|
86
|
+
todo(**opts)
|
87
87
|
when 39
|
88
|
-
|
88
|
+
face(**opts)
|
89
89
|
when 40
|
90
|
-
|
90
|
+
triangle(**opts)
|
91
91
|
when 41
|
92
|
-
|
92
|
+
embed_row(**opts)
|
93
93
|
when 42
|
94
|
+
embed_col50(**opts)
|
95
|
+
when 43
|
94
96
|
embed_col200(**opts)
|
95
97
|
end
|
96
98
|
end
|
@@ -203,6 +205,10 @@ module DrawioDsl
|
|
203
205
|
builder.add_ellipse(id, **opts, &block)
|
204
206
|
end
|
205
207
|
|
208
|
+
def group(id = nil, **opts, &block)
|
209
|
+
builder.add_group(id, **opts, &block)
|
210
|
+
end
|
211
|
+
|
206
212
|
def hexagon(id = nil, **opts, &block)
|
207
213
|
builder.add_hexagon(id, **opts, &block)
|
208
214
|
end
|
@@ -12,6 +12,78 @@ module DrawioDsl
|
|
12
12
|
@html = DrawioDsl::Formatters::HtmlBuilder.new(element_style_defaults)
|
13
13
|
end
|
14
14
|
|
15
|
+
def hr(size: 1)
|
16
|
+
html.hr(size: size)
|
17
|
+
|
18
|
+
self
|
19
|
+
end
|
20
|
+
|
21
|
+
def b(content, **opts)
|
22
|
+
html.b(content, **opts)
|
23
|
+
|
24
|
+
self
|
25
|
+
end
|
26
|
+
|
27
|
+
def p(content, **opts)
|
28
|
+
html.p(content, **opts)
|
29
|
+
|
30
|
+
self
|
31
|
+
end
|
32
|
+
|
33
|
+
def h1(content, **opts)
|
34
|
+
html.h1(content, **opts)
|
35
|
+
|
36
|
+
self
|
37
|
+
end
|
38
|
+
|
39
|
+
def h2(content, **opts)
|
40
|
+
html.h2(content, **opts)
|
41
|
+
|
42
|
+
self
|
43
|
+
end
|
44
|
+
|
45
|
+
def h3(content, **opts)
|
46
|
+
html.h3(content, **opts)
|
47
|
+
|
48
|
+
self
|
49
|
+
end
|
50
|
+
|
51
|
+
def h4(content, **opts)
|
52
|
+
html.h4(content, **opts)
|
53
|
+
|
54
|
+
self
|
55
|
+
end
|
56
|
+
|
57
|
+
def h5(content, **opts)
|
58
|
+
html.h5(content, **opts)
|
59
|
+
|
60
|
+
self
|
61
|
+
end
|
62
|
+
|
63
|
+
def h6(content, **opts)
|
64
|
+
html.h6(content, **opts)
|
65
|
+
|
66
|
+
self
|
67
|
+
end
|
68
|
+
|
69
|
+
def ul_s(**opts)
|
70
|
+
html.ul_s(**opts)
|
71
|
+
|
72
|
+
self
|
73
|
+
end
|
74
|
+
|
75
|
+
def ul_e(**opts)
|
76
|
+
html.ul_e(**opts)
|
77
|
+
|
78
|
+
self
|
79
|
+
end
|
80
|
+
|
81
|
+
def li(content, **opts)
|
82
|
+
html.li(content, **opts)
|
83
|
+
|
84
|
+
self
|
85
|
+
end
|
86
|
+
|
15
87
|
def empty?
|
16
88
|
html.empty?
|
17
89
|
end
|
@@ -19,6 +91,54 @@ module DrawioDsl
|
|
19
91
|
def as_html(new_line: false)
|
20
92
|
html.as_html(new_line: new_line)
|
21
93
|
end
|
94
|
+
|
95
|
+
private
|
96
|
+
|
97
|
+
# useful defaults
|
98
|
+
|
99
|
+
def ratio
|
100
|
+
@ratio ||= 1.2
|
101
|
+
end
|
102
|
+
|
103
|
+
def base_margin_bottom
|
104
|
+
@base_margin_bottom ||= 4
|
105
|
+
end
|
106
|
+
|
107
|
+
def p_margin_bottom
|
108
|
+
@p_margin_bottom ||= base_margin_bottom
|
109
|
+
end
|
110
|
+
|
111
|
+
def b_margin_bottom
|
112
|
+
@b_margin_bottom ||= base_margin_bottom
|
113
|
+
end
|
114
|
+
|
115
|
+
def li_margin_bottom
|
116
|
+
@li_margin_bottom ||= base_margin_bottom
|
117
|
+
end
|
118
|
+
|
119
|
+
def h6_margin_bottom
|
120
|
+
@h6_margin_bottom ||= base_margin_bottom
|
121
|
+
end
|
122
|
+
|
123
|
+
def h5_margin_bottom
|
124
|
+
@h5_margin_bottom ||= h6_margin_bottom * ratio
|
125
|
+
end
|
126
|
+
|
127
|
+
def h4_margin_bottom
|
128
|
+
@h4_margin_bottom ||= h5_margin_bottom * ratio
|
129
|
+
end
|
130
|
+
|
131
|
+
def h3_margin_bottom
|
132
|
+
@h3_margin_bottom ||= h4_margin_bottom * ratio
|
133
|
+
end
|
134
|
+
|
135
|
+
def h2_margin_bottom
|
136
|
+
@h2_margin_bottom ||= h3_margin_bottom * ratio
|
137
|
+
end
|
138
|
+
|
139
|
+
def h1_margin_bottom
|
140
|
+
@h1_margin_bottom ||= h2_margin_bottom * ratio
|
141
|
+
end
|
22
142
|
end
|
23
143
|
end
|
24
144
|
end
|
@@ -12,6 +12,9 @@ module DrawioDsl
|
|
12
12
|
@element_style_defaults = element_style_defaults
|
13
13
|
end
|
14
14
|
|
15
|
+
# Access the default styles for a HTML element
|
16
|
+
#
|
17
|
+
# Formatters can define the defaults styles for HTML elements such as <p>, <h1>, etc.
|
15
18
|
def default_for(tag)
|
16
19
|
element_style_defaults[tag] || {}
|
17
20
|
end
|
@@ -48,6 +51,42 @@ module DrawioDsl
|
|
48
51
|
add_line("<p#{style_for(:p, **opts)}>#{content}</p>")
|
49
52
|
end
|
50
53
|
|
54
|
+
def h1(content, **opts)
|
55
|
+
add_line("<h1#{style_for(:h1, **opts)}>#{content}</h1>")
|
56
|
+
end
|
57
|
+
|
58
|
+
def h2(content, **opts)
|
59
|
+
add_line("<h2#{style_for(:h2, **opts)}>#{content}</h2>")
|
60
|
+
end
|
61
|
+
|
62
|
+
def h3(content, **opts)
|
63
|
+
add_line("<h3#{style_for(:h3, **opts)}>#{content}</h3>")
|
64
|
+
end
|
65
|
+
|
66
|
+
def h4(content, **opts)
|
67
|
+
add_line("<h4#{style_for(:h4, **opts)}>#{content}</h4>")
|
68
|
+
end
|
69
|
+
|
70
|
+
def h5(content, **opts)
|
71
|
+
add_line("<h5#{style_for(:h5, **opts)}>#{content}</h5>")
|
72
|
+
end
|
73
|
+
|
74
|
+
def h6(content, **opts)
|
75
|
+
add_line("<h6#{style_for(:h6, **opts)}>#{content}</h6>")
|
76
|
+
end
|
77
|
+
|
78
|
+
def li(content, **opts)
|
79
|
+
add_line("<li#{style_for(:li, **opts)}>#{content}</li>")
|
80
|
+
end
|
81
|
+
|
82
|
+
def ul_s(**opts)
|
83
|
+
add_line("<ul#{style_for(:ul, **opts)}>")
|
84
|
+
end
|
85
|
+
|
86
|
+
def ul_e(**_opts)
|
87
|
+
add_line('</ul>')
|
88
|
+
end
|
89
|
+
|
51
90
|
def add_line(line)
|
52
91
|
lines << line
|
53
92
|
end
|
@@ -7,7 +7,19 @@ module DrawioDsl
|
|
7
7
|
# Format the HTML to display an interface on a class diagram
|
8
8
|
class InterfaceFormatter < BaseFormatter
|
9
9
|
def initialize
|
10
|
-
super(
|
10
|
+
super(
|
11
|
+
{
|
12
|
+
p: { margin: '0px', margin_left: '4px', margin_bottom: "#{p_margin_bottom}px" },
|
13
|
+
b: { margin: '0px', margin_left: '4px', margin_bottom: "#{b_margin_bottom}px" },
|
14
|
+
h1: { margin: '0px', margin_left: '4px', margin_bottom: "#{h1_margin_bottom}px" },
|
15
|
+
h2: { margin: '0px', margin_left: '4px', margin_bottom: "#{h2_margin_bottom}px" },
|
16
|
+
h3: { margin: '0px', margin_left: '4px', margin_bottom: "#{h3_margin_bottom}px" },
|
17
|
+
h4: { margin: '0px', margin_left: '4px', margin_bottom: "#{h4_margin_bottom}px" },
|
18
|
+
h5: { margin: '0px', margin_left: '4px', margin_bottom: "#{h5_margin_bottom}px" },
|
19
|
+
h6: { margin: '0px', margin_left: '4px', margin_bottom: "#{h6_margin_bottom}px" },
|
20
|
+
li: { margin: '0px', margin_left: '4px', margin_bottom: "#{li_margin_bottom}px" }
|
21
|
+
}
|
22
|
+
)
|
11
23
|
end
|
12
24
|
|
13
25
|
def header(name, description: nil, interface_type: 'Interface')
|
@@ -7,7 +7,19 @@ module DrawioDsl
|
|
7
7
|
# Format the HTML to display an class on a class diagram
|
8
8
|
class KlassFormatter < BaseFormatter
|
9
9
|
def initialize
|
10
|
-
super(
|
10
|
+
super(
|
11
|
+
{
|
12
|
+
p: { margin: '0px', margin_left: '4px', margin_bottom: "#{p_margin_bottom}px" },
|
13
|
+
b: { margin: '0px', margin_left: '4px', margin_bottom: "#{b_margin_bottom}px" },
|
14
|
+
h1: { margin: '0px', margin_left: '4px', margin_bottom: "#{h1_margin_bottom}px" },
|
15
|
+
h2: { margin: '0px', margin_left: '4px', margin_bottom: "#{h2_margin_bottom}px" },
|
16
|
+
h3: { margin: '0px', margin_left: '4px', margin_bottom: "#{h3_margin_bottom}px" },
|
17
|
+
h4: { margin: '0px', margin_left: '4px', margin_bottom: "#{h4_margin_bottom}px" },
|
18
|
+
h5: { margin: '0px', margin_left: '4px', margin_bottom: "#{h5_margin_bottom}px" },
|
19
|
+
h6: { margin: '0px', margin_left: '4px', margin_bottom: "#{h6_margin_bottom}px" },
|
20
|
+
li: { margin: '0px', margin_left: '4px', margin_bottom: "#{li_margin_bottom}px" }
|
21
|
+
}
|
22
|
+
)
|
11
23
|
end
|
12
24
|
|
13
25
|
def header(name, description: nil)
|
data/lib/drawio_dsl/schema/_.rb
CHANGED
@@ -39,6 +39,7 @@ require_relative 'shapes/db_json'
|
|
39
39
|
require_relative 'shapes/diamond'
|
40
40
|
require_relative 'shapes/document'
|
41
41
|
require_relative 'shapes/ellipse'
|
42
|
+
require_relative 'shapes/group'
|
42
43
|
require_relative 'shapes/hexagon'
|
43
44
|
require_relative 'shapes/interface'
|
44
45
|
require_relative 'shapes/klass'
|
data/lib/drawio_dsl/version.rb
CHANGED
data/package-lock.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "drawio_dsl",
|
3
|
-
"version": "0.8.
|
3
|
+
"version": "0.8.8",
|
4
4
|
"lockfileVersion": 2,
|
5
5
|
"requires": true,
|
6
6
|
"packages": {
|
7
7
|
"": {
|
8
8
|
"name": "drawio_dsl",
|
9
|
-
"version": "0.8.
|
9
|
+
"version": "0.8.8",
|
10
10
|
"devDependencies": {
|
11
11
|
"@klueless-js/semantic-release-rubygem": "github:klueless-js/semantic-release-rubygem",
|
12
12
|
"@semantic-release/changelog": "^6.0.1",
|
data/package.json
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: drawio_dsl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Cruwys
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03-
|
11
|
+
date: 2022-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: k_config
|
@@ -119,7 +119,10 @@ files:
|
|
119
119
|
- docs/domain-modal/domain_model.drawio
|
120
120
|
- docs/domain-modal/domain_model.svg
|
121
121
|
- docs/domain-modal/domain_model_custom.drawio
|
122
|
-
- docs/domain-modal/domain_model_custom.
|
122
|
+
- docs/domain-modal/domain_model_custom.svg
|
123
|
+
- docs/domain_model.drawio
|
124
|
+
- docs/domain_model.json
|
125
|
+
- docs/domain_model.svg
|
123
126
|
- docs/extensions.md
|
124
127
|
- docs/extensions/analyti_cs.svg
|
125
128
|
- docs/extensions/android_inputs.svg
|
@@ -353,6 +356,7 @@ files:
|
|
353
356
|
- lib/drawio_dsl/schema/shapes/embed_row.rb
|
354
357
|
- lib/drawio_dsl/schema/shapes/envelop.rb
|
355
358
|
- lib/drawio_dsl/schema/shapes/face.rb
|
359
|
+
- lib/drawio_dsl/schema/shapes/group.rb
|
356
360
|
- lib/drawio_dsl/schema/shapes/h1.rb
|
357
361
|
- lib/drawio_dsl/schema/shapes/h2.rb
|
358
362
|
- lib/drawio_dsl/schema/shapes/h3.rb
|
Binary file
|