Class: IsoDoc::Plateau::Xref

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

Instance Method Summary collapse

Constructor Details

#initialize(lang, script, klass, i18n, options) ⇒ Xref

Returns a new instance of Xref.



23
24
25
26
# File 'lib/isodoc/plateau/xref.rb', line 23

def initialize(lang, script, klass, i18n, options)
  @iso = ::IsoDoc::Iso::Xref.new(lang, script, klass, i18n, options)
  super
end

Instance Method Details

#clause_order_main(_docxml) ⇒ Object



28
29
30
31
32
33
34
35
36
# File 'lib/isodoc/plateau/xref.rb', line 28

def clause_order_main(_docxml)
  [
    {
      path: "//sections/introduction | //sections/clause | " \
            "//sections/terms | //sections/definitions | " \
            "//sections/references", multi: true
    },
  ]
end

#hierarchical_figure_class_names(clause, num) ⇒ Object



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

def hierarchical_figure_class_names(clause, num)
  c = {}
  j = 0
  clause.xpath(ns(".//figure[@class][not(@class = 'pseudocode')]"))
    .noblank.each do |t|
    c[t["class"]] ||= IsoDoc::XrefGen::Counter.new
    labelled_ancestor(t, %w(figure)) and next
    j = subfigure_increment(j, c[t["class"]], t)
    sublabel = j.zero? ? nil : "#{(j + 96).chr})"
    figure_anchor(t, sublabel, hiersemx(clause, num, c[t["class"]], t),
                  t["class"])
  end
end

#hierarchical_figure_names(clauses, num) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/isodoc/plateau/xref.rb', line 63

def hierarchical_figure_names(clauses, num)
  c = IsoDoc::XrefGen::Counter.new
  j = 0
  nodeSet(clauses).each do |clause|
    clause.xpath(ns(FIGURE_NO_CLASS)).noblank.each do |t|
      labelled_ancestor(t, %w(figure)) and next # do not label nested figure
      j = subfigure_increment(j, c, t)
      sublabel = subfigure_label(j)
      figure_anchor(t, sublabel, hiersemx(clause, num, c, t), "figure")
    end
    hierarchical_figure_class_names(clause, num)
  end
end

#hiersepObject



47
48
49
# File 'lib/isodoc/plateau/xref.rb', line 47

def hiersep
  "-"
end

#list_item_anchor_names(list, list_anchor, depth, prev_label, refer_list) ⇒ Object



91
92
93
94
95
96
97
# File 'lib/isodoc/plateau/xref.rb', line 91

def list_item_anchor_names(list, list_anchor, depth, prev_label,
refer_list)
  @iso.anchors.merge!(@anchors)
  @iso.list_item_anchor_names(list, list_anchor, depth, prev_label,
                              refer_list)
  @anchors.merge!(@iso.anchors)
end

#list_item_value(entry, counter, depth, opts) ⇒ Object



99
100
101
102
103
# File 'lib/isodoc/plateau/xref.rb', line 99

def list_item_value(entry, counter, depth, opts)
  @iso.anchors.merge!(@anchors)
  @iso.list_item_value(entry, counter, depth, opts)
  @anchors.merge!(@iso.anchors)
end

#middle_asset_names(clause, container: false) ⇒ Object

container makes numbering be prefixed with the parent clause reference



52
53
54
55
56
57
58
59
60
61
# File 'lib/isodoc/plateau/xref.rb', line 52

def middle_asset_names(clause, container: false)
  sequential_formula_names(clause, container:)
  sequential_permission_names(clause, container:)
  clause.each do |c|
    num = @anchors.dig(c["id"], :label) || @anchors.dig(c["id"], :xref) ||
      c.at(ns("./title"))&.text
    hierarchical_table_names(c, num)
    hierarchical_figure_names(c, num)
  end
end

#middle_section_asset_names(doc) ⇒ Object



38
39
40
41
42
43
44
45
# File 'lib/isodoc/plateau/xref.rb', line 38

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)))
  middle_asset_names(doc.xpath(ns(middle_sections)))
end