metanorma-plugin-lutaml 0.4.13 → 0.4.17

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c49af8286acd4f5489eb2e05561f365cf6597d8b7f5322950e376bceb85c7738
4
- data.tar.gz: 5c8a70a95bec419773bb11a387529994197bb12fd9e4dd882110ae57e33dc0b5
3
+ metadata.gz: b9de85f722161434bc11ef77517f1e739db67b01608aead2e935b8a38ff6594d
4
+ data.tar.gz: bf10f9594b2cf84b594c1dba9012e9979f1c3b3fd0339892f7302882039f7a9e
5
5
  SHA512:
6
- metadata.gz: f8bd4c3e9322bd693332f90b24130e2c685df40c0c073b6f145ed894980e965e91d3bdccd31e58b827b73d046589bd3b8e2ad23a6e6f3f68d3760403a019029c
7
- data.tar.gz: b94cb8be15a1da9111999bd7b85e97515f5677ec29b8165358c1232f49bb0c6c007db09eb6163423333e9087ff2ef593f1a9d259328b5136e587003bb6f72140
6
+ metadata.gz: e6125065c5246f84dee92b5894f0ffb5353c55cc1b8fc3e5355e738096b4db1b005a9ef5913070c6d2130cff77338c0913e3d8ba8bb93ef7a619415cfe2ae6a8
7
+ data.tar.gz: a77a4b168701ea0a425fd6bdf9cff83195926c16ff1be07db7bbb775e7d43d29a74d7754e9e43aeda508a16bd0d5096aee84c1dca5e1c4fa949de617cf5781a9
@@ -10,34 +10,6 @@ on:
10
10
 
11
11
  jobs:
12
12
  rake:
