module IsoDoc::Function::Section

Constants

TERM_CLAUSE

Public Instance Methods

abstract(isoxml, out) click to toggle source
# File lib/isodoc/function/section.rb, line 133
def abstract(isoxml, out)
  f = isoxml.at(ns("//preface/abstract")) || return
  page_break(out)
  out.div **attr_code(id: f["id"]) do |s|
    clause_name(nil, f.at(ns("./title")), s, { class: "AbstractTitle" })
    f.elements.each { |e| parse(e, s) unless e.name == "title" }
  end
end
acknowledgements(isoxml, out) click to toggle source
# File lib/isodoc/function/section.rb, line 121
def acknowledgements(isoxml, out)
  f = isoxml.at(ns("//acknowledgements")) || return
  title_attr = { class: "IntroTitle" }
  page_break(out)
  out.div **{ class: "Section3", id: f["id"] } do |div|
    clause_name(nil, f&.at(ns("./title")), div, title_attr)
    f.elements.each do |e|
      parse(e, div) unless e.name == "title"
    end
  end
end
annex(isoxml, out) click to toggle source
# File lib/isodoc/function/section.rb, line 35
def annex(isoxml, out)
  isoxml.xpath(ns("//annex")).each do |c|
    page_break(out)
    out.div **attr_code(annex_attrs(c)) do |s|
      c.elements.each do |c1|
        if c1.name == "title" then annex_name(c, c1, s)
        else
          parse(c1, s)
        end
      end
    end
  end
end
annex_attrs(node) click to toggle source
# File lib/isodoc/function/section.rb, line 31
def annex_attrs(node)
  { id: node["id"], class: "Section3" }
end
annex_name(_annex, name, div) click to toggle source
# File lib/isodoc/function/section_titles.rb, line 70
def annex_name(_annex, name, div)
  return if name.nil?

  div.h1 **{ class: "Annex" } do |t|
    name.children.each { |c2| parse(c2, t) }
    clause_parse_subtitle(name, t)
  end
end
clause(isoxml, out) click to toggle source
# File lib/isodoc/function/section.rb, line 20
def clause(isoxml, out)
  isoxml.xpath(ns(middle_clause(isoxml))).each do |c|
    out.div **attr_code(clause_attrs(c)) do |s|
      clause_name(nil, c&.at(ns("./title")), s, nil)
      c.elements.reject { |c1| c1.name == "title" }.each do |c1|
        parse(c1, s)
      end
    end
  end
end
clause_attrs(node) click to toggle source
# File lib/isodoc/function/section.rb, line 6
def clause_attrs(node)
  { id: node["id"] }
end
clause_name(_num, title, div, header_class) click to toggle source
# File lib/isodoc/function/section_titles.rb, line 57
def clause_name(_num, title, div, header_class)
  header_class = {} if header_class.nil?
  div.h1 **attr_code(header_class) do |h1|
    if title.is_a?(String)
      h1 << title
    else
      title&.children&.each { |c2| parse(c2, h1) }
      clause_parse_subtitle(title, h1)
    end
  end
  div.parent.at(".//h1")
end
clause_parse(node, out) click to toggle source

used for subclauses

# File lib/isodoc/function/section.rb, line 11
def clause_parse(node, out)
  out.div **attr_code(clause_attrs(node)) do |div|
    clause_parse_title(node, div, node.at(ns("./title")), out)
    node.children.reject { |c1| c1.name == "title" }.each do |c1|
      parse(c1, div)
    end
  end
end
clause_parse_subtitle(title, heading) click to toggle source
# File lib/isodoc/function/section_titles.rb, line 48
def clause_parse_subtitle(title, heading)
  if var = title&.at("./following-sibling::xmlns:variant-title"\
                     "[@type = 'sub']")&.remove
    heading.br nil
    heading.br nil
    var.children.each { |c2| parse(c2, heading) }
  end
end
clause_parse_title(node, div, title, out, header_class = {}) click to toggle source

used for subclauses

# File lib/isodoc/function/section_titles.rb, line 22
def clause_parse_title(node, div, title, out, header_class = {})
  return if title.nil?

  if node["inline-header"] == "true"
    inline_header_title(out, node, title)
  else
    clause_parse_title1(node, div, title, out, header_class)
  end
end
clause_parse_title1(node, div, title, _out, header_class = {}) click to toggle source
# File lib/isodoc/function/section_titles.rb, line 32
def clause_parse_title1(node, div, title, _out, header_class = {})
  depth = clause_title_depth(node, title)
  div.send "h#{depth}", **attr_code(header_class) do |h|
    title&.children&.each { |c2| parse(c2, h) }
    clause_parse_subtitle(title, h)
  end
end
clause_title_depth(node, title) click to toggle source
# File lib/isodoc/function/section_titles.rb, line 40
def clause_title_depth(node, title)
  depth = node.ancestors("clause, annex, terms, references, "\
                         "definitions, acknowledgements, introduction, "\
                         "foreword").size + 1
  depth = title["depth"] if title && title["depth"]
  depth
end
clausedelim() click to toggle source
# File lib/isodoc/function/section_titles.rb, line 4
def clausedelim
  "."
