Class: IsoDoc::Iso::Xref

Inherits:
Xref
  • Object
show all
Defined in:
lib/isodoc/iso/xref.rb

Instance Method Summary collapse

Instance Method Details

#annex_names(clause, num) ⇒ Object



27
28
29
30
# File 'lib/isodoc/iso/xref.rb', line 27

def annex_names(clause, num)
  appendix_names(clause, num)
  super
end

#annex_names1(clause, num, level) ⇒ Object



51
52
53
54
55
56
# File 'lib/isodoc/iso/xref.rb', line 51

def annex_names1(clause, num, level)
  @anchors[clause["id"]] = { label: num, xref: num, level: level }
  clause.xpath(ns("./clause | ./references")).each_with_index do |c, i|
    annex_names1(c, "#{num}.#{i + 1}", level + 1)
  end
end

#appendix_names(clause, num) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/isodoc/iso/xref.rb', line 32

def appendix_names(clause, num)
  clause.xpath(ns("./appendix")).each_with_index do |c, i|
    @anchors[c["id"]] = anchor_struct(i + 1, nil, @labels["appendix"], "clause")
    @anchors[c["id"]][:level] = 2
    @anchors[c["id"]][:container] = clause["id"]
  end
end

#figure_anchor(t, sublabel, label) ⇒ Object



69
70
71
72
73
74
75
# File 'lib/isodoc/iso/xref.rb', line 69

def figure_anchor(t, sublabel, label)
  @anchors[t["id"]] = anchor_struct(
    (sublabel ? "#{label} #{sublabel}" : label),
    nil, @labels["figure"], "figure", t["unnumbered"])
  sublabel && t["unnumbered"] != "true" and
    @anchors[t["id"]][:label] = sublabel
end

#hierarchical_figure_names(clause, num) ⇒ Object



89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/isodoc/iso/xref.rb', line 89

def hierarchical_figure_names(clause, num)
  c = IsoDoc::XrefGen::Counter.new
  j = 0
  clause.xpath(ns(".//figure |  .//sourcecode[not(ancestor::example)]")).
    each do |t|
    j = subfigure_increment(j, c, t)
    label = "#{num}#{hiersep}#{c.print}"
    sublabel = j.zero? ? nil : "#{(j+96).chr})"
    next if t["id"].nil? || t["id"].empty?
    figure_anchor(t, sublabel, label)
  end
end

#hierarchical_formula_names(clause, num) ⇒ Object



58
59
60
61
62
63
64
65
66
67
# File 'lib/isodoc/iso/xref.rb', line 58

def hierarchical_formula_names(clause, num)
  c = IsoDoc::XrefGen::Counter.new
  clause.xpath(ns(".//formula")).each do |t|
    next if t["id"].nil? || t["id"].empty?
    @anchors[t["id"]] =
      anchor_struct("#{num}#{hiersep}#{c.increment(t).print}", t,
                    t["inequality"] ? @labels["inequality"] : @labels["formula"],
                    "formula", t["unnumbered"])
  end
end

#initial_anchor_names(d) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/isodoc/iso/xref.rb', line 4

def initial_anchor_names(d)
  if @klass.amd(d)
    d.xpath(ns("//preface/*")).each { |c| c.element? and preface_names(c) }
    sequential_asset_names(d.xpath(ns("//preface/*")))
    middle_section_asset_names(d)
    termnote_anchor_names(d)
    termexample_anchor_names(d)
  else
    super
  end
  introduction_names(d.at(ns("//introduction")))
end

#introduction_names(clause) ⇒ Object

we can reference 0-number clauses in introduction



18
19
20
21
22
23
24
25
# File 'lib/isodoc/iso/xref.rb', line 18

def introduction_names(clause)
  return if clause.nil?
  clause.at(ns("./clause")) and @anchors[clause["id"]] = 
    { label: "0", level: 1, xref: clause.at(ns("./title"))&.text, type: "clause" }
  clause.xpath(ns("./clause")).each_with_index do |c, i|
    section_names1(c, "0.#{i + 1}", 2)
  end
end

#reference_names(ref) ⇒ Object



102
103
104
105
106
# File 'lib/isodoc/iso/xref.rb', line 102

def reference_names(ref)
  super
  @anchors[ref["id"]] = { xref: @anchors[ref["id"]][:xref].
                          sub(/ \(All Parts\)/i, "") }
end

#section_names1(clause, num, level) ⇒ Object



40
41
42
43
44
45
46
47
48
49
# File 'lib/isodoc/iso/xref.rb', line 40

def section_names1(clause, num, level)
  @anchors[clause["id"]] =
    { label: num, level: level, xref: num }
  # subclauses are not prefixed with "Clause"
  clause.xpath(ns("./clause | ./terms | ./term | ./definitions | "\
                  "./references")).
                 each_with_index do |c, i|
    section_names1(c, "#{num}.#{i + 1}", level + 1)
  end
end

#sequential_figure_names(clause) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
# File 'lib/isodoc/iso/xref.rb', line 77

def sequential_figure_names(clause)
  c = IsoDoc::XrefGen::Counter.new
  j = 0
  clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]")).
    each do |t|
    j = subfigure_increment(j, c, t)
    sublabel = j.zero? ? nil : "#{(j+96).chr})"
    next if t["id"].nil? || t["id"].empty?
    figure_anchor(t, sublabel, c.print)
  end
end