metanorma-ogc 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,7 @@
1
+ require_relative "base_convert"
2
+ require "fileutils"
1
3
  require "isodoc"
2
4
  require_relative "metadata"
3
- require "fileutils"
4
5
 
5
6
  module IsoDoc
6
7
  module Ogc
@@ -132,95 +133,6 @@ module IsoDoc
132
133
  %{\\1#{WORD_TOC_RECOMMENDATION_PREFACE1}}) + WORD_TOC_SUFFIX1
133
134
  end
134
135
 
135
- def annex_name(annex, name, div)
136
- div.h1 **{ class: "Annex" } do |t|
137
- t << "#{get_anchors[annex['id']][:label]} "
138
- t.br
139
- t.b do |b|
140
- name&.children&.each { |c2| parse(c2, b) }
141
- end
142
- end
143
- end
144
-
145
- def term_defs_boilerplate(div, source, term, preface)
146
- if source.empty? && term.nil?
147
- div << @no_terms_boilerplate
148
- else
149
- div << term_defs_boilerplate_cont(source, term)
150
- end
151
- end
152
-
153
- def fileloc(loc)
154
- File.join(File.dirname(__FILE__), loc)
155
- end
156
-
157
- def cleanup(docxml)
158
- super
159
- term_cleanup(docxml)
160
- end
161
-
162
- def term_cleanup(docxml)
163
- docxml.xpath("//p[@class = 'Terms']").each do |d|
164
- h2 = d.at("./preceding-sibling::*[@class = 'TermNum'][1]")
165
- h2.add_child("&nbsp;")
166
- h2.add_child(d.remove)
167
- end
168
- docxml
169
- end
170
-
171
- def info(isoxml, out)
172
- @meta.keywords isoxml, out
173
- super
174
- end
175
-
176
- def load_yaml(lang, script)
177
- y = if @i18nyaml then YAML.load_file(@i18nyaml)
178
- elsif lang == "en"
179
- YAML.load_file(File.join(File.dirname(__FILE__), "i18n-en.yaml"))
180
- else
181
- YAML.load_file(File.join(File.dirname(__FILE__), "i18n-en.yaml"))
182
- end
183
- super.merge(y)
184
- end
185
-
186
- def keywords(_docxml, out)
187
- kw = @meta.get[:keywords]
188
- kw.empty? and return
189
- @prefacenum += 1
190
- out.div **{ class: "Section3" } do |div|
191
- clause_name(RomanNumerals.to_roman(@prefacenum).downcase, "Keywords", div, class: "IntroTitle")
192
- div.p "The following are keywords to be used by search engines and document catalogues."
193
- div.p kw.join(", ")
194
- end
195
- end
196
-
197
- SUBMITTINGORGS =
198
- "//bibdata/contributor[role/@type = 'author']/organization/name".freeze
199
-
200
- def submittingorgs(docxml, out)
201
- orgs = []
202
- docxml.xpath(ns(SUBMITTINGORGS)).each { |org| orgs << org.text }
203
- return if orgs.empty?
204
- @prefacenum += 1
205
- out.div **{ class: "Section3" } do |div|
206
- clause_name(RomanNumerals.to_roman(@prefacenum).downcase, "Submitting Organizations", div, class: "IntroTitle")
207
- div.p "The following organizations submitted this Document to the Open Geospatial Consortium (OGC):"
208
- div.ul do |ul|
209
- orgs.each do |org|
210
- ul.li org
211
- end
212
- end
213
- end
214
- end
215
-
216
- def submitters(docxml, out)
217
- f = docxml.at(ns("//submitters")) || return
218
- out.div **{ class: "Section3" } do |div|
219
- clause_name(get_anchors[f['id']][:label], "Submitters", div, class: "IntroTitle")
220
- f.elements.each { |e| parse(e, div) unless e.name == "title" }
221
- end
222
- end
223
-
224
136
  def make_body2(body, docxml)
225
137
  body.div **{ class: "WordSection2" } do |div2|
226
138
  @prefacenum = 0
@@ -235,185 +147,7 @@ module IsoDoc
235
147
  section_break(body)
236
148
  end
237
149
 
238
- def preface_names(clause)
239
- return if clause.nil?
240
- @prefacenum += 1
241
- @anchors[clause["id"]] =
242
- { label: RomanNumerals.to_roman(@prefacenum).downcase,
243
- level: 1, xref: preface_clause_name(clause), type: "clause" }
244
- clause.xpath(ns("./clause | ./terms | ./term | ./definitions")).each_with_index do |c, i|
245
- section_names1(c, "#{@prefacenum}.#{i + 1}", 2)
246
- end
247
- end
248
-
249
- def abstract(isoxml, out)
250
- f = isoxml.at(ns("//preface/abstract")) || return
251
- @prefacenum += 1
252
- page_break(out)
253
- out.div **attr_code(id: f["id"]) do |s|
254
- clause_name(get_anchors[f["id"]][:label], @abstract_lbl, s, class: "AbstractTitle")
255
- f.elements.each { |e| parse(e, s) unless e.name == "title" }
256
- end
257
- end
258
-
259
- def foreword(isoxml, out)
260
- f = isoxml.at(ns("//foreword")) || return
261
- @prefacenum += 1
262
- page_break(out)
263
- out.div **attr_code(id: f["id"]) do |s|
264
- clause_name(get_anchors[f["id"]][:label], @foreword_lbl, s, class: "ForewordTitle")
265
- f.elements.each { |e| parse(e, s) unless e.name == "title" }
266
- end
267
- end
268
-
269
- def example_parse(node, out)
270
- name = node.at(ns("./name"))
271
- sourcecode_name_parse(node, out, name) if name
272
- super
273
- end
274
-
275
- def error_parse(node, out)
276
- case node.name
277
- when "recommendation" then recommendation_parse(node, out)
278
- when "requirement" then requirement_parse(node, out)
279
- when "permission" then permission_parse(node, out)
280
- else
281
- super
282
- end
283
- end
284
-
285
- def anchor_names(docxml)
286
- super
287
- recommendation_anchor_names(docxml)
288
- requirement_anchor_names(docxml)
289
- permission_anchor_names(docxml)
290
- end
291
-
292
- def recommendation_anchor_names(docxml)
293
- docxml.xpath(ns("//recommendation")).each_with_index do |x, i|
294
- @anchors[x["id"]] = anchor_struct(i+1, nil, "Recommendation", "recommendation")
295
- end
296
- end
297
-
298
- def requirement_anchor_names(docxml)
299
- docxml.xpath(ns("//requirement")).each_with_index do |x, i|
300
- @anchors[x["id"]] = anchor_struct(i+1, nil, "Requirement", "requirement")
301
- end
302
- end
303
-
304
- def permission_anchor_names(docxml)
305
- docxml.xpath(ns("//permission")).each_with_index do |x, i|
306
- @anchors[x["id"]] = anchor_struct(i+1, nil, "Permission", "permission")
307
- end
308
- end
309
-
310
- def recommend_table_attr(node)
311
- attr_code(id: node["id"], class: "recommend",
312
- cellspacing: 0, cellpadding: 0,
313
- style: "border-collapse:collapse" )
314
- end
315
-
316
- REQ_TBL_ATTR =
317
- { valign: "top", class: "example_label",
318
- style: "width:100.0pt;padding:0 0 0 1em;margin-left:0pt" }.freeze
319
-
320
- def recommend_name_parse(node, div)
321
- name = node&.at(ns("./name"))&.text or return
322
- div.p do |p|
323
- p.b name
324
- end
325
- end
326
-
327
- def recommendation_parse(node, out)
328
- out.table **recommend_table_attr(node) do |t|
329
- t.tr do |tr|
330
- tr.td **REQ_TBL_ATTR do |td|
331
- recommendation_label(node, td)
332
- end
333
- tr.td **{ valign: "top", class: "recommend" } do |td|
334
- recommend_name_parse(node, td)
335
- node.children.each { |n| parse(n, td) unless n.name == "name" }
336
- end
337
- end
338
- end
339
- end
340
-
341
- def recommendation_label(node, out)
342
- n = get_anchors[node["id"]]
343
- label = (n.nil? || n[:label].empty?) ?
344
- "Recommendation" : l10n("#{"Recommendation"} #{n[:label]}")
345
- out.p **{class: "RecommendationTitle" } do |p|
346
- p << label
347
- end
348
- end
349
-
350
- def requirement_parse(node, out)
351
- out.table **recommend_table_attr(node) do |t|
352
- t.tr do |tr|
353
- tr.td **REQ_TBL_ATTR do |td|
354
- requirement_label(node, td)
355
- end
356
- tr.td **{ valign: "top", class: "recommend" } do |td|
357
- recommend_name_parse(node, td)
358
- node.children.each { |n| parse(n, td) unless n.name == "name" }
359
- end
360
- end
361
- end
362
- end
363
-
364
- def requirement_label(node, out)
365
- n = get_anchors[node["id"]]
366
- label = (n.nil? || n[:label].empty?) ?
367
- "Requirement" : l10n("#{"Requirement"} #{n[:label]}")
368
- out.p **{class: "RecommendationTitle" } do |p|
369
- p << label
370
- end
371
- end
372
-
373
- def permission_parse(node, out)
374
- out.table **recommend_table_attr(node) do |t|
375
- t.tr do |tr|
376
- tr.td **REQ_TBL_ATTR do |td|
377
- permission_label(node, td)
378
- end
379
- tr.td **{ valign: "top", class: "recommend" } do |td|
380
- recommend_name_parse(node, td)
381
- node.children.each { |n| parse(n, td) unless n.name == "name" }
382
- end
383
- end
384
- end
385
- end
386
-
387
- def permission_label(node, out)
388
- n = get_anchors[node["id"]]
389
- label = (n.nil? || n[:label].empty?) ?
390
- "Permission" : l10n("#{"Permission"} #{n[:label]}")
391
- out.p **{class: "RecommendationTitle" } do |p|
392
- p << label
393
- end
394
- end
395
-
396
- def initial_anchor_names(d)
397
- @prefacenum = 0
398
- preface_names(d.at(ns("//preface/abstract")))
399
- @prefacenum += 1 if d.at(ns("//keyword"))
400
- preface_names(d.at(ns("//foreword")))
401
- #preface_names(d.at(ns("//introduction")))
402
- @prefacenum += 1 if d.at(ns(SUBMITTINGORGS))
403
- preface_names(d.at(ns("//submitters")))
404
- sequential_asset_names(d.xpath(ns("//preface/abstract | //foreword | //introduction | //submitters")))
405
- n = section_names(d.at(ns("//clause[title = 'Scope']")), 0, 1)
406
- n = section_names(d.at(ns("//clause[title = 'Conformance']")), n, 1)
407
- n = section_names(d.at(ns(
408
- "//references[title = 'Normative References' or title = 'Normative references']")), n, 1)
409
- n = section_names(d.at(ns("//sections/terms | "\
410
- "//sections/clause[descendant::terms]")), n, 1)
411
- n = section_names(d.at(ns("//sections/definitions")), n, 1)
412
- middle_section_asset_names(d)
413
- clause_names(d, n)
414
- termnote_anchor_names(d)
415
- termexample_anchor_names(d)
416
- end
150
+ include BaseConvert
417
151
  end
418
152
  end
419
153
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Ogc
3
- VERSION = "0.0.8"
3
+ VERSION = "0.0.9"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-ogc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-04-04 00:00:00.000000000 Z
11
+ date: 2019-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -264,7 +264,7 @@ dependencies:
264
264
  version: 1.1.2
265
265
  description: 'Metanorma for the Open Geospatial Consortium.
266
266
 
267
- '
267
+ '
268
268
  email:
269
269
  - open.source@ribose.com
270
270
  executables: []
@@ -294,6 +294,7 @@ files:
294
294
  - lib/asciidoctor/ogc/ogc.rng
295
295
  - lib/asciidoctor/ogc/reqt.rng
296
296
  - lib/isodoc/ogc.rb
297
+ - lib/isodoc/ogc/base_convert.rb
297
298
  - lib/isodoc/ogc/html/header.html
298
299
  - lib/isodoc/ogc/html/html_ogc_intro.html
299
300
  - lib/isodoc/ogc/html/html_ogc_titlepage.html