class Asciidoctor::Iec::Converter
Constants
- DOC_STAGE
- STAGE_ABBRS
- STAGE_CODES
- STAGE_NAMES
- XML_NAMESPACE
- XML_ROOT_TAG
Public Instance Methods
boilerplate_file(x_orig)
click to toggle source
# File lib/asciidoctor/iec/converter.rb, line 18 def boilerplate_file(x_orig) lang = case x_orig&.at("//bibdata/language")&.text when "fr" then "fr" else "en" end File.join(@libdir, "iec_intro_#{lang}.xml") end
doc_converter(node)
click to toggle source
# File lib/asciidoctor/iec/converter.rb, line 50 def doc_converter(node) node.nil? ? IsoDoc::Iec::WordConvert.new({}) : IsoDoc::Iec::WordConvert.new(doc_extract_attributes(node)) end
doctype_validate(xmldoc)
click to toggle source
# File lib/asciidoctor/iec/converter.rb, line 27 def doctype_validate(xmldoc) doctype = xmldoc&.at("//bibdata/ext/doctype")&.text %w(international-standard technical-specification technical-report publicly-available-specification international-workshop-agreement guide interpretation-sheet).include? doctype or @log.add("Document Attributes", nil, "#{doctype} is not a recognised document type") if function = xmldoc&.at("//bibdata/ext/function")&.text %w(emc quality-assurance safety environment).include? function or @log.add("Document Attributes", nil, "#{function} is not a recognised document function") end end
get_stage(node)
click to toggle source
# File lib/asciidoctor/iec/front.rb, line 164 def get_stage(node) stage = node.attr("status") || node.attr("docstage") || "60" m = /([0-9])CD$/.match(stage) and node.set_attr("iteration", m[1]) STAGE_CODES[stage] and stage = STAGE_CODES[stage][0..1] stage end
get_substage(node)
click to toggle source
# File lib/asciidoctor/iec/front.rb, line 171 def get_substage(node) st = node.attr("status") || node.attr("docstage") stage = get_stage(node) node.attr("docsubstage") || (if stage == "60" "60" else STAGE_CODES[st] ? STAGE_CODES[st][2..3] : "00" end) end
html_converter(node)
click to toggle source
# File lib/asciidoctor/iec/converter.rb, line 45 def html_converter(node) node.nil? ? IsoDoc::Iec::HtmlConvert.new({}) : IsoDoc::Iec::HtmlConvert.new(html_extract_attributes(node)) end
id_edition_suffix(docnum, node)
click to toggle source
# File lib/asciidoctor/iec/front.rb, line 54 def id_edition_suffix(docnum, node) ed = node.attr("edition") || 1 docnum += " ED #{ed}" docnum end
id_stage_abbr(stage, _substage, node)
click to toggle source
# File lib/asciidoctor/iec/front.rb, line 182 def id_stage_abbr(stage, _substage, node) return "" if stage == "60" abbr = DOC_STAGE[stage.to_sym] || "" abbr = node.attr("iteration") + abbr if node.attr("iteration") abbr end
image_name_validate(xmldoc)
click to toggle source
# File lib/asciidoctor/iec/converter.rb, line 101 def image_name_validate(xmldoc) end
init(node)
click to toggle source
Calls superclass method
# File lib/asciidoctor/iec/converter.rb, line 13 def init(node) super @is_iev = node.attr("docnumber") == "60050" end
iso_id(node, xml)
click to toggle source
# File lib/asciidoctor/iec/front.rb, line 44 def iso_id(node, xml) return unless node.attr("docnumber") part, subpart = node&.attr("partnumber")&.split(/-/) dn = add_id_parts(node.attr("docnumber"), part, subpart) dn = id_stage_prefix(dn, node, false) dn = id_edition_suffix(dn, node) xml.docidentifier dn, **attr_code(type: "ISO") end
metadata_copyright(node, xml)
click to toggle source
# File lib/asciidoctor/iec/front.rb, line 28 def metadata_copyright(node, xml) publishers = node.attr("copyright-holder") || node.attr("publisher") || "IEC" csv_split(publishers)&.each do |p| xml.copyright do |c| c.from (node.attr("copyright-year") || Date.today.year) c.owner do |owner| owner.organization do |o| organization(o, p, true, node, !node.attr("copyright-holder") || node.attr("publisher")) end end end end end
metadata_doctype(node, xml)
click to toggle source
# File lib/asciidoctor/iec/front.rb, line 202 def metadata_doctype(node, xml) xml.doctype doctype(node) xml.horizontal (node.attr("horizontal") || "false") a = node.attr("function") and xml.function a end
metadata_ext(node, xml)
click to toggle source
Calls superclass method
# File lib/asciidoctor/iec/front.rb, line 212 def metadata_ext(node, xml) super a = node.attr("accessibility-color-inside") and xml.accessibility_color_inside a a = node.attr("price-code") and xml.price_code a a = node.attr("cen-processing") and xml.cen_processing a a = node.attr("secretary") and xml.secretary a a = node.attr("interest-to-committees") and xml.interest_to_committees a end
metadata_publisher(node, xml)
click to toggle source
# File lib/asciidoctor/iec/front.rb, line 16 def metadata_publisher(node, xml) publishers = node.attr("publisher") || "IEC" csv_split(publishers)&.each do |p| xml.contributor do |c| c.role **{ type: "publisher" } c.organization do |a| organization(a, p, true, node, !node.attr("publisher")) end end end end
metadata_status(node, xml)
click to toggle source
# File lib/asciidoctor/iec/front.rb, line 190 def metadata_status(node, xml) stage = get_stage(node) substage = get_substage(node) xml.status do |s| s.stage stage, **attr_code(abbreviation: stage_abbr(stage, substage)) subst = status_abbrev1(stage, substage, node.attr("iteration"), doctype(node), node.attr("draft")) s.substage substage, **attr_code(abbreviation: subst) node.attr("iteration") && (s.iteration node.attr("iteration")) end end
norm_ref_preface(f)
click to toggle source
Calls superclass method
# File lib/asciidoctor/iec/converter.rb, line 66 def norm_ref_preface(f) return super unless @is_iev f.at("./title").next = "<p>#{@i18n.norm_empty_pref}</p>" end
note(n)
click to toggle source
Calls superclass method
# File lib/asciidoctor/iec/converter.rb, line 84 def note(n) if n.title == "Note from TC/SC Officers" noko do |xml| xml.tc_sc_officers_note do |c| wrap_in_para(n, c) end end.join("\n") else super end end
note_cleanup(xmldoc)
click to toggle source
Calls superclass method
# File lib/asciidoctor/iec/converter.rb, line 96 def note_cleanup(xmldoc) super n = xmldoc.at("//tc-sc-officers-note") and xmldoc.at("//bibdata/ext").add_child(n.remove) end
pdf_converter(node)
click to toggle source
# File lib/asciidoctor/iec/converter.rb, line 55 def pdf_converter(node) return if node.attr("no-pdf") node.nil? ? IsoDoc::Iec::PdfConvert.new({}) : IsoDoc::Iec::PdfConvert.new(doc_extract_attributes(node)) end
presentation_xml_converter(node)
click to toggle source
# File lib/asciidoctor/iec/converter.rb, line 61 def presentation_xml_converter(node) node.nil? ? IsoDoc::Iec::PresentationXMLConvert.new({}) : IsoDoc::Iec::PresentationXMLConvert.new(doc_extract_attributes(node)) end
relaton_relations()
click to toggle source
Calls superclass method
# File lib/asciidoctor/iec/front.rb, line 208 def relaton_relations super + %w(obsoletes) end
sections_names_cleanup(x)
click to toggle source
Calls superclass method
# File lib/asciidoctor/iec/converter.rb, line 79 def sections_names_cleanup(x) super @is_iev and replace_title(x, "//introduction", @i18n&.introduction_iev) end
stage_abbr(stage, _substage)
click to toggle source
# File lib/asciidoctor/iec/front.rb, line 154 def stage_abbr(stage, _substage) return "PPUB" if stage == "60" DOC_STAGE[stage.to_sym] || "??" end
stage_name(stage, _substage, _doctype, _iteration)
click to toggle source
# File lib/asciidoctor/iec/front.rb, line 160 def stage_name(stage, _substage, _doctype, _iteration) STAGE_NAMES[stage.to_sym] end
status_abbrev1(stage, substage, iter, doctype, _draft)
click to toggle source
# File lib/asciidoctor/iec/front.rb, line 128 def status_abbrev1(stage, substage, iter, doctype, _draft) return "" unless stage abbr = STAGE_ABBRS.dig(stage, substage) || "??" if stage == "35" && substage == "92" iter = (iter.to_i + 1) % "02" end case doctype when "technical-report" abbr = "ADTR" if stage == "40" && substage == "99" abbr = "CDTR" if stage == "50" && substage == "20" abbr = "DTRM" if stage == "50" && substage == "92" when "technical-specification" abbr = "ADTS" if stage == "40" && substage == "99" abbr = "CDTS" if stage == "50" && substage == "20" abbr = "DTSM" if stage == "50" && substage == "92" when "interpretation-sheet" abbr = "RDISH" if stage == "50" && substage == "00" abbr = "CDISH" if stage == "50" && substage == "20" when "publicly-available-specification" abbr = "CDPAS" if stage == "50" && substage == "20" end abbr = abbr.sub(/CD$/, "#{iter}CD") if iter abbr end
sts_converter(node)
click to toggle source
# File lib/asciidoctor/iec/converter.rb, line 76 def sts_converter(node) end
term_defs_boilerplate(div, source, term, preface, isodoc)
click to toggle source
Calls superclass method
# File lib/asciidoctor/iec/converter.rb, line 72 def term_defs_boilerplate(div, source, term, preface, isodoc) return super unless @is_iev end
validate(doc)
click to toggle source
# File lib/asciidoctor/iec/converter.rb, line 39 def validate(doc) content_validate(doc) schema_validate(formattedstr_strip(doc.dup), File.join(File.dirname(__FILE__), "iec.rng")) end