metanorma-plugin-lutaml 0.7.9 → 0.7.10

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: 29510e3dd02119b47d1d179c94d0a954b596dc0255410091d8c0db366e6a4dd3
4
- data.tar.gz: b2502ffd6bea597bc56c8882712c58d13e72799eca5387c76329a9ef813d62eb
3
+ metadata.gz: 4a8884a3a005d1987c9403af11f7dddb62657e28178881e7ef848383280edfcb
4
+ data.tar.gz: 210ca361b8facc4702196a1f2f734e79abe0b325e30db269c991884c0cbc2714
5
5
  SHA512:
6
- metadata.gz: b06a2f0d8be8e9073c3f631b260d8e88525353afb8e4e6cdf11bd6db9d78994543eb6a9acda9a2602212943ff972a700efa7c7d3dc870951cd3f2c6e5a219ff2
7
- data.tar.gz: c80c2d456bec408dccb3c621397bc9313e2cc6a53cf7c5671d504737087ebb597b446d2fc043e3deaaf809a0941f0f3b732837bf4b5aee404685d70cd6ab0d27
6
+ metadata.gz: ab318c1c9a6bf060093600533ff59c6b293c70a90c3096ec5ab88100546e2ae2a18d0e52f8571bdf72d1da14df0fd6fdbfbc7a8cf3c9716ba34a2f154a4e5f64
7
+ data.tar.gz: 0e3acb93421b591442d0293c08c5fb9b2e8e8c1f4925eb5f9f0fbbb77997b5cbc80e8e30cce5dd4accc4b1fe40d91c2ebce09e7f17db901ad8afbb82b8d0cb37
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
- * `"/path/to/dictionary.xml` specifies the path of xml file of the
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,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| 上位の型 2+| {{ root.general.upper_klass }}:{{ root.general.name }}
7
- h| ステレオタイプ 2+| << {{ root.stereotype }} >>
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| 属性名 h| 属性の型及び多重度 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| 関連役割名 h| 関連役割の型及び多重度 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| 関連役割名 h| 関連役割の型及び多重度 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
  |===
@@ -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/metanorma/plugin/lutaml/liquid_templates/<NAME>.liquid",
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
- result_path = Utils.relative_file_path(parent.document, target)
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
- result_path, attrs["name"]
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["table_template"], :table
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["row_template"], :row
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["assoc_template"], :assoc_row
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, template_path, tmpl_type)
177
- if template_path.nil?
178
- template_path = get_default_template_path(tmpl_type)
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
- when :row
191
- DEFAULT_ROW_TEMPLATE
192
- when :assoc_row
193
- DEFAULT_ASSOC_ROW_TEMPLATE
194
- else
195
- DEFAULT_TABLE_TEMPLATE
196
- end
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
@@ -1,7 +1,7 @@
1
1
  module Metanorma
2
2
  module Plugin
3
3
  module Lutaml
4
- VERSION = "0.7.9".freeze
4
+ VERSION = "0.7.10".freeze
5
5
  end
6
6
  end
7
7
  end
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.9
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-19 00:00:00.000000000 Z
11
+ date: 2024-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor