metanorma-ogc 1.4.0 → 1.4.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/lib/asciidoctor/ogc/boilerplate.xml +6 -6
  3. data/lib/asciidoctor/ogc/cleanup.rb +173 -0
  4. data/lib/asciidoctor/ogc/converter.rb +62 -64
  5. data/lib/asciidoctor/ogc/front.rb +1 -1
  6. data/lib/asciidoctor/ogc/isodoc.rng +211 -11
  7. data/lib/asciidoctor/ogc/reqt.rng +16 -0
  8. data/lib/asciidoctor/ogc/validate.rb +35 -20
  9. data/lib/isodoc/ogc/base_convert.rb +47 -10
  10. data/lib/isodoc/ogc/biblio.rb +57 -51
  11. data/lib/isodoc/ogc/html/htmlstyle.css +10 -0
  12. data/lib/isodoc/ogc/html/htmlstyle.scss +12 -0
  13. data/lib/isodoc/ogc/html/ogc.css +4 -0
  14. data/lib/isodoc/ogc/html/ogc.scss +4 -0
  15. data/lib/isodoc/ogc/i18n-en.yaml +24 -8
  16. data/lib/isodoc/ogc/metadata.rb +1 -1
  17. data/lib/isodoc/ogc/ogc.abstract-specification-topic.xsl +501 -127
  18. data/lib/isodoc/ogc/ogc.best-practice.xsl +501 -127
  19. data/lib/isodoc/ogc/ogc.change-request-supporting-document.xsl +501 -127
  20. data/lib/isodoc/ogc/ogc.community-practice.xsl +501 -127
  21. data/lib/isodoc/ogc/ogc.community-standard.xsl +501 -127
  22. data/lib/isodoc/ogc/ogc.discussion-paper.xsl +501 -127
  23. data/lib/isodoc/ogc/ogc.engineering-report.xsl +501 -127
  24. data/lib/isodoc/ogc/ogc.other.xsl +501 -127
  25. data/lib/isodoc/ogc/ogc.policy.xsl +501 -127
  26. data/lib/isodoc/ogc/ogc.reference-model.xsl +501 -127
  27. data/lib/isodoc/ogc/ogc.release-notes.xsl +501 -127
  28. data/lib/isodoc/ogc/ogc.standard.xsl +501 -127
  29. data/lib/isodoc/ogc/ogc.test-suite.xsl +501 -127
  30. data/lib/isodoc/ogc/ogc.user-guide.xsl +501 -127
  31. data/lib/isodoc/ogc/ogc.white-paper.xsl +358 -66
  32. data/lib/isodoc/ogc/presentation_xml_convert.rb +58 -48
  33. data/lib/isodoc/ogc/reqt.rb +64 -46
  34. data/lib/isodoc/ogc/xref.rb +1 -2
  35. data/lib/metanorma/ogc/version.rb +1 -1
  36. metadata +3 -2
@@ -20,15 +20,15 @@ module IsoDoc
20
20
 
21
21
  def preface_init_insert_pt(docxml)
22
22
  docxml.at(ns("//preface")) ||
23
- docxml.at(ns("//sections")).
24
- add_previous_sibling("<preface> </preface>").first
23
+ docxml.at(ns("//sections"))
24
+ .add_previous_sibling("<preface> </preface>").first
25
25
  end
26
26
 
27
27
  def submit_orgs_append_pt(docxml)
28
28
  docxml.at(ns("//introduction")) ||
29
- docxml.at(ns("//foreword")) ||
30
- docxml.at(ns("//preface/clause[@type = 'keywords']")) ||
31
- docxml.at(ns("//preface/abstract"))
29
+ docxml.at(ns("//foreword")) ||
30
+ docxml.at(ns("//preface/clause[@type = 'keywords']")) ||
31
+ docxml.at(ns("//preface/abstract"))
32
32
  end
33
33
 
34
34
  def insert_security(docxml)
@@ -37,42 +37,45 @@ module IsoDoc
37
37
  if a = submit_orgs_append_pt(docxml)
38
38
  a.next = s
39
39
  else
