Module: IsoDoc::XrefGen::Blocks
- Included in:
- IsoDoc::Xref
- Defined in:
- lib/isodoc/xref/xref_gen.rb,
lib/isodoc/xref/xref_util.rb,
lib/isodoc/xref/xref_gen_seq.rb
Constant Summary collapse
- NUMBERED_BLOCKS =
%w(termnote termexample note example requirement recommendation permission figure table formula admonition sourcecode).freeze
- SECTIONS_XPATH =
"//foreword | //introduction | //acknowledgements | " \ "//preface/abstract | " \ "//preface/terms | //preface/definitions | //preface/references | " \ "//preface/clause | //sections/terms | //annex | " \ "//sections/clause | //sections/definitions | " \ "//bibliography/references | //bibliography/clause".freeze
- CHILD_SECTIONS =
"./clause | ./appendix | ./terms | ./definitions | " \ "./references".freeze
- FIGURE_NO_CLASS =
<<~XPATH.freeze .//figure[not(@class)] | .//figure[@class = 'pseudocode'] | .//sourcecode[not(ancestor::example)] XPATH
- FIRST_LVL_REQ_RULE =
<<~XPATH.freeze [not(ancestor::permission or ancestor::requirement or ancestor::recommendation)] XPATH
- FIRST_LVL_REQ =
<<~XPATH.freeze .//permission#{FIRST_LVL_REQ_RULE} | .//requirement#{FIRST_LVL_REQ_RULE} | .//recommendation#{FIRST_LVL_REQ_RULE} XPATH
- REQ_CHILDREN =
<<~XPATH.freeze ./permission | ./requirement | ./recommendation XPATH
Instance Method Summary collapse
- #admonition_anchor_names(sections) ⇒ Object
- #admonition_anchor_names1(notes, counter) ⇒ Object
- #amend_autonums(amend) ⇒ Object
- #amend_preprocess(xmldoc) ⇒ Object
- #blank?(text) ⇒ Boolean
- #bookmark_anchor_names(xml) ⇒ Object
- #bookmark_container(parent) ⇒ Object
- #child_asset_path(asset) ⇒ Object
- #deflist_anchor_names(sections) ⇒ Object
- #deflist_anchor_names1(notes, counter) ⇒ Object
- #deflist_term_anchor_names(list, list_anchor) ⇒ Object
- #dt2xreflabel(dterm) ⇒ Object
- #example_anchor_names(sections) ⇒ Object
- #example_anchor_names1(notes, counter) ⇒ Object
- #hierarchical_asset_names(clause, num) ⇒ Object
- #hierarchical_figure_body(num, subfignum, counter, block, klass) ⇒ Object
- #hierarchical_figure_class_names(clause, num) ⇒ Object
- #hierarchical_figure_names(clause, num) ⇒ Object
- #hierarchical_formula_names(clause, num) ⇒ Object
- #hierarchical_permission_body(id, block, label, klass, model) ⇒ Object
- #hierarchical_permission_children(block, lbl) ⇒ Object
- #hierarchical_permission_names(clause, num) ⇒ Object
- #hierarchical_table_names(clause, num) ⇒ Object
- #hierfigsep ⇒ Object
- #hiersep ⇒ Object
- #id_ancestor(node) ⇒ Object
- #increment_label(elems, node, counter, increment: true) ⇒ Object
- #list_anchor_names(sections) ⇒ Object
- #list_item_anchor_label(label, list_anchor, prev_label, refer_list) ⇒ Object
- #list_item_anchor_names(list, list_anchor, depth, prev_label, refer_list) ⇒ Object
- #list_item_value(entry, counter, depth, opts) ⇒ Object
- #noblank(xpath) ⇒ Object
- #note_anchor_names(sections) ⇒ Object
- #note_anchor_names1(notes, counter) ⇒ Object
- #reqt2class_label(elem, model) ⇒ Object
- #reqt2class_nested_label(elem, model) ⇒ Object
- #sections_xpath ⇒ Object
-
#sequential_asset_names(clause, container: false) ⇒ Object
container makes numbering be prefixed with the parent clause reference.
- #sequential_figure_body(subfig, counter, elem, klass, container: false) ⇒ Object
- #sequential_figure_class_names(clause, container: false) ⇒ Object
- #sequential_figure_names(clause, container: false) ⇒ Object
- #sequential_formula_names(clause, container: false) ⇒ Object
- #sequential_permission_body(id, elem, label, klass, model, container: false) ⇒ Object
- #sequential_permission_children(elem, lbl, container: false) ⇒ Object
- #sequential_permission_names(clause, container: false) ⇒ Object
- #sequential_table_names(clause, container: false) ⇒ Object
- #subfigure_increment(idx, counter, elem) ⇒ Object
- #subfigure_label(subfignum) ⇒ Object
- #termexample_anchor_names(docxml) ⇒ Object
- #termnote_anchor_names(docxml) ⇒ Object
- #termnote_label(note) ⇒ Object
Instance Method Details
#admonition_anchor_names(sections) ⇒ Object
88 89 90 91 92 93 94 95 |
# File 'lib/isodoc/xref/xref_gen.rb', line 88 def admonition_anchor_names(sections) sections.each do |s| s.at(ns(".//admonition[@type = 'box']")) or next notes = s.xpath(child_asset_path("admonition[@type = 'box']")) admonition_anchor_names1(notes, Counter.new) admonition_anchor_names(s.xpath(ns(CHILD_SECTIONS))) end end |
#admonition_anchor_names1(notes, counter) ⇒ Object
97 98 99 100 101 102 103 |
# File 'lib/isodoc/xref/xref_gen.rb', line 97 def admonition_anchor_names1(notes, counter) notes.noblank.each do |n| @anchors[n["id"]] ||= anchor_struct(increment_label(notes, n, counter), n, @labels["box"], "admonition", n["unnumbered"]) end end |
#amend_autonums(amend) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/isodoc/xref/xref_gen.rb', line 23 def amend_autonums(amend) autonum = {} amend.xpath(ns("./autonumber")).each do |n| autonum[n["type"]] = n.text end autonum end |
#amend_preprocess(xmldoc) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/isodoc/xref/xref_gen.rb', line 11 def amend_preprocess(xmldoc) xmldoc.xpath(ns("//amend[newcontent]")).each do |a| autonum = amend_autonums(a) NUMBERED_BLOCKS.each do |b| a.xpath(ns("./newcontent//#{b}")).each_with_index do |e, i| autonum[b] && i.zero? and e["number"] = autonum[b] !autonum[b] and e["unnumbered"] = "true" end end end end |
#blank?(text) ⇒ Boolean
18 19 20 |
# File 'lib/isodoc/xref/xref_util.rb', line 18 def blank?(text) text.nil? || text.empty? end |
#bookmark_anchor_names(xml) ⇒ Object
227 228 229 230 231 232 233 234 235 |
# File 'lib/isodoc/xref/xref_gen.rb', line 227 def bookmark_anchor_names(xml) xml.xpath(ns(".//bookmark")).noblank.each do |n| _parent, id = id_ancestor(n) # container = bookmark_container(parent) @anchors[n["id"]] = { type: "bookmark", label: nil, value: nil, xref: @anchors.dig(id, :xref) || "???", container: @anchors.dig(id, :container) } end end |
#bookmark_container(parent) ⇒ Object
216 217 218 219 220 221 222 223 224 225 |
# File 'lib/isodoc/xref/xref_gen.rb', line 216 def bookmark_container(parent) if parent clause = parent.xpath(CLAUSE_ANCESTOR)&.last if clause["id"] == id nil else @anchors.dig(clause["id"], :xref) end end end |
#child_asset_path(asset) ⇒ Object
38 39 40 41 42 |
# File 'lib/isodoc/xref/xref_util.rb', line 38 def child_asset_path(asset) "./*[not(self::xmlns:clause) and not(self::xmlns:appendix) and " \ "not(self::xmlns:terms) and not(self::xmlns:definitions)]//xmlns:X | " \ "./xmlns:X".gsub("X", asset) end |
#deflist_anchor_names(sections) ⇒ Object
170 171 172 173 174 175 176 177 |
# File 'lib/isodoc/xref/xref_gen.rb', line 170 def deflist_anchor_names(sections) sections.each do |s| notes = s.xpath(ns(".//dl")) - s.xpath(ns(".//clause//dl")) - s.xpath(ns(".//appendix//dl")) - s.xpath(ns(".//dl//dl")) deflist_anchor_names1(notes, Counter.new) deflist_anchor_names(s.xpath(ns(CHILD_SECTIONS))) end end |
#deflist_anchor_names1(notes, counter) ⇒ Object
179 180 181 182 183 184 185 186 |
# File 'lib/isodoc/xref/xref_gen.rb', line 179 def deflist_anchor_names1(notes, counter) notes.noblank.each do |n| @anchors[n["id"]] = anchor_struct(increment_label(notes, n, counter), n, @labels["deflist"], "deflist", false) deflist_term_anchor_names(n, @anchors[n["id"]]) end end |
#deflist_term_anchor_names(list, list_anchor) ⇒ Object
188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/isodoc/xref/xref_gen.rb', line 188 def deflist_term_anchor_names(list, list_anchor) list.xpath(ns("./dt")).each do |li| label = "#{list_anchor[:xref]}: #{dt2xreflabel(li)}" li["id"] and @anchors[li["id"]] = { xref: label, type: "deflistitem", container: list_anchor[:container] } li.xpath(ns("./dl")).each do |dl| deflist_term_anchor_names(dl, list_anchor) end end end |
#dt2xreflabel(dterm) ⇒ Object
200 201 202 203 204 205 |
# File 'lib/isodoc/xref/xref_gen.rb', line 200 def dt2xreflabel(dterm) label = dterm.dup label.xpath(ns(".//p")).each { |x| x.replace(x.children) } label.xpath(ns(".//index")).each(&:remove) Common::to_xml(label.children) end |
#example_anchor_names(sections) ⇒ Object
105 106 107 108 109 110 111 |
# File 'lib/isodoc/xref/xref_gen.rb', line 105 def example_anchor_names(sections) sections.each do |s| notes = s.xpath(child_asset_path("example")) example_anchor_names1(notes, Counter.new) example_anchor_names(s.xpath(ns(CHILD_SECTIONS))) end end |
#example_anchor_names1(notes, counter) ⇒ Object
113 114 115 116 117 118 119 |
# File 'lib/isodoc/xref/xref_gen.rb', line 113 def example_anchor_names1(notes, counter) notes.noblank.each do |n| @anchors[n["id"]] ||= anchor_struct(increment_label(notes, n, counter), n, @labels["example_xref"], "example", n["unnumbered"]) end end |
#hierarchical_asset_names(clause, num) ⇒ Object
200 201 202 203 204 205 |
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 200 def hierarchical_asset_names(clause, num) hierarchical_table_names(clause, num) hierarchical_figure_names(clause, num) hierarchical_formula_names(clause, num) (clause, num) end |
#hierarchical_figure_body(num, subfignum, counter, block, klass) ⇒ Object
182 183 184 185 186 187 188 |
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 182 def hierarchical_figure_body(num, subfignum, counter, block, klass) label = "#{num}#{hiersep}#{counter.print}" + subfigure_label(subfignum) @anchors[block["id"]] = anchor_struct(label, nil, @labels[klass] || klass.capitalize, klass, block["unnumbered"]) end |
#hierarchical_figure_class_names(clause, num) ⇒ Object
170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 170 def hierarchical_figure_class_names(clause, num) c = {} j = 0 clause.xpath(ns(".//figure[@class][not(@class = 'pseudocode')]")) .noblank.each do |t| # labelled_ancestor(t, %w(figure)) and next c[t["class"]] ||= Counter.new j = subfigure_increment(j, c[t["class"]], t) hierarchical_figure_body(num, j, c[t["class"]], t, t["class"]) end end |
#hierarchical_figure_names(clause, num) ⇒ Object
159 160 161 162 163 164 165 166 167 168 |
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 159 def hierarchical_figure_names(clause, num) c = Counter.new j = 0 clause.xpath(ns(self.class::FIGURE_NO_CLASS)).noblank.each do |t| # labelled_ancestor(t, %w(figure)) and next j = subfigure_increment(j, c, t) hierarchical_figure_body(num, j, c, t, "figure") end hierarchical_figure_class_names(clause, num) end |
#hierarchical_formula_names(clause, num) ⇒ Object
207 208 209 210 211 212 213 214 215 216 |
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 207 def hierarchical_formula_names(clause, num) c = Counter.new clause.xpath(ns(".//formula")).noblank.each do |t| @anchors[t["id"]] = anchor_struct( "#{num}#{hiersep}#{c.increment(t).print}", nil, t["inequality"] ? @labels["inequality"] : @labels["formula"], "formula", t["unnumbered"] ) end end |
#hierarchical_permission_body(id, block, label, klass, model) ⇒ Object
240 241 242 243 244 245 246 247 248 249 |
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 240 def (id, block, label, klass, model) @anchors[block["id"]] = model.postprocess_anchor_struct( block, anchor_struct(id, nil, label, klass, block["unnumbered"]) ) model.(block, id, label, klass).each do |n| @anchors[n[:id]] = anchor_struct(n[:number], nil, n[:label], n[:klass], false) end end |
#hierarchical_permission_children(block, lbl) ⇒ Object
229 230 231 232 233 234 235 236 237 238 |
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 229 def (block, lbl) c = ReqCounter.new block.xpath(ns(REQ_CHILDREN)).noblank.each do |t| m = @reqt_models.model(t["model"]) klass, label = reqt2class_nested_label(t, m) id = "#{lbl}#{hierfigsep}#{c.increment(label, t).print}" (id, t, label, klass, m) (t, id) end end |
#hierarchical_permission_names(clause, num) ⇒ Object
218 219 220 221 222 223 224 225 226 227 |
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 218 def (clause, num) c = ReqCounter.new clause.xpath(ns(FIRST_LVL_REQ)).noblank.each do |t| m = @reqt_models.model(t["model"]) klass, label = reqt2class_label(t, m) id = "#{num}#{hiersep}#{c.increment(label, t).print}" (id, t, label, klass, m) (t, id) end end |
#hierarchical_table_names(clause, num) ⇒ Object
190 191 192 193 194 195 196 197 198 |
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 190 def hierarchical_table_names(clause, num) c = Counter.new clause.xpath(ns(".//table")).noblank.each do |t| # labelled_ancestor(t) and next @anchors[t["id"]] = anchor_struct("#{num}#{hiersep}#{c.increment(t).print}", nil, @labels["table"], "table", t["unnumbered"]) end end |
#hierfigsep ⇒ Object
10 11 12 |
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 10 def hierfigsep "-" end |
#hiersep ⇒ Object
6 7 8 |
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 6 def hiersep "." end |
#id_ancestor(node) ⇒ Object
207 208 209 210 211 212 213 214 |
# File 'lib/isodoc/xref/xref_gen.rb', line 207 def id_ancestor(node) parent = nil node.ancestors.each do |a| (a["id"] && (parent = a) && @anchors.dig(a["id"], :xref)) or next break end parent ? [parent, parent["id"]] : [nil, nil] end |
#increment_label(elems, node, counter, increment: true) ⇒ Object
35 36 37 38 39 |
# File 'lib/isodoc/xref/xref_gen.rb', line 35 def increment_label(elems, node, counter, increment: true) elems.size == 1 && !node["number"] and return "" counter.increment(node) if increment " #{counter.print}" end |
#list_anchor_names(sections) ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/isodoc/xref/xref_gen.rb', line 121 def list_anchor_names(sections) sections.each do |s| notes = s.xpath(ns(".//ol")) - s.xpath(ns(".//clause//ol")) - s.xpath(ns(".//appendix//ol")) - s.xpath(ns(".//ol//ol")) c = list_counter notes.noblank.each do |n| @anchors[n["id"]] = anchor_struct(increment_label(notes, n, c), n, @labels["list"], "list", false) list_item_anchor_names(n, @anchors[n["id"]], 1, "", notes.size != 1) end list_anchor_names(s.xpath(ns(CHILD_SECTIONS))) end end |
#list_item_anchor_label(label, list_anchor, prev_label, refer_list) ⇒ Object
160 161 162 163 164 165 166 167 168 |
# File 'lib/isodoc/xref/xref_gen.rb', line 160 def list_item_anchor_label(label, list_anchor, prev_label, refer_list) prev_label.empty? or label = @i18n.list_nested_xref.sub("%1", "#{prev_label})") .sub("%2", label) refer_list and label = @i18n.list_nested_xref.sub("%1", list_anchor[:xref]) .sub("%2", label) label end |
#list_item_anchor_names(list, list_anchor, depth, prev_label, refer_list) ⇒ Object
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/isodoc/xref/xref_gen.rb', line 135 def list_item_anchor_names(list, list_anchor, depth, prev_label, refer_list) c = list_counter(list["start"] ? list["start"].to_i - 1 : 0) list.xpath(ns("./li")).each do |li| , label = list_item_value(li, c, depth, { list_anchor:, prev_label:, refer_list: depth == 1 ? refer_list : nil }) li["id"] and @anchors[li["id"]] = { label: , bare_xref: "#{label})", xref: "#{label})", type: "listitem", refer_list:, container: list_anchor[:container] } (li.xpath(ns(".//ol")) - li.xpath(ns(".//ol//ol"))).each do |ol| list_item_anchor_names(ol, list_anchor, depth + 1, label, refer_list) end end end |
#list_item_value(entry, counter, depth, opts) ⇒ Object
153 154 155 156 157 158 |
# File 'lib/isodoc/xref/xref_gen.rb', line 153 def list_item_value(entry, counter, depth, opts) label = counter.increment(entry).listlabel(entry.parent, depth) [label, list_item_anchor_label(label, opts[:list_anchor], opts[:prev_label], opts[:refer_list])] end |
#noblank(xpath) ⇒ Object
22 23 24 |
# File 'lib/isodoc/xref/xref_util.rb', line 22 def noblank(xpath) xpath.reject { |n| blank?(n["id"]) } end |
#note_anchor_names(sections) ⇒ Object
71 72 73 74 75 76 77 78 |
# File 'lib/isodoc/xref/xref_gen.rb', line 71 def note_anchor_names(sections) sections.each do |s| notes = s.xpath(child_asset_path("note")) - s.xpath(ns(".//figure//note | .//table//note")) note_anchor_names1(notes, Counter.new) note_anchor_names(s.xpath(ns(CHILD_SECTIONS))) end end |
#note_anchor_names1(notes, counter) ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/isodoc/xref/xref_gen.rb', line 80 def note_anchor_names1(notes, counter) notes.noblank.each do |n| @anchors[n["id"]] = anchor_struct(increment_label(notes, n, counter), n, @labels["note_xref"], "note", false) end end |
#reqt2class_label(elem, model) ⇒ Object
134 135 136 137 138 139 140 141 |
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 134 def reqt2class_label(elem, model) elem["class"] and return [elem["class"], elem["class"]] model.req_class_paths.each do |n| v1 = ns("/#{n[:xpath]}").sub(%r{^/}, "") elem.at("./self::#{v1}") and return [n[:klass], n[:label]] end [nil, nil] end |
#reqt2class_nested_label(elem, model) ⇒ Object
143 144 145 146 147 148 149 |
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 143 def reqt2class_nested_label(elem, model) model.req_nested_class_paths.each do |n| v1 = ns("/#{n[:xpath]}").sub(%r{^/}, "") elem.at("./self::#{v1}") and return [n[:klass], n[:label]] end [nil, nil] end |
#sections_xpath ⇒ Object
34 35 36 |
# File 'lib/isodoc/xref/xref_util.rb', line 34 def sections_xpath SECTIONS_XPATH end |
#sequential_asset_names(clause, container: false) ⇒ Object
container makes numbering be prefixed with the parent clause reference
152 153 154 155 156 157 |
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 152 def sequential_asset_names(clause, container: false) sequential_table_names(clause, container:) sequential_figure_names(clause, container:) sequential_formula_names(clause, container:) (clause, container:) end |
#sequential_figure_body(subfig, counter, elem, klass, container: false) ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 56 def sequential_figure_body(subfig, counter, elem, klass, container: false) label = counter.print label &&= label + subfigure_label(subfig) @anchors[elem["id"]] = anchor_struct( label, container ? elem : nil, @labels[klass] || klass.capitalize, klass, elem["unnumbered"] ) end |
#sequential_figure_class_names(clause, container: false) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 38 def sequential_figure_class_names(clause, container: false) c = {} j = 0 clause.xpath(ns(".//figure[@class][not(@class = 'pseudocode')]")) .each do |t| c[t["class"]] ||= Counter.new # labelled_ancestor(t, %w(figure)) and next j = subfigure_increment(j, c[t["class"]], t) sequential_figure_body(j, c[t["class"]], t, t["class"], container:) end end |
#sequential_figure_names(clause, container: false) ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 27 def sequential_figure_names(clause, container: false) c = Counter.new j = 0 clause.xpath(ns(self.class::FIGURE_NO_CLASS)).noblank.each do |t| # labelled_ancestor(t, %w(figure)) and next # disable nested figure labelling j = subfigure_increment(j, c, t) sequential_figure_body(j, c, t, "figure", container:) end sequential_figure_class_names(clause, container:) end |
#sequential_formula_names(clause, container: false) ⇒ Object
77 78 79 80 81 82 83 84 85 86 |
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 77 def sequential_formula_names(clause, container: false) c = Counter.new clause.xpath(ns(".//formula")).noblank.each do |t| @anchors[t["id"]] = anchor_struct( c.increment(t).print, t, t["inequality"] ? @labels["inequality"] : @labels["formula"], "formula", t["unnumbered"] ) end end |
#sequential_permission_body(id, elem, label, klass, model, container: false) ⇒ Object
122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 122 def (id, elem, label, klass, model, container: false) @anchors[elem["id"]] = model.postprocess_anchor_struct( elem, anchor_struct(id, elem, label, klass, elem["unnumbered"]) ) model.(elem, id, label, klass).each do |n| @anchors[n[:id]] = anchor_struct(n[:number], n[:elem], n[:label], n[:klass], false) end end |
#sequential_permission_children(elem, lbl, container: false) ⇒ Object
110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 110 def (elem, lbl, container: false) c = ReqCounter.new elem.xpath(ns(REQ_CHILDREN)).noblank.each do |t| m = @reqt_models.model(t["model"]) klass, label = reqt2class_nested_label(t, m) id = "#{lbl}#{hierfigsep}#{c.increment(label, t).print}" (id, t, label, klass, m, container:) (t, id, container:) end end |
#sequential_permission_names(clause, container: false) ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 98 def (clause, container: false) c = ReqCounter.new clause.xpath(ns(FIRST_LVL_REQ)).noblank.each do |t| m = @reqt_models.model(t["model"]) klass, label = reqt2class_label(t, m) id = c.increment(label, t).print (id, t, label, klass, m, container:) (t, id, container:) end end |
#sequential_table_names(clause, container: false) ⇒ Object
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 66 def sequential_table_names(clause, container: false) c = Counter.new clause.xpath(ns(".//table")).noblank.each do |t| # labelled_ancestor(t) and next @anchors[t["id"]] = anchor_struct( c.increment(t).print, container ? t : nil, @labels["table"], "table", t["unnumbered"] ) end end |
#subfigure_increment(idx, counter, elem) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 14 def subfigure_increment(idx, counter, elem) if elem.parent.name == "figure" then idx += 1 else idx = 0 counter.increment(elem) end idx end |
#subfigure_label(subfignum) ⇒ Object
51 52 53 54 |
# File 'lib/isodoc/xref/xref_gen_seq.rb', line 51 def subfigure_label(subfignum) subfignum.zero? and return "" "#{hierfigsep}#{subfignum}" end |
#termexample_anchor_names(docxml) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/isodoc/xref/xref_gen.rb', line 55 def termexample_anchor_names(docxml) docxml.xpath(ns("//*[termexample]")).each do |t| examples = t.xpath(ns("./termexample")) c = Counter.new examples.noblank.each do |n| c.increment(n) idx = increment_label(examples, n, c, increment: false) @anchors[n["id"]] = { label: idx, type: "termexample", value: idx, elem: @labels["example_xref"], container: t["id"], xref: "#{@labels['example_xref']} #{idx}" } end end end |
#termnote_anchor_names(docxml) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/isodoc/xref/xref_gen.rb', line 41 def termnote_anchor_names(docxml) docxml.xpath(ns("//*[termnote]")).each do |t| c = Counter.new t.xpath(ns("./termnote")).noblank.each do |n| c.increment(n) @anchors[n["id"]] = { label: termnote_label(c.print), type: "termnote", value: c.print, elem: @labels["termnote"], container: t["id"], xref: "#{@labels['note_xref']} #{c.print}" } end end end |
#termnote_label(note) ⇒ Object
31 32 33 |
# File 'lib/isodoc/xref/xref_gen.rb', line 31 def termnote_label(note) @labels["termnote"].gsub("%", note.to_s) end |