metanorma-plugin-lutaml 0.7.58 → 0.7.59

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c90313afe5e40c1be36f364ea036e92e6f900631d118e2ea9153296b92adbfe2
4
- data.tar.gz: 0af70233ce559776a23fae4ffbd21147ceaab1daf60380f8ed576a5bb5a94aa7
3
+ metadata.gz: d96f09e7d7f1d19bbe312762e74ee2202906df8d101844b4f886cddf13a03835
4
+ data.tar.gz: 3e58ee7adb78b9f8fe376c8903802e7ccba16649ad569b981b67670f2bd46c36
5
5
  SHA512:
6
- metadata.gz: 288872689df43058c47cbfbe4eebf53343fe60b9030e25e26ca960353c727d90557790fec5beb45da7ed0fa7691bd195905ceac0209897237fa31cf005a70a03
7
- data.tar.gz: 953d776b5c798164079a7159e325b921a78361450c0c690a6311fa66f9f34ad75b6ffe7df1bbb884326a3184029d6fc25619b96149ad4ae10f6e11f589a9bf34
6
+ metadata.gz: f25f543755e3a342f1cd640b2413a1bcaef5b5a9ab7706d71c4786f35814d76e0aa9c37f03b381a381420be714bf190f5fde568cb5d725f357448670a3b7b81b
7
+ data.tar.gz: 646d8ddf3d4e5823a9a2740a8193d2e3109273587b33ffed2e02e338182e82241fc26e7b94dcc192922830b6d1ff8f3637eaec99564c4a4d422d3762ce6cb741
@@ -17,10 +17,6 @@ jobs:
17
17
  rake:
18
18
  uses: metanorma/ci/.github/workflows/generic-rake.yml@v1
19
19
  with:
20
- # svg_conform 0.2.5 was re-pushed with corrected metadata; the
21
- # compact-index line cached in ~/.bundle still carries the old
22
- # (lens_core) record and fails every install against it.
23
- before-setup-ruby: rm -rf ~/.bundle/cache/compact_index vendor/bundle/cache && mkdir -p vendor/bundle/cache && curl -sfL https://rubygems.org/gems/svg_conform-0.2.5.gem -o vendor/bundle/cache/svg_conform-0.2.5.gem
24
20
  setup-tools: graphviz
25
21
  submodules: true
26
22
  choco-cache: true
data/Gemfile CHANGED
@@ -42,4 +42,4 @@ gem "metanorma-document", github: "metanorma/metanorma-document", branch: "main"
42
42
  # re-pushed build carries a lens_core dependency that is not published);
43
43
  # 0.2.4 is the last clean release and rides moxml ~> 0.5 (= satisfied by
44
44
  # the 0.6 line). Lift when a clean 0.2.6 ships.
