Module: Asciidoctor::Standoc::Front

Included in:
Converter
Defined in:
lib/asciidoctor/standoc/front.rb

Instance Method Summary collapse

Instance Method Details

#committee_component(compname, node, out) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/asciidoctor/standoc/front.rb', line 27

def committee_component(compname, node, out)
  out.send compname.gsub(/-/, "_"), node.attr(compname),
    **attr_code(number: node.attr("#{compname}-number"),
                type: node.attr("#{compname}-type"))
  i = 2
  while node.attr(compname+"_#{i}") do
    out.send compname.gsub(/-/, "_"), node.attr(compname+"_#{i}"),
      **attr_code(number: node.attr("#{compname}-number_#{i}"),
                  type: node.attr("#{compname}-type_#{i}"))
    i += 1
  end
end

#datetypesObject



164
165
166
167
# File 'lib/asciidoctor/standoc/front.rb', line 164

def datetypes
  %w{ published accessed created implemented obsoleted
      confirmed updated issued circulated unchanged received }
end

#metadata(node, xml) ⇒ Object



224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
# File 'lib/asciidoctor/standoc/front.rb', line 224

def (node, xml)
  title node, xml
  (node, xml)
  (node, xml)
  (node, xml)
  (node, xml)
  (node, xml)
  (node, xml)
  (node, xml)
  (node, xml)
  (node, xml)
  (node, xml)
  (node, xml)
  (node, xml)
  (node, xml)
  (node, xml)
  xml.ext do |ext|
    (node, xml)
  end
end

#metadata_author(node, xml) ⇒ Object



44
45
46
47
48
49
50
51
52
# File 'lib/asciidoctor/standoc/front.rb', line 44

def (node, xml)
  (node.attr("publisher") || "").split(/,[ ]?/).each do |p|
    xml.contributor do |c|
      c.role **{ type: "author" }
      c.organization { |a| organization(a, p) }
    end
  end
  personal_author(node, xml)
end

#metadata_committee(node, xml) ⇒ Object



133
134
135
136
137
138
# File 'lib/asciidoctor/standoc/front.rb', line 133

def (node, xml)
  return unless node.attr("technical-committee")
  xml.editorialgroup do |a|
    committee_component("technical-committee", node, a)
  end
end


113
114
115
116
117
118
119
120
121
122
123
# File 'lib/asciidoctor/standoc/front.rb', line 113

def (node, xml)
  publishers = node.attr("publisher") || " "
  publishers.split(/,[ ]?/).each do |p|
    xml.copyright do |c|
      c.from (node.attr("copyright-year") || Date.today.year)
      p.match(/[A-Za-z]/).nil? or c.owner do |owner|
        owner.organization { |o| organization(o, p) }
      end
    end
  end
end

#metadata_date(node, xml) ⇒ Object



169
170
171
172
173
174
175
176
177
178
179
# File 'lib/asciidoctor/standoc/front.rb', line 169

def (node, xml)
  datetypes.each { |t| (node, xml, t) }
  node.attributes.keys.each do |a|
    next unless a == "date" || /^date_\d+$/.match(a)
    type, date = node.attr(a).split(/ /, 2)
    type or next
    xml.date **{ type: type } do |d|
      d.on date
    end
  end
end

#metadata_date1(node, xml, type) ⇒ Object



157
158
159
160
161
162
# File 'lib/asciidoctor/standoc/front.rb', line 157

def (node, xml, type)
  date = node.attr("#{type}-date")
  date and xml.date **{ type: type } do |d|
    d.on date
  end
end

#metadata_doctype(node, xml) ⇒ Object



251
252
253
# File 'lib/asciidoctor/standoc/front.rb', line 251

def (node, xml)
  xml.doctype doctype(node)
end

#metadata_ext(node, ext) ⇒ Object



245
246
247
248
249
# File 'lib/asciidoctor/standoc/front.rb', line 245

def (node, ext)
  (node, ext)
  (node, ext)
  (node, ext)
end

#metadata_getrelation(node, xml, type) ⇒ Object



204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/asciidoctor/standoc/front.rb', line 204

