metanorma-cc 1.7.9 → 1.7.13

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,10 +12,10 @@ module Asciidoctor
12
12
  end
13
13
 
14
14
  ONE_SYMBOLS_WARNING = "Only one Symbols and Abbreviated "\
15
- "Terms section in the standard".freeze
15
+ "Terms section in the standard".freeze
16
16
 
17
17
  NON_DL_SYMBOLS_WARNING = "Symbols and Abbreviated Terms can "\
18
- "only contain a definition list".freeze
18
+ "only contain a definition list".freeze
19
19
 
20
20
  def symbols_validate(root)
21
21
  f = root.xpath("//definitions")
@@ -32,8 +32,9 @@ module Asciidoctor
32
32
  def seqcheck(names, msg, accepted)
33
33
  n = names.shift
34
34
  return [] if n.nil?
35
+
35
36
  test = accepted.map { |a| n.at(a) }
36
- if test.all? { |a| a.nil? }
37
+ if test.all?(&:nil?)
37
38
  @log.add("Style", nil, msg)
38
39
  end
39
40
  names
@@ -45,77 +46,84 @@ module Asciidoctor
45
46
  [
46
47
  {
47
48
  msg: "Initial section must be (content) Foreword",
48
- val: ["./self::foreword"]
49
+ val: ["./self::foreword"],
49
50
  },
50
51
  {
51
52
  msg: "Prefatory material must be followed by (clause) Scope",
52
- val: ["./self::introduction", "./self::clause[@type = 'scope']" ]
53
+ val: ["./self::introduction", "./self::clause[@type = 'scope']"],
53
54
  },
54
55
  {
55
56
  msg: "Prefatory material must be followed by (clause) Scope",
56
- val: ["./self::clause[@type = 'scope']" ]
57
+ val: ["./self::clause[@type = 'scope']"],
57
58
  },
58
59
  {
59
60
  msg: "Normative References must be followed by "\
60
- "Terms and Definitions",
61
- val: ["./self::terms | .//terms"]
61
+ "Terms and Definitions",
62
+ val: ["./self::terms | .//terms"],
62
63
  },
63
- ].freeze
64
+ ].freeze
64
65
 
65
66
  SECTIONS_XPATH =
66
67
  "//foreword | //introduction | //sections/terms | .//annex | "\
67
- "//sections/definitions | //sections/clause | //references[not(parent::clause)] | "\
68
+ "//sections/definitions | //sections/clause | "\
69
+ "//references[not(parent::clause)] | "\
68
70
  "//clause[descendant::references][not(parent::clause)]".freeze
69
71
 
70
72
  def sections_sequence_validate(root)
71
73
  names = root.xpath(SECTIONS_XPATH)
72
- names = seqcheck(names, SEQ[0][:msg], SEQ[0][:val])
74
+ names = seqcheck(names, SEQ[0][:msg], SEQ[0][:val])
73
75
  n = names[0]
74
76
  names = seqcheck(names, SEQ[1][:msg], SEQ[1][:val])
75
77
  if n&.at("./self::introduction")
76
- names = seqcheck(names, SEQ[2][:msg], SEQ[2][:val])
78
+ names = seqcheck(names, SEQ[2][:msg], SEQ[2][:val])
77
79
  end
78
- names = seqcheck(names, SEQ[3][:msg], SEQ[3][:val])
80
+ names = seqcheck(names, SEQ[3][:msg], SEQ[3][:val])
79
81
  n = names.shift
80
82
  if n&.at("./self::definitions")
81
- n = names.shift
83
+ n = names.shift
82
84
  end
83
85
  if n.nil? || n.name != "clause"
84
86
  @log.add("Style", nil, "Document must contain at least one clause")
85
87
  end
86
88
  n&.at("./self::clause") ||
87
89
  @log.add("Style", nil, "Document must contain clause after "\
88
- "Terms and Definitions")
90
+ "Terms and Definitions")
89
91
  n&.at("./self::clause[@type = 'scope']") &&
90
- @log.add("Style", nil, "Scope must occur before Terms and Definitions")
91
- n = names.shift
92
+ @log.add("Style", nil,
93
+ "Scope must occur before Terms and Definitions")
94
+ n = names.shift
92
95
  while n&.name == "clause"
93
96
  n&.at("./self::clause[@type = 'scope']")
94
- @log.add("Style", nil, "Scope must occur before Terms and Definitions")
95
- n = names.shift
97
+ @log.add("Style", nil,
98
+ "Scope must occur before Terms and Definitions")
99
+ n = names.shift
96
100
  end
97
- unless %w(annex references).include? n&.name
98
- @log.add("Style", nil, "Only annexes and references can follow clauses")
101
+ unless %w(annex references).include? n&.name
102
+ @log.add("Style", nil,
103
+ "Only annexes and references can follow clauses")
99
104
  end
100
- while n&.name == "annex"
105
+ while n&.name == "annex"
101
106
  n = names.shift
102
107
  if n.nil?
103
108
  @log.add("Style", nil, "Document must include (references) "\
104
- "Normative References")
109
+ "Normative References")
105
110
  end
106
111
  end
107
- n&.at("./self::references[@normative = 'true']") ||
112
+ n&.at("./self::references[@normative = 'true']") ||
108
113
  @log.add("Style", nil, "Document must include (references) "\
109
- "Normative References")
114
+ "Normative References")
110
115
  n = names&.shift
111
116
  n&.at("./self::references[@normative = 'false']") ||
112
- @log.add("Style", nil, "Final section must be (references) Bibliography")
117
+ @log.add("Style", nil,
118
+ "Final section must be (references) Bibliography")
113
119
  names.empty? ||
114
- @log.add("Style", nil, "There are sections after the final Bibliography")
120
+ @log.add("Style", nil,
121
+ "There are sections after the final Bibliography")
115
122
  end
116
123
 
117
124
  def style_warning(node, msg, text = nil)
118
125
  return if @novalid
126
+
119
127
  w = msg
120
128
  w += ": #{text}" if text
121
129
  @log.add("Style", node, w)