suma 0.5.37 → 0.5.39

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: bea94fe44851bdeb821c7aa737d36f7185928cf57b0e573b691cee5572334d99
4
- data.tar.gz: f9b299305d868f1752948ad164cae19f72347b9911a2547c85e8593cae9cf995
3
+ metadata.gz: 22f28100458fea39621ee5b70b16745f37efe2eb6cac086570da5ced507a6e16
4
+ data.tar.gz: 47f7b5512cc818e306db23835c21150bccc8d92a8ee50701326eaf847a8a952d
5
5
  SHA512:
6
- metadata.gz: c1aed5fb8b9e4f65472cabd8736424d0b86e77dc6955da8b9ccf7b7d02fd7f92aeacd8c2b2e7430baaea2712049f4c62550bc08d8e69e9e68fe7ab4828f80c8b
7
- data.tar.gz: 983717feaf8b5c99f1eb50bb5d26d2af7d66e545b2dbc9ce40c5fd50a68857923976a65fcca2ccbe88fa4ca68f828dc9555c1bbf48e24859f10eddd4b7dfed4e
6
+ metadata.gz: '0484557c5ce603b7826f4134897122b61bc0f0940947637767376e312abb31144965ca3e3187b6124b2750e3c7b0860a007fad3ae832339c59fc67116f2b3168'
7
+ data.tar.gz: 94d0c922d2bd70ba7d6ce67f78ec135b4bb276d5a0119f57a28acdd69e877fdf300dafa4d753075efea0a80840a29300b0fb9f362e1a058d9d68e5f293cbd6a6
@@ -11,7 +11,7 @@ module Suma
11
11
  class CheckSvgQuality
12
12
  DATA_PATH = "schemas"
13
13
  DEFAULT_PATTERN = "**/*.svg"
14
- DEFAULT_PROFILE = :metanorma
14
+ DEFAULT_PROFILE = Suma::SvgQuality::Scanner.default_profile
15
15
 
16
16
  def initialize(pattern: DEFAULT_PATTERN, profile: DEFAULT_PROFILE,
17
17
  format: "terminal", output: nil, min_errors: nil,
@@ -14,8 +14,9 @@ module Suma
14
14
  class Delivery < Thor
15
15
  desc "verify SITE_DIR",
16
16
  "Verify every link in the stitched site resolves: cross-file " \
17
- "hrefs to files, fragments to anchors in their target. The " \
18
- "production gate is zero broken links; exits 1 on any break. " \
17
+ "hrefs to files, fragments to anchors in their target. Without " \
18
+ "--expectations the gate is zero broken links; with one, the " \
19
+ "manifest's thresholds (broken_links_max included) govern. " \
19
20
  "Intra-file fragment hrefs are reported but do not fail."
20
21
  option :out, type: :string,
21
22
  desc: "Also write the report as JSON to this path"
@@ -33,10 +34,26 @@ module Suma
33
34
  **verify_options).verify
34
35
  log_verify(result)
35
36
  failures = expectation_failures(result)
36
- raise "broken links found (#{result.broken_count})" unless
37
- result.broken_count.zero?
38
- raise "expectations violated: #{failures.join('; ')}" unless
39
- failures.empty?
37
+ verify_failures(result, failures)
38
+ end
39
+
40
+ # Without an expectations manifest the contract is zero broken
41
+ # links. With one, broken_links_max IS the broken-link contract:
42
+ # the unconditional raise would fire first and make the cap
43
+ # unreachable (TRThurman, iso-10303#835). Defined inside
44
+ # no_commands so Thor does not register a command for a helper
45
+ # and warn about the missing usage/description on every run.
46
+ no_commands do
47
+ def verify_failures(result, failures)
48
+ if options[:expectations]
49
+ raise "expectations violated: #{failures.join('; ')}" unless
50
+ failures.empty?
51
+ elsif result.broken_count.zero?
52
+ nil
53
+ else
54
+ raise "broken links found (#{result.broken_count})"
55
+ end
56
+ end
40
57
  end
41
58
 
42
59
  desc "resolve-fragments SITE_DIR",
@@ -106,7 +106,16 @@ module Suma
106
106
  end
107
107
 
108
108
  def relative_href(from, to)
109
- from.dirname.join(to.basename).relative_path_from(from.dirname).to_s
109
+ # The path FROM the citing page's directory TO the target page's
110
+ # own location. Joining the target's basename loses its directory:
111
+ # a schema-doc page citing a member page then emitted
112
+ # `member_0.xml.11.html#…`, unresolvable from schema_docs/ depth
113
+ # (TRThurman, iso-10303#835 — every remapped link broke).
114
+ to.realpath.relative_path_from(from.dirname.realpath).to_s
115
+ rescue Errno::ENOENT
116
+ # The target page does not exist on disk; leave the relative
117
+ # computation to fail softly by naming the page as stored.
118
+ to.basename.to_s
110
119
  end