40
- preface_init_insert_pt(docxml)&.children&.first&.
41
- add_previous_sibling(s)
40
+ preface_init_insert_pt(docxml)&.children&.first
41
+ &.add_previous_sibling(s)
42
42
  end
43
43
  end
44
44
 
45
45
  def insert_submitting_orgs(docxml)
46
- orgs = []
47
- docxml.xpath(ns(submittingorgs_path)).each { |org| orgs << org.text }
46
+ orgs = docxml.xpath(ns(submittingorgs_path))
47
+ .each_with_object([]) do |org, m|
48
+ m << org.text
49
+ end
48
50
  return if orgs.empty?
51
+
49
52
  if a = submit_orgs_append_pt(docxml)
50
53
  a.next = submitting_orgs_clause(orgs)
51
54
  else
52
- preface_init_insert_pt(docxml)&.children&.first&.
53
- add_previous_sibling(submitting_orgs_clause(orgs))
55
+ preface_init_insert_pt(docxml)&.children&.first
56
+ &.add_previous_sibling(submitting_orgs_clause(orgs))
54
57
  end
55
58
  end
56
59
 
57
60
  def submitting_orgs_clause(orgs)
58
- <<~END
59
- <clause id="_#{UUIDTools::UUID.random_create}" type="submitting_orgs">
60
- <title>Submitting Organizations</title>
61
- <p>The following organizations submitted this Document to the
62
- Open Geospatial Consortium (OGC):</p>
63
- <ul>#{orgs.map { |m| "<li>#{m}</li>" }.join("\n")}</ul>
64
- </clause>
65
- END
66
- end
67
-
68
- def keyword_clause(kw)
69
- <<~END
70
- <clause id="_#{UUIDTools::UUID.random_create}" type="keywords">
71
- <title>Keywords</title>
72
- <p>The following are keywords to be used by search engines and
73
- document catalogues.</p>
74
- <p>#{kw.join(", ")}</p></clause>
75
- END
61
+ <<~SUBMITTING
62
+ <clause id="_#{UUIDTools::UUID.random_create}" type="submitting_orgs">
63
+ <title>Submitting Organizations</title>
64
+ <p>The following organizations submitted this Document to the
65
+ Open Geospatial Consortium (OGC):</p>
66
+ <ul>#{orgs.map { |m| "<li>#{m}</li>" }.join("\n")}</ul>
67
+ </clause>
68
+ SUBMITTING
69
+ end
70
+
71
+ def keyword_clause(kwords)
72
+ <<~KEYWORDS
73
+ <clause id="_#{UUIDTools::UUID.random_create}" type="keywords">
74
+ <title>Keywords</title>
75
+ <p>The following are keywords to be used by search engines and
76
+ document catalogues.</p>
77
+ <p>#{kwords.join(', ')}</p></clause>
78
+ KEYWORDS
76
79
  end
77
80
 
78
81
  def insert_keywords(docxml)
@@ -81,28 +84,29 @@ module IsoDoc
81
84
  if abstract = docxml.at(ns("//preface/abstract"))
82
85
  abstract.next = keyword_clause(kw)
83
86
  else
84
- preface_init_insert_pt(docxml)&.children&.first&.
85
- add_previous_sibling(keyword_clause(kw))
87
+ preface_init_insert_pt(docxml)&.children&.first
88
+ &.add_previous_sibling(keyword_clause(kw))
86
89
  end
87
90
  end
88
91
 
89
- def example1(f)
90
- lbl = @xrefs.anchor(f['id'], :label, false) or return
91
- prefix_name(f, "&nbsp;&mdash; ", l10n("#{@i18n.example} #{lbl}"), "name")
92
+ def example1(elem)
93
+ lbl = @xrefs.anchor(elem["id"], :label, false) or return
94
+ prefix_name(elem, "&nbsp;&mdash; ", l10n("#{@i18n.example} #{lbl}"),
95
+ "name")
92
96
  end
93
97
 
