suma 0.5.22 → 0.5.24

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.
@@ -0,0 +1,487 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "erb"
4
+ require "fileutils"
5
+ require "json"
6
+ require "pathname"
7
+ require "leptris"
8
+
9
+ module Suma
10
+ module Delivery
11
+ # Merge independently rendered per-part sites into a single _site/,
12
+ # rewriting each part's <span class="unresolved-eref"
13
+ # data-bibitemid="…"> markers into cross-document <a href> elements
14
+ # resolved through anchor, document and attachment registries built
15
+ # from every bundle in the merge (TCSC410303-2952; port of
16
+ # scripts/suma2srl/srl_stitch.py).
17
+ #
18
+ # Correctness model (design doc §4): cross-doc bibitemids carry
19
+ # content-derived identifiers, and content-derived anchors are stable
20
+ # across per-part and full-collection build modes, so a full merge
21
+ # resolves every cross-doc reference; a broken record can only mean
22
+ # the target's bundle is absent from the merge.
23
+ #
24
+ # The stitch is atomic: everything lands in <out>.tmp, and the swap
25
+ # to <out> happens only after every step succeeded.
26
+ class Stitcher
27
+ # A faithful port of an algorithmic pipeline: the metrics would
28
+ # fragment it without making it clearer.
29
+ # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/ParameterLists, Layout/LineLength
30
+ # `<scope>_ISO_<docid>_<year>_…`: the scope is the lowercase
31
+ # identifier prefix. For docs published as IS the suffix is
32
+ # `_ISO_10303-43_2025_…`; for DIS/TS a docstage prefix appears
33
+ # between `_ISO_` and the docid.
34
+ ANCHOR_SCOPE_RE = /\A([a-z][a-z0-9_]*(?:\.[a-z0-9_.]+)?)_ISO_(?:[A-Z]+_)?[A-Za-z0-9-]+_[0-9]+(?:_ISO_.+)?\z/
35
+
36
+ # `express_<scope>_ISO_…`: schema/entity references.
37
+ EXPRESS_BIBID_RE = /\Aexpress_([a-z][a-z0-9_]*(?:\.[a-z0-9_.]+)?)_ISO_/
38
+
39
+ # `<schema>.html_ISO_…` / `<schema>.exp_ISO_…`: attachment refs.
40
+ ATTACHMENT_BIBID_RE = /\A([a-z][a-z0-9_]*\.(?:html|exp))_ISO_/
41
+
42
+ # Document-level bibitemid, both observed forms:
43
+ # `ISO_<docid>_ISO_…` and the relaton-style `iso<docnum>-<part>_ISO_…`.
44
+ DOC_LEVEL_BIBID_RE = /\A(?:ISO_(?<a>[A-Za-z0-9-]+)|iso(?<b>\d+-\d+))_ISO_/
45
+
46
+ SHARED_DIRS = %w[schema_docs plain_schemas].freeze
47
+ FRAME_ASSETS = %w[srl_index.html].freeze
48
+ FRAME_ASSET_DIRS = %w[images sys].freeze
49
+
50
+ Registries = Struct.new(:anchors, :docs, :attachments)
51
+ Result = Struct.new(:resolved, :broken, :parts, keyword_init: true)
52
+
53
+ # (a data-declaring initializer)
54
+ def initialize(bundles_dir:, plan_path:, out_dir:, assets_dir: nil,
55
+ inject: nil, source_repo: "wg12-step",
56
+ source_commit: nil, source_branch: nil)
57
+ @bundles_dir = Pathname.new(bundles_dir)
58
+ @plan = JSON.parse(File.read(plan_path))
59
+ @out_dir = Pathname.new(out_dir)
60
+ @assets_dir = assets_dir && Pathname.new(assets_dir)
61
+ @inject = inject
62
+ @source_repo = source_repo
63
+ @source_commit = source_commit
64
+ @source_branch = source_branch
65
+ end
66
+
67
+ def stitch
68
+ bundles = load_bundles
69
+ raise "No bundles loaded — nothing to stitch" if bundles.empty?
70
+
71
+ validate_injection(@inject, bundles) if @inject
72
+ registries = build_registries(bundles)
73
+ out_tmp = stage_merged_site(bundles)
74
+ registries.attachments = build_attachment_registry(out_tmp)
75
+ counts = patch_xrefs(out_tmp, registries)
76
+ write_merged_index(out_tmp, bundles)
77
+ copy_frame_assets(out_tmp)
78
+ write_collection_errors(out_tmp, bundles, counts)
79
+ write_build_info(out_tmp, bundles)
80
+ write_stitch_summary(out_tmp, bundles, registries, counts)
81
+ atomic_swap(out_tmp)
82
+ Result.new(resolved: counts[:resolved], broken: counts[:broken],
83
+ parts: bundles.keys.sort)
84
+ end
85
+
86
+ private
87
+
88
+ def load_bundles
89
+ @plan["parts"].each_with_object({}) do |entry, h|
90
+ part_dir = entry["part_dir"]
91
+ path = @bundles_dir / part_dir / "bundle.json"
92
+ h[part_dir] = JSON.parse(path.read) if path.exist?
93
+ end
94
+ end
95
+
96
+ # -- registries --------------------------------------------------
97
+
98
+ def build_registries(bundles)
99
+ anchors = {}
100
+ docs = {}
101
+ bundles.each do |part_dir, bundle|
102
+ iso_name = bundle["iso_name"]
103
+ index_anchors(bundle).each do |file, anchor|
104
+ scope = anchor_scope(anchor)
105
+ anchors[scope] ||= [iso_name, file, anchor] if scope
106
+ end
107
+ entry = @plan["parts"].find { |p| p["part_dir"] == part_dir }
108
+ docs["ISO_#{entry['doc_id']}"] = iso_name if entry
109
+ end
110
+ Registries.new(anchors, docs, {})
111
+ end
112
+
113
+ def index_anchors(bundle)
114
+ bundle["anchors"].flat_map do |file, list|
115
+ list.map { |a| [file, a] }
116
+ end
117
+ end
118
+
119
+ def anchor_scope(anchor)
120
+ ANCHOR_SCOPE_RE.match(anchor)&.[](1)
121
+ end
122
+
123
+ def build_attachment_registry(out_dir)
124
+ registry = {}
125
+ schema_docs = out_dir / "schema_docs"
126
+ schema_docs.glob("doc_*.html").sort.each do |html|
127
+ stem = html.basename.to_s.delete_suffix(".html")
128
+ key = "#{stem.delete_prefix('doc_')}.html"
129
+ registry[key] = [nil, html.relative_path_from(out_dir).to_s, nil]
130
+ end
131
+ plain = out_dir / "plain_schemas"
132
+ plain.glob("**/*.exp").sort.each do |exp|
133
+ registry[exp.basename.to_s] =
134
+ [nil, exp.relative_path_from(out_dir).to_s, nil]
135
+ end
136
+ registry
137
+ end
138
+
139
+ def resolve_bibitemid(bibitemid, registries)
140
+ return nil if bibitemid.nil? || bibitemid.empty?
141
+
142
+ if (m = EXPRESS_BIBID_RE.match(bibitemid))
143
+ return registries.anchors[m[1]]
144
+ end
145
+ return registries.attachments[m[1]] if (m = ATTACHMENT_BIBID_RE.match(bibitemid))
146
+
147
+ doc_level_target(bibitemid, registries)
148
+ end
149
+
150
+ def doc_level_target(bibitemid, registries)
151
+ m = DOC_LEVEL_BIBID_RE.match(bibitemid) or return nil
152
+ docid_key = m[:a] ? "ISO_#{m[:a]}" : "ISO_#{m[:b]}"
153
+ iso = registries.docs[docid_key] or return nil
154
+ [iso, "#{iso}_index.html", nil]
155
+ end
156
+
157
+ # -- merge + rewrite ----------------------------------------------
158
+
159
+ def stage_merged_site(bundles)
160
+ out_tmp = out_tmp_dir
161
+ FileUtils.rm_rf(out_tmp)
162
+ FileUtils.mkdir_p(out_tmp)
163
+ bundles.each do |part_dir, bundle|
164
+ merge_bundle(part_dir, bundle, out_tmp)
165
+ end
166
+ out_tmp
167
+ end
168
+
169
+ def merge_bundle(part_dir, bundle, out_tmp)
170
+ src_site = @bundles_dir / part_dir / "site"
171
+ iso_dir = src_site / bundle["iso_name"]
172
+ FileUtils.cp_r(iso_dir, out_tmp / bundle["iso_name"]) if iso_dir.exist?
173
+ SHARED_DIRS.each do |shared|
174
+ src = src_site / shared
175
+ merge_tree(src, out_tmp / shared) if src.exist?
176
+ end
177
+ end
178
+
179
+ def patch_xrefs(out_dir, registries)
180
+ resolved = 0
181
+ broken_records = []
182
+ html_files(out_dir).each do |html_file|
183
+ dirty = patch_file_xrefs(html_file, out_dir, registries) do |record|
184
+ broken_records << record
185
+ end
186
+ resolved += dirty
187
+ end
188
+ write_broken_xrefs(out_dir, broken_records)
189
+ { resolved: resolved, broken: broken_records.size }
190
+ end
191
+
192
+ # Returns the number of resolved spans in this file; broken spans
193
+ # are yielded as audit records.
194
+ def patch_file_xrefs(html_file, out_dir, registries)
195
+ owning_iso = infer_owning_iso(html_file, out_dir)
196
+ doc = Leptris::XML.parse_html(html_file.read)
197
+ resolved = 0
198
+ doc.css("span.unresolved-eref").each do |span|
199
+ target = resolve_bibitemid(span["data-bibitemid"].to_s, registries)
200
+ if target.nil?
201
+ yield broken_record(html_file, out_dir, span)
202
+ next
203
+ end
204
+ span.replace(resolved_link(owning_iso, target, span.text))
205
+ resolved += 1
206
+ end
207
+ html_file.write(doc.to_html) if resolved.positive?
208
+ resolved
209
+ end
210
+
211
+ def broken_record(html_file, out_dir, span)
212
+ {
213
+ "source_file" => html_file.relative_path_from(out_dir).to_s,
214
+ "bibitemid" => span["data-bibitemid"].to_s,
215
+ "display_text" => span.text.strip,
216
+ }
217
+ end
218
+
219
+ def resolved_link(owning_iso, target, text)
220
+ target_iso, target_file, target_anchor = target
221
+ href = link_href(owning_iso, target_iso, target_file)
222
+ href = "#{href}##{target_anchor}" if target_anchor
223
+ "<a href=\"#{ERB::Util.html_escape(href)}\" " \
224
+ "class=\"resolved-eref\">#{ERB::Util.html_escape(text)}</a>"
225
+ end
226
+
227
+ def link_href(owning_iso, target_iso, target_file)
228
+ return "../#{target_file}" if target_iso.nil?
229
+ return target_file.to_s if owning_iso == target_iso
230
+
231
+ "../#{target_iso}/#{target_file}"
232
+ end
233
+
234
+ def html_files(out_dir)
235
+ Dir.glob("#{out_dir}/**/*.html")
236
+ .reject { |f| f.end_with?(".err.html") }
237
+ .map { |f| Pathname.new(f) }
238
+ end
239
+
240
+ def infer_owning_iso(html_file, out_dir)
241
+ first = html_file.relative_path_from(out_dir).to_s
242
+ .split(File::SEPARATOR)[0].to_s
243
+ first.start_with?("ISO_") ? first : ""
244
+ end
245
+
246
+ def merge_tree(src, dst)
247
+ FileUtils.mkdir_p(dst)
248
+ src.each_child do |entry|
249
+ target = dst / entry.basename
250
+ next if target.exist? && entry.file?
251
+
252
+ if entry.directory?
253
+ merge_tree(entry,
254
+ target)
255
+ else
256
+ FileUtils.cp(entry, target)
257
+ end
258
+ end
259
+ end
260
+
261
+ # -- synthesized artifacts ----------------------------------------
262
+
263
+ def write_merged_index(out_dir, bundles)
264
+ rows = @plan["parts"].filter_map do |entry|
265
+ bundle = bundles[entry["part_dir"]] or next
266
+ iso_name = bundle["iso_name"]
267
+ %(<li><a href="#{iso_name}/#{iso_name}_index.html">#{iso_name}</a></li>)
268
+ end
269
+ html = <<~HTML
270
+ <!DOCTYPE html>
271
+ <html><head>
272
+ <meta charset="utf-8"/>
273
+ <title>STEP Resources Library</title>
274
+ </head><body>
275
+ <h1>STEP Resources Library</h1>
276
+ <ul>
277
+ #{rows.join("\n")}
278
+ </ul>
279
+ </body></html>
280
+ HTML
281
+ (out_dir / "index.html").write(html)
282
+ end
283
+
284
+ def copy_frame_assets(out_dir)
285
+ return unless @assets_dir&.exist?
286
+
287
+ FRAME_ASSETS.each do |name|
288
+ src = @assets_dir / name
289
+ FileUtils.cp(src, out_dir / name) if src.exist?
290
+ end
291
+ FRAME_ASSET_DIRS.each do |name|
292
+ src = @assets_dir / name
293
+ next unless src.directory?
294
+
295
+ dst = out_dir / name
296
+ FileUtils.rm_rf(dst)
297
+ FileUtils.cp_r(src, dst)
298
+ end
299
+ end
300
+
301
+ def write_collection_errors(out_dir, bundles, counts)
302
+ entries = JSON.parse((out_dir / "broken_xrefs.json").read)["entries"]
303
+ warnings = bundles.values.flat_map do |bundle|
304
+ bundle.dig("errors", "build_warnings").to_a
305
+ .map { |w| [bundle["iso_name"], w] }
306
+ end
307
+ rows = entries.map { |e| xref_error_row(e) } +
308
+ warnings.map { |iso, warn| error_row(iso, "Build warning", warn) }
309
+ html = error_page_html(rows, counts, warnings.size)
310
+ (out_dir / "collection-errors.html").write(html)
311
+ end
312
+
313
+ def xref_error_row(entry)
314
+ iso = entry["source_file"].to_s.split("/", 2)[0].to_s
315
+ detail = "bibitemid=#{entry['bibitemid'].to_s[0, 140]} " \
316
+ "text=#{entry['display_text'].to_s.inspect}"
317
+ error_row(iso, "Unresolved cross-doc xref", detail)
318
+ end
319
+
320
+ def error_row(iso, klass, detail)
321
+ cell = iso.empty? ? "&nbsp;" : ERB::Util.html_escape(iso)
322
+ "<tr><td>#{cell}</td><td>#{klass}</td>" \
323
+ "<td><code>#{ERB::Util.html_escape(detail)}</code></td></tr>"
324
+ end
325
+
326
+ def error_page_html(rows, counts, warning_count)
327
+ <<~HTML
328
+ <!DOCTYPE html>
329
+ <html><head><meta charset="utf-8"/><title>SRL Collection Errors</title>
330
+ <style>body{font-family:sans-serif;margin:1em}table{border-collapse:collapse;width:100%}
331
+ th,td{border:1px solid #ccc;padding:.3em .6em;text-align:left;vertical-align:top}
332
+ th{background:#f0f0f0}code{word-break:break-all}</style>
333
+ </head><body>
334
+ <h1>SRL Collection Errors</h1>
335
+ <p>Aggregated from per-bundle build warnings and unresolved cross-document references.</p>
336
+ <p><strong>#{counts[:resolved]}</strong> cross-doc xrefs resolved, <strong>#{counts[:broken]}</strong> unresolved,
337
+ <strong>#{warning_count}</strong> build warnings.</p>
338
+ <table>
339
+ <tr><th>Document</th><th>Class</th><th>Detail</th></tr>
340
+ #{rows.join("\n")}
341
+ </table>
342
+ </body></html>
343
+ HTML
344
+ end
345
+
346
+ def write_build_info(out_dir, bundles)
347
+ info = {
348
+ "source_repo" => @source_repo,
349
+ "source_commit" => @source_commit || @plan["build_commit"] || "unknown",
350
+ "source_branch" => @source_branch || "unknown",
351
+ "build_timestamp" => Time.now.utc.strftime("%Y-%m-%dT%H:%M:%SZ"),
352
+ "build_result" => "SUCCESSFUL",
353
+ "parts_count" => bundles.size,
354
+ "stitcher" => "suma srl stitch (TCSC410303-2952)",
355
+ }
356
+ (out_dir / "build-info.json").write(JSON.pretty_generate(info))
357
+ end
358
+
359
+ def write_stitch_summary(out_dir, bundles, registries, counts)
360
+ summary = {
361
+ "version" => 1,
362
+ "stitch_timestamp" => Time.now.utc.iso8601,
363
+ "build_commit" => @plan["build_commit"],
364
+ "inject_target" => @inject,
365
+ "parts_stitched" => bundles.keys.sort,
366
+ "anchor_registry_size" => registries.anchors.size,
367
+ "doc_registry_size" => registries.docs.size,
368
+ "xrefs_resolved" => counts[:resolved],
369
+ "xrefs_broken" => counts[:broken],
370
+ }
371
+ (out_dir / "stitch_summary.json").write(JSON.pretty_generate(summary))
372
+ end
373
+
374
+ def write_broken_xrefs(out_dir, broken_records)
375
+ (out_dir / "broken_xrefs.json").write(JSON.pretty_generate({
376
+ "version" => 1,
377
+ "count" => broken_records.size,
378
+ "entries" => broken_records,
379
+ }))
380
+ end
381
+
382
+ def out_tmp_dir
383
+ @out_dir.parent / "#{@out_dir.basename}.tmp"
384
+ end
385
+
386
+ def atomic_swap(out_tmp)
387
+ old = @out_dir.parent / "#{@out_dir.basename}.old"
388
+ FileUtils.rm_rf(old)
389
+ @out_dir.exist? and FileUtils.mv(@out_dir, old)
390
+ FileUtils.mv(out_tmp, @out_dir)
391
+ FileUtils.rm_rf(old)
392
+ end
393
+
394
+ # -- inject invariants (design doc §8) ----------------------------
395
+
396
+ def validate_injection(part_dir, bundles)
397
+ new_bundle = bundles[part_dir] or
398
+ raise "inject #{part_dir}: no current bundle loaded"
399
+ prev_bundle = prev_bundle_for(part_dir)
400
+ failures = injection_failures(part_dir, bundles, prev_bundle,
401
+ new_bundle)
402
+ raise "inject #{part_dir} rejected:\n#{failures.join("\n")}" if failures.any?
403
+ end
404
+
405
+ def prev_bundle_for(part_dir)
406
+ path = @bundles_dir / part_dir / "bundle.json.previous"
407
+ path.exist? ? JSON.parse(path.read) : nil
408
+ end
409
+
410
+ def injection_failures(part_dir, bundles, prev_bundle,
411
+ new_bundle)
412
+ failures = []
413
+ if prev_bundle && new_bundle["iso_name"] != prev_bundle["iso_name"]
414
+ failures << identity_failure(
415
+ prev_bundle, new_bundle
416
+ )
417
+ end
418
+ failures.concat(anchor_regression_failure(part_dir, bundles,
419
+ prev_bundle, new_bundle))
420
+ failures.concat(unresolvable_reference_failure(
421
+ bundles, new_bundle
422
+ ))
423
+ failures
424
+ end
425
+
426
+ def identity_failure(prev_bundle, new_bundle)
427
+ "identity: iso_name changed from #{prev_bundle['iso_name'].inspect} " \
428
+ "to #{new_bundle['iso_name'].inspect}; a full re-stitch is required."
429
+ end
430
+
431
+ def anchor_regression_failure(part_dir, bundles, prev_bundle, new_bundle)
432
+ return [] unless prev_bundle
433
+
434
+ consumed = consumed_scopes(part_dir, bundles, prev_bundle)
435
+ dropped = consumed - bundle_scopes(new_bundle)
436
+ return [] if dropped.empty?
437
+
438
+ ["anchor regression: #{dropped.size} scope(s) consumed by other parts " \
439
+ "are missing from the new bundle. Examples: #{dropped.sort.first(5)}"]
440
+ end
441
+
442
+ def consumed_scopes(part_dir, bundles, prev_bundle)
443
+ prev_scopes = bundle_scopes(prev_bundle)
444
+ bundles.filter_map do |other, other_bundle|
445
+ next if other == part_dir
446
+
447
+ other_bundle["unresolved_xrefs"].to_a
448
+ .map { |ux| scope_from_bibitemid(ux["bibitemid"].to_s) }
449
+ .select { |scope| scope && prev_scopes.include?(scope) }
450
+ end.flatten.uniq
451
+ end
452
+
453
+ def unresolvable_reference_failure(bundles, new_bundle)
454
+ all_scopes = bundles.values.flat_map { |b| bundle_scopes(b) }.uniq
455
+ anomalies = new_bundle["unresolved_xrefs"].to_a.filter_map do |ux|
456
+ unresolvable_scope(ux, all_scopes)
457
+ end
458
+ return [] if anomalies.empty?
459
+
460
+ sample = anomalies.first(3).map { |u| u["bibitemid"].to_s[0, 80] }
461
+ ["unresolvable new references: #{anomalies.size} bibitemid(s) target " \
462
+ "schemas not owned by any SRL part. Examples: #{sample}"]
463
+ end
464
+
465
+ def unresolvable_scope(unresolved, all_scopes)
466
+ m = EXPRESS_BIBID_RE.match(unresolved["bibitemid"].to_s) or return nil
467
+ scope = m[1]
468
+ return nil if all_scopes.include?(scope)
469
+
470
+ schema = scope.split(".", 2)[0]
471
+ return nil if all_scopes.any? { |s| s.split(".", 2)[0] == schema }
472
+
473
+ unresolved
474
+ end
475
+
476
+ def bundle_scopes(bundle)
477
+ (bundle["anchors"] || {}).values.flatten
478
+ .filter_map { |a| anchor_scope(a) }.uniq
479
+ end
480
+
481
+ def scope_from_bibitemid(bibitemid)
482
+ EXPRESS_BIBID_RE.match(bibitemid)&.[](1)
483
+ end
484
+ # rubocop:enable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/ParameterLists, Layout/LineLength
485
+ end
486
+ end
487
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Suma
4
+ # SRL delivery subsystem (TCSC410303-2952): merge independently rendered
5
+ # per-part sites and resolve their unresolved cross-document references.
6
+ module Delivery
7
+ autoload :FrameNav, "suma/delivery/frame_nav"
8
+ autoload :Plan, "suma/delivery/plan"
9
+ autoload :SiteVerifier, "suma/delivery/site_verifier"
10
+ autoload :Stitcher, "suma/delivery/stitcher"
11
+ end
12
+ end
@@ -18,7 +18,7 @@ module Suma
18
18
  staged_reinflate_shard: nil,
19
19
  incremental: false, state_file: nil, jobs: 1,
20
20
  provenance_file: nil, sign_method: nil, sign_key: nil,
21
- no_valid: false)
21
+ no_valid: false, unresolved_eref_markers: false)
22
22
  @metanorma_yaml_path = metanorma_yaml_path
23
23
  @schemas_all_path = schemas_all_path
24
24
  @compile_flag = compile
@@ -40,6 +40,7 @@ module Suma
40
40
  # Skip Metanorma document validation (metanorma `--no-valid`). Opt-in:
41
41
  # for collections whose flavor's validators are still in flight.
42
42
  @no_valid = no_valid
43
+ @unresolved_eref_markers = unresolved_eref_markers
43
44
  end
44
45
 
45
46
  def run
@@ -189,6 +190,7 @@ module Suma
189
190
  output_directory: output_directory,
190
191
  coverpage: collection_coverpage(collection_config),
191
192
  no_valid: @no_valid,
193
+ unresolved_eref_markers: @unresolved_eref_markers,
192
194
  workers: @staged_workers,
193
195
  batch_size: @staged_batch_size ||
194
196
  StagedCollectionBuilder::DEFAULT_BATCH_SIZE,
@@ -213,6 +215,7 @@ module Suma
213
215
  def compile_flags
214
216
  { install_fonts: false }.tap do |flags|
215
217
  flags[:novalid] = true if @no_valid
218
+ flags[:unresolved_eref_markers] = true if @unresolved_eref_markers
216
219
  end
217
220
  end
218
221
 
@@ -54,6 +54,7 @@ module Suma
54
54
  # (a data-declaring initializer)
55
55
  def initialize(collection_config_path:, output_directory:, coverpage: nil,
56
56
  store_dir: nil, formats: %i[xml html], no_valid: false,
57
+ unresolved_eref_markers: false,
57
58
  workers: 1, batch_size: DEFAULT_BATCH_SIZE,
58
59
  shard: nil, isolate: nil, reinflate_shard: nil) # rubocop:disable Metrics/ParameterLists
59
60
  @config_path = collection_config_path
@@ -63,6 +64,7 @@ module Suma
63
64
  @store_dir = store_dir || File.join(output_directory, STORE_DIRNAME)
64
65
  @formats = formats
65
66
  @no_valid = no_valid
67
+ @unresolved_eref_markers = unresolved_eref_markers
66
68
  @workers = [workers.to_i, 1].max
67
69
  @batch_size = [batch_size.to_i, 1].max
68
70
  @shard = shard
@@ -451,6 +453,7 @@ module Suma
451
453
  def compile_flags
452
454
  { install_fonts: false }.tap do |flags|
453
455
  flags[:novalid] = true if @no_valid
456
+ flags[:unresolved_eref_markers] = true if @unresolved_eref_markers
454
457
  end
455
458
  end
456
459
 
data/lib/suma/thor_ext.rb CHANGED
@@ -60,7 +60,7 @@ module Suma
60
60
  return if error.is_a?(Errno::EPIPE)
61
61
  raise if ENV["VERBOSE"] || !config.fetch(:exit_on_failure, true)
62
62
 
63
- message = error.message.to_s
63
+ message = error.message.dup
64
64
  message.prepend("[#{error.class}] ") if message.empty? || !error.is_a?(Thor::Error)
65
65
 
66
66
  config[:shell]&.say_error(message, :red)
data/lib/suma/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Suma
4
- VERSION = "0.5.22"
4
+ VERSION = "0.5.24"
5
5
  end
data/lib/suma.rb CHANGED
@@ -34,6 +34,7 @@ module Suma
34
34
  autoload :NullCache, "suma/null_cache"
35
35
  autoload :OutputCanonicalizer, "suma/output_canonicalizer"
36
36
  autoload :OwlProjection, "suma/owl_projection"
37
+ autoload :Delivery, "suma/delivery"
37
38
  autoload :RegisterManifestGenerator, "suma/register_manifest_generator"
38
39
  autoload :SchemaCache, "suma/schema_cache"
39
40
  autoload :SchemaCategory, "suma/schema_category"
data/suma.gemspec CHANGED
@@ -35,6 +35,7 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
35
35
 
36
36
  spec.add_dependency "expressir"
37
37
  spec.add_dependency "glossarist", "~> 2.8", ">= 2.8.7"
38
+ spec.add_dependency "leptris"
38
39
  spec.add_dependency "lutaml-model", "~> 0.8.0"
39
40
  spec.add_dependency "metanorma", "~> 2.3"
40
41
  spec.add_dependency "plurimath"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: suma
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.22
4
+ version: 0.5.24
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-02 00:00:00.000000000 Z
11
+ date: 2026-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: expressir
@@ -44,6 +44,20 @@ dependencies:
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
46
  version: 2.8.7
47
+ - !ruby/object:Gem::Dependency
48
+ name: leptris
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
47
61
  - !ruby/object:Gem::Dependency
48
62
  name: lutaml-model
49
63
  requirement: !ruby/object:Gem::Requirement
@@ -198,6 +212,7 @@ files:
198
212
  - lib/suma/cli/compare.rb
199
213
  - lib/suma/cli/convert_jsdai.rb
200
214
  - lib/suma/cli/core.rb
215
+ - lib/suma/cli/delivery.rb
201
216
  - lib/suma/cli/export.rb
202
217
  - lib/suma/cli/extract_terms.rb
203
218
  - lib/suma/cli/generate_register.rb
@@ -212,6 +227,11 @@ files:
212
227
  - lib/suma/collection_config.rb
213
228
  - lib/suma/collection_manifest.rb
214
229
  - lib/suma/corpus_graph.rb
230
+ - lib/suma/delivery.rb
231
+ - lib/suma/delivery/frame_nav.rb
232
+ - lib/suma/delivery/plan.rb
233
+ - lib/suma/delivery/site_verifier.rb
234
+ - lib/suma/delivery/stitcher.rb
215
235
  - lib/suma/eengine.rb
216
236
  - lib/suma/eengine/errors.rb
217
237
  - lib/suma/eengine/wrapper.rb