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



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

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

#annex_names1(clause, num, level) ⇒ Object



66
67
68
69
70
71
72
73
# File 'lib/isodoc/iso/xref.rb', line 66

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

#appendix_names(clause, num) ⇒ Object



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

def appendix_names(clause, num)
  i = Counter.new
  clause.xpath(ns("./appendix")).each do |c|
    i.increment(c)
    @anchors[c["id"]] = anchor_struct(i.print, nil, @labels["appendix"], "clause")
    @anchors[c["id"]][:level] = 2
    @anchors[c["id"]][:container] = clause["id"]
    j = Counter.new
    c.xpath(ns("./clause | ./references")).each do |c1|
      j.increment(c1)
      appendix_names1(c1, l10n("#{@labels["appendix"]} #{i.print}.#{j.print}"), 3, clause["id"])
    end
  end
end

#appendix_names1(clause, num, level, container) ⇒ Object



75
76
77
78
79
80
81
82
# File 'lib/isodoc/iso/xref.rb', line 75

def appendix_names1(clause, num, level, container)
  @anchors[clause["id"]] = { label: num, xref: num, level: level, container: container }
  i = Counter.new
  clause.xpath(ns("./clause | ./references")).each do |c|
    i.increment(c)
    appendix_names1(c, "#{num}.#{i.print}", level + 1, container)
  end
end

#figure_anchor(t, sublabel, label) ⇒ Object



95
96
97
98
99
100
101
# File 'lib/isodoc/iso/xref.rb', line 95

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



115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/isodoc/iso/xref.rb', line 115

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



84
85
86
87
88
89
90
91
92
93
# File 'lib/isodoc/iso/xref.rb', line 84

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



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/isodoc/iso/xref.rb', line 7

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/*")))
    d.xpath(ns("//sections/clause")).each { |c| c.element? and preface_names(c) }
    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



22
23
24
25
26
27
28
29
30
31
# File 'lib/isodoc/iso/xref.rb', line 22

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" }
  i = Counter.new
  clause.xpath(ns("./clause")).each do |c|
    i.increment(c)
    section_names1(c, "0.#{i.print}", 2)
  end
end

#reference_names(ref) ⇒ Object



128
129
130
131
132
# File 'lib/isodoc/iso/xref.rb', line 128

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

#section_names1(clause, num, level) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/isodoc/iso/xref.rb', line 53

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

#sequential_figure_names(clause) ⇒ Object



103
104
105
106
107
108
109
110
111
112
113
# File 'lib/isodoc/iso/xref.rb', line 103

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