Class: IsoDoc::Xref

Inherits:
Object
  • Object
show all
Includes:
Function::Utils, IsoDoc::XrefGen::Anchor, IsoDoc::XrefGen::Blocks, IsoDoc::XrefGen::Sections
Defined in:
lib/isodoc/xref.rb

Constant Summary

Constants included from Function::Utils

Function::Utils::CLAUSE_ANCESTOR, Function::Utils::DOCTYPE_HDR, Function::Utils::NOTE_CONTAINER_ANCESTOR

Constants included from IsoDoc::XrefGen::Sections

IsoDoc::XrefGen::Sections::ISO_PUBLISHER_XPATH, IsoDoc::XrefGen::Sections::SUBCLAUSES

Constants included from IsoDoc::XrefGen::Blocks

IsoDoc::XrefGen::Blocks::CHILD_EXAMPLES_XPATH, IsoDoc::XrefGen::Blocks::CHILD_NOTES_XPATH, IsoDoc::XrefGen::Blocks::CHILD_SECTIONS, IsoDoc::XrefGen::Blocks::FIGURE_NO_CLASS, IsoDoc::XrefGen::Blocks::FIRST_LVL_REQ, IsoDoc::XrefGen::Blocks::FIRST_LVL_REQ_RULE, IsoDoc::XrefGen::Blocks::NUMBERED_BLOCKS, IsoDoc::XrefGen::Blocks::REQ_CHILDREN, IsoDoc::XrefGen::Blocks::SECTIONS_XPATH

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Function::Utils

#attr_code, #cleanup_entities, #date_range, #emf?, #empty2nil, #eps?, #external_path, #extract_delims, #from_xhtml, #get_clause_id, #get_note_container_id, #header_strip, #header_strip_elem?, #image_localfile, #insert_tab, #labelled_ancestor, #liquid, #noko, #numeric_escapes, #populate_template, #save_dataimage, #save_svg, #sentence_join, #start_of_sentence, #to_xhtml, #to_xhtml_fragment, #to_xhtml_prep

Methods included from IsoDoc::XrefGen::Sections

#annex_name_anchors, #annex_name_lbl, #annex_names, #annex_names1, #asset_anchor_names, #back_anchor_names, #clause_names, #clause_title, #initial_anchor_names, #middle_section_asset_names, #preface_name_anchors, #preface_names, #preface_names1, #reference_names, #references, #section_name_anchors, #section_names, #section_names1

Methods included from IsoDoc::XrefGen::Blocks

#amend_autonums, #amend_preprocess, #blank?, #bookmark_anchor_names, #deflist_anchor_names, #deflist_anchor_names1, #deflist_term_anchor_names, #dt2xreflabel, #example_anchor_names, #example_anchor_names1, #hierarchical_asset_names, #hierarchical_figure_body, #hierarchical_figure_class_names, #hierarchical_figure_names, #hierarchical_formula_names, #hierarchical_permission_body, #hierarchical_permission_children, #hierarchical_permission_names, #hierarchical_table_names, #hierfigsep, #hiersep, #increment_label, #list_anchor_names, #list_item_anchor_names, #noblank, #note_anchor_names, #note_anchor_names1, #reqt2class_label, #reqt2class_nested_label, #sections_xpath, #sequential_asset_names, #sequential_figure_body, #sequential_figure_class_names, #sequential_figure_names, #sequential_formula_names, #sequential_permission_body, #sequential_permission_children, #sequential_permission_names, #sequential_table_names, #subfigure_increment, #termexample_anchor_names, #termnote_anchor_names, #termnote_label

Methods included from IsoDoc::XrefGen::Anchor

#anchor_struct, #anchor_struct_label, #anchor_struct_value, #anchor_struct_xref, #get_anchors

Constructor Details

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

Returns a new instance of Xref.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/isodoc/xref.rb', line 18

def initialize(lang, script, klass, i18n, options = {})
  @anchors = {}
  @lang = lang
  @script = script
  @klass = klass
  @options = options
  @i18n = i18n
  @labels = @i18n.get
  @klass.i18n = @i18n
  @locale = options[:locale]
  @reqt_models = @klass.requirements_processor
    .new({
           default: "default", lang: lang, script: script,
           labels: @i18n.get
         })
  @i18n
  @parse_settings = {}
end

Instance Attribute Details

#klassObject (readonly)

Returns the value of attribute klass.



16
17
18
# File 'lib/isodoc/xref.rb', line 16

def klass
  @klass
end

Instance Method Details

#anchor(ident, lbl, warning = true) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/isodoc/xref.rb', line 48

def anchor(ident, lbl, warning = true)
  return nil if ident.nil? || ident.empty?

  if warning && !@anchors[ident]
    @seen ||= SeenAnchor.instance
    @seen.seen(ident) or warn "No label has been processed for ID #{ident}"
    @seen.add(ident)
    return "[#{ident}]"
  end
  @anchors.dig(ident, lbl)
end

#getObject



37
38
39
# File 'lib/isodoc/xref.rb', line 37

def get
  @anchors
end

#l10n(text, lang = @lang, script = @script, locale = @locale) ⇒ Object



73
74
75
# File 'lib/isodoc/xref.rb', line 73

def l10n(text, lang = @lang, script = @script, locale = @locale)
  @i18n.l10n(text, lang, script, locale)
end

#ns(xpath) ⇒ Object



69
70
71
# File 'lib/isodoc/xref.rb', line 69

def ns(xpath)
  Common::ns(xpath)
end

#parse(docxml) ⇒ Object

extract names for all anchors, xref and label



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

def parse(docxml)
  amend_preprocess(docxml) if @parse_settings.empty?
  initial_anchor_names(docxml)
  back_anchor_names(docxml)
  asset_anchor_names(docxml)
  @parse_settings = {}
end

#parse_inclusions(options) ⇒ Object

parse only the elements set, if any are set defined are: clause: true, refs: true



43
44
45
46
# File 'lib/isodoc/xref.rb', line 43

def parse_inclusions(options)
  @parse_settings.merge!(options)
  self
end