end
clausedelimspace(out) click to toggle source
# File lib/isodoc/function/section_titles.rb, line 8
def clausedelimspace(out)
  insert_tab(out, 1)
end
feedback_parse(node, out) click to toggle source
# File lib/isodoc/function/section.rb, line 193
def feedback_parse(node, out)
  return if @bare

  out.div **{ class: "boilerplate-feedback" } do |div|
    node.children.each { |n| parse(n, div) }
  end
end
foreword(isoxml, out) click to toggle source
# File lib/isodoc/function/section.rb, line 111
def foreword(isoxml, out)
  f = isoxml.at(ns("//foreword")) || return
  page_break(out)
  out.div **attr_code(id: f["id"]) do |s|
    clause_name(nil, f.at(ns("./title")) || @i18n.foreword, s,
                { class: "ForewordTitle" })
    f.elements.each { |e| parse(e, s) unless e.name == "title" }
  end
end
inline_header_title(out, _node, title) click to toggle source
# File lib/isodoc/function/section_titles.rb, line 12
def inline_header_title(out, _node, title)
  out.span **{ class: "zzMoveToFollowing" } do |s|
    s.b do |b|
      title&.children&.each { |c2| parse(c2, b) }
      clausedelimspace(out) if /\S/.match?(title&.text)
    end
  end
end
introduction(isoxml, out) click to toggle source
# File lib/isodoc/function/section.rb, line 100
def introduction(isoxml, out)
  f = isoxml.at(ns("//introduction")) || return
  page_break(out)
  out.div **{ class: "Section3", id: f["id"] } do |div|
    clause_name(nil, f.at(ns("./title")), div, { class: "IntroTitle" })
    f.elements.each do |e|
      parse(e, div) unless e.name == "title"
    end
  end
end
is_clause?(name) click to toggle source
# File lib/isodoc/function/section.rb, line 155
def is_clause?(name)
  %w(clause references definitions terms foreword introduction abstract
     acknowledgements).include? name
end
license_parse(node, out) click to toggle source
# File lib/isodoc/function/section.rb, line 177
def license_parse(node, out)
  return if @bare

  out.div **{ class: "boilerplate-license" } do |div|
    node.children.each { |n| parse(n, div) }
  end
end
preface(isoxml, out) click to toggle source
# File lib/isodoc/function/section.rb, line 142
def preface(isoxml, out)
  isoxml.xpath(ns("//preface/clause | //preface/references | "\
                  "//preface/definitions | //preface/terms")).each do |f|
    page_break(out)
    out.div **{ class: "Section3", id: f["id"] } do |div|
      clause_name(nil, f&.at(ns("./title")), div, { class: "IntroTitle" })
      f.elements.each do |e|
        parse(e, div) unless e.name == "title"
      end
    end
  end
end
preface_block(isoxml, out) click to toggle source
# File lib/isodoc/function/section.rb, line 160
def preface_block(isoxml, out)
  p = isoxml.at(ns("//preface")) or return
  p.elements.each do |e|
    next if is_clause?(e.name)

    parse(e, out)
  end
end
scope(isoxml, out, num) click to toggle source
# File lib/isodoc/function/section.rb, line 49
def scope(isoxml, out, num)
  f = isoxml.at(ns("//clause[@type = 'scope']")) or return num
  out.div **attr_code(id: f["id"]) do |div|
    num = num + 1
    clause_name(num, f&.at(ns("./title")), div, nil)
    f.elements.each do |e|
      parse(e, div) unless e.name == "title"
    end
  end
  num
end
symbols_abbrevs(isoxml, out, num) click to toggle source
# File lib/isodoc/function/section.rb, line 81
def symbols_abbrevs(isoxml, out, num)
  f = isoxml.at(ns("//sections/definitions")) or return num
  out.div **attr_code(id: f["id"], class: "Symbols") do |div|
    num = num + 1
    clause_name(num, f&.at(ns("./title")) || @i18n.symbols, div, nil)
    f.elements.each do |e|
      parse(e, div) unless e.name == "title"
    end
  end
  num
end
symbols_parse(isoxml, out) click to toggle source

subclause

# File lib/isodoc/function/section.rb, line 94
def symbols_parse(isoxml, out)
  isoxml.at(ns("./title")) or
    isoxml.children.first.previous = "<title>#{@i18n.symbols}</title>"
  clause_parse(isoxml, out)
end
terms_defs(isoxml, out, num) click to toggle source
# File lib/isodoc/function/section.rb, line 64
def terms_defs(isoxml, out, num)
  f = isoxml.at(ns(TERM_CLAUSE)) or return num
  out.div **attr_code(id: f["id"]) do |div|
    num = num + 1
    clause_name(num, f&.at(ns("./title")), div, nil)
    f.elements.each do |e|
      parse(e, div) unless %w{title source}.include? e.name
    end
  end
  num
end
terms_parse(isoxml, out) click to toggle source

subclause

# File lib/isodoc/function/section.rb, line 77
def terms_parse(isoxml, out)
  clause_parse(isoxml, out)
end
variant_title(_node, _out) click to toggle source
# File lib/isodoc/function/section_titles.rb, line 79
def variant_title(_node, _out); end