def (node, xml, type)
  docs = node.attr(type) || return
  docs.split(/;\s*/).each do |d|
    id = d.split(/,\s*/)
    xml.relation **{ type: relation_normalise(type) } do |r|
      fetch_ref(r, d, nil, {}) or r.bibitem do |b|
        b.title id[1] ? id[1] : "--"
        b.docidentifier id[0]
      end
    end
  end
end

#metadata_ics(node, xml) ⇒ Object



140
141
142
143
144
145
# File 'lib/asciidoctor/standoc/front.rb', line 140

def (node, xml)
  ics = node.attr("library-ics")
  ics && ics.split(/,\s*/).each do |i|
    xml.ics { |ics| ics.code i }
  end
end

#metadata_id(node, xml) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/asciidoctor/standoc/front.rb', line 10

def (node, xml)
  part, subpart = node&.attr("partnumber")&.split(/-/)
  id = node.attr("docnumber") || ""
  id += "-#{part}" if part
  id += "-#{subpart}" if subpart
  xml.docidentifier id
  xml.docnumber node.attr("docnumber")
end

#metadata_keywords(node, xml) ⇒ Object



217
218
219
220
221
222
# File 'lib/asciidoctor/standoc/front.rb', line 217

def (node, xml)
  return unless node.attr("keywords")
  node.attr("keywords").split(/,[ ]*/).each do |kw|
    xml.keyword kw
  end
end

#metadata_language(node, xml) ⇒ Object



181
182
183
# File 'lib/asciidoctor/standoc/front.rb', line 181

def (node, xml)
  xml.language (node.attr("language") || "en")
end

#metadata_note(node, xml) ⇒ Object



255
256
# File 'lib/asciidoctor/standoc/front.rb', line 255

def (node, xml)
end

#metadata_publisher(node, xml) ⇒ Object



103
104
105
106
107
108
109
110
111
# File 'lib/asciidoctor/standoc/front.rb', line 103

def (node, xml)
  publishers = node.attr("publisher") || return
  publishers.split(/,[ ]?/).each do |p|
    xml.contributor do |c|
      c.role **{ type: "publisher" }
      c.organization { |a| organization(a, p) }
    end
  end
end

#metadata_relations(node, xml) ⇒ Object



193
194
195
196
197
# File 'lib/asciidoctor/standoc/front.rb', line 193

def (node, xml)
  relaton_relations.each do |t|
    (node, xml, t)
  end
end

#metadata_script(node, xml) ⇒ Object



185
186
187
# File 'lib/asciidoctor/standoc/front.rb', line 185

def (node, xml)
  xml.script (node.attr("script") || "Latn")
end

#metadata_series(node, xml) ⇒ Object



258
259
# File 'lib/asciidoctor/standoc/front.rb', line 258

def (node, xml)
end

#metadata_source(node, xml) ⇒ Object



147
148
149
150
151
152
153
154
155
# File 'lib/asciidoctor/standoc/front.rb', line 147

def (node, xml)
  node.attr("uri") && xml.uri(node.attr("uri"))
  node.attr("xml-uri") && xml.uri(node.attr("xml-uri"), type: "xml")
  node.attr("html-uri") && xml.uri(node.attr("html-uri"), type: "html")
  node.attr("pdf-uri") && xml.uri(node.attr("pdf-uri"), type: "pdf")
  node.attr("doc-uri") && xml.uri(node.attr("doc-uri"), type: "doc")
  node.attr("relaton-uri") && xml.uri(node.attr("relaton-uri"),
                                      type: "relaton")
end

#metadata_status(node, xml) ⇒ Object



125
126
127
128
129
130
131
# File 'lib/asciidoctor/standoc/front.rb', line 125

def (node, xml)
  xml.status do |s|
    s.stage ( node.attr("status") || node.attr("docstage") || "published" )
    node.attr("docsubstage") and s.substage node.attr("docsubstage")
    node.attr("iteration") and s.iteration node.attr("iteration")
  end
end

#metadata_version(node, xml) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/asciidoctor/standoc/front.rb', line 19

def (node, xml)
  xml.edition node.attr("edition") if node.attr("edition")
  xml.version do |v|
    v.revision_date node.attr("revdate") if node.attr("revdate")
    v.draft node.attr("draft") if node.attr("draft")
  end
