metanorma-ogc 1.1.3 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/lib/asciidoctor/ogc/converter.rb +11 -7
  3. data/lib/asciidoctor/ogc/isodoc.rng +12 -6
  4. data/lib/asciidoctor/ogc/validate.rb +13 -25
  5. data/lib/isodoc/ogc/base_convert.rb +2 -26
  6. data/lib/isodoc/ogc/html_convert.rb +2 -0
  7. data/lib/isodoc/ogc/i18n-en.yaml +1 -0
  8. data/lib/isodoc/ogc/i18n.rb +10 -0
  9. data/lib/isodoc/ogc/init.rb +32 -0
  10. data/lib/isodoc/ogc/metadata.rb +1 -1
  11. data/lib/isodoc/ogc/ogc.abstract-specification-topic.xsl +1312 -1461
  12. data/lib/isodoc/ogc/ogc.best-practice.xsl +1312 -1461
  13. data/lib/isodoc/ogc/ogc.change-request-supporting-document.xsl +1312 -1461
  14. data/lib/isodoc/ogc/ogc.community-practice.xsl +1312 -1461
  15. data/lib/isodoc/ogc/ogc.community-standard.xsl +1312 -1461
  16. data/lib/isodoc/ogc/ogc.discussion-paper.xsl +1312 -1461
  17. data/lib/isodoc/ogc/ogc.engineering-report.xsl +1312 -1461
  18. data/lib/isodoc/ogc/ogc.other.xsl +1312 -1461
  19. data/lib/isodoc/ogc/ogc.policy.xsl +1312 -1461
  20. data/lib/isodoc/ogc/ogc.reference-model.xsl +1312 -1461
  21. data/lib/isodoc/ogc/ogc.release-notes.xsl +1312 -1461
  22. data/lib/isodoc/ogc/ogc.standard.xsl +1312 -1461
  23. data/lib/isodoc/ogc/ogc.test-suite.xsl +1312 -1461
  24. data/lib/isodoc/ogc/ogc.user-guide.xsl +1312 -1461
  25. data/lib/isodoc/ogc/ogc.white-paper.xsl +1537 -1934
  26. data/lib/isodoc/ogc/presentation_xml_convert.rb +128 -1
  27. data/lib/isodoc/ogc/reqt.rb +4 -26
  28. data/lib/isodoc/ogc/sections.rb +18 -64
  29. data/lib/isodoc/ogc/word_convert.rb +2 -0
  30. data/lib/isodoc/ogc/xref.rb +9 -11
  31. data/lib/metanorma/ogc/version.rb +1 -1
  32. data/metanorma-ogc.gemspec +2 -4
  33. metadata +8 -34
@@ -1,9 +1,136 @@
1
- require_relative "base_convert"
1
+ require_relative "init"
2
2
  require "isodoc"
3
+ require "uuidtools"
3
4
 
4
5
  module IsoDoc
5
6
  module Ogc
6
7
  class PresentationXMLConvert < IsoDoc::PresentationXMLConvert