94
- def recommendation1(f, type)
95
- type = recommendation_class_label(f)
96
- label = f&.at(ns("./label"))&.text
97
- if inject_crossreference_reqt?(f, label)
98
+ def recommendation1(elem, _type)
99
+ type = recommendation_class_label(elem)
100
+ label = elem&.at(ns("./label"))&.text
101
+ if inject_crossreference_reqt?(elem, label)
98
102
  n = @xrefs.anchor(@xrefs.reqtlabels[label], :xref, false)
99
103
  lbl = (n.nil? ? type : n)
100
- f&.at(ns("./title"))&.remove # suppress from display if embedded
104
+ elem&.at(ns("./title"))&.remove # suppress from display if embedded
101
105
  else
102
- n = @xrefs.anchor(f['id'], :label, false)
106
+ n = @xrefs.anchor(elem["id"], :label, false)
103
107
  lbl = (n.nil? ? type : l10n("#{type} #{n}"))
104
108
  end
105
- prefix_name(f, "", lbl, "name")
109
+ prefix_name(elem, "", lbl, "name")
106
110
  end
107
111
 
108
112
  # embedded reqts xref to top level reqts via label lookup
@@ -126,23 +130,30 @@ module IsoDoc
126
130
  end
127
131
  end
128
132
 
129
- def annex1(f)
130
- lbl = @xrefs.anchor(f['id'], :label)
131
- if t = f.at(ns("./title"))
133
+ def annex1(elem)
134
+ lbl = @xrefs.anchor(elem["id"], :label)
135
+ if t = elem.at(ns("./title"))
132
136
  t.children = "<strong>#{t.children.to_xml}</strong>"
133
137
  end
134
- prefix_name(f, "<br/>", lbl, "title")
138
+ prefix_name(elem, "<br/>", lbl, "title")
135
139
  end
136
140
 
137
141
  def clause(docxml)
138
142
  super
139
143
  docxml.xpath(ns("//foreword | //preface/abstract | "\
140
- "//submitters | //introduction | //acknowledgements")).
141
- each do |f|
144
+ "//submitters | //introduction | //acknowledgements"))
145
+ .each do |f|
142
146
  clause1(f)
143
147
  end
144
148
  end
145
149
 
150
+ def clause1(elem)
151
+ return if elem.name == "terms" && elem.parent.name == "annex" &&
152
+ elem.parent.xpath(ns("./terms")).size == 1
153
+
154
+ super
155
+ end
156
+
146
157
  def block(docxml)
147
158
  super
148
159
  recommendation_to_table(docxml)
@@ -166,4 +177,3 @@ module IsoDoc
166
177
  end
167
178
  end
168
179
  end
169
-
@@ -1,4 +1,5 @@
1
1
  require "isodoc"
2
+ require "metanorma-utils"
2
3
 
3
4
  module IsoDoc
4
5
  module Ogc
@@ -12,6 +13,10 @@ module IsoDoc
12
13
  "recommend"
13
14
  end
14
15
 
16
+ def recommend_class?(node)
17
+ %w(recommendtest recommendclass recommend).include? node["type"]
18
+ end
19
+
15
20
  def recommendation_class(node)
16
21
  if node["type"] == "recommendtest"
17
22
  "RecommendationTestTitle"
@@ -30,24 +35,25 @@ module IsoDoc
30
35
  b = out.add_child("<p class='#{recommendation_class(node)}'></p>").first
31
36
  if name = node&.at(ns("./name"))&.remove
32
37
  name.children.each { |n| b << n }
33
- b << l10n(":")
34
38
  end
35
39
  if title = node&.at(ns("./title"))&.remove
36
- b << l10n(" ") if name
40
+ b << l10n(": ") if name
37
41
  title.children.each { |n| b << n }
38
42
  end
39
43
  end
40
44
 
41
45
  def recommend_title(node, out)
42
46
  label = node&.at(ns("./label"))&.remove or return
47
+ label.xpath(ns(".//xref | .//eref | .//quote/source"))
48
+ .each { |f| xref1(f) }
49
+ label.xpath(ns(".//concept")).each { |f| concept1(f) }
43
50
  b = out.add_child("<tr><td colspan='2'><p></p></td></tr>")
44
51
  p = b.at(ns(".//p"))
45
- p << label.children
52
+ p << label.text
46
53
  end
47
54
 
48
55
  def recommendation_attributes1(node)