13
- name: Test on Ruby ${{ matrix.ruby }} ${{ matrix.os }}
14
- runs-on: ${{ matrix.os }}
15
- continue-on-error: ${{ matrix.experimental }}
16
- strategy:
17
- fail-fast: false
18
- matrix:
19
- ruby: [ '3.0', '2.7', '2.6', '2.5' ]
20
- os: [ ubuntu-latest, windows-latest, macos-latest ]
21
- experimental: [ false ]
22
- steps:
23
- - uses: actions/checkout@master
24
-
25
- - uses: ruby/setup-ruby@v1
26
- with:
27
- ruby-version: ${{ matrix.ruby }}
28
- bundler-cache: true
29
-
30
- - uses: metanorma/metanorma-build-scripts/plantuml-setup-action@master
31
-
32
- - run: bundle exec rake
33
-
34
- tests-passed:
35
- needs: rake
36
- runs-on: ubuntu-latest
37
- steps:
38
- - uses: peter-evans/repository-dispatch@v1
39
- with:
40
- token: ${{ secrets.METANORMA_CI_PAT_TOKEN || secrets.GITHUB_TOKEN }}
41
- repository: ${{ github.repository }}
42
- event-type: tests-passed
43
- client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'
13
+ uses: metanorma/metanorma-build-scripts/.github/workflows/plantuml-rake.yml@main
14
+ secrets:
15
+ pat_token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
@@ -0,0 +1,24 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ name: release
4
+
5
+ on:
6
+ workflow_dispatch:
7
+ inputs:
8
+ next_version:
9
+ description: |
10
+ Next release version. Possible values: x.y.z, major, minor, patch or pre|rc|etc
11
+ required: true
12
+ default: 'skip'
13
+ push:
14
+ tags: [ v* ]
15
+
16
+ jobs:
17
+ release:
18
+ uses: metanorma/metanorma-build-scripts/.github/workflows/rubygems-release.yml@main
19
+ with:
20
+ next_version: ${{ github.event.inputs.next_version }}
21
+ event_name: ${{ github.event_name }}
22
+ secrets:
23
+ rubygems-api-key: ${{ secrets.METANORMA_CI_RUBYGEMS_API_KEY }}
24
+
data/README.adoc CHANGED
@@ -212,6 +212,80 @@ diagram MyView {
212
212
  ....
213
213
  ----
214
214
 
215
+ === Generating UML class and attributes: `lutaml_uml_class`
216
+
217
+ This command allows rendering a definition clause for a UML class.
218
+
219
+ Given `example.lutaml` with this content:
220
+
221
+ [source,java]
222
+ ----
223
+ class Register {
224
+ definition {
225
+ A register of information.
226
+ }
227
+
228
+ identifier: String[1] {
229
+ definition {
230
+ Unique identifier of the register.
231
+ }
232
+ }
233
+
234
+ concepts: Concept[0..*] {
235
+ definition {
236
+ Concepts.
237
+ }
238
+ }
239
+ }
240
+ ----
241
+
242
+ The command:
243
+
244
+ [source,adoc]
245
+ ----
246
+ [lutaml_uml_class,views/Register_Register.lutaml,Register]
247
+ ----
248
+
249
+ Will produce this output:
250
+
251
+ ____
252
+ == Register
253
+
254
+ A register of information.
255
+
256
+ === Attributes
257
+
258
+ ==== identifier
259
+
260
+ Unique identifier of the register.
261
+
262
+ .Specification of `Register.identifier`
263
+ |===
264
+ h|Value type and multiplicity | `String [1]`
265
+ |===
266
+
267
+ ==== concepts
268
+
269
+ Concepts.
270
+
271
+ .Specification of `Register.concepts`
272
+ |===
273
+ h|Value type and multiplicity | `Concepts [0..*]`
274
+ |===
275
+
276
+ ____
277
+
278
+ The command accepts two options:
279
+
280
+ * `skip_headers=true` (or just `skip_headers`). The initial heading (the UML class name)
281
+ will not be generated. This is useful if additional content is to be supplied
282
+ to the clause, such as diagrams that are defined outside the UML model.
283
+
284
+ * `depth={n}`. (default: `2`) This determines the depth of the generated headings.
285
+ A depth of `2` means the initial heading will have 2 equal signs, and so forth.
286
+ The heading depth of the attributes are in relation to the initial depth, so
287
+ a depth of `2` will have the "Attributes" section at depth `3`.
288
+
215
289
 
216
290
  === `lutaml_uml_attributes_table`
217
291
 
@@ -135,7 +135,7 @@ None.
135
135
  {% assign non_unions = package.data_types | where: "stereotype", "DataType" %}
136
136
  {% if non_unions.size > 0 %}
137
137
  {% for data_type in non_unions %}
138
- {% capture generalizations %}{% assign inheritance = klass.associations | where: "member_end_type", "inheritance" %}{% for assoc in inheritance %}{% capture ref_id %}{% if additional_context.external_classes[assoc.member_end] %}{{ additional_context.external_classes[assoc.member_end] }}{% else %}{{ assoc.member_end }}-section{% endif %}{% endcapture %}<<{{ ref_id }},{{ assoc.member_end }}>>{% endfor %}{% endcapture %}
138
+ {% capture generalizations %}{% assign inheritance = klass.associations | where: "member_end_type", "inheritance" %}{% for assoc in inheritance %}{% if additional_context.external_classes[assoc.member_end] %}<<{{ additional_context.external_classes[assoc.member_end] }},{{ assoc.member_end }}>>{% else %}<<section-{{ additional_context.external_classes[assoc.member_end] }},{{ assoc.member_end_xmi_id }}>>{% endif %}{% endfor %}{% endcapture %}
139
139
  [[section-{{ data_type.xmi_id }}]]
140
140
  {{equalsigns}}== {{ data_type.name }}
141
141
 
@@ -166,8 +166,7 @@ h| Constraint:
166
166
  {% if assoc.member_end_attribute_name.size > 0 %}
167
167
  {% capture cardinality %}&#91;{% case assoc.member_end_cardinality.min %}{% when "C" %}0{% when "M" %}1{% else %}{{assoc.member_end_cardinality.min}}{% endcase %}..{{ assoc.member_end_cardinality.max }}&#93;{% endcapture %}
168
168
  | {{ assoc.member_end_attribute_name }}
169
- {% capture ref_id %}{% if additional_context.external_classes[assoc.member_end] %}{{ additional_context.external_classes[assoc.member_end] }}{% else %}{{ assoc.member_end }}-section{% endif %}{% endcapture %}
170
- | <<{{ ref_id }},{{assoc.member_end}}>> {{ cardinality }}
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 %}
171
170
  | {{ assoc.definition | replace: '|', '\|' }}