8
+ def convert1(docxml, filename, dir)
9
+ info docxml, nil
10
+ insert_preface_sections(docxml)
11
+ super
12
+ end
13
+
14
+ def insert_preface_sections(docxml)
15
+ insert_keywords(docxml)
16
+ insert_submitting_orgs(docxml)
17
+ end
18
+
19
+ def preface_init_insert_pt(docxml)
20
+ docxml.at(ns("//preface")) ||
21
+ docxml.at(ns("//sections")).
22
+ add_previous_sibling("<preface> </preface>").first
23
+ end
24
+
25
+ def submit_orgs_append_pt(docxml)
26
+ docxml.at(ns("//introduction")) ||
27
+ docxml.at(ns("//foreword")) ||
28
+ docxml.at(ns("//preface/clause[@type = 'keywords']")) ||
29
+ docxml.at(ns("//preface/abstract"))
30
+ end
31
+
32
+ def insert_submitting_orgs(docxml)
33
+ orgs = []
34
+ docxml.xpath(ns(submittingorgs_path)).each { |org| orgs << org.text }
35
+ return if orgs.empty?
36
+ if a = submit_orgs_append_pt(docxml)
37
+ a.next = submitting_orgs_clause(orgs)
38
+ else
39
+ preface_init_insert_pt(docxml)&.children&.first&.
40
+ add_previous_sibling(submitting_orgs_clause(orgs))
41
+ end
42
+ end
43
+
44
+ def submitting_orgs_clause(orgs)
45
+ <<~END
46
+ <clause id="_#{UUIDTools::UUID.random_create}" type="submitting_orgs">
47
+ <title>Submitting Organizations</title>
48
+ <p>The following organizations submitted this Document to the
49
+ Open Geospatial Consortium (OGC):</p>
50
+ <ul>#{orgs.map { |m| "<li>#{m}</li>" }.join("\n")}</ul>
51
+ </clause>
52
+ END
53
+ end
54
+
55
+ def keyword_clause(kw)
56
+ <<~END
57
+ <clause id="_#{UUIDTools::UUID.random_create}" type="keywords">
58
+ <title>Keywords</title>
59
+ <p>The following are keywords to be used by search engines and
60
+ document catalogues.</p>
61
+ <p>#{kw.join(", ")}</p></clause>
62
+ END
63
+ end
64
+
65
+ def insert_keywords(docxml)
66
+ kw = @meta.get[:keywords]
67
+ kw.empty? and return
68
+ if abstract = docxml.at(ns("//preface/abstract"))
69
+ abstract.next = keyword_clause(kw)
70
+ else
71
+ preface_init_insert_pt(docxml)&.children&.first&.
72
+ add_previous_sibling(keyword_clause(kw))
73
+ end
74
+ end
75
+
76
+ def example1(f)
77
+ lbl = @xrefs.anchor(f['id'], :label, false) or return
78
+ prefix_name(f, "&nbsp;&mdash; ", l10n("#{@i18n.example} #{lbl}"), "name")
79
+ end
80
+
81
+ def recommendation1(f, type)
82
+ type = recommendation_class(f)
83
+ label = f&.at(ns("./label"))&.text
84
+ if inject_crossreference_reqt?(f, label)
85
+ n = @xrefs.anchor(@xrefs.reqtlabels[label], :xref, false)
86
+ lbl = (n.nil? ? type : n)
87
+ f&.at(ns("./title"))&.remove # suppress from display if embedded
88
+ else
89
+ n = @xrefs.anchor(f['id'], :label, false)
90
+ lbl = (n.nil? ? type : l10n("#{type} #{n}"))
91
+ end
92
+ prefix_name(f, "", lbl, "name")
93
+ end
94
+
95
+ # embedded reqts xref to top level reqts via label lookup
96
+ def inject_crossreference_reqt?(node, label)
97
+ !node.ancestors("requirement, recommendation, permission").empty? &&
98
+ @xrefs.reqtlabels[label]
99
+ end
100
+
101
+ def recommendation_class(node)
102
+ case node["type"]
103
+ when "verification" then @i18n.get["#{node.name}test"]
104
+ when "class" then @i18n.get["#{node.name}class"]
105
+ when "abstracttest" then @i18n.get["abstracttest"]
106
+ when "conformanceclass" then @i18n.get["conformanceclass"]
107
+ else
108
+ case node.name
109
+ when "recommendation" then @i18n.recommendation
110
+ when "requirement" then @i18n.requirement
111
+ when "permission" then @i18n.permission
112
+ end
113
+ end
114
+ end
115
+
116
+ def annex1(f)
117
+ lbl = @xrefs.anchor(f['id'], :label)
118
+ if t = f.at(ns("./title"))
119
+ t.children = "<strong>#{t.children.to_xml}</strong>"
120
+ end
121
+ prefix_name(f, "<br/>", lbl, "title")
122
+ end
123
+
124
+ def clause(docxml)
125
+ super
126
+ docxml.xpath(ns("//foreword | //preface/abstract | "\
127
+ "//submitters | //introduction | //acknowledgements")).
128
+ each do |f|
129
+ clause1(f)
130
+ end
131
+ end
132
+
133
+ include Init
7
134
  end
8
135
  end
9
136
  end
@@ -28,18 +28,14 @@ module IsoDoc
28
28
  def recommendation_name(node, out, type)
29
29
  label, title, lbl = recommendation_labels(node)
30
30
  out.p **{ class: recommendation_class(node) } do |b|
31
- if inject_crossreference_reqt?(node, label)
32
- lbl = @xrefs.anchor(@xrefs.reqtlabels[label.text], :xref, false)
33
- b << (lbl.nil? ? l10n("#{type}:") : l10n("#{lbl}:"))
34
- else
35
- b << (lbl.nil? ? l10n("#{type}:") : l10n("#{type} #{lbl}:"))
36
- end
31
+ lbl and lbl.children.each { |n| parse(n, b) }
32
+ b << l10n(":")
37
33
  recommendation_name1(title, node, label, b)
38
34
  end
39
35
  end
40
36
 
41
37
  def recommendation_name1(title, node, label, b)
42
- return unless title && !inject_crossreference_reqt?(node, label)
38
+ return unless title
43
39
  b << " "