49
56
  out = recommendation_attributes1_head(node, [])
50
- out = recommendation_attributes1_component(node, out)
51
57
  node.xpath(ns("./classification")).each do |c|
52
58
  line = recommendation_attr_keyvalue(c, "tag", "value") and out << line
53
59
  end
@@ -64,32 +70,28 @@ module IsoDoc
64
70
  out
65
71
  end
66
72
 
67
- def strict_capitalize_phrase(str)
68
- str.split(/ /).map do |w|
69
- letters = w.chars
70
- letters.first.upcase!
71
- letters.join
72
- end.join(" ")
73
+ def recommendation_steps(node)
74
+ node.elements.each { |e| recommendation_steps(e) }
75
+ return node unless node.at(ns("./component[@class = 'step']"))
76
+
77
+ d = node.at(ns("./component[@class = 'step']"))
78
+ d = d.replace("<ol><li>#{d.children.to_xml}</li></ol>").first
79
+ node.xpath(ns("./component[@class = 'step']")).each do |f|
80
+ f = f.replace("<li>#{f.children.to_xml}</li>").first
81
+ d << f
82
+ end
83
+ node
73
84
  end
74
85
 
75
86
  def recommendation_attributes1_component(node, out)
76
- node.xpath(ns("./component[not(@class = 'part')]")).each do |c|
77
- out << case c["class"]
78
- when "test-purpose" then ["Test Purpose", c.remove.children]
79
- when "test-method" then ["Test Method", c.remove.children]
80
- else [strict_capitalize_phrase(c["class"]), c.remove.children]
81
- end
82
- end
83
- node.xpath(ns("./component[@class = 'part']")).each_with_index do |c, i|
84
- out << [(i + "A".ord).chr.to_s, c.remove.children]
85
- end
86
- out
87
+ node = recommendation_steps(node)
88
+ out << "<tr><td>#{node['label']}</td><td>#{node.children}</td></tr>"
87
89
  end
88
90
 
89
91
  def rec_subj(node)
90
92
  case node["type_original"]
91
- when "class" then "Target Type"
92
- when "conformanceclass" then "Requirement Class"
93
+ when "class" then "Target type"
94
+ when "conformanceclass" then "Requirements class"
93
95
  when "verification", "abstracttest" then "Requirement"
94
96
  else "Subject"
95
97
  end
@@ -104,6 +106,7 @@ module IsoDoc
104
106
  end
105
107
 
106
108
  def recommendation_attributes(node, out)
109
+ recommend_title(node, out)
107
110
  recommendation_attributes1(node).each do |i|
108
111
  out.add_child("<tr><td>#{i[0]}</td><td>#{i[1]}</td></tr>")
109
112
  end
@@ -122,8 +125,11 @@ module IsoDoc
122
125
 
123
126
  node.elements.size == 1 && node.first_element_child.name == "dl" and
124
127
  return reqt_dl(node.first_element_child, out)
128
+ node.name == "component" and
129
+ return recommendation_attributes1_component(node, out)
125
130
  b = out.add_child("<tr><td colspan='2'></td></tr>").first
126
- b.at(ns(".//td")) << (preserve_in_nested_table?(node) ? node : node.children)
131
+ b.at(ns(".//td")) <<
132
+ (preserve_in_nested_table?(node) ? node : node.children)
127
133
  end
128
134
 
129
135
  def reqt_dl(node, out)
@@ -142,19 +148,31 @@ module IsoDoc
142
148
  node["class"] = klass
143
149
  node["type_original"] = node["type"]
144
150
  node["type"] = recommend_class(node)
151
+ recommendation_component_labels(node)
152
+ end
153
+
154
+ def recommendation_component_labels(node)
155
+ node.xpath(ns("./component[@class = 'part']")).each_with_index do |c, i|
156
+ c["label"] = (i + "A".ord).chr.to_s
157
+ end
158
+ node.xpath(ns("./component[not(@class = 'part')]")).each do |c|
159
+ c["label"] = case c["class"]
160
+ when "test-purpose" then "Test purpose"
161
+ when "test-method" then "Test method"
162
+ else Metanorma::Utils.strict_capitalize_first(c["class"])
163
+ end
164
+ end
145
165
  end
