metanorma-plugin-lutaml 0.7.84 → 0.7.86

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: 5bb7f7b3a8707045d949d4b907e3d3034a564282e63e7ef2706c2465603ffb83
4
- data.tar.gz: 1a59f94497331adb9c593f0410a8f3f4c70da2cf08e5287f19a22f8715a2c321
3
+ metadata.gz: e6066de126e9c2eeabb3c254bf7446810c22cbb7f7ef75f70179ffc97568d915
4
+ data.tar.gz: f2b0f5ee13ee7023b8187b64dd8e14c1b20055cba2039fb7b7a582ed96abc0eb
5
5
  SHA512:
6
- metadata.gz: 9bde2f3171d854725ec92efb7d28084eb92594621c053c32ddc5557724d719aa2e636588ae3da8fdf430a238fca8d5bb9a62f753ec556aa4bea76d5daded364c
7
- data.tar.gz: b9333bb75b9f4a43c761597b7338637cc84048b1ea61ae30f1a8bc4e469734094248fd9759acf8f64baed3d0a211c6303c198eb80f983f57cb9e90c71dc0ae58
6
+ metadata.gz: d871d39de216d5189c0a2b6ef9b63ce6e77a8171deea3824e8392fa4f7d879a48913001213489a6be9991dd645f76a5473fb379ae8f576353c4d01bd0fba6788
7
+ data.tar.gz: 07a28cf747dc81a66b2d18d6ca4d910c2ba0b2c722fc1fa9a713f9936d7730a277f77191fbe20d185700ba3c469e243f4632f724212cf5a5c5d40bd89096bd40
data/Rakefile CHANGED
@@ -17,11 +17,57 @@ XMI_SPEC_FILES = %w[
17
17
  spec/metanorma/plugin/lutaml/lutaml_xmi_uml_preprocessor_spec.rb
18
18
  ].freeze
19
19
 
20
+ # The diagram/GML/XSD/Liquid-rendering families each leave 25-70 MB of
21
+ # allocator high-water behind that no GC returns on darwin (measured
22
+ # 2026-11-26, #396: RSS is monotonic across file boundaries even with
23
+ # full flush + GC, and the bare process boot costs ~350 MB), so one
24
+ # process accumulates ~650 MB over the run. Grouping the heavy
25
+ # families into small dedicated tasks keeps every peak under the
26
+ # budget; the coverage is unchanged.
27
+ RENDER_SPEC_FILES = %w[
28
+ spec/metanorma/plugin/lutaml/lutaml_ea_diagram_block_macro_spec.rb
29
+ spec/metanorma/plugin/lutaml/lutaml_express_preprocessor_spec.rb
30
+ spec/metanorma/plugin/lutaml/lutaml_figure_inline_macro_spec.rb
31
+ ].freeze
32
+
33
+ GML_SPEC_FILES = %w[
34
+ spec/metanorma/plugin/lutaml/lutaml_gml_dictionary_block_macro_spec.rb
35
+ spec/metanorma/plugin/lutaml/lutaml_gml_dictionary_block_spec.rb
36
+ ].freeze
37
+
38
+ SCHEMA_SPEC_FILES = %w[
39
+ spec/metanorma/plugin/lutaml/lutaml_jsonschema_preprocessor_spec.rb
40
+ spec/metanorma/plugin/lutaml/lutaml_table_inline_macro_spec.rb
41
+ ].freeze
42
+
43
+ RENDER_TEXT_SPEC_FILES = %w[
44
+ spec/metanorma/plugin/lutaml/lutaml_text_preprocessor_spec.rb
45
+ spec/metanorma/plugin/lutaml/lutaml_xsd_preprocessor_spec.rb
46
+ ].freeze
47
+
20
48
  RSpec::Core::RakeTask.new(:spec)
21
49
 
22
50
  RSpec::Core::RakeTask.new(:fast) do |t|
23
51
  t.pattern =
24
- FileList["spec/**/*_spec.rb"] - XMI_SPEC_FILES - XMI_HEAVY_SPEC_FILES
52
+ FileList["spec/**/*_spec.rb"] - XMI_SPEC_FILES -
53
+ XMI_HEAVY_SPEC_FILES - RENDER_SPEC_FILES - GML_SPEC_FILES -
54
+ SCHEMA_SPEC_FILES - RENDER_TEXT_SPEC_FILES
55
+ end
56
+
57
+ RSpec::Core::RakeTask.new(:render) do |t|
58
+ t.pattern = FileList[RENDER_SPEC_FILES]
59
+ end
60
+
61
+ RSpec::Core::RakeTask.new(:gml) do |t|
62
+ t.pattern = FileList[GML_SPEC_FILES]
63
+ end
64
+
65
+ RSpec::Core::RakeTask.new(:schema) do |t|
66
+ t.pattern = FileList[SCHEMA_SPEC_FILES]
67
+ end
68
+
69
+ RSpec::Core::RakeTask.new(:render_text) do |t|
70
+ t.pattern = FileList[RENDER_TEXT_SPEC_FILES]
25
71
  end
