metanorma-plugin-lutaml 0.7.8 → 0.7.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -4
- data/README.adoc +58 -1
- data/lib/metanorma/plugin/lutaml/liquid/custom_filters.rb +1 -1
- data/lib/metanorma/plugin/lutaml/liquid_templates/_klass_table.liquid +11 -10
- data/lib/metanorma/plugin/lutaml/lutaml_ea_xmi_preprocessor.rb +310 -0
- data/lib/metanorma/plugin/lutaml/lutaml_klass_table_block_macro.rb +29 -56
- data/lib/metanorma/plugin/lutaml/version.rb +1 -1
- data/lib/metanorma-plugin-lutaml.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a8884a3a005d1987c9403af11f7dddb62657e28178881e7ef848383280edfcb
|
4
|
+
data.tar.gz: 210ca361b8facc4702196a1f2f734e79abe0b325e30db269c991884c0cbc2714
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab318c1c9a6bf060093600533ff59c6b293c70a90c3096ec5ab88100546e2ae2a18d0e52f8571bdf72d1da14df0fd6fdbfbc7a8cf3c9716ba34a2f154a4e5f64
|
7
|
+
data.tar.gz: 0e3acb93421b591442d0293c08c5fb9b2e8e8c1f4925eb5f9f0fbbb77997b5cbc80e8e30cce5dd4accc4b1fe40d91c2ebce09e7f17db901ad8afbb82b8d0cb37
|
data/Gemfile
CHANGED
data/README.adoc
CHANGED
@@ -315,7 +315,7 @@ lutaml_gml_dictionary::/path/to/dictionary.xml[template="/path/to/template.liqui
|
|
315
315
|
|
316
316
|
The command accepts the options listed below:
|
317
317
|
|
318
|
-
*
|
318
|
+
* `/path/to/dictionary.xml` specifies the path of xml file of the
|
319
319
|
GML Dictionary.
|
320
320
|
|
321
321
|
* `template="/path/to/template.liquid"` specifies the liquid template.
|
@@ -364,6 +364,36 @@ h| Help | Description
|
|
364
364
|
--
|
365
365
|
-----
|
366
366
|
|
367
|
+
=== Rendering a LutaML table of a class: `lutaml_klass_table`
|
368
|
+
|
369
|
+
This command allows to render a LutaML table of a class by using Liquid Drop.
|
370
|
+
|
371
|
+
The table will show:
|
372
|
+
|
373
|
+
* Class Name
|
374
|
+
* Class Definition
|
375
|
+
* Inherited Properties
|
376
|
+
* Self-defined Properties
|
377
|
+
* Properties Inherited from Association
|
378
|
+
* Properties Defined in Association
|
379
|
+
|
380
|
+
[source,adoc]
|
381
|
+
-----
|
382
|
+
lutaml_klass_table::/path/to/example.xmi[name="NameOfClass",tmpl_folder="/path/to/templates"]
|
383
|
+
-----
|
384
|
+
|
385
|
+
The command accepts the options listed below:
|
386
|
+
|
387
|
+
* `/path/to/example.xmi` specifies the path of xmi file.
|
388
|
+
|
389
|
+
* `name="NameOfClass"` specifies the name of the Class.
|
390
|
+
|
391
|
+
* `tmpl_folder="/path/to/templates"` specifies the folder path of the templates.
|
392
|
+
(Optional) By default, it will look for the templates `_klass_table.liquid`,
|
393
|
+
`_klass_row.liquid` and `_klass_assoc_row.liquid` defined in
|
394
|
+
`lib/metanorma/plugin/lutaml/templates`. These templates can be customized by
|
395
|
+
defining them in `/path/to/templates` and then set the `tmpl_folder` option.
|
396
|
+
|
367
397
|
=== Generating UML class and attributes: `lutaml_uml_class`
|
368
398
|
|
369
399
|
This command allows rendering a definition clause for a UML class.
|
@@ -796,6 +826,33 @@ and iterate through packages according to the order supplied in the file. All
|
|
796
826
|
packages that matches `skip` in the YAML config file will be skipped during
|
797
827
|
render.
|
798
828
|
|
829
|
+
=== Usage of `lutaml_ea_xmi` macro
|
830
|
+
|
831
|
+
This command is a replacement for `lutaml_uml_datamodel_description` to perform
|
832
|
+
the same functionalities of `lutaml_uml_datamodel_description`, which is to
|
833
|
+
render data model packages and its dependent objects for supplied XMI file, by
|
834
|
+
using Liquid Drop. The performance of `lutaml_ea_xmi` can be improved by
|
835
|
+
10~20 times. (Tested with a 10.6MB XMI file with 120000+ lines)
|
836
|
+
|
837
|
+
To use this macro, you only need to replace `lutaml_uml_datamodel_description`
|
838
|
+
by `lutaml_ea_xmi`.
|
839
|
+
|
840
|
+
Replace:
|
841
|
+
|
842
|
+
[source,adoc]
|
843
|
+
-----
|
844
|
+
[lutaml_uml_datamodel_description, path/to/example.xmi]
|
845
|
+
...
|
846
|
+
-----
|
847
|
+
|
848
|
+
By:
|
849
|
+
|
850
|
+
[source,adoc]
|
851
|
+
-----
|
852
|
+
[lutaml_ea_xmi, path/to/example.xmi]
|
853
|
+
...
|
854
|
+
-----
|
855
|
+
|
799
856
|
== Documentation
|
800
857
|
|
801
858
|
Please refer to https://www.metanorma.org.
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require "coradoc"
|
2
|
-
require "coradoc/input/html"
|
3
2
|
|
4
3
|
module Metanorma
|
5
4
|
module Plugin
|
@@ -7,6 +6,7 @@ module Metanorma
|
|
7
6
|
module Liquid
|
8
7
|
module CustomFilters
|
9
8
|
def html2adoc(input)
|
9
|
+
# Coradoc::ReverseAdoc.convert(input)
|
10
10
|
Coradoc::Input::HTML.convert(input)
|
11
11
|
end
|
12
12
|
|
@@ -1,23 +1,24 @@
|
|
1
1
|
[cols="1a,1a,2a"]
|
2
2
|
|===
|
3
|
-
|
|
3
|
+
| Definition of Type
|
4
4
|
2+| {{ root.definition }}
|
5
5
|
|
6
|
-
h|
|
7
|
-
h|
|
6
|
+
h| Upper Type 2+| {{ root.general.upper_klass }}:{{ root.general.name }}
|
7
|
+
h| Stereotype 2+| << {{ root.stereotype }} >>
|
8
8
|
|
9
|
-
3+h|
|
10
|
-
h|
|
9
|
+
3+h| Inherited Properties
|
10
|
+
h| Property Name h| Property Type and Multiplicity h| Definition
|
11
11
|
{{ content.inherited_props }}
|
12
12
|
|
13
|
-
3+h|
|
13
|
+
3+h| Self-defined Properties
|
14
|
+
h| Property Name h| Property Type and Multiplicity h| Definition
|
14
15
|
{{ content.owned_props }}
|
15
16
|
|
16
|
-
3+h|
|
17
|
-
h|
|
17
|
+
3+h| Properties Inherited from Association
|
18
|
+
h| Property Name h| Property Type and Multiplicity h| Definition
|
18
19
|
{{ content.inherited_assoc_props }}
|
19
20
|
|
20
|
-
3+h|
|
21
|
-
h|
|
21
|
+
3+h| Properties Defined in Association
|
22
|
+
h| Property Name h| Property Type and Multiplicity h| Definition
|
22
23
|
{{ content.assoc_props }}
|
23
24
|
|===
|
@@ -0,0 +1,310 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "liquid"
|
4
|
+
require "asciidoctor"
|
5
|
+
require "asciidoctor/reader"
|
6
|
+
require "lutaml"
|
7
|
+
# require "lutaml/uml"
|
8
|
+
require "xmi"
|
9
|
+
require "lutaml/xmi"
|
10
|
+
require "metanorma/plugin/lutaml/utils"
|
11
|
+
require "metanorma/plugin/lutaml/asciidoctor/preprocessor"
|
12
|
+
|
13
|
+
module Metanorma
|
14
|
+
module Plugin
|
15
|
+
module Lutaml
|
16
|
+
# Macro for quick rendering of datamodel attributes/values tables
|
17
|
+
# from liquid drop object
|
18
|
+
class LutamlEaXmiPreprocessor <
|
19
|
+
::Asciidoctor::Extensions::Preprocessor
|
20
|
+
MACRO_REGEXP =
|
21
|
+
/\[lutaml_ea_xmi,([^,]+),?(.+)?\]/.freeze
|
22
|
+
LIQUID_INCLUDE_PATH = File.join(
|
23
|
+
Gem.loaded_specs["metanorma-plugin-lutaml"].full_gem_path,
|
24
|
+
"lib", "metanorma", "plugin", "lutaml", "liquid_templates"
|
25
|
+
)
|
26
|
+
DEFAULT_RENDER_INCLUDE = "packages"
|
27
|
+
RENDER_STYLES_INCLUDES = {
|
28
|
+
"default" => "packages",
|
29
|
+
"entity_list" => "packages_entity_list",
|
30
|
+
"entity_list_class" => "packages_entity_list_class",
|
31
|
+
"data_dictionary" => "packages_data_dictionary",
|
32
|
+
}.freeze
|
33
|
+
RENDER_STYLE_ATTRIBUTE = "render_style"
|
34
|
+
SUPPORTED_NESTED_MACRO = %w[
|
35
|
+
before diagram_include_block after include_block package_text
|
36
|
+
].freeze
|
37
|
+
# search document for block `lutaml_ea_xmi`
|
38
|
+
# read include derectives that goes after that in block and transform
|
39
|
+
# into yaml2text blocks
|
40
|
+
def process(document, reader)
|
41
|
+
r = Asciidoctor::PreprocessorNoIfdefsReader.new document, reader.lines
|
42
|
+
input_lines = r.readlines.to_enum
|
43
|
+
Asciidoctor::PreprocessorNoIfdefsReader
|
44
|
+
.new(document, processed_lines(document, input_lines))
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def lutaml_document_from_file_or_cache(document, file_path, yaml_config)
|
50
|
+
full_path = Utils.relative_file_path(document, file_path)
|
51
|
+
if document.attributes["lutaml_xmi_cache"] &&
|
52
|
+
document.attributes["lutaml_xmi_cache"][full_path]
|
53
|
+
return document.attributes["lutaml_xmi_cache"][full_path]
|
54
|
+
end
|
55
|
+
|
56
|
+
yaml_config["ea_extension"]&.each do |ea_extension_path|
|
57
|
+
ea_extension_full_path = File.expand_path(
|
58
|
+
ea_extension_path, File.dirname(file_path)
|
59
|
+
)
|
60
|
+
Xmi::EaRoot.load_extension(ea_extension_full_path)
|
61
|
+
end
|
62
|
+
|
63
|
+
result_document = ::Lutaml::XMI::Parsers::XML.serialize_xmi_to_liquid(
|
64
|
+
File.new(
|
65
|
+
full_path, encoding: "UTF-8"
|
66
|
+
),
|
67
|
+
)
|
68
|
+
|
69
|
+
document.attributes["lutaml_xmi_cache"] ||= {}
|
70
|
+
document.attributes["lutaml_xmi_cache"][full_path] = result_document
|
71
|
+
result_document
|
72
|
+
end
|
73
|
+
|
74
|
+
def parse_yaml_config_file(document, file_path)
|
75
|
+
return {} if file_path.nil?
|
76
|
+
|
77
|
+
relative_file_path = Utils.relative_file_path(document, file_path)
|
78
|
+
YAML.safe_load(File.read(relative_file_path, encoding: "UTF-8"))
|
79
|
+
end
|
80
|
+
|
81
|
+
def processed_lines(document, input_lines)
|
82
|
+
result = []
|
83
|
+
loop do
|
84
|
+
result.push(*process_text_blocks(document, input_lines))
|
85
|
+
end
|
86
|
+
result
|
87
|
+
end
|
88
|
+
|
89
|
+
def process_text_blocks(document, input_lines)
|
90
|
+
line = input_lines.next
|
91
|
+
block_match = line.match(MACRO_REGEXP)
|
92
|
+
|
93
|
+
return [line] if block_match.nil?
|
94
|
+
|
95
|
+
yaml_config = parse_yaml_config_file(document, block_match[2])
|
96
|
+
lutaml_document = lutaml_document_from_file_or_cache(document,
|
97
|
+
block_match[1],
|
98
|
+
yaml_config)
|
99
|
+
fill_in_diagrams_attributes(document, lutaml_document)
|
100
|
+
model_representation(
|
101
|
+
lutaml_document, document,
|
102
|
+
collect_additional_context(document, input_lines, input_lines.next),
|
103
|
+
yaml_config
|
104
|
+
)
|
105
|
+
end
|
106
|
+
|
107
|
+
def fill_in_entities_refs_attributes(document,
|
108
|
+
lutaml_document, options)
|
109
|
+
# render_style = options.fetch(RENDER_STYLE_ATTRIBUTE, "default")
|
110
|
+
all_children_packages = lutaml_document.packages
|
111
|
+
.map(&:children_packages).flatten
|
112
|
+
package_flat_packages = lambda do |pks|
|
113
|
+
pks.each_with_object({}) do |package, res|
|
114
|
+
res[package.name] = package.xmi_id
|
115
|
+
end
|
116
|
+
end
|
117
|
+
children_pks = package_flat_packages.call(all_children_packages)
|
118
|
+
ref_dictionary = package_flat_packages.call(lutaml_document.packages)
|
119
|
+
.merge(children_pks)
|
120
|
+
%w[class enum data_type].each do |type|
|
121
|
+
package_flat = lambda do |pks|
|
122
|
+
pks.each_with_object({}) do |package, res|
|
123
|
+
plural = type == "class" ? "classes" : "#{type}s"
|
124
|
+
package.send(plural).map do |entity|
|
125
|
+
res["#{type}:#{package.name}:#{entity.name}"] = entity.xmi_id
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
children_pks_diags = package_flat.call(all_children_packages)
|
130
|
+
ref_dictionary = ref_dictionary
|
131
|
+
.merge(package_flat.call(lutaml_document.packages)
|
132
|
+
.merge(children_pks_diags))
|
133
|
+
end
|
134
|
+
document.attributes["lutaml_entity_id"] = ref_dictionary
|
135
|
+
end
|
136
|
+
|
137
|
+
def fill_in_diagrams_attributes(document, lutaml_document)
|
138
|
+
package_flat_diagrams = lambda do |pks|
|
139
|
+
pks.each_with_object({}) do |package, res|
|
140
|
+
package.diagrams.map do |diag|
|
141
|
+
res["#{package.name}:#{diag.name}"] = diag.xmi_id
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
children_pks_diags = package_flat_diagrams.call(
|
146
|
+
lutaml_document.packages.map(&:children_packages).flatten,
|
147
|
+
)
|
148
|
+
|
149
|
+
document.attributes["lutaml_figure_id"] = package_flat_diagrams
|
150
|
+
.call(lutaml_document.packages)
|
151
|
+
.merge(children_pks_diags)
|
152
|
+
end
|
153
|
+
|
154
|
+
def collect_additional_context(document, input_lines, end_mark)
|
155
|
+
additional_context = Hash.new { |hash, key| hash[key] = [] }
|
156
|
+
additional_context["all_macros"] = []
|
157
|
+
block_lines = []
|
158
|
+
while (block_line = input_lines.next) != end_mark
|
159
|
+
block_lines.push(block_line)
|
160
|
+
end
|
161
|
+
processed_lines =
|
162
|
+
process(document, ::Asciidoctor::PreprocessorReader.new(
|
163
|
+
document, block_lines
|
164
|
+
))
|
165
|
+
.read_lines
|
166
|
+
block_document = ::Asciidoctor::Document
|
167
|
+
.new(processed_lines, {}).parse
|
168
|
+
block_document.blocks.each do |block|
|
169
|
+
next unless SUPPORTED_NESTED_MACRO.include?(block.attributes["role"])
|
170
|
+
|
171
|
+
attrs = block.attributes
|
172
|
+
name = attrs.delete("role")
|
173
|
+
package = attrs.delete("package")
|
174
|
+
macro_keyword = [name, package].compact.join(";")
|
175
|
+
block_text = block.lines.length.positive? ? block.lines.join("\n") : ""
|
176
|
+
additional_context[macro_keyword]
|
177
|
+
.push({ "text" => block_text }.merge(attrs))
|
178
|
+
additional_context["all_macros"]
|
179
|
+
.push({ "text" => block_text,
|
180
|
+
"type" => name, "package" => package }.merge(attrs))
|
181
|
+
end
|
182
|
+
additional_context
|
183
|
+
end
|
184
|
+
|
185
|
+
def package_level(lutaml_document, level)
|
186
|
+
return lutaml_document if level <= 0
|
187
|
+
|
188
|
+
package_level(lutaml_document["packages"].first, level - 1)
|
189
|
+
end
|
190
|
+
|
191
|
+
def create_context_object(lutaml_document, additional_context, options)
|
192
|
+
root_package = package_level(lutaml_document.to_liquid,
|
193
|
+
options["package_root_level"] || 1)
|
194
|
+
if options.empty? || options["packages"].nil?
|
195
|
+
return {
|
196
|
+
"render_nested_packages" => true,
|
197
|
+
"packages" => root_package["packages"],
|
198
|
+
"root_packages" => [root_package],
|
199
|
+
"additional_context" => additional_context
|
200
|
+
.merge("external_classes" => options["external_classes"]),
|
201
|
+
"name" => root_package["name"],
|
202
|
+
}
|
203
|
+
end
|
204
|
+
|
205
|
+
all_packages = [root_package, *root_package["children_packages"]]
|
206
|
+
{
|
207
|
+
"packages" => sort_and_filter_out_packages(all_packages, options),
|
208
|
+
"package_entities" => package_entities(options),
|
209
|
+
"package_skip_sections" => package_skip_sections(options),
|
210
|
+
"additional_context" => additional_context
|
211
|
+
.merge("external_classes" => options["external_classes"]),
|
212
|
+
"root_packages" => [root_package],
|
213
|
+
"render_nested_packages" => options["render_nested_packages"] ||
|
214
|
+
false,
|
215
|
+
"name" => root_package["name"],
|
216
|
+
}
|
217
|
+
end
|
218
|
+
|
219
|
+
def package_entities(options)
|
220
|
+
return {} unless options["packages"]
|
221
|
+
|
222
|
+
options["packages"]
|
223
|
+
.find_all { |entity| entity.is_a?(Hash) && entity.values.first["render_entities"] }
|
224
|
+
.map do |entity|
|
225
|
+
[entity.keys.first,
|
226
|
+
entity.values.first["render_entities"].map { |n| [n, true] }.to_h]
|
227
|
+
end.to_h
|
228
|
+
end
|
229
|
+
|
230
|
+
def package_skip_sections(options)
|
231
|
+
return {} unless options["packages"]
|
232
|
+
|
233
|
+
options["packages"]
|
234
|
+
.find_all { |entity| entity.is_a?(Hash) && entity.values.first["skip_tables"] }
|
235
|
+
.map do |entity|
|
236
|
+
[entity.keys.first, entity.values.first["skip_tables"].map do |n|
|
237
|
+
[n, true]
|
238
|
+
end.to_h]
|
239
|
+
end.to_h
|
240
|
+
end
|
241
|
+
|
242
|
+
def sort_and_filter_out_packages(all_packages, options)
|
243
|
+
return all_packages if options["packages"].nil?
|
244
|
+
|
245
|
+
result = []
|
246
|
+
# Step one - filter out all skipped packages
|
247
|
+
options["packages"]
|
248
|
+
.find_all { |entity| entity.is_a?(Hash) && entity["skip"] }
|
249
|
+
.each do |entity|
|
250
|
+
entity_regexp = config_entity_regexp(entity["skip"])
|
251
|
+
all_packages
|
252
|
+
.delete_if { |package| package["name"] =~ entity_regexp }
|
253
|
+
end
|
254
|
+
# Step two - select supplied packages by pattern
|
255
|
+
options["packages"]
|
256
|
+
.find_all { |entity| entity.is_a?(String) || (entity.is_a?(Hash) && !entity["skip"]) }
|
257
|
+
.each do |entity_obj|
|
258
|
+
entity = entity_obj.is_a?(String) ? entity_obj : entity_obj.keys.first
|
259
|
+
entity_regexp = config_entity_regexp(entity)
|
260
|
+
all_packages.each do |package|
|
261
|
+
if package["name"]&.match?(entity_regexp)
|
262
|
+
result.push(package)
|
263
|
+
all_packages
|
264
|
+
.delete_if { |nest_package| nest_package["name"] == package["name"] }
|
265
|
+
end
|
266
|
+
end
|
267
|
+
end
|
268
|
+
result
|
269
|
+
end
|
270
|
+
|
271
|
+
def config_entity_regexp(entity)
|
272
|
+
additional_sym = ".*" if /\*$/.match?(entity)
|
273
|
+
%r{^#{Regexp.escape(entity.delete('*'))}#{additional_sym}$}
|
274
|
+
end
|
275
|
+
|
276
|
+
def model_representation(lutaml_document, document, additional_context,
|
277
|
+
options)
|
278
|
+
fill_in_entities_refs_attributes(document, lutaml_document, options)
|
279
|
+
render_result, errors = Utils.render_liquid_string(
|
280
|
+
template_string: template(options["section_depth"] || 2,
|
281
|
+
options["render_style"],
|
282
|
+
options["include_root"]),
|
283
|
+
context_items: create_context_object(lutaml_document,
|
284
|
+
additional_context,
|
285
|
+
options),
|
286
|
+
context_name: "context",
|
287
|
+
document: document,
|
288
|
+
include_path: LIQUID_INCLUDE_PATH,
|
289
|
+
)
|
290
|
+
Utils.notify_render_errors(document, errors)
|
291
|
+
render_result.split("\n")
|
292
|
+
end
|
293
|
+
|
294
|
+
def template(section_depth, render_style, include_root)
|
295
|
+
include_name = RENDER_STYLES_INCLUDES.fetch(render_style,
|
296
|
+
DEFAULT_RENDER_INCLUDE)
|
297
|
+
result = ""
|
298
|
+
if include_root
|
299
|
+
result += <<~LIQUID
|
300
|
+
{% include "#{include_name}", package_skip_sections: context.package_skip_sections, package_entities: context.package_entities, context: context.root_packages, additional_context: context.additional_context, render_nested_packages: false %}
|
301
|
+
LIQUID
|
302
|
+
end
|
303
|
+
result + <<~LIQUID
|
304
|
+
{% include "#{include_name}", depth: #{section_depth}, package_skip_sections: context.package_skip_sections, package_entities: context.package_entities, context: context, additional_context: context.additional_context, render_nested_packages: context.render_nested_packages %}
|
305
|
+
LIQUID
|
306
|
+
end
|
307
|
+
end
|
308
|
+
end
|
309
|
+
end
|
310
|
+
end
|
@@ -11,23 +11,23 @@ module Metanorma
|
|
11
11
|
class LutamlKlassTableBlockMacro < ::Asciidoctor::Extensions::BlockMacroProcessor
|
12
12
|
DEFAULT_TEMPLATE_PATH = File.join(
|
13
13
|
Gem::Specification.find_by_name("metanorma-plugin-lutaml").gem_dir,
|
14
|
-
"lib
|
14
|
+
"lib", "metanorma", "plugin", "lutaml", "liquid_templates"
|
15
15
|
)
|
16
|
-
DEFAULT_TABLE_TEMPLATE = DEFAULT_TEMPLATE_PATH
|
17
|
-
.gsub("<NAME>", "_klass_table")
|
18
|
-
DEFAULT_ROW_TEMPLATE = DEFAULT_TEMPLATE_PATH
|
19
|
-
.gsub("<NAME>", "_klass_row")
|
20
|
-
DEFAULT_ASSOC_ROW_TEMPLATE = DEFAULT_TEMPLATE_PATH
|
21
|
-
.gsub("<NAME>", "_klass_assoc_row")
|
22
16
|
|
23
17
|
use_dsl
|
24
18
|
named :lutaml_klass_table
|
25
19
|
|
26
20
|
def process(parent, target, attrs)
|
27
|
-
|
21
|
+
xmi_path = Utils.relative_file_path(parent.document, target)
|
22
|
+
|
23
|
+
if attrs["tmpl_folder"]
|
24
|
+
attrs["tmpl_folder"] = Utils.relative_file_path(
|
25
|
+
parent.document, attrs["tmpl_folder"]
|
26
|
+
)
|
27
|
+
end
|
28
28
|
|
29
29
|
gen = ::Lutaml::XMI::Parsers::XML.serialize_generalization_by_name(
|
30
|
-
|
30
|
+
xmi_path, attrs["name"]
|
31
31
|
)
|
32
32
|
|
33
33
|
render(gen, parent, attrs)
|
@@ -51,16 +51,6 @@ module Metanorma
|
|
51
51
|
gen, parent, attrs
|
52
52
|
)
|
53
53
|
|
54
|
-
# content[:inherited_props] += render_named_inherited_props(
|
55
|
-
# gen, parent, attrs, "gml"
|
56
|
-
# )
|
57
|
-
# content[:inherited_props] += render_named_inherited_props(
|
58
|
-
# gen, parent, attrs, "core"
|
59
|
-
# )
|
60
|
-
# content[:inherited_assoc_props] += render_named_inherited_props(
|
61
|
-
# gen, parent, attrs, "gen"
|
62
|
-
# )
|
63
|
-
|
64
54
|
rendered_table = render_table(gen, parent, attrs, content)
|
65
55
|
|
66
56
|
block = create_open_block(parent, "", attrs)
|
@@ -69,7 +59,7 @@ module Metanorma
|
|
69
59
|
|
70
60
|
def render_table(gen, parent, attrs, content)
|
71
61
|
table_tmpl = get_template(
|
72
|
-
parent.document, attrs
|
62
|
+
parent.document, attrs, :table
|
73
63
|
)
|
74
64
|
|
75
65
|
table_tmpl.assigns["root"] = KlassTableDrop.new(gen)
|
@@ -81,14 +71,14 @@ module Metanorma
|
|
81
71
|
|
82
72
|
def render_general_rows(general_item, parent, attrs)
|
83
73
|
row_tmpl = get_template(
|
84
|
-
parent.document, attrs
|
74
|
+
parent.document, attrs, :row
|
85
75
|
)
|
86
76
|
render_rows(general_item, row_tmpl)
|
87
77
|
end
|
88
78
|
|
89
79
|
def render_assoc_rows(general_item, parent, attrs)
|
90
80
|
row_tmpl = get_template(
|
91
|
-
parent.document, attrs
|
81
|
+
parent.document, attrs, :assoc_row
|
92
82
|
)
|
93
83
|
render_rows(general_item, row_tmpl)
|
94
84
|
end
|
@@ -127,28 +117,6 @@ module Metanorma
|
|
127
117
|
render_assoc_rows(gen, parent, attrs)
|
128
118
|
end
|
129
119
|
|
130
|
-
def render_gml_inherited_props(gen, parent, attrs)
|
131
|
-
render_named_inherited_props(gen, parent, attrs, "gml")
|
132
|
-
end
|
133
|
-
|
134
|
-
def render_core_inherited_props(gen, parent, attrs)
|
135
|
-
render_named_inherited_props(gen, parent, attrs, "core")
|
136
|
-
end
|
137
|
-
|
138
|
-
def render_gen_inherited_props(gen, parent, attrs)
|
139
|
-
render_named_inherited_props(gen, parent, attrs, "gen")
|
140
|
-
end
|
141
|
-
|
142
|
-
def render_named_inherited_props(gen, parent, attrs, name)
|
143
|
-
attr_key = "#{name}_attributes".to_sym
|
144
|
-
general_item = {}
|
145
|
-
general_item[:general_attributes] = gen[attr_key]
|
146
|
-
general_item[:general_upper_klass] = gen[attr_key].first[:upper_klass]
|
147
|
-
general_item[:general_name] = name
|
148
|
-
|
149
|
-
render_general_rows(general_item, parent, attrs)
|
150
|
-
end
|
151
|
-
|
152
120
|
def render_inherited_props(gen, parent, attrs)
|
153
121
|
render_inherited_rows(gen, parent, attrs, assoc: false)
|
154
122
|
end
|
@@ -173,10 +141,13 @@ module Metanorma
|
|
173
141
|
rendered_rows
|
174
142
|
end
|
175
143
|
|
176
|
-
def get_template(document,
|
177
|
-
|
178
|
-
|
144
|
+
def get_template(document, attrs, tmpl_type)
|
145
|
+
tmpl_folder = DEFAULT_TEMPLATE_PATH
|
146
|
+
if attrs["tmpl_folder"]
|
147
|
+
tmpl_folder = attrs["tmpl_folder"]
|
179
148
|
end
|
149
|
+
template_path = get_default_template_path(tmpl_type, tmpl_folder,
|
150
|
+
attrs)
|
180
151
|
|
181
152
|
rel_tmpl_path = Utils.relative_file_path(
|
182
153
|
document, template_path
|
@@ -185,15 +156,17 @@ module Metanorma
|
|
185
156
|
::Liquid::Template.parse(File.read(rel_tmpl_path))
|
186
157
|
end
|
187
158
|
|
188
|
-
def get_default_template_path(tmpl_type)
|
189
|
-
case tmpl_type
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
159
|
+
def get_default_template_path(tmpl_type, tmpl_folder, attrs)
|
160
|
+
liquid_template = case tmpl_type
|
161
|
+
when :row
|
162
|
+
attrs["row_tmpl_name"] || "_klass_row"
|
163
|
+
when :assoc_row
|
164
|
+
attrs["assoc_row_tmpl_name"] || "_klass_assoc_row"
|
165
|
+
else
|
166
|
+
attrs["table_tmpl_name"] || "_klass_table"
|
167
|
+
end
|
168
|
+
|
169
|
+
File.join(tmpl_folder, "#{liquid_template}.liquid")
|
197
170
|
end
|
198
171
|
end
|
199
172
|
end
|
@@ -3,6 +3,7 @@ require "metanorma/plugin/lutaml/lutaml_preprocessor"
|
|
3
3
|
require "metanorma/plugin/lutaml/lutaml_uml_class_preprocessor"
|
4
4
|
require "metanorma/plugin/lutaml/lutaml_uml_attributes_table_preprocessor"
|
5
5
|
require "metanorma/plugin/lutaml/lutaml_uml_datamodel_description_preprocessor"
|
6
|
+
require "metanorma/plugin/lutaml/lutaml_ea_xmi_preprocessor"
|
6
7
|
require "metanorma/plugin/lutaml/lutaml_diagram_block"
|
7
8
|
require "metanorma/plugin/lutaml/lutaml_diagram_block_macro"
|
8
9
|
require "metanorma/plugin/lutaml/lutaml_figure_inline_macro"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metanorma-plugin-lutaml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-09-
|
11
|
+
date: 2024-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|
@@ -355,6 +355,7 @@ files:
|
|
355
355
|
- lib/metanorma/plugin/lutaml/lutaml_diagram_block.rb
|
356
356
|
- lib/metanorma/plugin/lutaml/lutaml_diagram_block_macro.rb
|
357
357
|
- lib/metanorma/plugin/lutaml/lutaml_ea_diagram_block_macro.rb
|
358
|
+
- lib/metanorma/plugin/lutaml/lutaml_ea_xmi_preprocessor.rb
|
358
359
|
- lib/metanorma/plugin/lutaml/lutaml_figure_inline_macro.rb
|
359
360
|
- lib/metanorma/plugin/lutaml/lutaml_gml_dictionary_base.rb
|
360
361
|
- lib/metanorma/plugin/lutaml/lutaml_gml_dictionary_block.rb
|