Module: IsoDoc::XrefGen::Anchor
Defined Under Namespace
Classes: SeenAnchor
Constant Summary
Constants included from Util
Util::CHILD_SECTIONS, Util::FIRST_LVL_REQ, Util::FIRST_LVL_REQ_RULE, Util::REQ_CHILDREN, Util::SECTIONS_XPATH, Util::SUBCLAUSES
Instance Method Summary collapse
-
#anchor_struct(lbl, node, elem_name, type, opt = {}) ⇒ Object
def anchor_struct(lbl, container, elem, type, unnumb = false).
- #anchor_struct_label(lbl, node, elem) ⇒ Object
- #anchor_struct_value(lbl, elem) ⇒ Object
- #anchor_struct_xref(lbl, node, elem) ⇒ Object
-
#asset_title(node) ⇒ Object
Caption of a numbered asset (its
, or a modspec requirement's ), semx-wrapped, so that xrefstyle=full can render "Table 3, caption" the way clauses render "Clause 6, Title". - #get_anchors ⇒ Object
- #initialize ⇒ Object
Methods included from Util
#blank?, #child_asset_path, #child_sections, #delim_wrap, #first_lvl_req, #hier_separator, #hierfigsep, #hierreqtsep, #hiersemx, #hiersep, #increment_label, #labelled_autonum, #noblank, #nodeSet, #req_children, #sections_xpath, #semx, #stripsemx, #subclauses, #subfigure_delim, #subfigure_separator, #subreqt_separator
Instance Method Details
#anchor_struct(lbl, node, elem_name, type, opt = {}) ⇒ Object
def anchor_struct(lbl, container, elem, type, unnumb = false)
64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/isodoc/xref/xref_anchor.rb', line 64 def anchor_struct(lbl, node, elem_name, type, opt = {}) ret = { type: type, elem: elem_name, label: nil } opt[:unnumb] != "true" and ret[:label] = anchor_struct_label(lbl, node, elem_name) ret[:xref] = anchor_struct_xref(opt[:unnumb] == "true" ? "(??)" : lbl, node, elem_name) ret[:container] = @klass.get_clause_id(node) if opt[:container] ret[:value] = stripsemx(lbl) t = asset_title(node) and ret[:title] = t ret end |
#anchor_struct_label(lbl, node, elem) ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/isodoc/xref/xref_anchor.rb', line 33 def anchor_struct_label(lbl, node, elem) case elem when @labels["appendix"] s = "<semx element='autonum' source='#{node['id'] || node[:id]}'>" \ "#{lbl}</semx>" "<span class='fmt-element-name'>#{elem}</span> #{s}" else anchor_struct_value(lbl, elem) end end |
#anchor_struct_value(lbl, elem) ⇒ Object
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/isodoc/xref/xref_anchor.rb', line 52 def anchor_struct_value(lbl, elem) case elem # TODO hardcoded ( ) ? when @labels["formula"], @labels["inequality"] then <<~SPAN.strip #{delim_wrap('(')}#{lbl}#{delim_wrap(')')} SPAN else lbl.to_s end end |
#anchor_struct_xref(lbl, node, elem) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/isodoc/xref/xref_anchor.rb', line 44 def anchor_struct_xref(lbl, node, elem) unless lbl.blank? lbl = semx(node, lbl) s = " #{anchor_struct_value(lbl, elem)}" end "<span class='fmt-element-name'>#{elem}</span>#{s}".gsub(/ $/, "") end |
#asset_title(node) ⇒ Object
Caption of a numbered asset (its
81 82 83 84 |
# File 'lib/isodoc/xref/xref_anchor.rb', line 81 def asset_title(node) n = node.at(ns("./name")) || node.at(ns("./title")) or return nil semx(node, n.children.to_xml, n.name) end |
#get_anchors ⇒ Object
29 30 31 |
# File 'lib/isodoc/xref/xref_anchor.rb', line 29 def get_anchors @anchors end |
#initialize ⇒ Object
25 26 27 |
# File 'lib/isodoc/xref/xref_anchor.rb', line 25 def initialize @anchors = {} end |