172
171
  {% endif %}
173
172
  {% endfor %}
@@ -196,8 +195,7 @@ h| Constraint:
196
195
  {% for attr in data_type.attributes %}
197
196
  {% capture cardinality %}&#91;{% case attr.cardinality.min %}{% when 'C' %}0{% when 'M' %}1{% else %}{{ attr.cardinality.min }}{% endcase %}..{{ attr.cardinality.max }}&#93;{% endcapture %}
198
197
  | {{ attr.name }}
199
- {% capture ref_id %}{% if additional_context.external_classes[attr.type] %}{{ additional_context.external_classes[attr.type] }}{% else %}{{ attr.type }}-section{% endif %}{% endcapture %}
200
- | <<{{ ref_id }},{{ attr.type }}>> {{ cardinality }}
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 %}
201
199
  | {{ attr.definition | replace: '|', '\|' }}
202
200
 
203
201
  {% endfor %}
@@ -1,5 +1,5 @@
1
1
  {% capture equalsigns %}{% for count in (1..depth) %}={% endfor %}{% endcapture %}
2
- {% capture generalizations %}{% assign inheritance = klass.associations | where: "member_end_type", "inheritance" %}{% for assoc in inheritance %}{% capture ref_id %}{% if additional_context.external_classes[assoc.member_end] %}{{ additional_context.external_classes[assoc.member_end] }}{% else %}{{ assoc.member_end }}-section{% endif %}{% endcapture %}<<{{ ref_id }},{{ assoc.member_end }}>>{% endfor %}{% endcapture %}
2
+ {% capture generalizations %}{% assign inheritance = klass.associations | where: "member_end_type", "inheritance" %}{% for assoc in inheritance %}{% if additional_context.external_classes[assoc.member_end] %}<<{{ additional_context.external_classes[assoc.member_end] }},{{ assoc.member_end }}>>{% else %}<<section-{{ assoc.member_end_xmi_id }},{{ assoc.member_end }}>>{% endif %}{% endfor %}{% endcapture %}
3
3
  [[section-{{ klass.xmi_id }}]]
4
4
  {{equalsigns}} {{ klass.name }}
5
5
  {%comment%}(inside class: depth is {{ depth }}, equalsigns {{equalsigns}}){%endcomment%}
@@ -31,8 +31,7 @@ h| Constraint:
31
31
  {% if assoc.member_end_attribute_name.size > 0 %}
32
32
  {% capture cardinality %}&#91;{% case assoc.member_end_cardinality.min %}{% when "C" %}0{% when "M" %}1{% else %}{{assoc.member_end_cardinality.min}}{% endcase %}..{{ assoc.member_end_cardinality.max }}&#93;{% endcapture %}
33
33
  | {{ assoc.member_end_attribute_name }}
34
- {% capture ref_id %}{% if additional_context.external_classes[assoc.member_end] %}{{ additional_context.external_classes[assoc.member_end] }}{% else %}{{ assoc.member_end }}-section{% endif %}{% endcapture %}
35
- | <<{{ ref_id }},{{assoc.member_end}}>> {{ cardinality }}
34
+ {% 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 %}
36
35
  | {{ assoc.definition | replace: '|', '\|' }}
37
36
  {% endif %}
38
37
  {% endfor %}
@@ -60,8 +59,7 @@ h| Constraint:
60
59
  {% for attr in klass.attributes %}