146
166
 
147
167
  def recommendation_parse1(node, klass)
148
168
  recommendation_base(node, klass)
149
169
  recommendation_header(node)
150
170
  b = node.add_child("<tbody></tbody>").first
151
- recommend_title(node, b)
152
171
  recommendation_attributes(node, b)
153
- node.elements.each do |n|
154
- next if %w(thead tbody).include?(n.name)
155
-
156
- requirement_component_parse(n, b)
157
- end
172
+ node.elements.reject do |n|
173
+ %w(thead tbody classification subject
174
+ inherit).include?(n.name)
175
+ end.each { |n| requirement_component_parse(n, b) }
158
176
  node.delete("type_original")
159
177
  end
160
178
 
@@ -172,27 +190,27 @@ module IsoDoc
172
190
  end
173
191
 
174
192
  # table nested in table: merge label and caption into a single row
175
- def requirement_table_cleanup1(x, y)
176
- x.delete("colspan")
177
- x.delete("scope")
178
- y.delete("colspan")
179
- y.delete("scope")
180
- x.name = "td"
181
- p = x.at(ns("./p[@class = 'RecommendationTitle']")) and
193
+ def requirement_table_cleanup1(outer, inner)
194
+ outer.delete("colspan")
195
+ outer.delete("scope")
196
+ inner.delete("colspan")
197
+ inner.delete("scope")
198
+ outer.name = "td"
199
+ p = outer.at(ns("./p[@class = 'RecommendationTitle']")) and
182
200
  p.delete("class")
183
- x.parent << y.dup
184
- y.parent.remove
201
+ outer.parent << inner.dup
202
+ inner.parent.remove
185
203
  end
186
204
 
187
205
  def requirement_table_cleanup(docxml)
188
- docxml.xpath(ns("//table[@type = 'recommendclass']/tbody/tr/td/table")).each do |t|
189
- x = t.at(ns("./thead")) and x.replace(x.children)
190
- x = t.at(ns("./tbody")) and x.replace(x.children)
191
- x = t.at(ns("./tfoot")) and x.replace(x.children)
192
- if (x = t.at(ns("./tr/th[@colspan = '2']"))) &&
193
- (y = t.at(ns("./tr/td[@colspan = '2']")))
194
- requirement_table_cleanup1(x, y)
206
+ docxml.xpath(ns("//table[@type = 'recommendclass']/tbody/tr/td/table"))
207
+ .each do |t|
208
+ t.xpath(ns("./thead | ./tbody |./tfoot")).each do |x|
209
+ x.replace(x.children)
195
210
  end
211
+ (x = t.at(ns("./tr/th[@colspan = '2']"))) &&
212
+ (y = t.at(ns("./tr/td[@colspan = '2']"))) and
213
+ requirement_table_cleanup1(x, y)
196
214
  t.parent.parent.replace(t.children)
197
215
  end
198
216
  end
@@ -200,8 +200,7 @@ module IsoDoc
200
200
  when 6 then "(#{num})"
201
201
  when 7 then "(#{(96 + num).chr})"
202
202
  when 8 then "(#{RomanNumerals.to_roman(num).downcase})"
203
- else
204
- num.to_s
203
+ else num.to_s
205
204
  end
206
205
  end
207
206
 
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Ogc
3
- VERSION = "1.4.0".freeze
3
+ VERSION = "1.4.3.1".freeze
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: 1.4.0
4
+ version: 1.4.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-16 00:00:00.000000000 Z
11
+ date: 2021-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: iso-639
@@ -218,6 +218,7 @@ files:
218
218
  - lib/asciidoctor/ogc/basicdoc.rng
219
219
  - lib/asciidoctor/ogc/biblio.rng
220
220
  - lib/asciidoctor/ogc/boilerplate.xml
221
+ - lib/asciidoctor/ogc/cleanup.rb
221
222
  - lib/asciidoctor/ogc/converter.rb
222
223
  - lib/asciidoctor/ogc/front.rb
223
224
  - lib/asciidoctor/ogc/isodoc.rng