metanorma-plugin-lutaml 0.7.80 → 0.7.81

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: 31d20784c59524dc4c775cf8bc7ab345543da4ec44f04cd69961d20f7a15db24
4
- data.tar.gz: 7532df396b22c7b72c15818e74926964683b2ca363faf25a745193cbc5850675
3
+ metadata.gz: 1dfb4b9c90d1ffba66925177643b11f954b9aa0640e3fdc0c3beefec359267f5
4
+ data.tar.gz: b211eedd83758587686f9387f8e9875b52d0c9252632fedb7b9aacbd31e405a4
5
5
  SHA512:
6
- metadata.gz: fd731ef555de17f5de92763b077038b5661c42757b553552bd006e77d020d1c532cb7f4c86e5460f808c0b9738daa549fcbd1d8a194548b436984df23f39a819
7
- data.tar.gz: bb40b6f99bcc348bdd0141bc4078266a3ee0c09d589824aace7cf3e1e129a13afa9466272f1d12f4d5cb8e1645daea133e37a4246ca9ae3fd971466cb6d494a9
6
+ metadata.gz: ed7b5fe9f10850fe9a3066c73996f38eb73445c5265a790685cc4af60b6c95740ab1e0860239ff5ba03156307c0c08715c5be3e671798533faf43ea25b9c88f9
7
+ data.tar.gz: ea8a4b896bd48f51fa4214c5e2d81fd24bc3bfe059a457d2cbed544e2d23f7a12c0a02eb47d92667c4e9d407ff72ac5a9e1b1a8e120947a4678c71ecf11df0cf
@@ -1,7 +1,7 @@
1
1
  module Metanorma
2
2
  module Plugin
3
3
  module Lutaml
4
- VERSION = "0.7.80".freeze
4
+ VERSION = "0.7.81".freeze
5
5
  end
6
6
  end
7
7
  end
@@ -117,12 +117,27 @@ module Metanorma
117
117
 
118
118
  def add_model_anchor_context(context, root_package)
119
119
  packages = model_packages(root_package)
120
+ register_model_anchors(context, packages, root_package)
121
+ register_anchorable_ids(context, packages, root_package)
122
+ end
123
+
124
+ def register_model_anchors(context, packages, root_package)
120
125
  context["additional_context"]["model_anchors"] =
121
126
  model_reference_targets(packages)
122
127
  .merge(model_anchors(packages))
123
128
  .merge(model_stub_anchors(root_package))
124
129
  end
125
130
 
131
+ # Real model entities AND stubs (#70): both are XMI-declared
132
+ # objects, so their links survive templates that do not render
133
+ # their sections. Only ids the XMI never defines (attribute
134
+ # types, association ends present solely as idrefs) degrade.
135
+ def register_anchorable_ids(context, packages, root_package)
136
+ stub_ids = model_stub_anchors(root_package).keys
137
+ context["additional_context"]["model_anchorable"] =
138
+ model_anchors(packages).keys | stub_ids
139
+ end
140
+
126
141
  # Ids the XMI templates link to (attribute types, association ends),
127
142
  # including ones the XMI never defines. Unnamed; anchors override.
128
143
  def model_reference_targets(packages)
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "asciidoctor"
4
4
  require "asciidoctor/extensions"
5
+ require "set"
5
6
 
6
7
  module Metanorma
7
8
  module Plugin
@@ -16,6 +17,11 @@ module Metanorma
16
17
  (?:,(?<content>.*?))?&gt;&gt;/x)
17
18
 
18
19
  INVENTORY_ATTRIBUTE = "lutaml_model_anchors"
20
+ # Ids of real model entities (classes, enums, data types, packages).
21
+ # These never degrade to plain text (#70): even when the current
22
+ # template does not render their sections, the link must survive
23
+ # for collection-level documents to resolve.
24
+ ANCHORABLE_ATTRIBUTE = "lutaml_model_anchorable"
19
25
 
20
26
  def self.root_document(document)
21
27
  document = document.parent_document while document.parent_document
@@ -32,12 +38,23 @@ module Metanorma
32
38
  .merge!(anchors) { |_, old, new| new || old }
33
39
  end
34
40
 
41
+ # The subset of the inventory that is a real model entity
42
+ # (classes, enums, data types, packages, stubs). Only ids the XMI
43
+ # never defines (attribute types and association ends present
44
+ # solely as idrefs) degrade to plain text; XMI-declared objects
45
+ # stay linked (#70).
46
+ def self.register_anchorable(document, ids)
47
+ document = root_document(document)
48
+ document.attributes[ANCHORABLE_ATTRIBUTE] ||= Set.new
49
+ document.attributes[ANCHORABLE_ATTRIBUTE].merge(ids)
50
+ end
51
+
35
52
  def process(parent, target, attrs)
36
53
  document = self.class.root_document(parent.document)
37
54
  inventory = document.attributes.fetch(INVENTORY_ATTRIBUTE, {})
38
55
  name = inventory[target]
39
56
  text = reference_text(parent, attrs["text"], target, name)
40
- value = if inventory.key?(target) && !anchored?(document, target)
57
+ value = if suppress_link?(document, target)
41
58
  plain_text(parent, text, target)
42
59
  else
43
60
  label = text ? ",#{text}" : ""
@@ -48,6 +65,13 @@ module Metanorma
48
65
 
49
66
  private
50
67
 
68
+ def suppress_link?(document, target)
69
+ inventory = document.attributes.fetch(INVENTORY_ATTRIBUTE, {})
70
+ anchorable = document.attributes.fetch(ANCHORABLE_ATTRIBUTE, Set.new)
71
+ inventory.key?(target) && !anchored?(document, target) &&
72
+ !anchorable.member?(target)
73
+ end
74
+
51
75
  def anchored?(document, target)
52
76
  document.catalog[:refs].key?("section-#{target}")
53
77
  end
@@ -41,6 +41,9 @@ module Metanorma
41
41
  XmiModelReference.register(
42
42
  document, additional_context["model_anchors"] || {}
43
43
  )
44
+ XmiModelReference.register_anchorable(
45
+ document, additional_context["model_anchorable"] || []
46
+ )
44
47
  render_result.split("\n")
45
48
  end
46
49
 
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.80
4
+ version: 0.7.81
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-19 00:00:00.000000000 Z
11
+ date: 2026-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor