lib/asciidoctor/nist/validate.rb in metanorma-nist-1.1.3 vs lib/asciidoctor/nist/validate.rb in metanorma-nist-1.2.0
- old
+ new
@@ -19,38 +19,43 @@
end
def doctype_validate(xmldoc)
doctype = xmldoc&.at("//bibdata/ext/doctype")&.text
%w(standard).include? doctype or
- @log.add("Document Attributes", nil, "#{doctype} is not a recognised document type")
+ @log.add("Document Attributes", nil,
+ "#{doctype} is not a recognised document type")
end
def stage_validate(xmldoc)
stage = xmldoc&.at("//bibdata/status/stage")&.text
%w(draft-internal draft-wip draft-prelim draft-public draft-approval
final final-review).include? stage or
- @log.add("Document Attributes", nil, "#{stage} is not a recognised stage")
+ @log.add("Document Attributes", nil,
+ "#{stage} is not a recognised stage")
end
def substage_validate(xmldoc)
substage = xmldoc&.at("//bibdata/status/substage")&.text or return
%w(active retired withdrawn).include? substage or
- @log.add("Document Attributes", nil, "#{substage} is not a recognised substage")
+ @log.add("Document Attributes", nil,
+ "#{substage} is not a recognised substage")
end
def iteration_validate(xmldoc)
iteration = xmldoc&.at("//bibdata/status/iteration")&.text or return
%w(final).include? iteration.downcase or /^\d+$/.match(iteration) or
- @log.add("Document Attributes", nil, "#{iteration} is not a recognised iteration")
+ @log.add("Document Attributes", nil,
+ "#{iteration} is not a recognised iteration")
end
def series_validate(xmldoc)
series = xmldoc&.at("//bibdata/series/title")&.text or return
found = false
SERIES.each { |_, v| found = true if v == series }
found or
- @log.add("Document Attributes", nil, "#{series} is not a recognised series")
+ @log.add("Document Attributes", nil,
+ "#{series} is not a recognised series")
end
def validate(doc)
content_validate(doc)
schema_validate(formattedstr_strip(doc.dup),
@@ -58,12 +63,13 @@
end
def introduction_validate(doc)
intro = doc.at("//sections/clause/title")
intro&.text == "Introduction" or
- @log.add("Style", intro, "First section of document body should be Introduction, "\
- "not #{intro&.text}")
+ @log.add("Style", intro,
+ "First section of document body should be Introduction, "\
+ "not #{intro&.text}")
end
REF_SECTIONS_TO_VALIDATE = "//references[not(parent::clause)]/title | "\
"//clause[descendant::references][not(parent::clause)]/title".freeze
@@ -78,11 +84,12 @@
names = f.map { |s| s&.text }
return if names.empty?
return if names == ["References"]
return if names == ["Bibliography"]
return if names == ["References", "Bibliography"]
- @log.add("Style", nil, "Reference clauses #{names.join(', ')} do not follow expected "\
- "pattern in NIST")
+ @log.add("Style", nil,
+ "Reference clauses #{names.join(', ')} do not follow "\
+ "expected pattern in NIST")
end
end
end
end