44
40
  title.children.each { |n| parse(n,b) }
45
41
  end
@@ -55,12 +51,6 @@ module IsoDoc
55
51
  end
56
52
  end
57
53
 
58
- # embedded reqts xref to top level reqts via label lookup
59
- def inject_crossreference_reqt?(node, label)
60
- !node.ancestors("requirement, recommendation, permission").empty? &&
61
- @xrefs.reqtlabels[label&.text]
62
- end
63
-
64
54
  def recommendation_attributes1(node)
65
55
  out = []
66
56
  oblig = node["obligation"] and out << ["Obligation", oblig]
@@ -163,19 +153,7 @@ module IsoDoc
163
153
  end
164
154
 
165
155
  def recommendation_parse0(node, out, r)
166
- label = case node["type"]
167
- when "verification" then @labels["#{r}test"]
168
- when "class" then @labels["#{r}class"]
169
- when "abstracttest" then @labels["abstracttest"]
170
- when "conformanceclass" then @labels["conformanceclass"]
171
- else
172
- case r
173
- when "recommendation" then @recommendation_lbl
174
- when "requirement" then @requirement_lbl
175
- when "permission" then @permission_lbl
176
- end
177
- end
178
- recommendation_parse1(node, out, label)
156
+ recommendation_parse1(node, out, nil)
179
157
  end
180
158
 
181
159
  def requirement_parse(node, out)
@@ -1,108 +1,62 @@
1
1
  module IsoDoc
2
2
  module Ogc
3
3
  module BaseConvert
4
- def annex_name(annex, name, div)
5
- div.h1 **{ class: "Annex" } do |t|
6
- t << "#{@xrefs.anchor(annex['id'], :label)} "
7
- t.br
8
- t.b do |b|
9
- name&.children&.each { |c2| parse(c2, b) }
10
- end
11
- end
12
- end
13
-
14
- def keywords(_docxml, out)
15
- kw = @meta.get[:keywords]
16
- kw.empty? and return
17
- @prefacenum += 1
18
- out.div **{ class: "Section3" } do |div|
19
- clause_name(RomanNumerals.to_roman(@prefacenum).downcase,
20
- "Keywords", div, class: "IntroTitle")
21
- div.p "The following are keywords to be used by search engines and "\
22
- "document catalogues."
23
- div.p kw.join(", ")
4
+ def intro_clause(f, out)
5
+ out.div **{ class: "Section3", id: f["id"] } do |div|
6
+ clause_name(nil, f&.at(ns("./title")), div, class: "IntroTitle")
7
+ f.elements.each { |e| parse(e, div) unless e.name == "title" }
24
8
  end
25
9
  end
26
10
 
27
- def submittingorgs_path
28
- "//bibdata/contributor[role/@type = 'author']/organization/name"
11
+ def keywords(docxml, out)
12
+ f = docxml.at(ns("//preface/clause[@type = 'keywords']")) || return
13
+ intro_clause(f, out)
29
14
  end
30
15
 
31
16
  def submittingorgs(docxml, out)
32
- orgs = []
33
- docxml.xpath(ns(submittingorgs_path)).each { |org| orgs << org.text }
34
- return if orgs.empty?
35
- @prefacenum += 1
36
- out.div **{ class: "Section3" } do |div|
37
- clause_name(RomanNumerals.to_roman(@prefacenum).downcase,
38
- "Submitting Organizations", div, class: "IntroTitle")
39
- div.p "The following organizations submitted this Document to the "\
40
- "Open Geospatial Consortium (OGC):"
41
- div.ul do |ul|
42
- orgs.each { |org| ul.li org }
43
- end
44
- end
17
+ f = docxml.at(ns("//preface/clause[@type = 'submitting_orgs']")) || return
18
+ intro_clause(f, out)
45
19
  end
46
20
 
47
21
  def submitters(docxml, out)
48
22
  f = docxml.at(ns("//submitters")) || return
49
- @prefacenum += 1
50
- out.div **{ class: "Section3" } do |div|
51
- clause_name(@xrefs.anchor(f['id'], :label), "Submitters", div,
52
- class: "IntroTitle")
53
- f.elements.each { |e| parse(e, div) unless e.name == "title" }
54
- end
23
+ intro_clause(f, out)
55
24
  end
56
25
 
57
26
  def preface(isoxml, out)