61
60
  {% capture cardinality %}&#91;{% case attr.cardinality.min %}{% when 'C' %}0{% when 'M' %}1{% else %}{{ attr.cardinality.min }}{% endcase %}..{{ attr.cardinality.max }}&#93;{% endcapture %}
62
61
  | {{ attr.name }}
63
- {% capture ref_id %}{% if additional_context.external_classes[attr.type] %}{{ additional_context.external_classes[attr.type] }}{% else %}{{ attr.type }}-section{% endif %}{% endcapture %}
64
- | <<{{ ref_id }},{{ attr.type }}>> {{ cardinality }}
62
+ {% 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 %}
65
63
  | {{ attr.definition | replace: '|', '\|' }}
66
64
 
67
65
  {% endfor %}
@@ -89,8 +89,11 @@
89
89
 
90
90
  {% for klass in package.classes %}
91
91
  {% unless not_classes_stereotypes contains klass.stereotype %}
92
- {% capture ref_id %}{% if additional_context.external_classes[klass.name] %}{{ additional_context.external_classes[klass.name] }}{% else %}{{ klass.name }}-section{% endif %}{% endcapture %}
93
- | <<{{ ref_id }},{{ klass.name }}>> «{{ klass.stereotype }}»
92
+ {% if additional_context.external_classes[klass.name] %}
93
+ | <<{{ additional_context.external_classes[klass.name] }},{{ klass.name }}>> «{{ klass.stereotype }}»
94
+ {% else %}
95
+ | <<section-{{ klass.xmi_id }},{{ klass.name }}>> «{{ klass.stereotype }}»
96
+ {% endif %}
94
97
  | {{ klass.definition | replace: '|', '\|' }}
95
98
 
96
99
  {% endunless %}
@@ -98,7 +101,7 @@
98
101
  |===
99
102
  {% endunless %}
100
103
 
101
- {% assign non_unions = package.data_types | where: "stereotype", "DataType" %}
104
+ {% assign non_unions = package.data_types | where: "stereotype", "DataType" %}
102
105
  {% if non_unions.size > 0 %}
103
106
  {% include "packages_entity_list_classes", classes: non_unions, type: "Data types", depth: nested_depth %}
104
107
  {% endif %}
@@ -9,7 +9,7 @@
9
9
  {% assign package_name = package.name %}
10
10
  {% unless package_entities and package_entities[package_name][klass_name] != true %}
11
11
  {% unless not_classes_stereotypes contains klass.stereotype %}
12
- | <<{{ klass.name }}-section,{{ klass.name }}>> «{{ klass.stereotype }}»
12
+ | <<section-{{ klass.xmi_id }},{{ klass.name }}>> «{{ klass.stereotype }}»
13
13
  | {{ klass.definition | replace: '|', '\|' }}
14
14
 
15
15
  {% endunless %}
@@ -4,7 +4,7 @@
4
4
  |Name |Description
5
5
 
6
6
  {% for klass in classes %}
7
- | <<{{ klass.name }}-section,{{ klass.name }}>> «{{ klass.stereotype | default: "Enumeration" }}»
7
+ | <<section-{{ klass.xmi_id }},{{ klass.name }}>> «{{ klass.stereotype | default: "Enumeration" }}»
8
8
  | {{ klass.definition | replace: '|', '\|' }}
9
9
 
10
10
  {% endfor %}
@@ -5,7 +5,6 @@ require "asciidoctor"
5
5
  require "asciidoctor/reader"
6
6
  require "lutaml"
7
7
  require "metanorma/plugin/lutaml/utils"
8
- require "metanorma/plugin/lutaml/utils"
9
8
  require "metanorma/plugin/lutaml/express_remarks_decorator"
10
9
 
11
10
  module Metanorma
@@ -17,7 +17,7 @@ module Metanorma
17
17
  xmi_id = parent.document.attributes['lutaml_entity_id'][entity_key]
18
18
  return unless xmi_id
