metanorma-ogc 1.0.7 → 1.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,5 @@
1
1
  require "isodoc"
2
- require_relative "metadata"
3
- require "fileutils"
2
+ require_relative "reqt_xref"
4
3
 
5
4
  module IsoDoc
6
5
  module Ogc
@@ -14,27 +13,37 @@ module IsoDoc
14
13
  end
15
14
 
16
15
  def recommend_table_attr(node)
17
- attr_code(id: node["id"],
18
- class: recommend_class(node),
16
+ attr_code(id: node["id"], class: recommend_class(node),
19
17
  style: "border-collapse:collapse;border-spacing:0;")
20
18
  end
21
19
 
22
20
  REQ_TBL_ATTR =
23
21
  { style: "vertical-align:top;", class: "recommend" }.freeze
24
22
 
23
+ def recommendation_class(node)
24
+ %w(verification abstracttest).include?(node["type"]) ?
25
+ "RecommendationTestTitle" : "RecommendationTitle"
26
+ end
27
+
25
28
  def recommendation_name(node, out, type)
26
29
  label, title, lbl = recommendation_labels(node)
27
- out.p **{ class: %w(verification abstracttest).include?(node["type"]) ?
28
- "RecommendationTestTitle" : "RecommendationTitle" } do |b|
29
- lbl = anchor(node['id'], :label, false)
30
- b << (lbl.nil? ? l10n("#{type}:") : l10n("#{type} #{lbl}:"))
31
- if title
32
- b << " "
33
- title.children.each { |n| parse(n,b) }
30
+ out.p **{ class: recommendation_class(node) } do |b|
31
+ if inject_crossreference_reqt?(node, label)
32
+ lbl = anchor(@reqtlabels[label.text], :xref, false)
33
+ b << (lbl.nil? ? l10n("#{type}:") : l10n("#{lbl}:"))
34
+ else
35
+ b << (lbl.nil? ? l10n("#{type}:") : l10n("#{type} #{lbl}:"))
34
36
  end
37
+ recommendation_name1(title, node, label, b)
35
38
  end
36
39
  end
37
40
 
41
+ def recommendation_name1(title, node, label, b)
42
+ return unless title && !inject_crossreference_reqt?(node, label)
43
+ b << " "
44
+ title.children.each { |n| parse(n,b) }
45
+ end
46
+
38
47
  def recommend_title(node, out)
39
48
  label = node.at(ns("./label")) or return
40
49
  out.tr do |tr|
@@ -46,6 +55,12 @@ module IsoDoc
46
55
  end
47
56
  end
48
57
 
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
+ @reqtlabels[label&.text]
62
+ end
63
+
49
64
  def recommendation_attributes1(node)
50
65
  out = []
51
66
  oblig = node["obligation"] and out << ["Obligation", oblig]
@@ -61,7 +76,7 @@ module IsoDoc
61
76
 
62
77
  def rec_subj(node)
63
78
  %w(class conformanceclass).include?(node["type"]) ?
64
- "Target Type" : "Subject"
79
+ "Target Type" : "Subject"
65
80
  end
66
81
 
67
82
  def recommendation_attr_parse(node, label)
@@ -78,9 +93,7 @@ module IsoDoc
78
93
  end
79
94
 
80
95
  def recommendation_attributes(node, out)
81
- ret = recommendation_attributes1(node)
82
- return if ret.empty?
83
- ret.each do |i|
96
+ recommendation_attributes1(node).each do |i|
84
97
  out.tr do |tr|
85
98
  tr.td **REQ_TBL_ATTR do |td|
86
99
  td << i[0]
@@ -141,125 +154,31 @@ module IsoDoc
141
154
  end
142
155
 
143
156
  def recommendation_parse(node, out)
144
- label = case node["type"]
145
- when "verification" then @labels["recommendationtest"]
146
- when "class" then @labels["recommendationclass"]
147
- when "abstracttest" then @labels["abstracttest"]
148
- when "conformanceclass" then @labels["conformanceclass"]
149
- else
150
- @recommendation_lbl
151
- end
152
- recommendation_parse1(node, out, label)
157
+ recommendation_parse0(node, out, "recommendation")
153
158
  end
154
159
 
155
- def requirement_parse(node, out)
160
+ def recommendation_parse0(node, out, r)
156
161
  label = case node["type"]
157
- when "verification" then @labels["requirementtest"]
158
- when "class" then @labels["requirementclass"]
162
+ when "verification" then @labels["#{r}test"]
163
+ when "class" then @labels["#{r}class"]
159
164
  when "abstracttest" then @labels["abstracttest"]
160
165
  when "conformanceclass" then @labels["conformanceclass"]
161
- else
162
- @requirement_lbl
166
+ else
167
+ case r
168
+ when "recommendation" then @recommendation_lbl
169
+ when "requirement" then @requirement_lbl
170
+ when "permission" then @permission_lbl
171
+ end
163
172
  end
164
173
  recommendation_parse1(node, out, label)
165
174
  end
166
175
 
167
- def permission_parse(node, out)
168
- label = case node["type"]
169
- when "verification" then @labels["permissiontest"]
170
- when "class" then @labels["permissionclass"]
171
- when "abstracttest" then @labels["abstracttest"]
172
- when "conformanceclass" then @labels["conformanceclass"]
173
- else
174
- @permission_lbl
175
- end
176
- recommendation_parse1(node, out, label)
177
- end
178
-
179
- FIRST_LVL_REQ = IsoDoc::Function::XrefGen::FIRST_LVL_REQ
180
-
181
- def sequential_permission_names(clause, klass, label)
182
- c = ::IsoDoc::Function::XrefGen::Counter.new
183
- clause.xpath(ns(".//#{klass}#{FIRST_LVL_REQ}")).each do |t|
184
- next if t["id"].nil? || t["id"].empty?
185
- id = c.increment(t).print
186
- @anchors[t["id"]] = anchor_struct(id, t, label, klass, t["unnumbered"])
187
- sequential_permission_children(t, id)
188
- end
189
- end
190
-
191
- def req_class_paths
192
- {
193
- "class" => "@type = 'class'",
194
- "test" => "@type = 'verification'",
195
- "" => "not(@type = 'verification' or @type = 'class' or @type = 'abstracttest' or @type = 'conformanceclass')",
196
- }
197
- end
198
-
199
- def req_class_paths2
200
- {
201
- "abstracttest" => "@type = 'abstracttest'",
202
- "conformanceclass" => "@type = 'conformanceclass'",
203
- }
204
- end
205
-
206
- def sequential_permission_children(t, id)
207
- req_class_paths.each do |k, v|
208
- sequential_permission_names1(t, id, "permission[#{v}]", @labels["permission#{k}"])
209
- sequential_permission_names1(t, id, "requirement[#{v}]", @labels["requirement#{k}"])
210
- sequential_permission_names1(t, id, "recommendation[#{v}]", @labels["recommendation#{k}"])
211
- end
212
- req_class_paths2.each do |k, v|
213
- sequential_permission_names1(t, id, "*[#{v}]", @labels[k])
214
- end
215
- end
216
-
217
- def sequential_permission_names1(block, lbl, klass, label)
218
- c = ::IsoDoc::Function::XrefGen::Counter.new
219
- block.xpath(ns("./#{klass}")).each do |t|
220
- next if t["id"].nil? || t["id"].empty?
221
- id = "#{lbl}#{hierfigsep}#{c.increment(t).print}"
222
- @anchors[t["id"]] = anchor_struct(id, t, label, klass, t["unnumbered"])
223
- sequential_permission_children(t, id)
224
- end
225
- end
226
-
227
- def sequential_asset_names(clause)
228
- sequential_table_names(clause)
229
- sequential_figure_names(clause)
230
- sequential_formula_names(clause)
231
- req_class_paths.each do |k, v|
232
- sequential_permission_names(clause, "permission[#{v}]", @labels["permission#{k}"])
233
- sequential_permission_names(clause, "requirement[#{v}]", @labels["requirement#{k}"])
234
- sequential_permission_names(clause, "recommendation[#{v}]", @labels["recommendation#{k}"])
235
- end
236
- req_class_paths2.each do |k, v|
237
- sequential_permission_names(clause, "*[#{v}]", @labels[k])
238
- end
239
- end
240
-
241
- def hierarchical_asset_names(clause, num)
242
- hierarchical_table_names(clause, num)
243
- hierarchical_figure_names(clause, num)
244
- hierarchical_formula_names(clause, num)
245
- req_class_paths.each do |k, v|
246
- hierarchical_permission_names(clause, num, "permission[#{v}]", @labels["permission#{k}"])
247
- hierarchical_permission_names(clause, num, "requirement[#{v}]", @labels["requirement#{k}"])
248
- hierarchical_permission_names(clause, num, "recommendation[#{v}]", @labels["recommendation#{k}"])
249
- end
250
- req_class_paths2.each do |k, v|
251
- hierarchical_permission_names(clause, num, "*[#{v}]", @labels[k])
252
- end
176
+ def requirement_parse(node, out)
177
+ recommendation_parse0(node, out, "requirement")
253
178
  end
254
179
 
255
- def hierarchical_permission_names(clause, num, klass, label)
256
- c = ::IsoDoc::Function::XrefGen::Counter.new
257
- clause.xpath(ns(".//#{klass}#{FIRST_LVL_REQ}")).each do |t|
258
- next if t["id"].nil? || t["id"].empty?
259
- lbl = "#{num}#{hiersep}#{c.increment(t).print}"
260
- @anchors[t["id"]] = anchor_struct(lbl, t, label, klass, t["unnumbered"])
261
- sequential_permission_children(t, lbl)
262
- end
180
+ def permission_parse(node, out)
181
+ recommendation_parse0(node, out, "permission")
263
182
  end
264
183
  end
265
184
  end
@@ -0,0 +1,96 @@
1
+ module IsoDoc
2
+ module Ogc
3
+ module BaseConvert
4
+ FIRST_LVL_REQ = IsoDoc::Function::XrefGen::FIRST_LVL_REQ
5
+
6
+ def sequential_permission_names(clause, klass, label)
7
+ c = ::IsoDoc::Function::XrefGen::Counter.new
8
+ clause.xpath(ns(".//#{klass}#{FIRST_LVL_REQ}")).each do |t|
9
+ next if t["id"].nil? || t["id"].empty?
10
+ id = c.increment(t).print
11
+ @anchors[t["id"]] = anchor_struct(id, t, label, klass, t["unnumbered"])
12
+ l = t.at(ns("./label"))&.text and @reqtlabels[l] = t["id"]
13
+ sequential_permission_children(t, id)
14
+ end
15
+ end
16
+
17
+ def req_class_paths
18
+ { "class" => "@type = 'class'",
19
+ "test" => "@type = 'verification'",
20
+ "" => "not(@type = 'verification' or @type = 'class' or "\
21
+ "@type = 'abstracttest' or @type = 'conformanceclass')", }
22
+ end
23
+
24
+ def req_class_paths2
25
+ { "abstracttest" => "@type = 'abstracttest'",
26
+ "conformanceclass" => "@type = 'conformanceclass'", }
27
+ end
28
+
29
+ def sequential_permission_children(t, id)
30
+ req_class_paths.each do |k, v|
31
+ %w(permission requirement recommendation).each do |r|
32
+ sequential_permission_names1(t, id, "#{r}[#{v}]", @labels["#{r}#{k}"])
33
+ sequential_permission_names1(t, id, "#{r}[#{v}]", @labels["#{r}#{k}"])
34
+ sequential_permission_names1(t, id, "#{r}[#{v}]", @labels["#{r}#{k}"])
35
+ end
36
+ end
37
+ req_class_paths2.each do |k, v|
38
+ sequential_permission_names1(t, id, "*[#{v}]", @labels[k])
39
+ end
40
+ end
41
+
42
+ def sequential_permission_names1(block, lbl, klass, label)
43
+ c = ::IsoDoc::Function::XrefGen::Counter.new
44
+ block.xpath(ns("./#{klass}")).each do |t|
45
+ next if t["id"].nil? || t["id"].empty?
46
+ id = "#{lbl}#{hierfigsep}#{c.increment(t).print}"
47
+ @anchors[t["id"]] = anchor_struct(id, t, label, klass, t["unnumbered"])
48
+ sequential_permission_children(t, id)
49
+ end
50
+ end
51
+
52
+ def sequential_asset_names(clause)
53
+ sequential_table_names(clause)
54
+ sequential_figure_names(clause)
55
+ sequential_formula_names(clause)
56
+ req_class_paths.each do |k, v|
57
+ %w(permission requirement recommendation).each do |r|
58
+ sequential_permission_names(clause, "#{r}[#{v}]", @labels["#{r}#{k}"])
59
+ sequential_permission_names(clause, "#{r}[#{v}]", @labels["#{r}#{k}"])
60
+ sequential_permission_names(clause, "#{r}[#{v}]", @labels["#{r}#{k}"])
61
+ end
62
+ end
63
+ req_class_paths2.each do |k, v|
64
+ sequential_permission_names(clause, "*[#{v}]", @labels[k])
65
+ end
66
+ end
67
+
68
+ def hierarchical_asset_names(clause, num)
69
+ hierarchical_table_names(clause, num)
70
+ hierarchical_figure_names(clause, num)
71
+ hierarchical_formula_names(clause, num)
72
+ req_class_paths.each do |k, v|
73
+ %w(permission requirement recommendation).each do |r|
74
+ hierarchical_permission_names(clause, num, "#{r}[#{v}]", @labels["#{r}#{k}"])
75
+ hierarchical_permission_names(clause, num, "#{r}[#{v}]", @labels["#{r}#{k}"])
76
+ hierarchical_permission_names(clause, num, "#{r}[#{v}]", @labels["#{r}#{k}"])
77
+ end
78
+ end
79
+ req_class_paths2.each do |k, v|
80
+ hierarchical_permission_names(clause, num, "*[#{v}]", @labels[k])
81
+ end
82
+ end
83
+
84
+ def hierarchical_permission_names(clause, num, klass, label)
85
+ c = ::IsoDoc::Function::XrefGen::Counter.new
86
+ clause.xpath(ns(".//#{klass}#{FIRST_LVL_REQ}")).each do |t|
87
+ next if t["id"].nil? || t["id"].empty?
88
+ lbl = "#{num}#{hiersep}#{c.increment(t).print}"
89
+ @anchors[t["id"]] = anchor_struct(lbl, t, label, klass, t["unnumbered"])
90
+ l = t.at(ns("./label"))&.text and @reqtlabels[l] = t["id"]
91
+ sequential_permission_children(t, lbl)
92
+ end
93
+ end
94
+ end
95
+ end
96
+ end
@@ -11,6 +11,7 @@ module IsoDoc
11
11
  class WordConvert < IsoDoc::WordConvert
12
12
  def initialize(options)
13
13
  @libdir = File.dirname(__FILE__)
14
+ @reqtlabels = {}
14
15
  super
15
16
  end
16
17
 
@@ -18,9 +19,9 @@ module IsoDoc
18
19
  {
19
20
  bodyfont: (options[:script] == "Hans" ? '"SimSun",serif' :
20
21
  '"Times New Roman",serif'),
21
- headerfont: (options[:script] == "Hans" ? '"SimHei",sans-serif' :
22
- '"Times New Roman",serif'),
23
- monospacefont: '"Courier New",monospace'
22
+ headerfont: (options[:script] == "Hans" ? '"SimHei",sans-serif' :
23
+ '"Times New Roman",serif'),
24
+ monospacefont: '"Courier New",monospace'
24
25
  }
25
26
  end
26
27
 
@@ -185,11 +186,6 @@ module IsoDoc
185
186
  end
186
187
  end
187
188
 
188
- def authority_cleanup(docxml)
189
- docxml&.at("//div[@id = 'boilerplate-contact']")&.remove
190
- super
191
- end
192
-
193
189
  include BaseConvert
194
190
  end
195
191
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Ogc
3
- VERSION = "1.0.7"
3
+ VERSION = "1.0.8"
4
4
  end
5
5
  end
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
26
26
 
27
27
  spec.add_dependency "htmlentities", "~> 4.3.4"
28
28
  spec.add_dependency "ruby-jing"
29
- spec.add_dependency "metanorma-standoc", "~> 1.3.20"
29
+ spec.add_dependency "metanorma-standoc", "~> 1.4.0"
30
30
  spec.add_dependency "isodoc", "~> 1.0.20"
31
31
  spec.add_dependency "iso-639"
32
32
 
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.0.7
4
+ version: 1.0.8
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-05-26 00:00:00.000000000 Z
11
+ date: 2020-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htmlentities
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.3.20
47
+ version: 1.4.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.3.20
54
+ version: 1.4.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: isodoc
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -273,6 +273,7 @@ files:
273
273
  - lib/isodoc/ogc/ogc.white-paper.xsl
274
274
  - lib/isodoc/ogc/pdf_convert.rb
275
275
  - lib/isodoc/ogc/reqt.rb
276
+ - lib/isodoc/ogc/reqt_xref.rb
276
277
  - lib/isodoc/ogc/sections.rb
277
278
  - lib/isodoc/ogc/word_convert.rb
278
279
  - lib/metanorma-ogc.rb