26
72
 
27
73
  RSpec::Core::RakeTask.new(:xmi) do |t|
@@ -35,6 +81,7 @@ end
35
81
  # The XMI/uml-rendering specs accumulate more memory per process than
36
82
  # the macos ruby-3.3 runner provides — they are killed mid-suite there
37
83
  # (#304) no matter the grouping, while passing on 3.4/4.0 and via the
38
- # dedicated tasks. The push gate therefore runs `fast`; run `rake xmi`
39
- # and `rake xmi_heavy` (ad hoc / nightly) for the heavy sets.
40
- task default: :fast
84
+ # dedicated tasks. The push gate therefore runs the two bounded
85
+ # non-XMI processes; run `rake xmi` and `rake xmi_heavy` (ad hoc /
86
+ # nightly) for the heavy sets.
87
+ task default: %i[fast render gml schema render_text]
@@ -82,7 +82,7 @@ module Metanorma
82
82
  def format_without_prose
83
83
  items = @schema.remark_items
84
84
  @schema.remark_items = items - [@prose]
85
- @format.call.to_s
85
+ @format.call(@schema).to_s
86
86
  ensure
87
87
  @schema.remark_items = items
88
88
  end
@@ -100,12 +100,16 @@ module Metanorma
100
100
  def decorate_remarks(options)
101
101
  prose = promote_schema_prose
102
102
  stash_figure_remarks(options)
103
- # The spliced prose blocks are built here, after the figure
104
- # rewrite, so they print the resolved targets — and rebuilt
105
- # on every decoration, so a process rendering several
106
- # documents off one index prints each document's own
107
- # resolution rather than the first document's (#381).
108
- hide_from_source_formats(prose) if prose
103
+ # The document faces are installed for every decorated schema:
104
+ # figures ride remark items regardless of whether schema-level
105
+ # prose exists, and expressir's own faces strip remarks since
106
+ # 2.4.89. The spliced prose blocks are built after the figure
107
+ # rewrite so they print the resolved targets — and rebuilt on
108
+ # every decoration, so a process rendering several documents
109
+ # off one index prints each document's own resolution rather
110
+ # than the first document's (#381).
111
+ install_document_faces
112
+ splice_schema_prose(prose) if prose
109
113
  end
110
114
 
111
115
  private
@@ -139,20 +143,44 @@ module Metanorma
139
143
  prose
140
144
  end
141
145
 
142
- # Each format is still computed lazily and memoized by expressir;
143
- # it just runs without the promoted item in remark_items. The
144
- # prose block itself is formatted per render by the splicer.
145
- def hide_from_source_formats(prose)
146
- SOURCE_FORMATS.each do |name|
147
- splice_prose_into_format(name, prose)
148
- end
146
+ # The faces render per call. The plain face must reach the
147
+ # model's expressir memo through the CLASS method — binding
148
+ # `formatted` off the instance would resolve through the
149
+ # singleton these very definitions install and recurse — so
150
+ # it is bound from the class hierarchy instead.
151
+ def document_faces
152
+ class_formatted = @model.class
153
+ .instance_method(:formatted).bind(@model)
154
+ {
155
+ formatted: ->(_schema) { class_formatted.call },
156
+ formatted_hyperlinked: ->(schema) do
157
+ DocumentSourceFormatter.format(schema)
158
+ end,
159
+ formatted_hyperlinked_adoc: ->(schema) do
160
+ ExpressRemarkAdapter.hyperlinked_adoc(schema)
161
+ end,
162
+ }
149
163
  end
150
164
 
151
- def splice_prose_into_format(name, prose)
152
- format = @model.method(name)
153
- splicer = ProseSplicer.new(@model, format, prose, name)
165
+ # The faces are Schema-level (only Schema carries the formatted
166
+ # methods); child-model decorations install nothing.
167
+ def install_document_faces
168
+ return unless @model.is_a?(Expressir::Model::Declarations::Schema)
169
+
170
+ document_faces.each do |name, face|
171
+ @model.define_singleton_method(name) { face.call(self) }
172
+ end
173
+ end
154
174
 