19
19
 
20
- %Q(<xref target="section-#{xmi_id}"></xref>)
20
+ %Q(<xref target="section-#{xmi_id}"/>)
21
21
  end
22
22
  end
23
23
  end
@@ -1,75 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "liquid"
4
- require "asciidoctor"
5
- require "asciidoctor/reader"
6
- require "lutaml"
7
- require "lutaml/uml"
8
- require "metanorma/plugin/lutaml/utils"
3
+ require_relative "./lutaml_uml_class_preprocessor.rb"
9
4
 
10
5
  module Metanorma
11
6
  module Plugin
12
7
  module Lutaml
13
8
  # Macro for quick rendering of datamodel attributes/values table
14
9
  # @example [lutaml_uml_attributes_table,path/to/lutaml,EntityName]
15
- class LutamlUmlAttributesTablePreprocessor < Asciidoctor::Extensions::Preprocessor
16
- MARCO_REGEXP =
10
+ class LutamlUmlAttributesTablePreprocessor < LutamlUmlClassPreprocessor
11
+ MACRO_REGEXP =
17
12
  /\[lutaml_uml_attributes_table,([^,]+),?([^,]+),?(.+?)?\]/
18
- # search document for block `datamodel_attributes_table`
19
- # read include derectives that goes after that in block and transform
20
- # into yaml2text blocks
21
- def process(document, reader)
22
- input_lines = reader.readlines.to_enum
23
- Asciidoctor::Reader.new(processed_lines(document, input_lines))
24
- end
25
-
26
- private
27
-
28
- def lutaml_document_from_file(document, file_path)
29
- ::Lutaml::Parser
30
- .parse(File.new(Utils.relative_file_path(document, file_path),
31
- encoding: "UTF-8"))
32
- .first
33
- end
34
-
35
- def processed_lines(document, input_lines)
36
- input_lines.each_with_object([]) do |line, result|
37
- if match = line.match(MARCO_REGEXP)
38
- lutaml_path = match[1]
39
- entity_name = match[2]
40
- skip_headers = match[3]
41
- result.push(*parse_marco(lutaml_path, entity_name, document, skip_headers))
42
- else
43
- result.push(line)
44
- end
45
- end
46
- end
47
-
48
- def parse_marco(lutaml_path, entity_name, document, skip_headers)
49
- lutaml_document = lutaml_document_from_file(document, lutaml_path)
50
- .serialized_document
51
- entities = [lutaml_document["classes"], lutaml_document["enums"]]
52
- .compact
53
- .flatten
54
- entity_definition = entities.detect do |klass|
55
- klass["name"] == entity_name.strip
56
- end
57
- model_representation(entity_definition, document, skip_headers)
58
- end
59
-
60
- def model_representation(entity_definition, document, skip_headers)
61
- render_result, errors = Utils.render_liquid_string(
62
- template_string: table_template(skip_headers),
63
- context_items: entity_definition,
64
- context_name: "definition",
65
- document: document
66
- )
67
- Utils.notify_render_errors(document, errors)
68
- render_result.split("\n")
69
- end
70
13
 
71
14
  # rubocop:disable Layout/IndentHeredoc
72
- def table_template(skip_headers)
15
+ def template(options)
16
+ skip_headers = options[:skip_headers]
17
+
73
18
  <<~TEMPLATE
74
19
  #{"=== {{ definition.name }}" unless skip_headers}
75
20
  {{ definition.definition }}
@@ -100,6 +45,7 @@ module Metanorma
100
45
  end
101
46
  # rubocop:enable Layout/IndentHeredoc
102
47
  end
48
+
103
49
  end
104
50
  end
105
51
  end
