metanorma-standoc 2.3.4 → 2.3.5
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 +4 -4
- data/lib/metanorma/standoc/validate.rb +28 -19
- data/lib/metanorma/standoc/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f9f12b5e7f44419a449863f517b7d2d285b904f9e33380cbd42bfd1c91043f2
|
4
|
+
data.tar.gz: f7b1ed6976dfcf5711f6c287d9c442e82bbc754278f843b0f2066f7f046efab6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
46
|
-
|
47
|
-
|
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 =
|
85
|
+
err =
|
86
|
+
"There is an instance of #{inner.name} nested within #{outer.name}"
|
82
87
|
@log.add("Syntax", inner, err)
|
83
|
-
|
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
|
-
|
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(
|
130
|
-
if
|
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 #{
|
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
|
-
|
144
|
+
@doc_ids[elem["id"]] = elem.line
|
137
145
|
end
|
138
146
|
|
139
147
|
def repeat_id_validate(doc)
|
140
|
-
|
148
|
+
@doc_ids = {}
|
141
149
|
doc.xpath("//*[@id]").each do |x|
|
142
|
-
|
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
|
-
|
192
|
-
|
193
|
-
|
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
|
204
|
+
"Crossreference target #{x} is undefined")
|
196
205
|
end
|
197
206
|
end
|
198
207
|
|