metanorma-iso 3.1.7 → 3.2.0
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/isodoc/iso/i18n-de.yaml +2 -0
- data/lib/isodoc/iso/i18n-en.yaml +3 -0
- data/lib/isodoc/iso/i18n-fr.yaml +3 -1
- data/lib/isodoc/iso/i18n-ja.yaml +2 -2
- data/lib/isodoc/iso/i18n-ru.yaml +3 -1
- data/lib/isodoc/iso/i18n-zh-Hans.yaml +2 -0
- data/lib/isodoc/iso/iso.amendment.xsl +373 -249
- data/lib/isodoc/iso/iso.international-standard.xsl +373 -249
- data/lib/isodoc/iso/presentation_xml_convert.rb +2 -2
- data/lib/isodoc/iso/xref.rb +15 -1
- data/lib/metanorma/iso/cleanup.rb +1 -2
- data/lib/metanorma/iso/converter.rb +2 -0
- data/lib/metanorma/iso/front.rb +1 -2
- data/lib/metanorma/iso/front_contributor.rb +0 -2
- data/lib/metanorma/iso/log.rb +148 -0
- data/lib/metanorma/iso/validate.rb +10 -17
- data/lib/metanorma/iso/validate_section.rb +24 -48
- data/lib/metanorma/iso/validate_style.rb +1 -1
- data/lib/metanorma/iso/validate_title.rb +13 -16
- data/lib/metanorma/iso/validate_xref.rb +8 -18
- data/lib/metanorma/iso/version.rb +1 -1
- data/lib/relaton/render/config.yml +11 -11
- data/metanorma-iso.gemspec +2 -1
- metadata +19 -4
|
@@ -37,7 +37,8 @@ module IsoDoc
|
|
|
37
37
|
requirement docxml
|
|
38
38
|
recommendation docxml
|
|
39
39
|
requirement_render docxml
|
|
40
|
-
@xrefs.anchors_previous =
|
|
40
|
+
@xrefs.anchors_previous =
|
|
41
|
+
@xrefs.anchors.transform_values(&:dup) # store old xrefs of reqts
|
|
41
42
|
@xrefs.parse docxml
|
|
42
43
|
# TODO move this dependency around: requirements at root should be processed before everything else
|
|
43
44
|
table docxml # have table include requirements newly converted to tables
|
|
@@ -125,7 +126,6 @@ module IsoDoc
|
|
|
125
126
|
|
|
126
127
|
def table1(elem)
|
|
127
128
|
table1_key(elem)
|
|
128
|
-
#require "debug"; binding.b
|
|
129
129
|
if elem["class"] == "modspec"
|
|
130
130
|
if n = elem.at(ns(".//fmt-name"))
|
|
131
131
|
n.remove.name = "name"
|
data/lib/isodoc/iso/xref.rb
CHANGED
|
@@ -250,7 +250,21 @@ container: false)
|
|
|
250
250
|
has_table_prefix = @anchors.dig(e, :has_table_prefix)
|
|
251
251
|
has_table_prefix and return
|
|
252
252
|
super
|
|
253
|
-
#has_table_prefix and @anchors[e][:has_table_prefix] = true # restore
|
|
253
|
+
# has_table_prefix and @anchors[e][:has_table_prefix] = true # restore
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
def localise_anchors(type = nil)
|
|
257
|
+
@anchors.each do |id, v|
|
|
258
|
+
type && v[:type] != type and next
|
|
259
|
+
#v[:has_table_prefix] and next
|
|
260
|
+
# has already been l10n'd, is copied from prev iteration
|
|
261
|
+
%i(label value xref xref_bare modspec).each do |t|
|
|
262
|
+
v[t] && !v[t].empty? or next
|
|
263
|
+
# Skip if value unchanged from previous iteration
|
|
264
|
+
@anchors_previous&.dig(id, t) == v[t] and next
|
|
265
|
+
v[t] = @i18n.l10n(v[t])
|
|
266
|
+
end
|
|
267
|
+
end
|
|
254
268
|
end
|
|
255
269
|
end
|
|
256
270
|
end
|
data/lib/metanorma/iso/front.rb
CHANGED
|
@@ -67,8 +67,7 @@ module Metanorma
|
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
def report_illegal_stage(stage, substage)
|
|
70
|
-
|
|
71
|
-
@log.add("Document Attributes", nil, err)
|
|
70
|
+
@log.add("ISO_9", nil, params: [stage, substage])
|
|
72
71
|
end
|
|
73
72
|
|
|
74
73
|
def title_component(node, xml, lang, comp)
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
module Metanorma
|
|
2
|
+
module Iso
|
|
3
|
+
class Converter
|
|
4
|
+
ISO_LOG_MESSAGES = {
|
|
5
|
+
# rubocop:disable Naming/VariableNumber
|
|
6
|
+
"ISO_1": { category: "Style",
|
|
7
|
+
error: "Style override set for ordered list",
|
|
8
|
+
severity: 2 },
|
|
9
|
+
"ISO_2": { category: "Document Attributes",
|
|
10
|
+
error: "invalid technical committee type %s",
|
|
11
|
+
severity: 2 },
|
|
12
|
+
"ISO_3": { category: "Document Attributes",
|
|
13
|
+
error: "invalid subcommittee type %s",
|
|
14
|
+
severity: 2 },
|
|
15
|
+
"ISO_4": { category: "Style",
|
|
16
|
+
error: "term definition starts with article: %s",
|
|
17
|
+
severity: 2 },
|
|
18
|
+
"ISO_5": { category: "Document Attributes",
|
|
19
|
+
error: "%s is not a recognised document type", severity: 2 },
|
|
20
|
+
"ISO_6": { category: "Document Attributes",
|
|
21
|
+
error: "%s is not a recognised iteration", severity: 2 },
|
|
22
|
+
"ISO_7": { category: "Style",
|
|
23
|
+
error: "%s is not permitted in a subfigure", severity: 2 },
|
|
24
|
+
"ISO_8": { category: "Style",
|
|
25
|
+
error: "Reference does not have an associated footnote indicating unpublished status",
|
|
26
|
+
severity: 2 },
|
|
27
|
+
"ISO_9": { category: "Document Attributes",
|
|
28
|
+
error: "Illegal document stage: %s.%s", severity: 2 },
|
|
29
|
+
"ISO_10": { category: "Style", error: "No English Title Intro!",
|
|
30
|
+
severity: 2 },
|
|
31
|
+
"ISO_11": { category: "Style", error: "No French Title Intro!",
|
|
32
|
+
severity: 2 },
|
|
33
|
+
"ISO_12": { category: "Style", error: "No English Title!",
|
|
34
|
+
severity: 2 },
|
|
35
|
+
"ISO_13": { category: "Style", error: "No French Title!", severity: 2 },
|
|
36
|
+
"ISO_14": { category: "Style", error: "No English Title Part!",
|
|
37
|
+
severity: 2 },
|
|
38
|
+
"ISO_15": { category: "Style", error: "No French Title Part!",
|
|
39
|
+
severity: 2 },
|
|
40
|
+
"ISO_16": { category: "Style",
|
|
41
|
+
error: "Subpart defined on non-IEC document!",
|
|
42
|
+
severity: 2 },
|
|
43
|
+
"ISO_17": { category: "Style",
|
|
44
|
+
error: "Main Title may name document type",
|
|
45
|
+
severity: 2 },
|
|
46
|
+
"ISO_18": { category: "Style",
|
|
47
|
+
error: "Title Intro may name document type",
|
|
48
|
+
severity: 2 },
|
|
49
|
+
"ISO_19": { category: "Style",
|
|
50
|
+
error: "%s: each first-level subclause must have a title",
|
|
51
|
+
severity: 2 },
|
|
52
|
+
"ISO_20": { category: "Style",
|
|
53
|
+
error: "%s: all subclauses must have a title, or none",
|
|
54
|
+
severity: 2 },
|
|
55
|
+
"ISO_21": { category: "Style", error: "%s %s has not been cross-referenced within document",
|
|
56
|
+
severity: 1 },
|
|
57
|
+
"ISO_22": { category: "Style", error: "(formula) %s %s has not been cross-referenced within document",
|
|
58
|
+
severity: 2 },
|
|
59
|
+
"ISO_23": { category: "Style", error: "foreword contains subclauses",
|
|
60
|
+
severity: 2 },
|
|
61
|
+
"ISO_24": { category: "Style",
|
|
62
|
+
error: "normative references contains subclauses",
|
|
63
|
+
severity: 2 },
|
|
64
|
+
"ISO_25": { category: "Style",
|
|
65
|
+
error: "Only one Symbols and Abbreviated Terms section in the standard",
|
|
66
|
+
severity: 2 },
|
|
67
|
+
"ISO_26": { category: "Style",
|
|
68
|
+
error: "Symbols and Abbreviated Terms can only contain a definition list",
|
|
69
|
+
severity: 2 },
|
|
70
|
+
"ISO_27": { category: "Style",
|
|
71
|
+
error: "In vocabulary documents, Symbols and Abbreviated Terms are only permitted in annexes",
|
|
72
|
+
severity: 2 },
|
|
73
|
+
"ISO_28": { category: "Style", error: "(section sequencing) %s",
|
|
74
|
+
severity: 2 },
|
|
75
|
+
"ISO_29": { category: "Style", error: "Scope clause missing",
|
|
76
|
+
severity: 2 },
|
|
77
|
+
"ISO_30": { category: "Style", error: "Normative references missing",
|
|
78
|
+
severity: 2 },
|
|
79
|
+
"ISO_31": { category: "Style", error: "Terms & definitions missing",
|
|
80
|
+
severity: 2 },
|
|
81
|
+
"ISO_32": { category: "Style",
|
|
82
|
+
error: "Document must contain at least one clause",
|
|
83
|
+
severity: 2 },
|
|
84
|
+
"ISO_33": { category: "Style",
|
|
85
|
+
error: "Document must contain clause after Terms and Definitions",
|
|
86
|
+
severity: 2 },
|
|
87
|
+
"ISO_34": { category: "Style",
|
|
88
|
+
error: "Scope must not occur after Terms and Definitions",
|
|
89
|
+
severity: 2 },
|
|
90
|
+
"ISO_35": { category: "Style",
|
|
91
|
+
error: "term definition ends with period: %s",
|
|
92
|
+
severity: 2 },
|
|
93
|
+
"ISO_36": { category: "Style",
|
|
94
|
+
error: "Only annexes and references can follow clauses",
|
|
95
|
+
severity: 2 },
|
|
96
|
+
"ISO_37": { category: "Style",
|
|
97
|
+
error: "Only annexes and references can follow terms and clauses",
|
|
98
|
+
severity: 2 },
|
|
99
|
+
"ISO_38": { category: "Style",
|
|
100
|
+
error: "Document must include (references) Normative References",
|
|
101
|
+
severity: 2 },
|
|
102
|
+
"ISO_39": { category: "Style",
|
|
103
|
+
error: "Scope contains subclauses: should be succinct",
|
|
104
|
+
severity: 2 },
|
|
105
|
+
"ISO_40": { category: "Style",
|
|
106
|
+
error: "Final section must be (references) Bibliography",
|
|
107
|
+
severity: 2 },
|
|
108
|
+
"ISO_41": { category: "Style",
|
|
109
|
+
error: "There are sections after the final Bibliography",
|
|
110
|
+
severity: 2 },
|
|
111
|
+
"ISO_42": { category: "Style",
|
|
112
|
+
error: "non-ISO/IEC reference is allowed as normative only subject to the conditions in ISO/IEC DIR 2 10.2: %s",
|
|
113
|
+
severity: 2 },
|
|
114
|
+
"ISO_43": { category: "Style", error: "subclause is only child",
|
|
115
|
+
severity: 2 },
|
|
116
|
+
"ISO_44": { category: "Style",
|
|
117
|
+
error: "Single terms clause in vocabulary document should have normal Terms and definitions heading",
|
|
118
|
+
severity: 2 },
|
|
119
|
+
"ISO_45": { category: "Style",
|
|
120
|
+
error: "Multiple terms clauses in vocabulary document should have 'Terms related to' heading",
|
|
121
|
+
severity: 2 },
|
|
122
|
+
"ISO_46": { category: "Style",
|
|
123
|
+
error: "'see %s' is pointing to a normative section",
|
|
124
|
+
severity: 2 },
|
|
125
|
+
"ISO_47": { category: "Bibliography",
|
|
126
|
+
error: "'%s is not pointing to a real reference",
|
|
127
|
+
severity: 2 },
|
|
128
|
+
"ISO_48": { category: "Style",
|
|
129
|
+
error: "'see %s' is pointing to a normative reference",
|
|
130
|
+
severity: 2 },
|
|
131
|
+
"ISO_49": { category: "Style",
|
|
132
|
+
error: "undated reference %s should not contain specific elements",
|
|
133
|
+
severity: 2 },
|
|
134
|
+
"ISO_50": { category: "Style",
|
|
135
|
+
error: "only terms clauses can cross-reference terms clause (%s)",
|
|
136
|
+
severity: 2 },
|
|
137
|
+
"ISO_51": { category: "Style",
|
|
138
|
+
error: "non-terms clauses cannot cross-reference terms clause (%s)",
|
|
139
|
+
severity: 2 },
|
|
140
|
+
}.freeze
|
|
141
|
+
# rubocop:enable Naming/VariableNumber
|
|
142
|
+
|
|
143
|
+
def log_messages
|
|
144
|
+
super.merge(ISO_LOG_MESSAGES)
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
end
|
|
@@ -20,18 +20,16 @@ module Metanorma
|
|
|
20
20
|
def isosubgroup_validate(root)
|
|
21
21
|
root.xpath("#{COMMITTEE_XPATH}[@type = 'Technical committee']/@subtype").each do |t|
|
|
22
22
|
%w{TC PC JTC JPC}.include?(t.text) or
|
|
23
|
-
@log.add("
|
|
24
|
-
"invalid technical committee type #{t}")
|
|
23
|
+
@log.add("ISO_2", nil, params: [t.text])
|
|
25
24
|
end
|
|
26
25
|
root.xpath("#{COMMITTEE_XPATH}[@type = 'Subcommittee']/@subtype").each do |t|
|
|
27
26
|
%w{SC JSC}.include?(t.text) or
|
|
28
|
-
@log.add("
|
|
29
|
-
"invalid subcommittee type #{t}")
|
|
27
|
+
@log.add("ISO_3", nil, params: [t.text])
|
|
30
28
|
end
|
|
31
29
|
end
|
|
32
30
|
|
|
33
31
|
def termdef_warn(text, regex, elem, term, msg)
|
|
34
|
-
regex.match(text) && @log.add(
|
|
32
|
+
regex.match(text) && @log.add(msg, elem, params: [term])
|
|
35
33
|
end
|
|
36
34
|
|
|
37
35
|
# ISO/IEC DIR 2, 16.5.6
|
|
@@ -39,11 +37,10 @@ module Metanorma
|
|
|
39
37
|
xmldoc.xpath("//term").each do |t|
|
|
40
38
|
para = t.at("./definition/verbal-definition") || return
|
|
41
39
|
term = t.at("./preferred//name").text
|
|
42
|
-
@lang == "en" and
|
|
43
|
-
|
|
40
|
+
@lang == "en" and
|
|
41
|
+
termdef_warn(para.text, /\A(the|a)\b/i, t, term, "ISO_4")
|
|
44
42
|
%(Cyrl Latn).include?(@script) and
|
|
45
|
-
termdef_warn(para.text, /\.\Z/i, t, term,
|
|
46
|
-
"term definition ends with period")
|
|
43
|
+
termdef_warn(para.text, /\.\Z/i, t, term, "ISO_35")
|
|
47
44
|
end
|
|
48
45
|
end
|
|
49
46
|
|
|
@@ -53,15 +50,13 @@ module Metanorma
|
|
|
53
50
|
guide amendment technical-corrigendum committee-document addendum
|
|
54
51
|
recommendation)
|
|
55
52
|
.include? @doctype or
|
|
56
|
-
@log.add("
|
|
57
|
-
"#{@doctype} is not a recognised document type")
|
|
53
|
+
@log.add("ISO_5", nil, params: [@doctype])
|
|
58
54
|
end
|
|
59
55
|
|
|
60
56
|
def iteration_validate(xmldoc)
|
|
61
57
|
iteration = xmldoc&.at("//bibdata/status/iteration")&.text or return
|
|
62
58
|
/^\d+/.match(iteration) or
|
|
63
|
-
@log.add("
|
|
64
|
-
"#{iteration} is not a recognised iteration")
|
|
59
|
+
@log.add("ISO_6", nil, params: [iteration])
|
|
65
60
|
end
|
|
66
61
|
|
|
67
62
|
def bibdata_validate(doc)
|
|
@@ -75,7 +70,7 @@ module Metanorma
|
|
|
75
70
|
xmldoc.xpath("//figure//figure").each do |f|
|
|
76
71
|
elems.each do |k, v|
|
|
77
72
|
f.xpath(".//#{v}").each do |n|
|
|
78
|
-
@log.add("
|
|
73
|
+
@log.add("ISO_7", n, params: [k])
|
|
79
74
|
end
|
|
80
75
|
end
|
|
81
76
|
end
|
|
@@ -106,9 +101,7 @@ module Metanorma
|
|
|
106
101
|
def bibitem_validate(xmldoc)
|
|
107
102
|
xmldoc.xpath("//bibitem[date/on = '–']").each do |b|
|
|
108
103
|
b.at("./note[@type = 'Unpublished-Status']") or
|
|
109
|
-
@log.add("
|
|
110
|
-
"Reference does not have an " \
|
|
111
|
-
"associated footnote indicating unpublished status")
|
|
104
|
+
@log.add("ISO_8", b)
|
|
112
105
|
end
|
|
113
106
|
end
|
|
114
107
|
|
|
@@ -22,32 +22,26 @@ module Metanorma
|
|
|
22
22
|
def foreword_validate(root)
|
|
23
23
|
f = root.at("//foreword") || return
|
|
24
24
|
s = f.at("./clause")
|
|
25
|
-
@log.add("
|
|
25
|
+
@log.add("ISO_23", f) unless s.nil?
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
# ISO/IEC DIR 2, 15.4
|
|
29
29
|
def normref_validate(root)
|
|
30
30
|
f = root.at("//references[@normative = 'true']") || return
|
|
31
31
|
f.at("./references | ./clause") &&
|
|
32
|
-
@log.add("
|
|
32
|
+
@log.add("ISO_24", f)
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
ONE_SYMBOLS_WARNING = "Only one Symbols and Abbreviated " \
|
|
36
|
-
"Terms section in the standard".freeze
|
|
37
|
-
NON_DL_SYMBOLS_WARNING = "Symbols and Abbreviated Terms can " \
|
|
38
|
-
"only contain a definition list".freeze
|
|
39
|
-
|
|
40
35
|
def symbols_validate(root)
|
|
41
36
|
f = root.xpath("//definitions")
|
|
42
37
|
f.empty? && return
|
|
43
38
|
(f.size == 1 || @vocab) or
|
|
44
|
-
@log.add("
|
|
39
|
+
@log.add("ISO_25", f.first)
|
|
45
40
|
f.first.elements.reject { |e| %w(title dl).include? e.name }.empty? or
|
|
46
|
-
@log.add("
|
|
41
|
+
@log.add("ISO_26", f.first)
|
|
47
42
|
@vocab and f.each do |f1|
|
|
48
43
|
f1.at("./ancestor::annex") or
|
|
49
|
-
@log.add("
|
|
50
|
-
"Abbreviated Terms are only permitted in annexes")
|
|
44
|
+
@log.add("ISO_27", f1)
|
|
51
45
|
end
|
|
52
46
|
end
|
|
53
47
|
|
|
@@ -57,18 +51,18 @@ module Metanorma
|
|
|
57
51
|
|
|
58
52
|
test = accepted.map { |a| n.at(a) }
|
|
59
53
|
if test.all?(&:nil?)
|
|
60
|
-
@log.add("
|
|
54
|
+
@log.add("ISO_28", nil, params: [msg])
|
|
61
55
|
end
|
|
62
56
|
names
|
|
63
57
|
end
|
|
64
58
|
|
|
65
59
|
def sections_presence_validate(root)
|
|
66
60
|
root.at("//sections/clause[@type = 'scope']") or
|
|
67
|
-
@log.add("
|
|
61
|
+
@log.add("ISO_29", nil)
|
|
68
62
|
root.at("//references[@normative = 'true']") or
|
|
69
|
-
@log.add("
|
|
63
|
+
@log.add("ISO_30", nil)
|
|
70
64
|
root.at("//terms") or
|
|
71
|
-
@log.add("
|
|
65
|
+
@log.add("ISO_31", nil)
|
|
72
66
|
end
|
|
73
67
|
|
|
74
68
|
# spec of permissible section sequence
|
|
@@ -116,24 +110,20 @@ module Metanorma
|
|
|
116
110
|
|
|
117
111
|
def sections_sequence_validate_body(names, elem)
|
|
118
112
|
if elem.nil? || elem.name != "clause"
|
|
119
|
-
@log.add("
|
|
113
|
+
@log.add("ISO_32", elem)
|
|
120
114
|
end
|
|
121
115
|
elem&.at("./self::clause") or
|
|
122
|
-
@log.add("
|
|
123
|
-
"Terms and Definitions")
|
|
116
|
+
@log.add("ISO_33", elem)
|
|
124
117
|
elem&.at("./self::clause[@type = 'scope']") and
|
|
125
|
-
@log.add("
|
|
126
|
-
"Scope must not occur after Terms and Definitions")
|
|
118
|
+
@log.add("ISO_34", elem)
|
|
127
119
|
elem = names.shift
|
|
128
120
|
while elem&.name == "clause"
|
|
129
121
|
elem&.at("./self::clause[@type = 'scope']") and
|
|
130
|
-
@log.add("
|
|
131
|
-
"Scope must not occur after Terms and Definitions")
|
|
122
|
+
@log.add("ISO_34", elem)
|
|
132
123
|
elem = names.shift
|
|
133
124
|
end
|
|
134
125
|
%w(annex references).include? elem&.name or
|
|
135
|
-
@log.add("
|
|
136
|
-
"Only annexes and references can follow clauses")
|
|
126
|
+
@log.add("ISO_36", elem)
|
|
137
127
|
[names, elem]
|
|
138
128
|
end
|
|
139
129
|
|
|
@@ -142,8 +132,7 @@ module Metanorma
|
|
|
142
132
|
elem = names.shift
|
|
143
133
|
end
|
|
144
134
|
%w(annex references).include? elem&.name or
|
|
145
|
-
@log.add("
|
|
146
|
-
"Only annexes and references can follow terms and clauses")
|
|
135
|
+
@log.add("ISO_37", elem)
|
|
147
136
|
[names, elem]
|
|
148
137
|
end
|
|
149
138
|
|
|
@@ -151,36 +140,27 @@ module Metanorma
|
|
|
151
140
|
while elem&.name == "annex"
|
|
152
141
|
elem = names.shift
|
|
153
142
|
if elem.nil?
|
|
154
|
-
@log.add("
|
|
155
|
-
"Normative References")
|
|
143
|
+
@log.add("ISO_38", nil)
|
|
156
144
|
end
|
|
157
145
|
end
|
|
158
146
|
elem.nil? and return
|
|
159
147
|
elem&.at("./self::references[@normative = 'true']") ||
|
|
160
|
-
@log.add("
|
|
161
|
-
"Normative References")
|
|
148
|
+
@log.add("ISO_38", nil)
|
|
162
149
|
elem = names&.shift
|
|
163
150
|
elem.nil? and return
|
|
164
151
|
elem&.at("./self::references[@normative = 'false']") ||
|
|
165
|
-
@log.add("
|
|
166
|
-
"Final section must be (references) Bibliography")
|
|
152
|
+
@log.add("ISO_40", elem)
|
|
167
153
|
names.empty? ||
|
|
168
|
-
@log.add("
|
|
169
|
-
"There are sections after the final Bibliography")
|
|
154
|
+
@log.add("ISO_41", elem)
|
|
170
155
|
end
|
|
171
156
|
|
|
172
|
-
NORM_ISO_WARN = <<~WARN.freeze
|
|
173
|
-
non-ISO/IEC reference is allowed as normative only subject to the conditions in ISO/IEC DIR 2 10.2
|
|
174
|
-
WARN
|
|
175
|
-
SCOPE_WARN = "Scope contains subclauses: should be succinct".freeze
|
|
176
|
-
|
|
177
157
|
def section_style(root)
|
|
178
158
|
foreword_style(root.at("//foreword"))
|
|
179
159
|
introduction_style(root.at("//introduction"))
|
|
180
160
|
scope_style(root.at("//clause[@type = 'scope']"))
|
|
181
161
|
scope = root.at("//clause[@type = 'scope']/clause")
|
|
182
162
|
# ISO/IEC DIR 2, 14.4
|
|
183
|
-
scope.nil? ||
|
|
163
|
+
scope.nil? || @log.add("ISO_39", scope)
|
|
184
164
|
tech_report_style(root)
|
|
185
165
|
end
|
|
186
166
|
|
|
@@ -205,7 +185,7 @@ module Metanorma
|
|
|
205
185
|
def norm_bibitem_style(root)
|
|
206
186
|
root.xpath(NORM_BIBITEMS).each do |b|
|
|
207
187
|
if b.at(ISO_PUBLISHER_XPATH).nil?
|
|
208
|
-
@log.add("
|
|
188
|
+
@log.add("ISO_42", b, params: [b.text])
|
|
209
189
|
end
|
|
210
190
|
end
|
|
211
191
|
end
|
|
@@ -221,7 +201,7 @@ module Metanorma
|
|
|
221
201
|
def onlychild_clause_validate(root)
|
|
222
202
|
root.xpath(Standoc::Utils::SUBCLAUSE_XPATH).each do |c|
|
|
223
203
|
c.xpath("../clause").size == 1 or next
|
|
224
|
-
@log.add("
|
|
204
|
+
@log.add("ISO_43", c)
|
|
225
205
|
end
|
|
226
206
|
end
|
|
227
207
|
|
|
@@ -230,15 +210,11 @@ module Metanorma
|
|
|
230
210
|
terms = root.xpath("//sections/terms | //sections/clause[.//terms]")
|
|
231
211
|
if terms.size == 1
|
|
232
212
|
((t = terms.first.at("./title")) && (t&.text == @i18n.termsdef)) or
|
|
233
|
-
@log.add("
|
|
234
|
-
"Single terms clause in vocabulary document " \
|
|
235
|
-
"should have normal Terms and definitions heading")
|
|
213
|
+
@log.add("ISO_44", terms.first)
|
|
236
214
|
elsif terms.size > 1
|
|
237
215
|
terms.each do |x|
|
|
238
216
|
((t = x.at("./title")) && /^#{@i18n.termsrelated}/.match?(t&.text)) or
|
|
239
|
-
@log.add("
|
|
240
|
-
"Multiple terms clauses in vocabulary document " \
|
|
241
|
-
"should have 'Terms related to' heading")
|
|
217
|
+
@log.add("ISO_45", x)
|
|
242
218
|
end
|
|
243
219
|
end
|
|
244
220
|
end
|
|
@@ -11,10 +11,10 @@ module Metanorma
|
|
|
11
11
|
title_intro_en = title_lang_part(root, "intro", "en")
|
|
12
12
|
title_intro_fr = title_lang_part(root, "intro", "fr")
|
|
13
13
|
if title_intro_en.nil? && !title_intro_fr.nil?
|
|
14
|
-
@log.add("
|
|
14
|
+
@log.add("ISO_10", title_intro_fr)
|
|
15
15
|
end
|
|
16
16
|
if !title_intro_en.nil? && title_intro_fr.nil?
|
|
17
|
-
@log.add("
|
|
17
|
+
@log.add("ISO_11", title_intro_en)
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
|
|
@@ -22,20 +22,20 @@ module Metanorma
|
|
|
22
22
|
title_main_en = title_lang_part(root, "main", "en")
|
|
23
23
|
title_main_fr = title_lang_part(root, "main", "fr")
|
|
24
24
|
if title_main_en.nil? && !title_main_fr.nil?
|
|
25
|
-
@log.add("
|
|
25
|
+
@log.add("ISO_12", title_main_fr)
|
|
26
26
|
end
|
|
27
27
|
if !title_main_en.nil? && title_main_fr.nil?
|
|
28
|
-
@log.add("
|
|
28
|
+
@log.add("ISO_13", title_main_en)
|
|
29
29
|
end
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
def title_part_validate(root)
|
|
33
33
|
title_part_en = title_lang_part(root, "part", "en")
|
|
34
34
|
title_part_fr = title_lang_part(root, "part", "fr")
|
|
35
|
-
|
|
36
|
-
@log.add("
|
|
37
|
-
|
|
38
|
-
@log.add("
|
|
35
|
+
title_part_en.nil? && !title_part_fr.nil? &&
|
|
36
|
+
@log.add("ISO_14", title_part_fr)
|
|
37
|
+
!title_part_en.nil? && title_part_fr.nil? &&
|
|
38
|
+
@log.add("ISO_15", title_part_en)
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
# ISO/IEC DIR 2, 11.4
|
|
@@ -46,7 +46,7 @@ module Metanorma
|
|
|
46
46
|
"organization[abbreviation = 'IEC' or " \
|
|
47
47
|
"name = 'International Electrotechnical Commission']")
|
|
48
48
|
subpart && !iec and
|
|
49
|
-
@log.add("
|
|
49
|
+
@log.add("ISO_16", docid)
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
# ISO/IEC DIR 2, 11.5.2
|
|
@@ -56,11 +56,10 @@ module Metanorma
|
|
|
56
56
|
Publicly\sAvailable\sSpecification | Technical\sReport | Guide /xi
|
|
57
57
|
title_main_en = title_lang_part(root, "main", "en")
|
|
58
58
|
!title_main_en.nil? && doctypes.match(title_main_en.text) and
|
|
59
|
-
@log.add("
|
|
59
|
+
@log.add("ISO_17", title_main_en)
|
|
60
60
|
title_intro_en = title_lang_part(root, "intro", "en")
|
|
61
61
|
!title_intro_en.nil? && doctypes.match(title_intro_en.text) and
|
|
62
|
-
@log.add("
|
|
63
|
-
"Title Intro may name document type")
|
|
62
|
+
@log.add("ISO_18", title_intro_en)
|
|
64
63
|
end
|
|
65
64
|
|
|
66
65
|
# ISO/IEC DIR 2, 22.2
|
|
@@ -70,8 +69,7 @@ module Metanorma
|
|
|
70
69
|
s.xpath("./clause | ./terms | ./references").each do |ss|
|
|
71
70
|
subtitle = ss.at("./title")
|
|
72
71
|
(!subtitle.nil? && !subtitle&.text&.empty?) or
|
|
73
|
-
@log.add("
|
|
74
|
-
"#{title}: each first-level subclause must have a title")
|
|
72
|
+
@log.add("ISO_19", ss, params: [title])
|
|
75
73
|
end
|
|
76
74
|
end
|
|
77
75
|
end
|
|
@@ -88,8 +86,7 @@ module Metanorma
|
|
|
88
86
|
withtitle = withtitle || (subtitle && !subtitle.text.empty?)
|
|
89
87
|
end
|
|
90
88
|
notitle && withtitle &&
|
|
91
|
-
@log.add("
|
|
92
|
-
"#{label}: all subclauses must have a title, or none")
|
|
89
|
+
@log.add("ISO_20", nil, params: [label])
|
|
93
90
|
end
|
|
94
91
|
|
|
95
92
|
# https://www.iso.org/ISO-house-style.html#iso-hs-s-text-r-p-full
|
|
@@ -11,8 +11,7 @@ module Metanorma
|
|
|
11
11
|
!preceding.nil? &&
|
|
12
12
|
/\b(see| refer to)\p{Zs}*\Z/mi.match(preceding) or next
|
|
13
13
|
anchors[t["target"]] and
|
|
14
|
-
@log.add("
|
|
15
|
-
"'see #{t['target']}' is pointing to a normative section")
|
|
14
|
+
@log.add("ISO_46", t, params: [t["target"]])
|
|
16
15
|
end
|
|
17
16
|
end
|
|
18
17
|
|
|
@@ -37,13 +36,11 @@ module Metanorma
|
|
|
37
36
|
!prec.nil? && /\b(see|refer to)\p{Zs}*\Z/mi.match(prec) or next
|
|
38
37
|
unless target = bibitemids[t["bibitemid"]]
|
|
39
38
|
# unless target = root.at("//bibitem[@anchor = '#{t['bibitemid']}']")
|
|
40
|
-
@log.add("
|
|
41
|
-
"'#{t} is not pointing to a real reference")
|
|
39
|
+
@log.add("ISO_47", t, params: [t])
|
|
42
40
|
next
|
|
43
41
|
end
|
|
44
42
|
target[:norm] and
|
|
45
|
-
@log.add("
|
|
46
|
-
"'see #{t}' is pointing to a normative reference")
|
|
43
|
+
@log.add("ISO_48", t, params: [t])
|
|
47
44
|
end
|
|
48
45
|
end
|
|
49
46
|
|
|
@@ -64,9 +61,7 @@ module Metanorma
|
|
|
64
61
|
root.xpath("//eref[descendant::locality]").each do |t|
|
|
65
62
|
if /^(ISO|IEC)/.match?(t["citeas"]) &&
|
|
66
63
|
!/: ?(\d+{4}|–)$/.match?(t["citeas"])
|
|
67
|
-
@log.add("
|
|
68
|
-
"undated reference #{t['citeas']} should not contain " \
|
|
69
|
-
"specific elements")
|
|
64
|
+
@log.add("ISO_49", t, params: [t["citeas"]])
|
|
70
65
|
end
|
|
71
66
|
end
|
|
72
67
|
end
|
|
@@ -88,13 +83,9 @@ module Metanorma
|
|
|
88
83
|
def term_xrefs_validate1(xref, termids)
|
|
89
84
|
closest_id = xref.xpath("./ancestor::*[@id]")&.last or return
|
|
90
85
|
termids[xref["target"]] && !termids[closest_id["id"]] and
|
|
91
|
-
@log.add("
|
|
92
|
-
"only terms clauses can cross-reference terms clause " \
|
|
93
|
-
"(#{xref['target']})")
|
|
86
|
+
@log.add("ISO_50", xref, params: [xref["target"]])
|
|
94
87
|
!termids[xref["target"]] && termids[closest_id["id"]] and
|
|
95
|
-
@log.add("
|
|
96
|
-
"non-terms clauses cannot cross-reference terms clause " \
|
|
97
|
-
"(#{xref['target']})")
|
|
88
|
+
@log.add("ISO_51", xref, params: [xref["target"]])
|
|
98
89
|
end
|
|
99
90
|
|
|
100
91
|
# require that all assets of a particular type be cross-referenced
|
|
@@ -112,9 +103,8 @@ module Metanorma
|
|
|
112
103
|
(xmldoc.xpath(xpath) - xmldoc.xpath(exc)).each do |x|
|
|
113
104
|
x["unnumbered"] == "true" and next
|
|
114
105
|
@doc_xrefs[x["anchor"]] or
|
|
115
|
-
@log.add("
|
|
116
|
-
|
|
117
|
-
severity: xpath == "//formula" ? 2 : 1)
|
|
106
|
+
@log.add(xpath == "//formula" ? "ISO_22" : "ISO_21",
|
|
107
|
+
x, params: [name, x["anchor"]])
|
|
118
108
|
end
|
|
119
109
|
end
|
|
120
110
|
|