@@ -0,0 +1,163 @@
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 "metanorma/plugin/lutaml/utils"
9
+
10
+ module Metanorma
11
+ module Plugin
12
+ module Lutaml
13
+ # Macro for quick rendering of datamodel attributes/values table
14
+ # @example [lutaml_uml_class,path/to/lutaml,EntityName]
15
+ class LutamlUmlClassPreprocessor < Asciidoctor::Extensions::Preprocessor
16
+ MACRO_REGEXP =
17
+ /\[lutaml_uml_class,([^,]+),?([^,]+),?(.+?)?\]/
18
+
19
+ def get_macro_regexp
20
+ self.class.const_get(:MACRO_REGEXP)
21
+ end
22
+
23
+ # search document for block `datamodel_attributes_table`
24
+ # read include derectives that goes after that in block and transform
25
+ # into yaml2text blocks
26
+ def process(document, reader)
27
+ input_lines = reader.readlines.to_enum
28
+ Asciidoctor::Reader.new(processed_lines(document, input_lines))
29
+ end
30
+
31
+ private
32
+
33
+ def lutaml_document_from_file(document, file_path)
34
+ ::Lutaml::Parser.parse(
35
+ File.new(
36
+ Utils.relative_file_path(document, file_path),
37
+ encoding: "UTF-8")
38
+ ).first
39
+ end
40
+
41
+ DEFAULT_OPTIONS = {
42
+ depth: 2
43
+ }
44
+ def parse_options_to_hash(options_string)
45
+ return DEFAULT_OPTIONS.dup if options_string.nil? || options_string.empty?
46
+
47
+ opts = options_string.split(",").inject({}) do |acc,pair|
48
+ key, value = pair.split("=")
49
+ key = key.to_sym
50
+ value = true if value.nil?
51
+ value = value.to_i if key == :depth
52
+ acc[key] = value if key
53
+ acc
54
+ end
55
+
56
+ DEFAULT_OPTIONS.dup.merge(opts)
57
+ end
58
+
59
+ def processed_lines(document, input_lines)
60
+ input_lines.each_with_object([]) do |line, result|
61
+ if match = line.match(get_macro_regexp)
62
+ lutaml_path = match[1]
63
+ entity_name = match[2]
64
+ options = parse_options_to_hash(match[3])
65
+
66
+ result.push(*parse_marco(lutaml_path, entity_name, document, options))
67
+ else
68
+ result.push(line)
69
+ end
70
+ end
71
+ end
72
+
73
+ def parse_marco(lutaml_path, entity_name, document, options)
74
+ lutaml_document = lutaml_document_from_file(document, lutaml_path)
75
+ .serialized_document
76
+ entities = [lutaml_document["classes"], lutaml_document["enums"]]
77
+ .compact
78
+ .flatten
79
+ entity_definition = entities.detect do |klass|
80
+ klass["name"] == entity_name.strip
81
+ end
82
+ model_representation(entity_definition, document, options)
83
+ end
84
+
85
+ def model_representation(entity_definition, document, options)
86
+ render_result, errors = Utils.render_liquid_string(
87
+ template_string: template(options),
88
+ context_items: entity_definition,
89
+ context_name: "definition",
90
+ document: document
91
+ )
92
+ Utils.notify_render_errors(document, errors)
93
+ render_result.split("\n")
94
+ end
95
+
96
+ def equalsigns(depth)
97
+ "=" * depth
98
+ end
99
+
100
+ # rubocop:disable Layout/IndentHeredoc
101
+ def template(options)
102
+ skip_headers = options[:skip_headers]
103
+ depth = options[:depth]
104
+
105
+ <<~TEMPLATE
106
+ #{equalsigns(depth) + " {{ definition.name }}" unless skip_headers}
107
+ {{ definition.definition }}
108
+
109
+ {% if definition.attributes %}
110
+ {% if definition.keyword == 'enumeration' %}
111
+ .{{ definition.name }} values
112
+ |===
113
+ |Name |Definition
114
+
115
+ {% for item in definition.attributes %}
116
+ |{{ item.name }} |{{ item.definition }}
117
+ {% endfor %}
118
+ |===
119
+ {% else %}
120
+ #{equalsigns(depth+1)} Attributes
121
+
122
+ {% for item in definition.attributes %}
123
+ #{equalsigns(depth+2)} {{item.name}}
124
+
125
+ {% if item.definition %}
126
+ {{ item.definition }}
127
+ {% endif %}
128
+
129
+ .Specification of `{{ definition.name }}.{{ item.name }}`
130
+ [cols="h,a"]
131
+ |===
132
+
133
+ h|Value type and multiplicity
134
+ |
135
+ `{{ item.type }}`
136
+ {% if item.cardinality.min -%}
137
+ {% if item.cardinality.max -%}
138
+ `[{{item.cardinality.min}}..{{item.cardinality.max}}]`
139
+ {% else -%}
140
+ `[{{item.cardinality.min}}]`
141
+ {% endif -%}
142
+ {% else -%}
143
+ (multiplicity unspecified)
144
+ {% endif %}
145
+
146
+ {% if item.origin %}
147
+ h|Origin
148
+ |<<{{ item.origin }}>>
149
+ {% endif %}
150
+
151
+ |===
152
+ {% endfor %}
153
+
154
+ {% endif %}
155
+ {% endif %}
156
+
157
+ TEMPLATE
158
+ end
159
+ # rubocop:enable Layout/IndentHeredoc
160
+ end
161
+ end
162
+ end
163
+ end
@@ -14,7 +14,7 @@ module Metanorma
14
14
  # @example [lutaml_uml_attributes_table,path/to/lutaml,EntityName]