45
- gem "svg_conform", "0.2.4"
45
+ gem "svg_conform", "~> 0.2.6"
data/README.adoc CHANGED
@@ -39,6 +39,8 @@ link:docs/usages/lutaml-gml.adoc[Usage with LutaML GML Dictionary by lutaml_gml_
39
39
 
40
40
  link:docs/usages/json_yaml.adoc[Usage with JSON or YAML files by data2text, yaml2text or json2text]
41
41
 
42
+ link:docs/usages/lutaml-data.adoc[Usage with LutaML data files by lutaml_data]
43
+
42
44
  link:docs/usages/lutaml-xsd.adoc[Usage with XML Schema files by lutaml_xsd]
43
45
 
44
46
  == Documentation
@@ -0,0 +1,227 @@
1
+ == Usage with LutaML data files by lutaml_data
2
+
3
+ === General
4
+
5
+ The `lutaml_data` block command loads data that is defined with LutaML models
6
+ and makes it available to a Liquid template in the block.
7
+
8
+ The data consists of two parts:
9
+
10
+ * the *data definitions*: LutaML models, always written in a `.lml` file; and
11
+ * the *data instances*: values of those models, written in `.lml`, `.yaml`,
12
+ `.yml` or `.json`.
13
+
14
+ === Defining a block
15
+
16
+ Data definitions and data instances in separate files:
17
+
18
+ [source,asciidoc]
19
+ ------
20
+ [lutaml_data,{definition_file},{instance_file},{context_name},options={...}]
21
+ ----
22
+ ...Liquid template...
23
+ ----
24
+ ------
25
+
26
+ Data definitions and data instances in the same `.lml` file:
27
+
28
+ [source,asciidoc]
29
+ ------
30
+ [lutaml_data,{definition_file},{context_name},options={...}]
31
+ ----
32
+ ...Liquid template...
33
+ ----
34
+ ------
35
+
36
+ `definition_file`:: (required) Path to the `.lml` file that holds the LutaML
37
+ models. Relative paths are resolved from the directory of the Metanorma
38
+ document. When this is the only file given, the same file must also contain
39
+ the instances.
40
+
41
+ `instance_file`:: (optional) Path to the file that holds the data instances,
42
+ with extension `.lml`, `.yaml`, `.yml` or `.json`. The `.lml` instance file
43
+ usually starts with `require "<definition_file>"`.
44
+
45
+ `context_name`:: (optional) The name under which the data is exposed to the
46
+ Liquid template. Defaults to `lutaml_data`.
47
+
48
+ `options`:: (optional) Rendering options, given either as a JSON object
49
+ (`options={"include_path":"templates"}`) or as inline `key=value` pairs
50
+ (`include_path=templates`). The supported option is `include_path`, a
51
+ comma-separated list of directories searched by the Liquid `include` tag.
52
+
53
+ NOTE: A segment is taken as the instance file when its extension is one of
54
+ `.lml`, `.yaml`, `.yml` or `.json`; any other segment is taken as the context
55
+ name.
56
+
57
+ === Data in the Liquid context
58
+
59
+ The data is exposed under `context_name`, then the name of the instance.
60
+
61
+ * For `.lml` instances, the key is the instance name (`instance S158Checks { ... }`
62
+ is `S158Checks`).
63
+ * For `.yaml` and `.json` instances, the key is the model name given by the
64
+ required `type` entry (`type: Widgets` is `Widgets`). A file may hold one
65
+ object or a list of objects.
66
+
67
+ Attributes are read by name (`check.dev_id`), collections are iterated with
68
+ `for`, and enum values expose the attributes defined in the model
69
+ (`check.classification.description`).
70
+
71
+ === Example
72
+
73
+ Data definitions, `s102_models.lml`:
74
+
75
+ [source]
76
+ ----
77
+ models IhoS102Check {
78
+ enum CheckClassification {
79
+ critical_error {
80
+ description "Critical Error"
81
+ }
82
+ warning {
83
+ description "Warning"
84
+ }
85
+ }
86
+
87
+ class ValidationChecks {
88
+ attribute checks {
89
+ type ValidationCheck
90
+ cardinality 0..n
91
+ }
92
+ }
93
+
94
+ class ValidationCheck {
95
+ attribute dev_id {
96
+ type String
97
+ cardinality 1
98
+ }
99
+
100
+ attribute classification {
101
+ type CheckClassification
102
+ cardinality 1
103
+ }
104
+
105
+ attribute check_message {
106
+ type String
107
+ cardinality 1
108
+ }
109
+ }
110
+ }
111
+ ----
112
+
113
+ Data instances, `s102_checks.lml`:
114
+
115
+ [source]
116
+ ----
117
+ // s102_checks.lml
118
+ require "s102_models.lml"
119
+ instance S158Checks {
120
+ type ValidationChecks
121
+
122
+ checks = [
123
+ instance IhoS102Check::ValidationCheck {
124
+ dev_id = "S102_Dev1001"
125
+ classification = CheckClassification::critical_error
126
+ check_message = "No feature information group"
127
+ },
128
+
129
+ instance IhoS102Check::ValidationCheck {
130
+ dev_id = "S102_Dev1002"
131
+ classification = CheckClassification::warning
132
+ check_message = "Mandatory metadata attribute missing"
133
+ }
134
+ ]
135
+ }
136
+ ----
137
+
138
+ NOTE: In `.lml` files, comments start with `//`. A `#` comment is rejected by
139
+ the instance parser.
140
+
141
+ The Metanorma document:
142
+
143
+ [source,asciidoc]
144
+ ------
145
+ [lutaml_data,s102_models.lml,s102_checks.lml,lml]
146
+ ----
147
+ {% for check in lml.S158Checks.checks %}
148
+ === S-102 Validation Check `{{ check.dev_id }}`
149
+
150
+ classification: {{ check.classification.description }}
151
+
152
+ check message: {{ check.check_message }}
153
+
154
+ {% endfor %}
155
+ ----
156
+ ------
157
+
158
+ renders as:
159
+
160
+ [source,asciidoc]
161
+ ----
162
+ === S-102 Validation Check `S102_Dev1001`
163
+
164
+ classification: Critical Error
165
+
166
+ check message: No feature information group
167
+
168
+ === S-102 Validation Check `S102_Dev1002`
169
+
170
+ classification: Warning
171
+
172
+ check message: Mandatory metadata attribute missing
173
+ ----
174
+
175
+ === Instances in YAML or JSON
176
+
177
+ The same data can be given as YAML (`s102_checks.yaml`):
178
+
179
+ [source,yaml]
180
+ ----
181
+ type: ValidationChecks
182
+ checks:
183
+ - dev_id: S102_Dev1001
184
+ check_message: No feature information group
185
+ ----
186
+
187
+ NOTE: Enum-typed attributes (such as `classification` above) cannot currently
188
+ be set from YAML or JSON instances; loading fails. Use `.lml` instances for
189
+ data that has enum values.
190
+
191
+ The key in the template is the type name:
192
+
193
+ [source,asciidoc]
194
+ ------
195
+ [lutaml_data,s102_models.lml,s102_checks.yaml,lml]
196
+ ----
197
+ {% for check in lml.ValidationChecks.checks %}
198
+ {{ check.dev_id }}
199
+ {% endfor %}
200
+ ----
201
+ ------
202
+
203
+ === Instances in the definition file
204
+
205
+ If the instances are in the definition file, omit the instance file:
206
+
207
+ [source,asciidoc]
208
+ ------
209
+ [lutaml_data,widgets.lml,store]
210
+ ----
211
+ {% for widget in store.AllWidgets.widgets %}
212
+ {{ widget.id }}: {{ widget.name }}
213
+ {% endfor %}
214
+ ----
215
+ ------
216
+
217
+ === Options
218
+
219
+ Directories for Liquid `include` can be set with `options`:
220
+
221
+ [source,asciidoc]
222
+ ------
223
+ [lutaml_data,widgets.lml,store,options={"include_path":"templates"}]
224
+ ----
225
+ {% include 'heading' %}
226
+ ----
227
+ ------
@@ -17,22 +17,19 @@ module Metanorma
17
17
  )