end

#organization(org, orgname) ⇒ Object



40
41
42
# File 'lib/asciidoctor/standoc/front.rb', line 40

def organization(org, orgname)
  org.name orgname
end

#person_affiliation(node, xml, suffix, p) ⇒ Object



92
93
94
95
96
97
98
99
100
101
# File 'lib/asciidoctor/standoc/front.rb', line 92

def person_affiliation(node, xml, suffix, p)
  node.attr("affiliation#{suffix}") and p.affiliation do |a|
    a.organization do |o|
      o.name node.attr("affiliation#{suffix}")
      node.attr("address#{suffix}") and o.address do |ad|
        ad.formattedAddress node.attr("address#{suffix}")
      end
    end
  end
end

#person_name(node, xml, suffix, p) ⇒ Object



80
81
82
83
84
85
86
87
88
89
90
# File 'lib/asciidoctor/standoc/front.rb', line 80

def person_name(node, xml, suffix, p)
  p.name do |n|
    if node.attr("fullname#{suffix}")
      n.completename node.attr("fullname#{suffix}")
    else
      n.forename node.attr("givenname#{suffix}")
      n.initial node.attr("initials#{suffix}")
      n.surname node.attr("surname#{suffix}")
    end
  end
end

#personal_author(node, xml) ⇒ Object



54
55
56
57
58
59
60
61
62
# File 'lib/asciidoctor/standoc/front.rb', line 54

def personal_author(node, xml)
  (node.attr("fullname") || node.attr("surname")) and
    personal_author1(node, xml, "")
  i = 2
  while node.attr("fullname_#{i}") || node.attr("surname_#{i}")
    personal_author1(node, xml, "_#{i}")
    i += 1
  end
end

#personal_author1(node, xml, suffix) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/asciidoctor/standoc/front.rb', line 64

def personal_author1(node, xml, suffix)
  xml.contributor do |c|
    c.role **{ type: node.attr("role#{suffix}")&.downcase || "author" }
    c.person do |p|
      person_name(node, xml, suffix, p)
      person_affiliation(node, xml, suffix, p)
      node.attr("phone#{suffix}") and p.phone node.attr("phone#{suffix}")
      node.attr("fax#{suffix}") and
        p.phone node.attr("fax#{suffix}"), **{type: "fax"}
      node.attr("email#{suffix}") and p.email node.attr("email#{suffix}")
      node.attr("contributor-uri#{suffix}") and
        p.uri node.attr("contributor-uri#{suffix}")
    end
  end
end

#relation_normalise(type) ⇒ Object



199
200
201
202
# File 'lib/asciidoctor/standoc/front.rb', line 199

def relation_normalise(type)
  type.sub(/-by$/, "By").sub(/-of$/, "Of").sub(/-from$/, "From").
    sub(/-in$/, "In")
end

#relaton_relationsObject



189
190
191
# File 'lib/asciidoctor/standoc/front.rb', line 189

def relaton_relations
  %w(part-of translated-from)
end

#title(node, xml) ⇒ Object



261
262
263
264
# File 'lib/asciidoctor/standoc/front.rb', line 261

def title(node, xml)
  title_english(node, xml)
  title_otherlangs(node, xml)
end

#title_english(node, xml) ⇒ Object



266
267
268
269
270
271
272
273
274
# File 'lib/asciidoctor/standoc/front.rb', line 266

def title_english(node, xml)
  ["en"].each do |lang|
    at = { language: lang, format: "text/plain" }
    xml.title **attr_code(at) do |t|
      t << Utils::asciidoc_sub(node.attr("title") || node.attr("title-en") ||
                               node.title)
    end
  end
end

#title_otherlangs(node, xml) ⇒ Object



276
277
278
279
280
281
282
# File 'lib/asciidoctor/standoc/front.rb', line 276

def title_otherlangs(node, xml)
  node.attributes.each do |k, v|
    next unless /^title-(?<titlelang>.+)$/ =~ k
    next if titlelang == "en"
    xml.title v, { language: titlelang, format: "text/plain" }
  end
end