58
- title_attr = { class: "IntroTitle" }
59
- isoxml.xpath(ns("//preface/clause")).each do |f|
60
- @prefacenum += 1
61
- out.div **{ class: "Section3", id: f["id"] } do |div|
62
- clause_name(RomanNumerals.to_roman(@prefacenum).downcase,
63
- f&.at(ns("./title")), div, title_attr)
64
- f.elements.each { |e| parse(e, div) unless e.name == "title" }
65
- end
27
+ isoxml.xpath(ns("//preface/clause[not(@type = 'keywords' or "\
28
+ "@type = 'submitting_orgs')]")).each do |f|
29
+ intro_clause(f, out)
66
30
  end
67
31
  end
68
32
 
69
33
  def abstract(isoxml, out)
70
34
  f = isoxml.at(ns("//preface/abstract")) || return
71
- @prefacenum += 1
72
35
  page_break(out)
73
36
  out.div **attr_code(id: f["id"]) do |s|
74
- clause_name(@xrefs.anchor(f["id"], :label), @abstract_lbl, s,
75
- class: "AbstractTitle")
37
+ clause_name(nil, f&.at(ns("./title")), s, class: "AbstractTitle")
76
38
  f.elements.each { |e| parse(e, s) unless e.name == "title" }
77
39
  end
78
40
  end
79
41
 
80
42
  def foreword(isoxml, out)
81
43
  f = isoxml.at(ns("//foreword")) || return
82
- @prefacenum += 1
83
44
  page_break(out)
84
45
  out.div **attr_code(id: f["id"]) do |s|
85
- clause_name(@xrefs.anchor(f["id"], :label), @foreword_lbl, s,
86
- class: "ForewordTitle")
46
+ clause_name(nil, f&.at(ns("./title")), s, class: "ForewordTitle")
87
47
  f.elements.each { |e| parse(e, s) unless e.name == "title" }
88
48
  end
89
49
  end
90
50
 
91
51
  def acknowledgements(isoxml, out)
92
52
  f = isoxml.at(ns("//acknowledgements")) || return
93
- @prefacenum += 1
94
- out.div **{ class: "Section3", id: f["id"] } do |div|
95
- clause_name(@xrefs.anchor(f["id"], :label), f&.at(ns("./title")), div,
96
- class: "IntroTitle")
97
- f.elements.each { |e| parse(e, div) unless e.name == "title" }
98
- end
53
+ intro_clause(f, out)
99
54
  end
100
55
 
101
56
  def conformance(isoxml, out, num)
102
- f = isoxml.at(ns("//clause[title = 'Conformance']")) or return num
57
+ f = isoxml.at(ns("//clause[@type = 'conformance']")) or return num
103
58
  out.div **attr_code(id: f["id"]) do |div|
104
- num = num + 1
105
- clause_name(num, "Conformance", div, nil)
59
+ clause_name(nil, f&.at(ns("./title")), div, nil)
106
60
  f.elements.each { |e| parse(e, div) unless e.name == "title" }
107
61
  end
108
62
  num
@@ -1,4 +1,5 @@
1
1
  require_relative "base_convert"
2
+ require_relative "init"
2
3
  require "fileutils"
3
4
  require "isodoc"
4
5
  require_relative "metadata"
@@ -182,6 +183,7 @@ module IsoDoc
182
183
  end
183
184
 
184
185
  include BaseConvert
186
+ include Init
185
187
  end
186
188
  end
187
189
  end
@@ -104,23 +104,22 @@ module IsoDoc
104
104
  def initial_anchor_names(d)
105
105
  @prefacenum = 0
106
106
  preface_names_numbered(d.at(ns("//preface/abstract")))
107
- @prefacenum += 1 if d.at(ns("//keyword"))
107
+ preface_names_numbered(d.at(ns("//preface/clause[@type = 'keywords']")))
108
108
  preface_names_numbered(d.at(ns("//foreword")))
109
109
  preface_names_numbered(d.at(ns("//introduction")))
110
- @prefacenum += 1 if d.at(ns(@klass.submittingorgs_path))
110
+ preface_names_numbered(d.at(ns("//preface/clause[@type = 'submitting_orgs']")))
111
111
  preface_names_numbered(d.at(ns("//submitters")))
112
- d.xpath(ns("//preface/clause")).each do |c|
112
+ d.xpath(ns("//preface/clause[not(@type = 'keywords' or "\
113
+ "@type = 'submitting_orgs')]")).each do |c|
113
114
  preface_names_numbered(c)
114
115
  end
115
116
  preface_names_numbered(d.at(ns("//acknowledgements")))
116
117
  sequential_asset_names(d.xpath(ns(
117
118
  "//preface/abstract | //foreword | //introduction | "\
118
119
  "//submitters | //acknowledgements | //preface/clause")))
