Module: IsoDoc::Function::Section
- Included in:
- Common
- Defined in:
- lib/isodoc/function/section.rb
Constant Summary collapse
- MIDDLE_CLAUSE =
"//clause[parent::sections][not(xmlns:title = 'Scope')]"\ "[not(descendant::terms)]".freeze
- TERM_CLAUSE =
"//sections/terms | "\ "//sections/clause[descendant::terms]".freeze
Instance Method Summary collapse
- #annex(isoxml, out) ⇒ Object
- #annex_name(annex, name, div) ⇒ Object
- #clause(isoxml, out) ⇒ Object
- #clause_name(num, title, div, header_class) ⇒ Object
- #clause_parse(node, out) ⇒ Object
- #clause_parse_title(node, div, c1, out) ⇒ Object
- #external_terms_boilerplate(sources) ⇒ Object
- #foreword(isoxml, out) ⇒ Object
- #inline_header_title(out, node, c1) ⇒ Object
- #internal_external_terms_boilerplate(sources) ⇒ Object
- #introduction(isoxml, out) ⇒ Object
- #scope(isoxml, out, num) ⇒ Object
- #symbols_abbrevs(isoxml, out, num) ⇒ Object
-
#symbols_parse(isoxml, out) ⇒ Object
subclause.
- #term_defs_boilerplate(div, source, term, preface) ⇒ Object
- #term_defs_boilerplate_cont(src, term) ⇒ Object
- #terms_defs(isoxml, out, num) ⇒ Object
- #terms_defs_title(f) ⇒ Object
-
#terms_parse(isoxml, out) ⇒ Object
subclause.
Instance Method Details
#annex(isoxml, out) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/isodoc/function/section.rb', line 73 def annex(isoxml, out) isoxml.xpath(ns("//annex")).each do |c| page_break(out) out.div **attr_code(id: c["id"], class: "Section3") do |s| c.elements.each do |c1| if c1.name == "title" then annex_name(c, c1, s) else parse(c1, s) end end end end end |
#annex_name(annex, name, div) ⇒ Object
66 67 68 69 70 71 |
# File 'lib/isodoc/function/section.rb', line 66 def annex_name(annex, name, div) div.h1 **{ class: "Annex" } do |t| t << "#{get_anchors[annex['id']][:label]}<br/><br/>" t << "<b>#{name.text}</b>" end end |
#clause(isoxml, out) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/isodoc/function/section.rb', line 51 def clause(isoxml, out) isoxml.xpath(ns(MIDDLE_CLAUSE)).each do |c| out.div **attr_code(id: c["id"]) do |s| c.elements.each do |c1| if c1.name == "title" clause_name("#{get_anchors[c['id']][:label]}.", c1.content, s, nil) else parse(c1, s) end end end end end |
#clause_name(num, title, div, header_class) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/isodoc/function/section.rb', line 35 def clause_name(num, title, div, header_class) header_class = {} if header_class.nil? div.h1 **attr_code(header_class) do |h1| if num h1 << num insert_tab(h1, 1) end h1 << title end div.parent.at(".//h1") end |
#clause_parse(node, out) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/isodoc/function/section.rb', line 23 def clause_parse(node, out) out.div **attr_code(id: node["id"]) do |div| node.children.each do |c1| if c1.name == "title" clause_parse_title(node, div, c1, out) else parse(c1, div) end end end end |
#clause_parse_title(node, div, c1, out) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/isodoc/function/section.rb', line 12 def clause_parse_title(node, div, c1, out) if node["inline-header"] == "true" inline_header_title(out, node, c1) else div.send "h#{get_anchors[node['id']][:level]}" do |h| h << "#{get_anchors[node['id']][:label]}. " c1.children.each { |c2| parse(c2, h) } end end end |
#external_terms_boilerplate(sources) ⇒ Object
99 100 101 |
# File 'lib/isodoc/function/section.rb', line 99 def external_terms_boilerplate(sources) @external_terms_boilerplate.gsub(/%/, sources) end |
#foreword(isoxml, out) ⇒ Object
192 193 194 195 196 197 198 199 |
# File 'lib/isodoc/function/section.rb', line 192 def foreword(isoxml, out) f = isoxml.at(ns("//foreword")) || return page_break(out) out.div **attr_code(id: f["id"]) do |s| s.h1(**{ class: "ForewordTitle" }) { |h1| h1 << @foreword_lbl } f.elements.each { |e| parse(e, s) unless e.name == "title" } end end |
#inline_header_title(out, node, c1) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/isodoc/function/section.rb', line 4 def inline_header_title(out, node, c1) out.span **{ class: "zzMoveToFollowing" } do |s| s.b do |b| b << "#{get_anchors[node['id']][:label]}. #{c1.content} " end end end |
#internal_external_terms_boilerplate(sources) ⇒ Object
103 104 105 |
# File 'lib/isodoc/function/section.rb', line 103 def internal_external_terms_boilerplate(sources) @internal_external_terms_boilerplate.gsub(/%/, sources) end |
#introduction(isoxml, out) ⇒ Object
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/isodoc/function/section.rb', line 174 def introduction(isoxml, out) f = isoxml.at(ns("//introduction")) || return num = f.at(ns(".//clause")) ? "0." : nil title_attr = { class: "IntroTitle" } page_break(out) out.div **{ class: "Section3", id: f["id"] } do |div| # div.h1 "Introduction", **attr_code(title_attr) clause_name(num, @introduction_lbl, div, title_attr) f.elements.each do |e| if e.name == "patent-notice" e.elements.each { |e1| parse(e1, div) } else parse(e, div) unless e.name == "title" end end end end |
#scope(isoxml, out, num) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/isodoc/function/section.rb', line 87 def scope(isoxml, out, num) f = isoxml.at(ns("//clause[title = 'Scope']")) or return num out.div **attr_code(id: f["id"]) do |div| num = num + 1 clause_name("#{num}.", @scope_lbl, div, nil) f.elements.each do |e| parse(e, div) unless e.name == "title" end end num end |
#symbols_abbrevs(isoxml, out, num) ⇒ Object
155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/isodoc/function/section.rb', line 155 def symbols_abbrevs(isoxml, out, num) f = isoxml.at(ns("//sections/symbols-abbrevs")) or return num out.div **attr_code(id: f["id"], class: "Symbols") do |div| num = num + 1 clause_name("#{num}.", @symbols_lbl, div, nil) f.elements.each do |e| parse(e, div) unless e.name == "title" end end num end |
#symbols_parse(isoxml, out) ⇒ Object
subclause
168 169 170 171 172 |
# File 'lib/isodoc/function/section.rb', line 168 def symbols_parse(isoxml, out) isoxml.children.first.previous = "<title>#{@symbols_lbl}</title>" clause_parse(isoxml, out) end |
#term_defs_boilerplate(div, source, term, preface) ⇒ Object
107 108 109 110 111 112 113 114 |
# File 'lib/isodoc/function/section.rb', line 107 def term_defs_boilerplate(div, source, term, preface) if source.empty? && term.nil? div << @no_terms_boilerplate else div << term_defs_boilerplate_cont(source, term) end div << @term_def_boilerplate end |
#term_defs_boilerplate_cont(src, term) ⇒ Object
116 117 118 119 120 121 122 123 124 125 |
# File 'lib/isodoc/function/section.rb', line 116 def term_defs_boilerplate_cont(src, term) sources = sentence_join(src.map { |s| @anchors[s["bibitemid"]][:xref] }) if src.empty? @internal_terms_boilerplate elsif term.nil? external_terms_boilerplate(sources) else internal_external_terms_boilerplate(sources) end end |
#terms_defs(isoxml, out, num) ⇒ Object
136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/isodoc/function/section.rb', line 136 def terms_defs(isoxml, out, num) f = isoxml.at(ns(TERM_CLAUSE)) or return num out.div **attr_code(id: f["id"]) do |div| num = num + 1 clause_name("#{num}.", terms_defs_title(f), div, nil) term_defs_boilerplate(div, isoxml.xpath(ns(".//termdocsource")), f.at(ns(".//term")), f.at(ns("./p"))) f.elements.each do |e| parse(e, div) unless %w{title source}.include? e.name end end num end |
#terms_defs_title(f) ⇒ Object
127 128 129 130 131 |
# File 'lib/isodoc/function/section.rb', line 127 def terms_defs_title(f) symbols = f.at(".//symbols-abbrevs") return @termsdefsymbols_lbl if symbols @termsdef_lbl end |
#terms_parse(isoxml, out) ⇒ Object
subclause
151 152 153 |
# File 'lib/isodoc/function/section.rb', line 151 def terms_parse(isoxml, out) clause_parse(isoxml, out) end |