metanorma-standoc 2.3.4 → 2.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/metanorma/standoc/validate.rb +34 -20
- 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: d7c637a8a2cab495ee675be427ab80dbfa3268f7630cc1161ca3f1b75c40688c
|
4
|
+
data.tar.gz: db253ce3dde5b476d87a404d6de2d99606410262ad091edacea453c18476910c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ba632dd7ca73b0c6314212c57d9a56ed2da84f52b4ab2cd32c46d53a1a994d096d2b6a43cdc4dd161f2ddfff19a2ac7d4c113e6181054631cb3494421ff02b0
|
7
|
+
data.tar.gz: bc6cf925cc3bd5aa0777044a2568368600adcffe486e164d1ca7d0dd31370c729e45eafc62e0d3dd64d0238d618efdf9a2fc4405dddfe5af25d982f93de69966
|
@@ -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"
|
@@ -76,11 +80,21 @@ module Metanorma
|
|
76
80
|
end
|
77
81
|
end
|
78
82
|
|
79
|
-
def nested_asset_report(outer, inner,
|
83
|
+
def nested_asset_report(outer, inner, doc)
|
80
84
|
outer.name == "figure" && inner.name == "figure" and return
|
81
|
-
|
85
|
+
outer.name != "formula" && inner.name == "formula" and return
|
86
|
+
err =
|
87
|
+
"There is an instance of #{inner.name} nested within #{outer.name}"
|
82
88
|
@log.add("Syntax", inner, err)
|
83
|
-
|
89
|
+
nested_asset_xref_report(outer, inner, doc)
|
90
|
+
end
|
91
|
+
|
92
|
+
def nested_asset_xref_report(outer, inner, _doc)
|
93
|
+
i = @doc_xrefs[inner["id"]] or return
|
94
|
+
err2 = "There is a crossreference to an instance of #{inner.name} " \
|
95
|
+
"nested within #{outer.name}: #{i.to_xml}"
|
96
|
+
@log.add("Style", i, err2)
|
97
|
+
@fatalerror << err2
|
84
98
|
end
|
85
99
|
|
86
100
|
def norm_ref_validate(doc)
|
@@ -103,8 +117,8 @@ module Metanorma
|
|
103
117
|
@log.add("Anchors", x, concept_validate_msg(doc, tag, refterm, x))
|
104
118
|
found = true
|
105
119
|
end
|
106
|
-
found and
|
107
|
-
|
120
|
+
found and @fatalerror << "#{tag.capitalize} not cross-referencing " \
|
121
|
+
"term or symbol"
|
108
122
|
end
|
109
123
|
|
110
124
|
def concept_validate_ids(doc)
|
@@ -126,20 +140,19 @@ module Metanorma
|
|
126
140
|
ret
|
127
141
|
end
|
128
142
|
|
129
|
-
def repeat_id_validate1(
|
130
|
-
if
|
143
|
+
def repeat_id_validate1(elem)
|
144
|
+
if @doc_ids[elem["id"]]
|
131
145
|
@log.add("Anchors", elem, "Anchor #{elem['id']} has already been " \
|
132
|
-
"used at line #{
|
146
|
+
"used at line #{@doc_ids[elem['id']]}")
|
133
147
|
@fatalerror << "Multiple instances of same ID: #{elem['id']}"
|
134
|
-
else ids[elem["id"]] = elem.line
|
135
148
|
end
|
136
|
-
|
149
|
+
@doc_ids[elem["id"]] = elem.line
|
137
150
|
end
|
138
151
|
|
139
152
|
def repeat_id_validate(doc)
|
140
|
-
|
153
|
+
@doc_ids = {}
|
141
154
|
doc.xpath("//*[@id]").each do |x|
|
142
|
-
|
155
|
+
repeat_id_validate1(x)
|
143
156
|
end
|
144
157
|
end
|
145
158
|
|
@@ -188,11 +201,12 @@ module Metanorma
|
|
188
201
|
|
189
202
|
# manually check for xref/@target, xref/@to integrity
|
190
203
|
def xref_validate(doc)
|
191
|
-
|
192
|
-
|
193
|
-
|
204
|
+
@doc_xrefs = doc.xpath("//xref/@target | //xref/@to")
|
205
|
+
.each_with_object({}) do |x, m|
|
206
|
+
m[x.text] = x
|
207
|
+
@doc_ids[x] and next
|
194
208
|
@log.add("Anchors", x.parent,
|
195
|
-
"Crossreference target #{x
|
209
|
+
"Crossreference target #{x} is undefined")
|
196
210
|
end
|
197
211
|
end
|
198
212
|
|