119
- n = section_names(d.at(ns("//clause[title = 'Scope']")), 0, 1)
120
- n = section_names(d.at(ns("//clause[title = 'Conformance']")), n, 1)
121
- n = section_names(d.at(ns(
122
- "//references[title = 'Normative References' or "\
123
- "title = 'Normative references']")), n, 1)
120
+ n = section_names(d.at(ns("//clause[@type = 'scope']")), 0, 1)
121
+ n = section_names(d.at(ns("//clause[@type = 'conformance']")), n, 1)
122
+ n = section_names(d.at(ns(@klass.norm_ref_xpath)), n, 1)
124
123
  n = section_names(
125
124
  d.at(ns("//sections/terms | //sections/clause[descendant::terms]")),
126
125
  n, 1)
@@ -132,11 +131,10 @@ module IsoDoc
132
131
  end
133
132
 
134
133
  def middle_section_asset_names(d)
135
- middle_sections = "//clause[title = 'Scope' or title = 'Conformance'] "\
134
+ middle_sections = "//clause[@type = 'scope' or @type = 'conformance'] "\
136
135
  "| //foreword | //introduction | //preface/abstract | "\
137
136
  "//submitters | //acknowledgements | //preface/clause | "\
138
- "//references[title = 'Normative References' or title = "\
139
- "'Normative references'] | //sections/terms | "\
137
+ " #{@klass.norm_ref_xpath} | //sections/terms | "\
140
138
  "//sections/definitions | //clause[parent::sections]"
141
139
  sequential_asset_names(d.xpath(ns(middle_sections)))
142
140
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Ogc
3
- VERSION = "1.1.3"
3
+ VERSION = "1.2.0"
4
4
  end
5
5
  end
@@ -24,10 +24,8 @@ Gem::Specification.new do |spec|
24
24
  spec.require_paths = ["lib"]
25
25
  spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
26
26
 
27
- spec.add_dependency "htmlentities", "~> 4.3.4"
28
- spec.add_dependency "ruby-jing"
29
- spec.add_dependency "metanorma-standoc", "~> 1.4.0"
30
- spec.add_dependency "isodoc", "~> 1.1.0"
27
+ spec.add_dependency "metanorma-standoc", "~> 1.5.0"
28
+ spec.add_dependency "isodoc", "~> 1.2.0"
31
29
  spec.add_dependency "iso-639"
32
30
 
33
31
  spec.add_development_dependency "byebug", "~> 9.1"
metadata CHANGED
@@ -1,71 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-ogc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-26 00:00:00.000000000 Z
11
+ date: 2020-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: htmlentities
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: 4.3.4
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: 4.3.4
27
- - !ruby/object:Gem::Dependency
28
- name: ruby-jing
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
13
  - !ruby/object:Gem::Dependency
42
14
  name: metanorma-standoc
43
15
  requirement: !ruby/object:Gem::Requirement
44
16
  requirements:
45
17
  - - "~>"
46
18
  - !ruby/object:Gem::Version
47
- version: 1.4.0
19
+ version: 1.5.0
48
20
  type: :runtime
49
21
  prerelease: false
50
22
  version_requirements: !ruby/object:Gem::Requirement
51
23
  requirements:
52
24
  - - "~>"
53
25
  - !ruby/object:Gem::Version
54
- version: 1.4.0
26
+ version: 1.5.0
55
27
  - !ruby/object:Gem::Dependency
56
28
  name: isodoc
57
29
  requirement: !ruby/object:Gem::Requirement
58
30
  requirements:
59
31
  - - "~>"
60
32
  - !ruby/object:Gem::Version
61
- version: 1.1.0
33
+ version: 1.2.0
62
34
  type: :runtime
63
35
  prerelease: false
64
36
  version_requirements: !ruby/object:Gem::Requirement
65
37
  requirements:
66
38
  - - "~>"
67
39
  - !ruby/object:Gem::Version
68
- version: 1.1.0
40
+ version: 1.2.0
69
41
  - !ruby/object:Gem::Dependency
70
42
  name: iso-639
71
43
  requirement: !ruby/object:Gem::Requirement
@@ -273,6 +245,8 @@ files:
273
245
  - lib/isodoc/ogc/html/wordstyle.scss
274
246
  - lib/isodoc/ogc/html_convert.rb
275
247
  - lib/isodoc/ogc/i18n-en.yaml
248
+ - lib/isodoc/ogc/i18n.rb
249
+ - lib/isodoc/ogc/init.rb
276
250
  - lib/isodoc/ogc/metadata.rb
277
251
  - lib/isodoc/ogc/ogc.abstract-specification-topic.xsl
278
252
  - lib/isodoc/ogc/ogc.best-practice.xsl