metanorma-plugin-lutaml 0.7.37 → 0.7.38
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/docs/usages/enterprise_architect.adoc +17 -0
- data/lib/metanorma/plugin/lutaml/base_structured_text_preprocessor.rb +1 -1
- data/lib/metanorma/plugin/lutaml/express_remarks_decorator.rb +1 -1
- data/lib/metanorma/plugin/lutaml/lutaml_ea_xmi_base.rb +39 -0
- data/lib/metanorma/plugin/lutaml/lutaml_enum_table_block_macro.rb +7 -39
- data/lib/metanorma/plugin/lutaml/lutaml_klass_table_block_macro.rb +7 -39
- data/lib/metanorma/plugin/lutaml/lutaml_preprocessor.rb +4 -1
- data/lib/metanorma/plugin/lutaml/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cb242e5ff7bfcfa7b4baec472a6fc0ecf0be94558913c8bb39bcf19655640e12
|
|
4
|
+
data.tar.gz: 81455de9a154af7534d43830562613fbee00bd8ce2c252ce13be79fc790efaec
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c84b7143c72c6bbb6334bc9c27faea196a516edd34c67607579f61b0a371be648c9087e5b297159f98d60654f43ffc9a2c736a5e5c546196f7251917cc042d28
|
|
7
|
+
data.tar.gz: b68b53795e9576abc2e1beb3746219ae2ca0ab8e888ab15f0c79430f94eedb870a568fe425e9a3ae503ba34e03d603436cc2dcb0cd64068500d30db421e079e5
|
|
@@ -184,6 +184,15 @@ The command accepts the options listed below:
|
|
|
184
184
|
`lib/metanorma/plugin/lutaml/templates`. This template can be customized by
|
|
185
185
|
changing the template path in the `template` option.
|
|
186
186
|
|
|
187
|
+
* `external_data="context_name:/path/to/my_data.yml"` specifies the path of
|
|
188
|
+
the YAML/JSON file of the external data to be used in the liquid template.
|
|
189
|
+
(Optional)
|
|
190
|
+
You can specify multiple external data by separating them with `;`.
|
|
191
|
+
(e.g. `external_data="my_data:/path/to/my_data.yml;second_data:/path/to/my_second_data.yml"`)
|
|
192
|
+
In the liquid template, you can access the data by using `context_name`.
|
|
193
|
+
(e.g. `my_data` or `second_data` in the above example)
|
|
194
|
+
The external data file should be in YAML/JSON format.
|
|
195
|
+
|
|
187
196
|
* `guidance="/path/to/my_guidance.yml"` specifies the path of
|
|
188
197
|
the yaml file of the guidance. (Optional)
|
|
189
198
|
|
|
@@ -240,6 +249,14 @@ The command accepts the options listed below:
|
|
|
240
249
|
`lib/metanorma/plugin/lutaml/templates`. This template can be customized by
|
|
241
250
|
changing the template path in the `template` option.
|
|
242
251
|
|
|
252
|
+
* `external_data="context_name:/path/to/my_data.yml"` specifies the path of
|
|
253
|
+
the YAML/JSON file of the external data to be used in the liquid template.
|
|
254
|
+
(Optional)
|
|
255
|
+
You can specify multiple external data by separating them with `;`.
|
|
256
|
+
(e.g. `external_data="my_data:/path/to/my_data.yml;second_data:/path/to/my_second_data.yml"`)
|
|
257
|
+
In the liquid template, you can access the data by using `context_name`.
|
|
258
|
+
(e.g. `my_data` or `second_data` in the above example)
|
|
259
|
+
The external data file should be in YAML/JSON format.
|
|
243
260
|
|
|
244
261
|
=== Usage of `lutaml_ea_xmi` command
|
|
245
262
|
|
|
@@ -153,7 +153,7 @@ module Metanorma
|
|
|
153
153
|
end
|
|
154
154
|
line
|
|
155
155
|
.gsub(/(?<!{){(?!%)([^{}]{1,900})(?<!%)}(?!})/, '{{\1}}')
|
|
156
|
-
.gsub(/[a-z
|
|
156
|
+
.gsub(/[a-z.]{1,900}\#/, "index")
|
|
157
157
|
.gsub(/{{([^}]{1,900})\s+\+\s+(\d+)\s*?}}/, '{{ \1 | plus: \2 }}')
|
|
158
158
|
.gsub(/{{([^}]{1,900})\s+-\s+(\d+)\s*?}}/, '{{ \1 | minus: \2 }}')
|
|
159
159
|
.gsub(/{{([^}]{1,500})\.values([^}]{0,500})}}/,
|
|
@@ -9,7 +9,7 @@ module Metanorma
|
|
|
9
9
|
(link|image|video|audio|include) # Capture group 1: content type
|
|
10
10
|
(:+)? # Capture group 2: optional colons
|
|
11
11
|
(?! # Negative lookahead
|
|
12
|
-
[
|
|
12
|
+
[^/:]+://| # Don't match URLs (http://, etc.)
|
|
13
13
|
[A-Z]:/| # Don't match Windows paths
|
|
14
14
|
/ # Don't match absolute paths
|
|
15
15
|
) # End negative lookahead
|
|
@@ -434,6 +434,45 @@ module Metanorma
|
|
|
434
434
|
{% 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 %}
|
|
435
435
|
LIQUID
|
|
436
436
|
end
|
|
437
|
+
|
|
438
|
+
def render_table(context, context_name, parent, attrs) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
|
439
|
+
table_tmpl = get_template(parent.document, attrs)
|
|
440
|
+
table_tmpl.assigns[context_name] = context
|
|
441
|
+
|
|
442
|
+
if attrs["external_data"]
|
|
443
|
+
data_array = attrs["external_data"].split(";")
|
|
444
|
+
data_array.each do |data_item|
|
|
445
|
+
context_name, external_data_path = data_item.split(":")
|
|
446
|
+
external_data = content_from_file(
|
|
447
|
+
parent.document, external_data_path.strip
|
|
448
|
+
)
|
|
449
|
+
table_tmpl.assigns[context_name.strip] = external_data
|
|
450
|
+
end
|
|
451
|
+
end
|
|
452
|
+
|
|
453
|
+
rendered_table = table_tmpl.render
|
|
454
|
+
block = create_open_block(parent, "", attrs)
|
|
455
|
+
parse_content(block, rendered_table, attrs)
|
|
456
|
+
end
|
|
457
|
+
|
|
458
|
+
def get_template(document, attrs)
|
|
459
|
+
template = get_default_template
|
|
460
|
+
template = attrs["template"] if attrs["template"]
|
|
461
|
+
|
|
462
|
+
rel_tmpl_path = Utils.relative_file_path(
|
|
463
|
+
document, template
|
|
464
|
+
)
|
|
465
|
+
|
|
466
|
+
::Liquid::Template.parse(File.read(rel_tmpl_path))
|
|
467
|
+
end
|
|
468
|
+
|
|
469
|
+
def get_name_path(attrs)
|
|
470
|
+
return attrs["path"] if attrs["path"]
|
|
471
|
+
|
|
472
|
+
return "#{attrs['package']}::#{attrs['name']}" if attrs["package"]
|
|
473
|
+
|
|
474
|
+
attrs["name"]
|
|
475
|
+
end
|
|
437
476
|
end
|
|
438
477
|
end
|
|
439
478
|
end
|
|
@@ -6,6 +6,7 @@ module Metanorma
|
|
|
6
6
|
class LutamlEnumTableBlockMacro <
|
|
7
7
|
::Asciidoctor::Extensions::BlockMacroProcessor
|
|
8
8
|
include LutamlEaXmiBase
|
|
9
|
+
include Content
|
|
9
10
|
|
|
10
11
|
DEFAULT_TEMPLATE = File.join(
|
|
11
12
|
Gem::Specification.find_by_name("metanorma-plugin-lutaml").gem_dir,
|
|
@@ -13,59 +14,26 @@ module Metanorma
|
|
|
13
14
|
"_enum_table.liquid"
|
|
14
15
|
)
|
|
15
16
|
|
|
17
|
+
CONTEXT_NAME = "enum"
|
|
18
|
+
|
|
16
19
|
use_dsl
|
|
17
20
|
named :lutaml_enum_table
|
|
18
21
|
|
|
19
22
|
def process(parent, target, attrs) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
|
20
23
|
xmi_path = get_xmi_path(parent, target, attrs)
|
|
21
|
-
|
|
22
|
-
if attrs["template"]
|
|
23
|
-
attrs["template"] = Utils.relative_file_path(
|
|
24
|
-
parent.document, attrs["template"]
|
|
25
|
-
)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
path = if !attrs["path"].nil?
|
|
29
|
-
attrs["path"]
|
|
30
|
-
elsif !attrs["package"].nil? && !attrs["name"].nil?
|
|
31
|
-
"#{attrs['package']}::#{attrs['name']}"
|
|
32
|
-
else
|
|
33
|
-
attrs["name"]
|
|
34
|
-
end
|
|
24
|
+
path = get_name_path(attrs)
|
|
35
25
|
|
|
36
26
|
enum = ::Lutaml::XMI::Parsers::XML.serialize_enumeration_by_name(
|
|
37
27
|
xmi_path, path
|
|
38
28
|
)
|
|
39
29
|
|
|
40
|
-
|
|
30
|
+
render_table(enum, CONTEXT_NAME, parent, attrs)
|
|
41
31
|
end
|
|
42
32
|
|
|
43
33
|
private
|
|
44
34
|
|
|
45
|
-
def
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
block = create_open_block(parent, "", attrs)
|
|
49
|
-
parse_content(block, rendered_table, attrs)
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def render_table(enum, parent, attrs)
|
|
53
|
-
table_tmpl = get_template(parent.document, attrs)
|
|
54
|
-
table_tmpl.assigns["enum"] = enum
|
|
55
|
-
table_tmpl.render
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
def get_template(document, attrs)
|
|
59
|
-
template = DEFAULT_TEMPLATE
|
|
60
|
-
if attrs["template"]
|
|
61
|
-
template = attrs["template"]
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
rel_tmpl_path = Utils.relative_file_path(
|
|
65
|
-
document, template
|
|
66
|
-
)
|
|
67
|
-
|
|
68
|
-
::Liquid::Template.parse(File.read(rel_tmpl_path))
|
|
35
|
+
def get_default_template
|
|
36
|
+
DEFAULT_TEMPLATE
|
|
69
37
|
end
|
|
70
38
|
end
|
|
71
39
|
end
|
|
@@ -6,6 +6,7 @@ module Metanorma
|
|
|
6
6
|
class LutamlKlassTableBlockMacro <
|
|
7
7
|
::Asciidoctor::Extensions::BlockMacroProcessor
|
|
8
8
|
include LutamlEaXmiBase
|
|
9
|
+
include Content
|
|
9
10
|
|
|
10
11
|
DEFAULT_TEMPLATE = File.join(
|
|
11
12
|
Gem::Specification.find_by_name("metanorma-plugin-lutaml").gem_dir,
|
|
@@ -13,64 +14,31 @@ module Metanorma
|
|
|
13
14
|
"_klass_table.liquid"
|
|
14
15
|
)
|
|
15
16
|
|
|
17
|
+
CONTEXT_NAME = "klass"
|
|
18
|
+
|
|
16
19
|
use_dsl
|
|
17
20
|
named :lutaml_klass_table
|
|
18
21
|
|
|
19
22
|
def process(parent, target, attrs) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
|
20
23
|
xmi_path = get_xmi_path(parent, target, attrs)
|
|
21
|
-
|
|
22
|
-
if attrs["template"]
|
|
23
|
-
attrs["template"] = Utils.relative_file_path(
|
|
24
|
-
parent.document, attrs["template"]
|
|
25
|
-
)
|
|
26
|
-
end
|
|
24
|
+
path = get_name_path(attrs)
|
|
27
25
|
|
|
28
26
|
guidance = nil
|
|
29
27
|
if attrs["guidance"]
|
|
30
28
|
guidance = get_guidance(parent.document, attrs["guidance"])
|
|
31
29
|
end
|
|
32
30
|
|
|
33
|
-
path = if !attrs["path"].nil?
|
|
34
|
-
attrs["path"]
|
|
35
|
-
elsif !attrs["package"].nil? && !attrs["name"].nil?
|
|
36
|
-
"#{attrs['package']}::#{attrs['name']}"
|
|
37
|
-
else
|
|
38
|
-
attrs["name"]
|
|
39
|
-
end
|
|
40
|
-
|
|
41
31
|
klass = ::Lutaml::XMI::Parsers::XML.serialize_generalization_by_name(
|
|
42
32
|
xmi_path, path, guidance
|
|
43
33
|
)
|
|
44
34
|
|
|
45
|
-
|
|
35
|
+
render_table(klass, CONTEXT_NAME, parent, attrs)
|
|
46
36
|
end
|
|
47
37
|
|
|
48
38
|
private
|
|
49
39
|
|
|
50
|
-
def
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
block = create_open_block(parent, "", attrs)
|
|
54
|
-
parse_content(block, rendered_table, attrs)
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
def render_table(klass, parent, attrs)
|
|
58
|
-
table_tmpl = get_template(parent.document, attrs)
|
|
59
|
-
table_tmpl.assigns["klass"] = klass
|
|
60
|
-
table_tmpl.render
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def get_template(document, attrs)
|
|
64
|
-
template = DEFAULT_TEMPLATE
|
|
65
|
-
if attrs["template"]
|
|
66
|
-
template = attrs["template"]
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
rel_tmpl_path = Utils.relative_file_path(
|
|
70
|
-
document, template
|
|
71
|
-
)
|
|
72
|
-
|
|
73
|
-
::Liquid::Template.parse(File.read(rel_tmpl_path))
|
|
40
|
+
def get_default_template
|
|
41
|
+
DEFAULT_TEMPLATE
|
|
74
42
|
end
|
|
75
43
|
end
|
|
76
44
|
end
|
|
@@ -13,6 +13,8 @@ module Metanorma
|
|
|
13
13
|
module Lutaml
|
|
14
14
|
# Class for processing Lutaml files
|
|
15
15
|
class LutamlPreprocessor < ::Asciidoctor::Extensions::Preprocessor
|
|
16
|
+
include Utils
|
|
17
|
+
|
|
16
18
|
REMARKS_ATTRIBUTE = "remarks"
|
|
17
19
|
EXPRESS_PREPROCESSOR_REGEX = %r{
|
|
18
20
|
^ # Start of line
|
|
@@ -225,7 +227,8 @@ module Metanorma
|
|
|
225
227
|
.new(include_paths, ["%s.liquid", "_%s.liquid", "_%s.adoc"])
|
|
226
228
|
|
|
227
229
|
# Parse template once outside the loop
|
|
228
|
-
template = ::Liquid::Template
|
|
230
|
+
template = ::Liquid::Template
|
|
231
|
+
.parse(lines.join("\n"), environment: create_liquid_environment)
|
|
229
232
|
template.registers[:file_system] = file_system
|
|
230
233
|
|
|
231
234
|
# Render for each item
|
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.38
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-10-
|
|
11
|
+
date: 2025-10-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: asciidoctor
|