lib/asciidoctor/iso/validate_section.rb in asciidoctor-iso-0.10.1 vs lib/asciidoctor/iso/validate_section.rb in asciidoctor-iso-0.10.2

- old
+ new

@@ -1,19 +1,18 @@ require "nokogiri" module Asciidoctor module ISO - module Validate + class Converter < Standoc::Converter def section_validate(doc) foreword_validate(doc.root) normref_validate(doc.root) symbols_validate(doc.root) sections_sequence_validate(doc.root) section_style(doc.root) subclause_validate(doc.root) - sourcecode_style(doc.root) - asset_style(doc.root) + super end def foreword_validate(root) f = root.at("//foreword") || return s = f.at("./clause") @@ -141,10 +140,17 @@ warn("ISO style: Final section must be (references) Bibliography") names.empty? || warn("ISO style: There are sections after the final Bibliography") end + def style_warning(node, msg, text) + return if @novalid + w = "ISO style: WARNING (#{Standoc::Utils::current_location(node)}): #{msg}" + w += ": #{text}" if text + warn w + end + NORM_ISO_WARN = "non-ISO/IEC reference not expected as normative".freeze SCOPE_WARN = "Scope contains subclauses: should be succint".freeze def section_style(root) foreword_style(root.at("//foreword")) @@ -180,23 +186,23 @@ end end def norm_bibitem_style(root) root.xpath(NORM_BIBITEMS).each do |b| - if b.at(Cleanup::ISO_PUBLISHER_XPATH).nil? - Utils::warning(b, NORM_ISO_WARN, b.text) + if b.at(Standoc::Converter::ISO_PUBLISHER_XPATH).nil? + Standoc::Utils::warning(b, NORM_ISO_WARN, b.text) end end end def asset_style(root) root.xpath("//example | //termexample").each { |e| example_style(e) } root.xpath("//definition").each { |e| definition_style(e) } root.xpath("//note").each { |e| note_style(e) } root.xpath("//fn").each { |e| footnote_style(e) } root.xpath(ASSETS_TO_STYLE).each { |e| style(e, extract_text(e)) } - asset_title_style(root) norm_bibitem_style(root) + super end def subclause_validate(root) root.xpath("//clause/clause/clause/clause/clause/clause/clause/clause").each do |c| style_warning(c, "Exceeds the maximum clause depth of 7", nil)