155
- @model.define_singleton_method(name) { splicer.call }
175
+ # The splicer reprints each face without the promoted prose
176
+ # item and splices the prose block back right after the
177
+ # SCHEMA line — its standard position — so the listing shows
178
+ # the resolved prose exactly once.
179
+ def splice_schema_prose(prose)
180
+ document_faces.each do |name, face|
181
+ splicer = ProseSplicer.new(@model, face, prose, name)
182
+ @model.define_singleton_method(name) { splicer.call }
183
+ end
156
184
  end
157
185
 
158
186
  # Stages the schema's EXPRESS-G figures into the directory the
@@ -289,16 +317,51 @@ module Metanorma
289
317
  def decorate_remarks(_options); end
290
318
  end
291
319
 
292
- SOURCE_FORMATS = %i[
293
- formatted formatted_hyperlinked formatted_hyperlinked_adoc
294
- ].freeze
320
+ # Document faces for decorated schemas. expressir 2.4.89's
321
+ # prebuilt SourceFormatter/AdocSourceFormatter faces print
322
+ # without tagged description blocks (metanorma-cli#522,
323
+ # expressir#704) — their `initialize` hard-codes no_remarks and
324
+ # discards caller options. On a decorated schema the remark
325
+ # items are the document content: the __expressg figure blocks
326
+ # stage through them (#360/#371) and the schema prose prints
327
+ # through the splicer. These subclasses restore the
328
+ # remark-bearing form of the same faces — for the models this
329
+ # adapter decorates only; undecorated prints keep expressir's
330
+ # plain faces.
331
+ class DocumentSourceFormatter < Expressir::Express::Formatter
332
+ include Expressir::Express::HyperlinkFormatter
333
+
334
+ def owner_tagged_blocks?
335
+ false
336
+ end
337
+ end
338
+
339
+ class DocumentAdocSourceFormatter < Expressir::Express::Formatter
340
+ include Expressir::Express::AdocHyperlinkFormatter
341
+
342
+ def owner_tagged_blocks?
343
+ false
344
+ end
345
+ end
346
+
347
+ # The adoc face's post-formatting chain, mirroring
348
+ # Schema#formatted_hyperlinked_adoc.
349
+ def self.hyperlinked_adoc(schema)
350
+ mod = Expressir::Express::AdocHyperlinkFormatter
351
+ text = DocumentAdocSourceFormatter.format(schema)
352
+ mod.keep_opening_parentheses(
353
+ mod.keep_plus_signs(mod.neutralise_stem_macros(text)),
354
+ )
355
+ end
295
356
 
296
357
  # The formatter family behind each source format, so the spliced
297
- # prose prints the way its format prints references.
358
+ # prose prints the way its format prints references. The
359
+ # hyperlinked faces are the document formatters above —
360
+ # expressir's prebuilt faces strip remarks since 2.4.89.
298
361
  SOURCE_FORMATTERS = {
299
362
  formatted: Expressir::Express::Formatter,
300
- formatted_hyperlinked: Expressir::Express::SourceFormatter,
301
- formatted_hyperlinked_adoc: Expressir::Express::AdocSourceFormatter,
363
+ formatted_hyperlinked: DocumentSourceFormatter,
364
+ formatted_hyperlinked_adoc: DocumentAdocSourceFormatter,
302
365
  }.freeze
303
366
  end
304
367
  end
@@ -195,7 +195,9 @@ module Metanorma
195
195
  match = IMAGE_MACRO_REGEXP.match(line) or return line
196
196
  before = @errors.length
197
197
  final = final_target(match[1])
198
- return @errors[before..].join("\n") if final.nil? && @errors.length > before
198
+ if final.nil? && @errors.length > before
199
+ return @errors[before..].join("\n")
200
+ end
199
201
 
200
202
  return line if final == match[1]
201
203
 
@@ -210,15 +212,19 @@ module Metanorma
210
212
 
211
213
  file = File.expand_path(target, @schema_directory.to_s)
212
214
  unless File.file?(file)
215
+ # An already-resolved line fed back on a second pass
216
+ # (metanorma-plugin-lutaml#388) stands staged: pass it
217
+ # through unchanged instead of erroring.
218
+ return target if File.file?(File.join(@imagesdir_directory,
219
+ target))
220
+
213
221
  # A missing figure must NOT reach asciidoctor as a broken
214
222
  # image macro — metanorma's image-existence check then
215
223
  # FATALs the whole build (#371). Emit a visible, localized