111
120
 
112
121
  def html_pages
@@ -13,13 +13,24 @@ module Suma
13
13
  # +#call(index, total, report)+. +NullProgress+ is the default
14
14
  # no-op; the CLI passes a lambda that writes to +$stderr+.
15
15
  class Scanner
16
- DEFAULT_PROFILE = :metanorma
16
+ # The operative metanorma profile ships from metanorma-standoc by
17
+ # path: svg_conform's bundled copy is a sample only, and the
18
+ # "metanorma" engine name fails loudly by design (svg_conform#132).
19
+ STANDOC_PROFILE_PATH =
20
+ "lib/metanorma/standoc/svg_conform_profile/metanorma.yml"
21
+
22
+ def self.default_profile
23
+ File.join(
24
+ Gem::Specification.find_by_name("metanorma-standoc").gem_dir,
25
+ STANDOC_PROFILE_PATH,
26
+ )
27
+ end
17
28
 
18
29
  attr_reader :profile, :progress
19
30
 
20
- def initialize(profile: DEFAULT_PROFILE,
31
+ def initialize(profile: nil,
21
32
  progress: NullProgress.new)
22
- @profile = profile
33
+ @profile = profile || self.class.default_profile
23
34
  @progress = progress
24
35
  end
25
36
 
@@ -288,7 +288,7 @@ module Suma
288
288
  "#{entity_name_to_text(entity.id)} #{entity_ref}"
289
289
  else
290
290
  entity_subtypes = subtypes.map do |e|
291
- owner = declaring_schema_id(schema, e.id) || schema.id
291
+ owner = declaring_owner(schema, e.id)
292
292
  urn_mention(express_entity_urn("#{owner}.#{e.id}"), e.id)
293
293
  end
294
294
 
@@ -299,6 +299,13 @@ module Suma
299
299
  end
300
300
  end
301
301
 
302
+ # The owner a supertype citation qualifies with: the closure declarer,
303
+ # else the sibling-schema declarer, else the citing schema.
304
+ def declaring_owner(schema, entity_id)
305
+ declaring_schema_id(schema, entity_id) ||
306
+ sibling_declaring_schema_id(entity_id) || schema.id
307
+ end
308
+
302
309
  # The schema an imported declaration is declared in, resolved through
303
310
  # +schema+'s USE-FROM closure — the same resolution the source remark
304
311
  # xrefs carry: a local declaration wins; otherwise the USE FROM edges
@@ -321,6 +328,39 @@ module Suma
321
328
  end
322
329
  end
323
330
 
331
+ # When the closure walk finds no declarer, the declaration may sit
332
+ # in a sibling schema with no interface edge to the citing one: the
333
+ # _arm/_mim pairs cite across without USE FROM/REFERENCE FROM, so
334
+ # `X_arm.Y` lands on a concept declared under `X_mim` (TRThurman's
335
+ # 148 distinct wrong-qualifier targets, iso-10303#835 /
336
+ # metanorma/suma#197). Scan the manifest's schemas for the entity
337
+ # name; exactly one declarer resolves, several stay nil.
338
+ def sibling_declaring_schema_id(entity_id)
339
+ @sibling_cache ||= {}
340
+ @sibling_cache.fetch(entity_id) do
341
+ declarers = declarers_in_manifest(entity_id)
342
+ unique_declarer(declarers)
343
+ end
344
+ end
345
+
346
+ # The manifest schemas whose entity collection declares +entity_id+.
347
+ def declarers_in_manifest(entity_id)
348
+ schema_manifest_paths.keys.filter_map do |id|
349
+ loaded = loaded_schema(id)
350
+ declares_entity?(loaded, entity_id) ? id : nil
351
+ end
352
+ end
353
+
354
+ def declares_entity?(schema, entity_id)
355
+ schema&.entities&.any? { |e| e.id == entity_id } ? true : false
356
+ end
357
+
358
+ # The single distinct declarer, or nil when none or several — an
359
+ # ambiguous name never resolves to a guess.
360
+ def unique_declarer(declarers)
361
+ declarers.uniq.one? ? declarers.first : nil
362
+ end
363
+
324
364
  # Distinct schema ids within +schema+'s USE-FROM closure declaring
325
365
  # +entity_id+. An interface whose item list names the declaration
326
366
  # claims it outright (that is what the item list means in EXPRESS) —
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.37"
4
+ VERSION = "0.5.39"
5
5
  end
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.37
4
+ version: 0.5.39
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-12 00:00:00.000000000 Z
11
+ date: 2026-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64