metanorma-standoc 2.3.4 → 2.3.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 62a2a480483e6cad337d48919668d1276a587c0c6173ffc7ea8cb773f605b1fb
4
- data.tar.gz: 5a9bf620c79d8ec2993a96727f7b8c2874ee8d8c3865a5efd71941fb83ed8fc1
3
+ metadata.gz: 0f9f12b5e7f44419a449863f517b7d2d285b904f9e33380cbd42bfd1c91043f2
4
+ data.tar.gz: f7b1ed6976dfcf5711f6c287d9c442e82bbc754278f843b0f2066f7f046efab6
5
5
  SHA512:
6
- metadata.gz: 226d8eaa68590e2dbf12917371afe5f2c4c60242397e459543da0ec3471a7a0abc7f5736e92b43f053854329f460bbc70155040bd0ae1df89efa0a62f8765d8e
7
- data.tar.gz: 65a7c4e9794199fd48f3d18f3009a41d02ae837753d9e9e9cd41f755384f7b89f3376f5a6c9182de5f184eb4934a9fc9682b8ea708037aa315d9e243f83485bf
6
+ metadata.gz: d53ac6951b2ad0e44ae89353ea98d4fbe4790171677fcf0e995fc269c8a760853589d668ea2ee31f151edbb04cbc3931c60f45c22b9b809ee52d94da40443b79
7
+ data.tar.gz: 8381ff1864c867d118d60111752882ed3c5566301dfb7339e3bb10902c41e1bda29b23c755c4564a0a154304d0ddb18c28782e984dc55c6d3990753d6a42acfe
@@ -42,12 +42,11 @@ module Metanorma
42
42
  end
43
43
 
44
44
  def content_validate(doc)
45
- nested_asset_validate_basic(doc)
46
- nested_note_validate(doc)
47
- xref_validate(doc)
45
+ repeat_id_validate(doc.root) # feeds xref_validate
46
+ xref_validate(doc) # feeds nested_asset_validate
47
+ nested_asset_validate(doc)
48
48
  section_validate(doc)
49
49
  norm_ref_validate(doc)
50
- repeat_id_validate(doc.root)
51
50
  iev_validate(doc.root)
52
51
  concept_validate(doc, "concept", "refterm")
53
52
  concept_validate(doc, "related", "preferred//name")
@@ -58,6 +57,11 @@ module Metanorma
58
57
  clean_abort(@fatalerror.join("\n"), doc)
59
58
  end
60
59
 
60
+ def nested_asset_validate(doc)
61
+ nested_asset_validate_basic(doc)
62
+ nested_note_validate(doc)
63
+ end
64
+
61
65
  def nested_asset_validate_basic(doc)
62
66
  a = "//formula | //example | //figure | //termnote | //termexample | " \
63
67
  "//table"
@@ -78,9 +82,14 @@ module Metanorma
78
82
 
79
83
  def nested_asset_report(outer, inner, _doc)
80
84
  outer.name == "figure" && inner.name == "figure" and return
81
- err = "There is an instance of #{inner.name} nested within #{outer.name}"
85
+ err =
86
+ "There is an instance of #{inner.name} nested within #{outer.name}"
82
87
  @log.add("Syntax", inner, err)
83
- @fatalerror << "#{err}:\n#{inner.to_xml}"
88
+ i = @doc_xrefs[inner["id"]] or return
89
+ err2 = "There is a crossreference to an instance of #{inner.name} " \
90
+ "nested within #{outer.name}: #{i.to_xml}"
91
+ @log.add("Style", i, err2)
92
+ @fatalerror << err2
84
93
  end
85
94
 
86
95
  def norm_ref_validate(doc)
@@ -103,8 +112,8 @@ module Metanorma
103
112
  @log.add("Anchors", x, concept_validate_msg(doc, tag, refterm, x))
104
113
  found = true
105
114
  end
106
- found and
107
- @fatalerror << "#{tag.capitalize} not cross-referencing term or symbol"
115
+ found and @fatalerror << "#{tag.capitalize} not cross-referencing " \
116
+ "term or symbol"
108
117
  end
109
118
 
110
119
  def concept_validate_ids(doc)
@@ -126,20 +135,19 @@ module Metanorma
126
135
  ret
127
136
  end
128
137
 
129
- def repeat_id_validate1(ids, elem)
130
- if ids[elem["id"]]
138
+ def repeat_id_validate1(elem)
139
+ if @doc_ids[elem["id"]]
131
140
  @log.add("Anchors", elem, "Anchor #{elem['id']} has already been " \
132
- "used at line #{ids[elem['id']]}")
141
+ "used at line #{@doc_ids[elem['id']]}")
133
142
  @fatalerror << "Multiple instances of same ID: #{elem['id']}"
134
- else ids[elem["id"]] = elem.line
135
143
  end
136
- ids
144
+ @doc_ids[elem["id"]] = elem.line
137
145
  end
138
146
 
139
147
  def repeat_id_validate(doc)
140
- ids = {}
148
+ @doc_ids = {}
141
149
  doc.xpath("//*[@id]").each do |x|
142
- ids = repeat_id_validate1(ids, x)
150
+ repeat_id_validate1(x)
143
151
  end
144
152
  end
145
153
 
@@ -188,11 +196,12 @@ module Metanorma
188
196
 
189
197
  # manually check for xref/@target, xref/@to integrity
190
198
  def xref_validate(doc)
191
- ids = doc.xpath("//*/@id").each_with_object({}) { |x, m| m[x.text] = 1 }
192
- doc.xpath("//xref/@target | //xref/@to").each do |x|
193
- ids[x.text] and next
199
+ @doc_xrefs = doc.xpath("//xref/@target | //xref/@to")
200
+ .each_with_object({}) do |x, m|
201
+ m[x.text] = x
202
+ @doc_ids[x] and next
194
203
  @log.add("Anchors", x.parent,
195
- "Crossreference target #{x.text} is undefined")
204
+ "Crossreference target #{x} is undefined")
196
205
  end
197
206
  end
198
207
 
@@ -19,6 +19,6 @@ module Metanorma
19
19
  end
20
20
 
21
21
  module Standoc
22
- VERSION = "2.3.4".freeze
22
+ VERSION = "2.3.5".freeze
23
23
  end
24
24
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-standoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.4
4
+ version: 2.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.