216
224
  # error line in its place: what was expected, where it was
217
225
  # looked for.
218
- @errors << (
219
- "[EXPRESS-G figure error] '#{target}' not found beside " \
220
- "the schema (looked in '#{@schema_directory}')"
221
- )
226
+ @errors << "[EXPRESS-G figure error] '#{target}' not found beside " \
227
+ "the schema (looked in '#{@schema_directory}')"
222
228
  return
223
229
  end
224
230
 
@@ -227,7 +233,7 @@ module Metanorma
227
233
  return target if FileUtils.identical?(file, staged)
228
234
 
229
235
  unique = File.join(@imagesdir_directory,
230
- Digest::SHA256.hexdigest(file)[0, 12],
236
+ Digest::SHA256.file(file).hexdigest[0, 12],
231
237
  target)
232
238
  return target if File.file?(unique)
233
239
 
@@ -251,10 +257,18 @@ module Metanorma
251
257
  def flat_target(target)
252
258
  file = File.expand_path(target, @schema_directory.to_s)
253
259
  unless File.file?(file)
254
- @errors << (
255
- "[EXPRESS-G figure error] '#{target}' not found beside " \
256
- "the schema (looked in '#{@schema_directory}')"
257
- )
260
+ # A second pass may feed this resolver its own output -
261
+ # the flat name, or the digest-qualified form (#388).
262
+ # Both stand staged after the first pass; pass them
263
+ # through unchanged.
264
+ flat = File.basename(target)
265
+ return flat if target == flat &&
266
+ File.file?(File.join(@imagesdir_directory, flat))
267
+ return target if File.file?(File.join(@imagesdir_directory,
268
+ target))
269
+
270
+ @errors << "[EXPRESS-G figure error] '#{target}' not found beside " \
271
+ "the schema (looked in '#{@schema_directory}')"
258
272
  return
259
273
  end
260
274
 
@@ -263,7 +277,7 @@ module Metanorma
263
277
  if File.file?(staged)
264
278
  return flat if FileUtils.identical?(file, staged)
265
279
 
266
- digest = Digest::SHA256.hexdigest(file)[0, 12]
280
+ digest = Digest::SHA256.file(file).hexdigest[0, 12]
267
281
  unique = File.join(digest, flat)
268
282
  staged_unique = File.join(@imagesdir_directory, unique)
269
283
  return unique if File.file?(staged_unique)
@@ -261,19 +261,45 @@ module Metanorma
261
261
  target_namespace = schema_target_namespace(definition_path,
262
262
  schema_source)
263
263
 
264
- ::Lutaml::Model::Schema.from_xml(
265
- schema_source,
266
- load_classes: true,
267
- module_namespace: module_namespace,
268
- namespace: target_namespace,
269
- register_id: module_namespace,
270
- location: definition_path,
271
- )
264
+ derivation = lambda do
265
+ ::Lutaml::Model::Schema.from_xml(
266
+ schema_source,
267
+ load_classes: true,
268
+ module_namespace: module_namespace,
269
+ namespace: target_namespace,
270
+ register_id: module_namespace,
271
+ location: definition_path,
272
+ )
273
+
274
+ load_xml_instances(instances_path, module_namespace)
275
+ end
272
276
 
273
- instances = load_xml_instances(instances_path, module_namespace)
277
+ # The derivation and instance parse must run under moxml: the
278
+ # metanorma stack pins lutaml-model's process-wide adapter to
279
+ # engines whose namespaced-child binding mishandles the
280
+ # cross-namespace children of XmlCompiler-derived models
281
+ # (lutaml-model#1212; metanorma pins :nokogiri from
282
+ # metanorma/collection/config/config.rb, uniword re-asserts
283
+ # :leptris). with_adapter is lutaml-model's thread-local
284
+ # per-operation override — it touches nothing outside this
285
+ # block, and the moxml engine ships as a lutaml-model
286
+ # dependency. Bundles whose lutaml-model adapter registry
287
+ # predates moxml (the umbrella lutaml gem's vendored model
288
+ # copy, lutaml#251) do not know the :moxml type; there the
289
+ # scoped override is skipped and the derivation runs under
290
+ # whatever the process pinned, as before.
291
+ instances = derive_with_namespaced_children_safe(&derivation)
274
292
  [render_liquid(lines, document, options, context_name, instances)]
275
293
  end
276
294
 
295
+ def derive_with_namespaced_children_safe
296
+ ::Lutaml::Model::Config.with_adapter(xml: :moxml) { yield }
297
+ rescue StandardError => e
298
+ raise e unless e.message.include?("Unknown adapter")
299
+
300
+ yield
301
+ end
302
+
277
303
  def schema_module_namespace(definition_path)
