module IsoDoc::XrefGen::Sections
Constants
- ISO_PUBLISHER_XPATH
- SUBCLAUSES
Public Instance Methods
annex_name_lbl(clause, num)
click to toggle source
# File lib/isodoc/xref/xref_sect_gen.rb, line 103 def annex_name_lbl(clause, num) obl = l10n("(#{@labels['inform_annex']})") clause["obligation"] == "normative" and obl = l10n("(#{@labels['norm_annex']})") l10n("<strong>#{@labels['annex']} #{num}</strong><br/>#{obl}") end
annex_names(clause, num)
click to toggle source
# File lib/isodoc/xref/xref_sect_gen.rb, line 119 def annex_names(clause, num) @anchors[clause["id"]] = { label: annex_name_lbl(clause, num), type: "clause", value: num.to_s, xref: "#{@labels['annex']} #{num}", level: 1 } if a = single_annex_special_section(clause) annex_names1(a, num.to_s, 1) else i = Counter.new clause.xpath(ns(SUBCLAUSES)).each do |c| i.increment(c) annex_names1(c, "#{num}.#{i.print}", 2) end end hierarchical_asset_names(clause, num) end
annex_names1(clause, num, level)
click to toggle source
# File lib/isodoc/xref/xref_sect_gen.rb, line 135 def annex_names1(clause, num, level) @anchors[clause["id"]] = { label: num, xref: "#{@labels['annex']} #{num}", level: level, type: "clause" } i = Counter.new clause.xpath(ns(SUBCLAUSES)).each do |c| i.increment(c) annex_names1(c, "#{num}.#{i.print}", level + 1) end end
back_anchor_names(docxml)
click to toggle source
# File lib/isodoc/xref/xref_sect_gen.rb, line 3 def back_anchor_names(docxml) i = Counter.new("@") docxml.xpath(ns("//annex")).each do |c| i.increment(c) annex_names(c, i.print) end docxml.xpath(ns(@klass.bibliography_xpath)).each do |b| preface_names(b) end docxml.xpath(ns("//bibitem[not(ancestor::bibitem)]")).each do |ref| reference_names(ref) end end
clause_names(docxml, num)
click to toggle source
# File lib/isodoc/xref/xref_sect_gen.rb, line 71 def clause_names(docxml, num) docxml.xpath(ns(@klass.middle_clause(docxml))).each_with_index do |c, _i| section_names(c, num, 1) end end
initial_anchor_names(doc)
click to toggle source
# File lib/isodoc/xref/xref_sect_gen.rb, line 17 def initial_anchor_names(doc) doc.xpath(ns("//preface/*")).each { |c| c.element? and preface_names(c) } # potentially overridden in middle_section_asset_names() sequential_asset_names(doc.xpath(ns("//preface/*"))) n = Counter.new n = section_names(doc.at(ns("//clause[@type = 'scope']")), n, 1) n = section_names(doc.at(ns(@klass.norm_ref_xpath)), n, 1) n = section_names(doc.at(ns("//sections/terms | "\ "//sections/clause[descendant::terms]")), n, 1) n = section_names(doc.at(ns("//sections/definitions")), n, 1) clause_names(doc, n) middle_section_asset_names(doc) termnote_anchor_names(doc) termexample_anchor_names(doc) end
middle_section_asset_names(doc)
click to toggle source
# File lib/isodoc/xref/xref_sect_gen.rb, line 63 def middle_section_asset_names(doc) middle_sections = "//clause[@type = 'scope'] | "\ "#{@klass.norm_ref_xpath} | "\ "//sections/terms | //preface/* | "\ "//sections/definitions | //clause[parent::sections]" sequential_asset_names(doc.xpath(ns(middle_sections))) end
preface_clause_name(clause)
click to toggle source
# File lib/isodoc/xref/xref_sect_gen.rb, line 33 def preface_clause_name(clause) clause.at(ns("./title"))&.text || clause.name.capitalize end
preface_names(clause)
click to toggle source
in StanDoc, prefaces have no numbering; they are referenced only by title
# File lib/isodoc/xref/xref_sect_gen.rb, line 41 def preface_names(clause) return if clause.nil? @anchors[clause["id"]] = { label: nil, level: 1, xref: preface_clause_name(clause), type: "clause" } clause.xpath(ns(SUBCLAUSES)).each_with_index do |c, i| preface_names1(c, c.at(ns("./title"))&.text, "#{preface_clause_name(clause)}, #{i + 1}", 2) end end
preface_names1(clause, title, parent_title, level)
click to toggle source
# File lib/isodoc/xref/xref_sect_gen.rb, line 53 def preface_names1(clause, title, parent_title, level) label = title || parent_title @anchors[clause["id"]] = { label: nil, level: level, xref: label, type: "clause" } clause.xpath(ns(SUBCLAUSES)).each_with_index do |c, i| preface_names1(c, c.at(ns("./title"))&.text, "#{label} #{i + 1}", level + 1) end end
reference_names(ref)
click to toggle source
# File lib/isodoc/xref/xref_sect_gen.rb, line 151 def reference_names(ref) # isopub = ref.at(ns(ISO_PUBLISHER_XPATH)) ids = @klass.bibitem_ref_code(ref) identifiers = @klass.render_identifier(ids) # date = ref.at(ns("./date[@type = 'published']")) reference = @klass.docid_l10n(identifiers[0] || identifiers[1]) @anchors[ref["id"]] = { xref: reference } end
section_names(clause, num, lvl)
click to toggle source
# File lib/isodoc/xref/xref_sect_gen.rb, line 77 def section_names(clause, num, lvl) return num if clause.nil? num.increment(clause) @anchors[clause["id"]] = { label: num.print, xref: l10n("#{@labels['clause']} #{num.print}"), level: lvl, type: "clause" } i = Counter.new clause.xpath(ns(SUBCLAUSES)).each do |c| i.increment(c) section_names1(c, "#{num.print}.#{i.print}", lvl + 1) end num end
section_names1(clause, num, level)
click to toggle source
# File lib/isodoc/xref/xref_sect_gen.rb, line 92 def section_names1(clause, num, level) @anchors[clause["id"]] = { label: num, level: level, xref: l10n("#{@labels['clause']} #{num}"), type: "clause" } i = Counter.new clause.xpath(ns(SUBCLAUSES)).each do |c| i.increment(c) section_names1(c, "#{num}.#{i.print}", level + 1) end end
single_annex_special_section(clause)
click to toggle source
# File lib/isodoc/xref/xref_sect_gen.rb, line 110 def single_annex_special_section(clause) a = clause.xpath(ns("./references | ./terms | ./definitions")) a.size == 1 or return nil clause.xpath(ns("./clause | ./p | ./table | ./ol | ./ul | ./dl | "\ "./note | ./admonition | ./figure")).empty? or return nil a[0] end