metanorma-plugin-lutaml 0.4.18.2 → 0.4.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/metanorma/plugin/lutaml/liquid_templates/_packages.liquid +1 -1
- data/lib/metanorma/plugin/lutaml/liquid_templates/_packages_data_dictionary.liquid +10 -10
- data/lib/metanorma/plugin/lutaml/liquid_templates/_packages_data_dictionary_class.liquid +20 -6
- data/lib/metanorma/plugin/lutaml/lutaml_preprocessor.rb +28 -13
- data/lib/metanorma/plugin/lutaml/version.rb +1 -1
- data/metanorma-plugin-lutaml.gemspec +4 -3
- metadata +4 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e771e99cf0ac118f04aa3b40610b0e071ff98d78ebaa34b7ac4516636a2e1808
|
4
|
+
data.tar.gz: 17ae5e488c425071a80aaa0799736b1f336611ef0caa68e2eebaa0788df86383
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8260ba15824b2e1838e34e3ba3f5d954ee3dfaf6b697821ce55972aa8b428ea12a932b6eafb71275e5958b971f65a30481431c86a34f1de9e6b1a28d7c68010c
|
7
|
+
data.tar.gz: '008027e782ef69b19b6132a6fd139b8f04cd7dd5cc6e7ada361ef4c70c36923023213d3eccc4b30118c64421574700d1cf83677969047d99bceaf440e08bd8e4'
|
@@ -1,5 +1,5 @@
|
|
1
1
|
{% for package in context.packages %}
|
2
|
-
{% assign package_name = package.name | downcase | replace: ":", "" | replace: " ", "_" %}
|
2
|
+
{% assign package_name = package.name | downcase | replace: ":", "" | replace: " ", "_" | replace: "-", "_" %}
|
3
3
|
{% if additional_context.before and additional_context.before.size > 0 %}
|
4
4
|
{% for before in additional_context.before %}
|
5
5
|
{% if before.text %}
|
@@ -67,13 +67,13 @@
|
|
67
67
|
{% endfor %}
|
68
68
|
{% endif %}
|
69
69
|
|
70
|
-
.Metadata of {{ package.name }}
|
70
|
+
.Metadata of {{ package.name }} {% if package.stereotype %}(«{{package.stereotype}}»){% endif %}
|
71
71
|
[cols="1a,4a"]
|
72
72
|
|===
|
73
73
|
|
74
|
-
h|Description: | {{ package.definition | replace: '|', '\|' }}
|
74
|
+
h|Description: | {{ package.definition | replace: '|', '\|' | html2adoc }}
|
75
75
|
h|Parent package: | {{ context.name }}
|
76
|
-
h|Stereotype: | «{{
|
76
|
+
h|Stereotype: | {% if package.stereotype %}«{{package.stereotype}}»{% else %}None{% endif %}
|
77
77
|
|
78
78
|
|===
|
79
79
|
|
@@ -139,12 +139,12 @@ None.
|
|
139
139
|
[[section-{{ data_type.xmi_id }}]]
|
140
140
|
{{equalsigns}}== {{ data_type.name }}
|
141
141
|
|
142
|
-
.Metadata of {{ data_type.name }}
|
142
|
+
.Metadata of {{ data_type.name }} {% if data_type.stereotype %}(«{{data_type.stereotype}}»){% endif %}
|
143
143
|
[cols="1a,4a"]
|
144
144
|
|===
|
145
|
-
h|Definition: | {{ data_type.definition | replace: '|', '\|' }}
|
145
|
+
h|Definition: | {{ data_type.definition | replace: '|', '\|' | html2adoc }}
|
146
146
|
h|Subclass of: | {% if generalizations.size > 0 %}{{ generalizations }}{% else %}None{% endif %}
|
147
|
-
h|Stereotype: | «{{
|
147
|
+
h|Stereotype: | {% if data_type.stereotype %}«{{data_type.stereotype}}»{% else %}None{% endif %}
|
148
148
|
|
149
149
|
{% if data_type.constraints.size > 0 %}
|
150
150
|
{% for constraint in data_type.constraints %}
|
@@ -167,7 +167,7 @@ h| Constraint:
|
|
167
167
|
{% capture cardinality %}[{% case assoc.member_end_cardinality.min %}{% when "C" %}0{% when "M" %}1{% else %}{{assoc.member_end_cardinality.min}}{% endcase %}..{{ assoc.member_end_cardinality.max }}]{% endcapture %}
|
168
168
|
| {{ assoc.member_end_attribute_name }}
|
169
169
|
{% if additional_context.external_classes[assoc.member_end] %}| <<{{ additional_context.external_classes[assoc.member_end] }},{{assoc.member_end}}>> {{ cardinality }}{% else %}| <<section-{{ assoc.member_end_xmi_id }},{{assoc.member_end}}>> {{ cardinality }}{% endif %}
|
170
|
-
| {{ assoc.definition | replace: '|', '\|' }}
|
170
|
+
| {{ assoc.definition | replace: '|', '\|' | html2adoc }}
|
171
171
|
{% endif %}
|
172
172
|
{% endfor %}
|
173
173
|
{% endcapture %}
|
@@ -196,7 +196,7 @@ h| Constraint:
|
|
196
196
|
{% capture cardinality %}[{% case attr.cardinality.min %}{% when 'C' %}0{% when 'M' %}1{% else %}{{ attr.cardinality.min }}{% endcase %}..{{ attr.cardinality.max }}]{% endcapture %}
|
197
197
|
| {{ attr.name }}
|
198
198
|
{% if additional_context.external_classes[attr.type] %}| <<{{ additional_context.external_classes[attr.type] }},{{ attr.type }}>> {{ cardinality }}{% else %}| <<section-{{ attr.xmi_id }},{{ attr.type }}>> {{ cardinality }}{% endif %}
|
199
|
-
| {{ attr.definition | replace: '|', '\|' }}
|
199
|
+
| {{ attr.definition | replace: '|', '\|' | html2adoc }}
|
200
200
|
|
201
201
|
{% endfor %}
|
202
202
|
|===
|
@@ -223,7 +223,7 @@ None.
|
|
223
223
|
.Metadata of {{ enum.name }} (Enumeration)
|
224
224
|
[cols="1a,4a"]
|
225
225
|
|===
|
226
|
-
h|Definition: | {{ enum.definition | replace: '|', '\|' }}
|
226
|
+
h|Definition: | {{ enum.definition | replace: '|', '\|' | html2adoc }}
|
227
227
|
h|Stereotype: | «Enumeration»
|
228
228
|
|===
|
229
229
|
|
@@ -235,7 +235,7 @@ h|Stereotype: | «Enumeration»
|
|
235
235
|
|
236
236
|
{% for val in enum.values %}
|
237
237
|
| {{ val.name }}
|
238
|
-
| {{ val.definition | replace: '|', '\|' }}
|
238
|
+
| {{ val.definition | replace: '|', '\|' | html2adoc }}
|
239
239
|
|
240
240
|
{% endfor %}
|
241
241
|
|
@@ -4,12 +4,26 @@
|
|
4
4
|
{{equalsigns}} {{ klass.name }}
|
5
5
|
{%comment%}(inside class: depth is {{ depth }}, equalsigns {{equalsigns}}){%endcomment%}
|
6
6
|
|
7
|
-
.Metadata of {{ klass.name }} ({{klass.stereotype}})
|
7
|
+
.Metadata of {{ klass.name }} {% if klass.stereotype %}(«{{klass.stereotype}}»){% endif %}
|
8
8
|
[cols="1a,4a"]
|
9
9
|
|===
|
10
|
-
h| Definition:
|
11
|
-
|
12
|
-
|
10
|
+
h| Definition:
|
11
|
+
|
|
12
|
+
{% if klass.definition %}
|
13
|
+
{{ klass.definition | replace: '|', '\|' | html2adoc }}
|
14
|
+
{% endif %}
|
15
|
+
|
16
|
+
h| Subclass of:
|
17
|
+
|
|
18
|
+
{% if generalizations.size > 0 %}{{ generalizations }}{% else %}None{% endif %}
|
19
|
+
|
20
|
+
h| Stereotype:
|
21
|
+
|
|
22
|
+
{% if klass.stereotype %}
|
23
|
+
«{{ klass.stereotype }}»
|
24
|
+
{% else %}
|
25
|
+
None
|
26
|
+
{% endif %}
|
13
27
|
|
14
28
|
{% if klass.constraints.size > 0 %}
|
15
29
|
{% for constraint in klass.constraints %}
|
@@ -32,7 +46,7 @@ h| Constraint:
|
|
32
46
|
{% capture cardinality %}[{% case assoc.member_end_cardinality.min %}{% when "C" %}0{% when "M" %}1{% else %}{{assoc.member_end_cardinality.min}}{% endcase %}..{{ assoc.member_end_cardinality.max }}]{% endcapture %}
|
33
47
|
| {{ assoc.member_end_attribute_name }}
|
34
48
|
{% if additional_context.external_classes[assoc.member_end] %}| <<{{ additional_context.external_classes[assoc.member_end] }},{{assoc.member_end}}>> {{ cardinality }}{% else %}| <<section-{{ assoc.member_end_xmi_id }},{{ assoc.member_end }}>> {{ cardinality }}{% endif %}
|
35
|
-
| {{ assoc.definition | replace: '|', '\|' }}
|
49
|
+
| {{ assoc.definition | replace: '|', '\|' | html2adoc }}
|
36
50
|
{% endif %}
|
37
51
|
{% endfor %}
|
38
52
|
{% endcapture %}
|
@@ -60,7 +74,7 @@ h| Constraint:
|
|
60
74
|
{% capture cardinality %}[{% case attr.cardinality.min %}{% when 'C' %}0{% when 'M' %}1{% else %}{{ attr.cardinality.min }}{% endcase %}..{{ attr.cardinality.max }}]{% endcapture %}
|
61
75
|
| {{ attr.name }}
|
62
76
|
{% if additional_context.external_classes[attr.type] %}| <<{{ additional_context.external_classes[attr.type] }},{{ attr.type }}>> {{ cardinality }}{% else %}| <<section-{{ attr.xmi_id }},{{ attr.type }}>> {{ cardinality }}{% endif %}
|
63
|
-
| {{ attr.definition | replace: '|', '\|' }}
|
77
|
+
| {{ attr.definition | replace: '|', '\|' | html2adoc }}
|
64
78
|
|
65
79
|
{% endfor %}
|
66
80
|
|===
|
@@ -12,24 +12,38 @@ module Metanorma
|
|
12
12
|
module Lutaml
|
13
13
|
# Class for processing Lutaml files
|
14
14
|
class LutamlPreprocessor < Asciidoctor::Extensions::Preprocessor
|
15
|
-
REMARKS_ATTRIBUTE = "remarks"
|
15
|
+
REMARKS_ATTRIBUTE = "remarks"
|
16
16
|
|
17
17
|
def process(document, reader)
|
18
18
|
input_lines = reader.readlines.to_enum
|
19
|
+
has_lutaml = !input_lines.select { |x| lutaml?(x) }.empty?
|
19
20
|
express_indexes = Utils.parse_document_express_indexes(
|
20
21
|
document,
|
21
|
-
input_lines
|
22
|
+
input_lines,
|
22
23
|
)
|
23
|
-
result_content = processed_lines(document, input_lines,
|
24
|
-
|
25
|
-
|
24
|
+
result_content = processed_lines(document, input_lines,
|
25
|
+
express_indexes)
|
26
|
+
has_lutaml and log(document, result_content)
|
27
|
+
Asciidoctor::PreprocessorReader.new(document, result_content)
|
26
28
|
end
|
27
29
|
|
28
30
|
protected
|
29
31
|
|
32
|
+
def log(document, result)
|
33
|
+
File.open("#{document.attr('docfile')}.lutaml.log.txt",
|
34
|
+
"w:UTF-8") do |f|
|
35
|
+
f.write(result.join("\n"))
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def lutaml?(line)
|
40
|
+
line.match(/^\[(?:\blutaml\b|\blutaml_express\b),([^,]+)?,?([^,]+)?,?([^,]+)?\]/)
|
41
|
+
end
|
42
|
+
|
30
43
|
def content_from_files(document, file_paths)
|
31
44
|
file_list = file_paths.map do |file_path|
|
32
|
-
File.new(Utils.relative_file_path(document, file_path),
|
45
|
+
File.new(Utils.relative_file_path(document, file_path),
|
46
|
+
encoding: "UTF-8")
|
33
47
|
end
|
34
48
|
::Lutaml::Parser.parse(file_list)
|
35
49
|
end
|
@@ -43,7 +57,7 @@ module Metanorma
|
|
43
57
|
.push(*process_text_blocks(
|
44
58
|
document,
|
45
59
|
input_lines,
|
46
|
-
express_indexes
|
60
|
+
express_indexes,
|
47
61
|
))
|
48
62
|
end
|
49
63
|
result
|
@@ -51,7 +65,7 @@ module Metanorma
|
|
51
65
|
|
52
66
|
def process_text_blocks(document, input_lines, express_indexes)
|
53
67
|
line = input_lines.next
|
54
|
-
block_match = line
|
68
|
+
block_match = lutaml?(line)
|
55
69
|
return [line] if block_match.nil?
|
56
70
|
|
57
71
|
end_mark = input_lines.next
|
@@ -97,7 +111,8 @@ module Metanorma
|
|
97
111
|
result
|
98
112
|
end
|
99
113
|
|
100
|
-
def parse_template(document, current_block, block_match,
|
114
|
+
def parse_template(document, current_block, block_match,
|
115
|
+
express_indexes)
|
101
116
|
options = parse_options(block_match[3])
|
102
117
|
contexts_items(block_match, document, express_indexes)
|
103
118
|
.map do |items|
|
@@ -112,9 +127,9 @@ module Metanorma
|
|
112
127
|
context_items: items,
|
113
128
|
context_name: block_match[2].strip)
|
114
129
|
end.flatten
|
115
|
-
|
116
|
-
|
117
|
-
|
130
|
+
rescue StandardError => e
|
131
|
+
document.logger.warn("Failed to parse lutaml block: #{e.message}")
|
132
|
+
[]
|
118
133
|
end
|
119
134
|
|
120
135
|
def parse_options(options_string)
|
@@ -155,7 +170,7 @@ module Metanorma
|
|
155
170
|
template_string: context_lines.join("\n"),
|
156
171
|
context_items: context_items,
|
157
172
|
context_name: context_name,
|
158
|
-
document: document
|
173
|
+
document: document,
|
159
174
|
)
|
160
175
|
Utils.notify_render_errors(document, errors)
|
161
176
|
render_result.split("\n")
|
@@ -17,7 +17,9 @@ Gem::Specification.new do |spec|
|
|
17
17
|
# Specify which files should be added to the gem when it is released.
|
18
18
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
19
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
20
|
-
`git ls-files -z`.split("\x0").reject
|
20
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
21
|
+
f.match(%r{^(test|spec|features)/})
|
22
|
+
end
|
21
23
|
end
|
22
24
|
spec.bindir = "exe"
|
23
25
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
@@ -30,10 +32,9 @@ Gem::Specification.new do |spec|
|
|
30
32
|
spec.add_dependency "relaton-cli"
|
31
33
|
spec.add_dependency "reverse_adoc"
|
32
34
|
|
33
|
-
spec.add_development_dependency "
|
35
|
+
spec.add_development_dependency "debug"
|
34
36
|
spec.add_development_dependency "equivalent-xml"
|
35
37
|
spec.add_development_dependency "metanorma-standoc"
|
36
|
-
spec.add_development_dependency "pry", "~> 0.12.2"
|
37
38
|
spec.add_development_dependency "rake", "~> 13"
|
38
39
|
spec.add_development_dependency "rspec", "~> 3.6"
|
39
40
|
spec.add_development_dependency "rubocop", "= 0.54.0"
|
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.4.
|
4
|
+
version: 0.4.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|
@@ -95,7 +95,7 @@ dependencies:
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: debug
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
@@ -136,20 +136,6 @@ dependencies:
|
|
136
136
|
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
|
-
- !ruby/object:Gem::Dependency
|
140
|
-
name: pry
|
141
|
-
requirement: !ruby/object:Gem::Requirement
|
142
|
-
requirements:
|
143
|
-
- - "~>"
|
144
|
-
- !ruby/object:Gem::Version
|
145
|
-
version: 0.12.2
|
146
|
-
type: :development
|
147
|
-
prerelease: false
|
148
|
-
version_requirements: !ruby/object:Gem::Requirement
|
149
|
-
requirements:
|
150
|
-
- - "~>"
|
151
|
-
- !ruby/object:Gem::Version
|
152
|
-
version: 0.12.2
|
153
139
|
- !ruby/object:Gem::Dependency
|
154
140
|
name: rake
|
155
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -316,7 +302,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
316
302
|
- !ruby/object:Gem::Version
|
317
303
|
version: '0'
|
318
304
|
requirements: []
|
319
|
-
rubygems_version: 3.
|
305
|
+
rubygems_version: 3.3.26
|
320
306
|
signing_key:
|
321
307
|
specification_version: 4
|
322
308
|
summary: Metanorma plugin for LutaML
|