278
304
  base = File.basename(definition_path, ".*")
279
305
  "LutamlXml#{base.gsub(/[^A-Za-z0-9]/, "_").split("_")
@@ -288,10 +314,10 @@ module Metanorma
288
314
  end
289
315
 
290
316
  def load_xml_instances(instances_path, module_namespace)
291
- require "nokogiri"
317
+ require "moxml"
292
318
 
293
319
  instance_xml = File.read(instances_path, encoding: "UTF-8")
294
- root_name = Nokogiri::XML(instance_xml).root.name
320
+ root_name = Moxml.parse(instance_xml).root.name
295
321
 
296
322
  namespace = Object.const_get(module_namespace)
297
323
  root_class = namespace.constants.filter_map do |const|
@@ -57,9 +57,14 @@ module Metanorma
57
57
  ea_extension_path, File.dirname(yaml_config_path)
58
58
  )
59
59
 
60
- # unload the extension if it is already loaded
61
- xmi_doc = Nokogiri::XML(File.read(ea_extension_full_path))
62
- extension_id = Xmi::EaRoot.get_module_name(xmi_doc)
60
+ # unload the extension if it is already loaded — the module
61
+ # name mirrors Xmi::EaRoot#get_module_name_from_definition,
62
+ # read through moxml so this repo parses nothing with
63
+ # Nokogiri
64
+ xmi_doc = Moxml.parse(File.read(ea_extension_full_path))
65
+ profile_node = xmi_doc.at_xpath("//UMLProfile/Documentation")
66
+ extension_id = profile_node.attributes
67
+ .find { |attr| attr.name == "name" }.value.capitalize
63
68
  if Xmi::EaRoot.extension_loaded?(extension_id)
64
69
  Xmi::EaRoot.unload_extension(extension_id)
65
70
  end
@@ -1,7 +1,7 @@
1
1
  module Metanorma
2
2
  module Plugin
3
3
  module Lutaml
4
- VERSION = "0.7.84".freeze
4
+ VERSION = "0.7.86".freeze
5
5
  end
6
6
  end
7
7
  end
@@ -39,14 +39,14 @@ Gem::Specification.new do |spec|
39
39
  # ea/qea/rules/generalization.rb (0.6.149-0.6.156 are broken for the
40
40
  # diagram/Liquid-drops path — lutaml/ea#234, #246). Ea::Xmi.load/load_graph
41
41
  # (lutaml/ea#86): the partial-load API this gem calls.
42
- spec.add_dependency "ea", "~> 0.6.157"
42
+ spec.add_dependency "ea", "~> 0.6.160"
43
43
  spec.add_dependency "expressir", "~> 2.3", ">= 2.3.5"
44
44
  spec.add_dependency "isodoc", ">= 3.5.0"
45
45
  spec.add_dependency "liquid", "~> 5"
46
46
  spec.add_dependency "lutaml-jsonschema", "~> 0.1", ">= 0.1.29"
47
47
  spec.add_dependency "lutaml-graphviz"
48
48
  spec.add_dependency "lutaml-lml"
49
- spec.add_dependency "lutaml-model", "~> 0.8.156"
49
+ spec.add_dependency "lutaml-model", "~> 0.8.159"
50
50
  # >= 1.0.4: Lutaml::Uml::Value#initial (enum literal codes) — required by
51
51
  # ea >= 0.6.151+ which writes initial values during XMI parsing.
52
52
  spec.add_dependency "lutaml-uml", "~> 1.0", ">= 1.0.4"
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.84
4
+ version: 0.7.86
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-25 00:00:00.000000000 Z
11
+ date: 2026-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.6.157
75
+ version: 0.6.160
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 0.6.157
82
+ version: 0.6.160
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: expressir
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -182,14 +182,14 @@ dependencies:
182
182
  requirements:
183
183
  - - "~>"
184
184
  - !ruby/object:Gem::Version
185
- version: 0.8.156
185
+ version: 0.8.159
186
186
  type: :runtime
187
187
  prerelease: false
188
188
  version_requirements: !ruby/object:Gem::Requirement
189
189
  requirements:
190
190
  - - "~>"
191
191
  - !ruby/object:Gem::Version
192
- version: 0.8.156
192
+ version: 0.8.159
193
193
  - !ruby/object:Gem::Dependency
194
194
  name: lutaml-uml
195
195
  requirement: !ruby/object:Gem::Requirement