18
18
  resolved = document.path_resolver
19
19
  .system_path(file_path, docfile_directory)
20
- # The decorator expands emitted paths against this base: relative
21
- # prefixes alone get re-anchored by asciidoctor's imagesdir
22
- # handling (images/../../schemas collapses a level), so the
23
- # decoration must produce paths that resolve from the docfile.
24
- options["relative_path_base"] =
25
- File.expand_path(docfile_directory)
26
20
  # The prefix lands inside emitted image macros, so it must not
27
21
  # carry the absolute build path: two builds of the same tree in
28
22
  # two directories produced different image/@src values
29
23
  # (metanorma/metanorma-plugin-lutaml#325). A path relative to the
30
24
  # docfile resolves to the same schema file at render time and is
31
- # byte-identical across build directories.
25
+ # byte-identical across build directories; the decorator joins it
26
+ # as written rather than expanding it.
32
27
  # The docfile directory may be relative ("."): relative_path_from
33
28
  # refuses mixed prefixes, so both sides expand first
34
29
  Pathname.new(File.expand_path(resolved))
35
- .relative_path_from(Pathname.new(File.expand_path(docfile_directory)))
30
+ .relative_path_from(
31
+ Pathname.new(File.expand_path(docfile_directory)),
32
+ )
36
33
  .to_s
37
34
  end
38
35
 
@@ -68,19 +68,15 @@ module Metanorma
68
68
  return line if path_prefix && line.include?(path_prefix)
69
69
 
70
70
  line.gsub(RELATIVE_PREFIX_MACRO_REGEXP) do |_match|
71
- # Expand against the docfile directory (passed by the adapter
72
- # as relative_path_base), NOT the process CWD: a CWD expansion
73
- # produced absolute image paths under whatever directory the
74
- # build was launched from (e.g. <repo>/../../schemas/...).
75
- # The absolute result is deliberate: relative targets are
76
- # re-anchored by asciidoctor's imagesdir handling
77
- # (images/../../schemas collapses a level), which made every
78
- # decorated diagram unresolvable at render time.
79
- full_path = File.expand_path(
80
- File.join(path_prefix, $3.strip),
81
- options["relative_path_base"] || Dir.pwd,
82
- )
83
- "#{$1}#{$2}#{full_path}#{$4}"
71
+ # The prefix is already docfile-relative (see
72
+ # ExpressRemarkAdapter.relative_path_prefix), so joining it
73
+ # keeps the emitted path relative to the docfile too. Expanding
74
+ # to an absolute path embedded the build directory in the
75
+ # output, making semantic XML, presentation XML and HTML differ
76
+ # between two builds of the same tree (#325). Resolution is the
77
+ # renderer's job: a relative target joined with imagesdir still
78
+ # resolves against the docfile at render time.
79
+ "#{$1}#{$2}#{File.join(path_prefix, $3.strip)}#{$4}"
84
80
  end
85
81
  end
86
82
  end
@@ -1,7 +1,7 @@
1
1
  module Metanorma
2
2
  module Plugin
3
3
  module Lutaml
4
- VERSION = "0.7.58".freeze
4
+ VERSION = "0.7.59".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.58
4
+ version: 0.7.59
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-11-01 00:00:00.000000000 Z
11
+ date: 2026-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -187,6 +187,7 @@ files:
187
187
  - docs/usages/enterprise_architect_uml.adoc
188
188
  - docs/usages/express.adoc
189
189
  - docs/usages/json_yaml.adoc
190
+ - docs/usages/lutaml-data.adoc
190
191
  - docs/usages/lutaml-gml.adoc
191
192
  - docs/usages/lutaml-uml.adoc
192
193
  - docs/usages/lutaml-xsd.adoc