15
15
  class LutamlUmlDatamodelDescriptionPreprocessor <
16
16
  Asciidoctor::Extensions::Preprocessor
17
- MARCO_REGEXP =
17
+ MACRO_REGEXP =
18
18
  /\[lutaml_uml_datamodel_description,([^,]+),?(.+)?\]/
19
19
  LIQUID_INCLUDE_PATH = File.join(
20
20
  Gem.loaded_specs["metanorma-plugin-lutaml"].full_gem_path,
@@ -72,7 +72,7 @@ module Metanorma
72
72
 
73
73
  def process_text_blocks(document, input_lines)
74
74
  line = input_lines.next
75
- block_match = line.match(MARCO_REGEXP)
75
+ block_match = line.match(MACRO_REGEXP)
76
76
  return [line] if block_match.nil?
77
77
 
78
78
  lutaml_document = lutaml_document_from_file_or_cache(document, block_match[1])
@@ -232,7 +232,7 @@ module Metanorma
232
232
  def model_representation(lutaml_document, document, additional_context, options)
233
233
  fill_in_entities_refs_attributes(document, lutaml_document, options)
234
234
  render_result, errors = Utils.render_liquid_string(
235
- template_string: table_template(options['section_depth'] || 2, options['render_style'], options['include_root']),
235
+ template_string: template(options['section_depth'] || 2, options['render_style'], options['include_root']),
236
236
  context_items: create_context_object(lutaml_document,
237
237
  additional_context,
238
238
  options),
@@ -244,7 +244,7 @@ module Metanorma
244
244
  render_result.split("\n")
245
245
  end
246
246
 
247
- def table_template(section_depth, render_style, include_root)
247
+ def template(section_depth, render_style, include_root)
248
248
  include_name = RENDER_STYLES_INCLUDES.fetch(render_style, DEFAULT_RENDER_INCLUDE)
249
249
  result = ""
250
250
  if include_root
@@ -1,3 +1,5 @@
1
+ require "expressir"
2
+ require "expressir/express/parser"
1
3
  require "expressir/express/cache"
2
4
  require "metanorma/plugin/lutaml/liquid/custom_filters"
3
5
  require "metanorma/plugin/lutaml/liquid/multiply_local_file_system"
@@ -1,7 +1,7 @@
1
1
  module Metanorma
2
2
  module Plugin
3
3
  module Lutaml
4
- VERSION = "0.4.13".freeze
4
+ VERSION = "0.4.17".freeze
5
5
  end
6
6
  end
7
7
  end
@@ -1,5 +1,6 @@
1
1
  require "metanorma/plugin/lutaml/version"
2
2
  require "metanorma/plugin/lutaml/lutaml_preprocessor"
3
+ require "metanorma/plugin/lutaml/lutaml_uml_class_preprocessor"
3
4
  require "metanorma/plugin/lutaml/lutaml_uml_attributes_table_preprocessor"
4
5
  require "metanorma/plugin/lutaml/lutaml_uml_datamodel_description_preprocessor"
5
6
  require "metanorma/plugin/lutaml/lutaml_diagram_block"
@@ -12,4 +13,15 @@ module Metanorma
12
13
  module Lutaml
13
14
  end
14
15
  end
16
+
17
+ Asciidoctor::Extensions.register do
18
+ preprocessor Metanorma::Plugin::Lutaml::LutamlPreprocessor
19
+ preprocessor Metanorma::Plugin::Lutaml::LutamlUmlAttributesTablePreprocessor
20
+ preprocessor Metanorma::Plugin::Lutaml::LutamlUmlDatamodelDescriptionPreprocessor
21
+ preprocessor Metanorma::Plugin::Lutaml::LutamlUmlClassPreprocessor
22
+ inline_macro Metanorma::Plugin::Lutaml::LutamlFigureInlineMacro
23
+ inline_macro Metanorma::Plugin::Lutaml::LutamlTableInlineMacro
24
+ block_macro Metanorma::Plugin::Lutaml::LutamlDiagramBlockMacro
25
+ block Metanorma::Plugin::Lutaml::LutamlDiagramBlock
26
+ end
15
27
  end
@@ -28,6 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.add_dependency "metanorma"
29
29
  spec.add_dependency "relaton-cli"
30
30
  spec.add_dependency "reverse_adoc"
31
+ spec.add_dependency "expressir"
31
32
 
32
33
  spec.add_development_dependency "byebug"
33
34
  spec.add_development_dependency "equivalent-xml"
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.13
4
+ version: 0.4.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-11-21 00:00:00.000000000 Z
11
+ date: 2022-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: liquid
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: expressir
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: byebug
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -242,6 +256,7 @@ extensions: []
242
256
  extra_rdoc_files: []
243
257
  files:
244
258
  - ".github/workflows/rake.yml"
259
+ - ".github/workflows/release.yml"
245
260
  - ".gitignore"
246
261
  - ".hound.yml"
247
262
  - ".rubocop.yml"
@@ -277,16 +292,16 @@ files:
277
292
  - lib/metanorma/plugin/lutaml/lutaml_preprocessor.rb
278
293
  - lib/metanorma/plugin/lutaml/lutaml_table_inline_macro.rb
279
294
  - lib/metanorma/plugin/lutaml/lutaml_uml_attributes_table_preprocessor.rb
295
+ - lib/metanorma/plugin/lutaml/lutaml_uml_class_preprocessor.rb
280
296
  - lib/metanorma/plugin/lutaml/lutaml_uml_datamodel_description_preprocessor.rb
281
297
  - lib/metanorma/plugin/lutaml/utils.rb
282
298
  - lib/metanorma/plugin/lutaml/version.rb
283
299
  - metanorma-plugin-lutaml.gemspec
284
- - pkg/metanorma-plugin-lutaml-0.2.0.gem
285
300
  homepage: https://github.com/metanorma/metanorma-plugin-lutaml
286
301
  licenses:
287
302
  - BSD-2-Clause
288
303
  metadata: {}
289
- post_install_message:
304
+ post_install_message:
290
305
  rdoc_options: []
291
306
  require_paths:
292
307
  - lib
@@ -302,7 +317,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
302
317
  version: '0'
303
318
  requirements: []
304
319
  rubygems_version: 3.1.6
305
- signing_key:
320
+ signing_key:
306
321
  specification_version: 4
307
322
  summary: Metanorma plugin for LutaML
308
323
  test_files: []
Binary file