metanorma-ogc 1.3.5 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,17 +8,22 @@ module IsoDoc
8
8
  return "recommendtest" if node["type"] == "abstracttest"
9
9
  return "recommendclass" if node["type"] == "class"
10
10
  return "recommendclass" if node["type"] == "conformanceclass"
11
+
11
12
  "recommend"
12
13
  end
13
14
 
14
15
  def recommendation_class(node)
15
- node["type"] == "recommendtest" ?
16
- "RecommendationTestTitle" : "RecommendationTitle"
16
+ if node["type"] == "recommendtest"
17
+ "RecommendationTestTitle"
18
+ else
19
+ "RecommendationTitle"
20
+ end
17
21
  end
18
22
 
19
- def recommendation_header(r)
20
- h = r.add_child("<thead><tr><th scope='colgroup' colspan='2'></th></tr></thead>")
21
- recommendation_name(r, h.at(ns(".//th")))
23
+ def recommendation_header(recommend)
24
+ h = recommend.add_child("<thead><tr><th scope='colgroup' colspan='2'>"\
25
+ "</th></tr></thead>")
26
+ recommendation_name(recommend, h.at(ns(".//th")))
22
27
  end
23
28
 
24
29
  def recommendation_name(node, out)
@@ -27,7 +32,7 @@ module IsoDoc
27
32
  name.children.each { |n| b << n }
28
33
  b << l10n(":")
29
34
  end
30
- if title = node&.at(ns("./title"))&.remove
35
+ if title = node&.at(ns("./title"))&.remove
31
36
  b << l10n(" ") if name
32
37
  title.children.each { |n| b << n }
33
38
  end
@@ -41,20 +46,53 @@ module IsoDoc
41
46
  end
42
47
 
43
48
  def recommendation_attributes1(node)
44
- out = []
49
+ out = recommendation_attributes1_head(node, [])
50
+ out = recommendation_attributes1_component(node, out)
51
+ node.xpath(ns("./classification")).each do |c|
52
+ line = recommendation_attr_keyvalue(c, "tag", "value") and out << line
53
+ end
54
+ out
55
+ end
56
+
57
+ def recommendation_attributes1_head(node, out)
45
58
  oblig = node["obligation"] and out << ["Obligation", oblig]
46
- subj = node&.at(ns("./subject"))&.remove&.children and out << [rec_subj(node), subj]
59
+ subj = node&.at(ns("./subject"))&.remove&.children and
60
+ out << [rec_subj(node), subj]
47
61
  node.xpath(ns("./inherit")).each do |i|
48
62
  out << ["Dependency", i.remove.children]
49
63
  end
50
- node.xpath(ns("./classification")).each do |c|
51
- line = recommendation_attr_keyvalue(c, "tag", "value") and out << line
64
+ out
65
+ end
66
+
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
+ end
74
+
75
+ 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]
52
85
  end
53
86
  out
54
87
  end
55
88
 
56
89
  def rec_subj(node)
57
- node["type"] == "recommendclass" ? "Target Type" : "Subject"
90
+ case node["type_original"]
91
+ when "class" then "Target Type"
92
+ when "conformanceclass" then "Requirement Class"
93
+ when "verification", "abstracttest" then "Requirement"
94
+ else "Subject"
95
+ end
58
96
  end
59
97
 
60
98
  def recommendation_attr_keyvalue(node, key, value)
@@ -72,13 +110,16 @@ module IsoDoc
72
110
  end
73
111
 
74
112
  def preserve_in_nested_table?(node)
75
- return true if %w(recommendation requirement permission table).include?(node.name)
113
+ return true if %w(recommendation requirement permission
114
+ table).include?(node.name)
115
+
76
116
  false
77
117
  end
78
118
 
79
119
  def requirement_component_parse(node, out)
80
120
  node.remove
81
121
  return if node["exclude"] == "true"
122
+
82
123
  node.elements.size == 1 && node.first_element_child.name == "dl" and
83
124
  return reqt_dl(node.first_element_child, out)
84
125
  b = out.add_child("<tr><td colspan='2'></td></tr>").first
@@ -99,6 +140,7 @@ module IsoDoc
99
140
  def recommendation_base(node, klass)
100
141
  node.name = "table"
101
142
  node["class"] = klass
143
+ node["type_original"] = node["type"]
102
144
  node["type"] = recommend_class(node)
103
145
  end
104
146
 
@@ -110,8 +152,10 @@ module IsoDoc
110
152
  recommendation_attributes(node, b)
111
153
  node.elements.each do |n|
112
154
  next if %w(thead tbody).include?(n.name)
155
+
113
156
  requirement_component_parse(n, b)
114
157
  end
158
+ node.delete("type_original")
115
159
  end
116
160
 
117
161
  def recommendation_to_table(docxml)
@@ -145,8 +189,8 @@ module IsoDoc
145
189
  x = t.at(ns("./thead")) and x.replace(x.children)
146
190
  x = t.at(ns("./tbody")) and x.replace(x.children)
147
191
  x = t.at(ns("./tfoot")) and x.replace(x.children)
148
- if x = t.at(ns("./tr/th[@colspan = '2']")) and
149
- y = t.at(ns("./tr/td[@colspan = '2']"))
192
+ if (x = t.at(ns("./tr/th[@colspan = '2']"))) &&
193
+ (y = t.at(ns("./tr/td[@colspan = '2']")))
150
194
  requirement_table_cleanup1(x, y)
151
195
  end
152
196
  t.parent.parent.replace(t.children)
@@ -15,7 +15,7 @@ module IsoDoc
15
15
  super
16
16
  end
17
17
 
18
- def default_fonts(options)
18
+ def default_fonts(_options)
19
19
  {
20
20
  bodyfont: '"Times New Roman",serif',
21
21
  headerfont: '"Times New Roman",serif',
@@ -27,7 +27,7 @@ module IsoDoc
27
27
  }
28
28
  end
29
29
 
30
- def default_file_locations(options)
30
+ def default_file_locations(_options)
31
31
  {
32
32
  wordstylesheet: html_doc_path("wordstyle.scss"),
33
33
  standardstylesheet: html_doc_path("ogc.scss"),
@@ -40,7 +40,7 @@ module IsoDoc
40
40
  end
41
41
 
42
42
  def convert1(docxml, filename, dir)
43
- if docxml&.at(ns('//bibdata/ext/doctype'))&.text == "white-paper"
43
+ if docxml&.at(ns("//bibdata/ext/doctype"))&.text == "white-paper"
44
44
  @wordstylesheet_name = html_doc_path("wordstyle_wp.scss")
45
45
  @standardstylesheet_name = html_doc_path("ogc_wp.scss")
46
46
  @wordcoverpage = html_doc_path("word_ogc_titlepage_wp.html")
@@ -86,7 +86,7 @@ module IsoDoc
86
86
  <span lang="EN-GB"><span
87
87
  style='mso-element:field-begin'></span><span
88
88
  style='mso-spacerun:yes'>&#xA0;</span>TOC
89
- \\h \\z \\t &quot;RecommendationTitle,recommendationtitle&quot;
89
+ \\h \\z \\t &quot;RecommendationTitle,recommendationtitle&quot;#{' '}
90
90
  <span style='mso-element:field-separator'></span></span>
91
91
  TOC
92
92
 
@@ -117,7 +117,7 @@ module IsoDoc
117
117
  toc += word_toc_entry(1, header_strip(h))
118
118
  end
119
119
  toc.sub(/(<p class="MsoToc1">)/,
120
- %{\\1#{WORD_TOC_TABLE_PREFACE1}}) + WORD_TOC_SUFFIX1
120
+ %{\\1#{WORD_TOC_TABLE_PREFACE1}}) + WORD_TOC_SUFFIX1
121
121
  end
122
122
 
123
123
  def make_FigureWordToC(docxml)
@@ -126,7 +126,7 @@ module IsoDoc
126
126
  toc += word_toc_entry(1, header_strip(h))
127
127
  end
128
128
  toc.sub(/(<p class="MsoToc1">)/,
129
- %{\\1#{WORD_TOC_FIGURE_PREFACE1}}) + WORD_TOC_SUFFIX1
129
+ %{\\1#{WORD_TOC_FIGURE_PREFACE1}}) + WORD_TOC_SUFFIX1
130
130
  end
131
131
 
132
132
  def make_RecommendationWordToC(docxml)
@@ -135,7 +135,7 @@ module IsoDoc
135
135
  toc += word_toc_entry(1, header_strip(h))
136
136
  end
137
137
  toc.sub(/(<p class="MsoToc1">)/,
138
- %{\\1#{WORD_TOC_RECOMMENDATION_PREFACE1}}) + WORD_TOC_SUFFIX1
138
+ %{\\1#{WORD_TOC_RECOMMENDATION_PREFACE1}}) + WORD_TOC_SUFFIX1
139
139
  end
140
140
 
141
141
  def make_body2(body, docxml)
@@ -179,10 +179,11 @@ module IsoDoc
179
179
  x = "//div[@class = 'boilerplate-copyright']/div[1]/p[not(@class)]"
180
180
  docxml.xpath(x).each { |p| p["align"] = "center" }
181
181
  return unless @doctype == "white-paper"
182
- docxml.xpath("//div[@class = 'boilerplate-copyright']//p[not(@class)]").
183
- each { |p| p["class"] = "license" }
184
- docxml.xpath("//div[@class = 'boilerplate-legal']//p[not(@class)]").
185
- each { |p| p["class"] = "license" }
182
+
183
+ docxml.xpath("//div[@class = 'boilerplate-copyright']//p[not(@class)]")
184
+ .each { |p| p["class"] = "license" }
185
+ docxml.xpath("//div[@class = 'boilerplate-legal']//p[not(@class)]")
186
+ .each { |p| p["class"] = "license" }
186
187
  end
187
188
 
188
189
  def word_term_cleanup(docxml)
@@ -199,7 +200,7 @@ module IsoDoc
199
200
  style_update(tr, "background:#A5A5A5;")
200
201
  end
201
202
  docxml.xpath("//table[@class = 'recommend']/tbody").each do |tr|
202
- tr.xpath("./tr").each_slice(2) do |tr1, tr2|
203
+ tr.xpath("./tr").each_slice(2) do |_tr1, tr2|
203
204
  tr2 && style_update(tr2, "background:#C9C9C9;")
204
205
  end
205
206
  end
@@ -24,6 +24,7 @@ module IsoDoc
24
24
  @anchors[t["id"]] = anchor_struct(id, t, label, klass,
25
25
  t["unnumbered"])
26
26
  l = t.at(ns("./label"))&.text and @reqtlabels[l] = t["id"]
27
+ permission_parts(t, label, klass)
27
28
  sequential_permission_children(t, id)
28
29
  end
29
30
  end
@@ -32,7 +33,7 @@ module IsoDoc
32
33
  { "class" => "@type = 'class'",
33
34
  "test" => "@type = 'verification'",
34
35
  "" => "not(@type = 'verification' or @type = 'class' or "\
35
- "@type = 'abstracttest' or @type = 'conformanceclass')" }
36
+ "@type = 'abstracttest' or @type = 'conformanceclass')" }
36
37
  end
37
38
 
38
39
  def req_class_paths2
@@ -40,15 +41,27 @@ module IsoDoc
40
41
  "conformanceclass" => "@type = 'conformanceclass'" }
41
42
  end
42
43
 
43
- def sequential_permission_children(t, id)
44
+ def permission_parts(block, label, klass)
45
+ block.xpath(ns("./component[@class = 'part']"))
46
+ .each_with_index do |c, i|
47
+ next if c["id"].nil? || c["id"].empty?
48
+
49
+ @anchors[c["id"]] = anchor_struct((i + "A".ord).chr.to_s, c, label,
50
+ klass, c["unnumbered"])
51
+ end
52
+ end
53
+
54
+ REQS = %w(permission requirement recommendation).freeze
55
+
56
+ def sequential_permission_children(block, idx)
44
57
  req_class_paths.each do |k, v|
45
- %w(permission requirement recommendation).each do |r|
46
- sequential_permission_names1(t, id, "#{r}[#{v}]",
58
+ REQS.each do |r|
59
+ sequential_permission_names1(block, idx, "#{r}[#{v}]",
47
60
  @labels["#{r}#{k}"])
48
61
  end
49
62
  end
50
63
  req_class_paths2.each do |k, v|
51
- sequential_permission_names1(t, id, "*[#{v}]", @labels[k])
64
+ sequential_permission_names1(block, idx, "*[#{v}]", @labels[k])
52
65
  end
53
66
  end
54
67
 
@@ -60,6 +73,7 @@ module IsoDoc
60
73
  id = "#{lbl}#{hierfigsep}#{c.increment(t).print}"
61
74
  @anchors[t["id"]] = anchor_struct(id, t, label, klass,
62
75
  t["unnumbered"])
76
+ permission_parts(t, label, klass)
63
77
  sequential_permission_children(t, id)
64
78
  end
65
79
  end
@@ -69,7 +83,7 @@ module IsoDoc
69
83
  sequential_figure_names(clause)
70
84
  sequential_formula_names(clause)
71
85
  req_class_paths.each do |k, v|
72
- %w(permission requirement recommendation).each do |r|
86
+ REQS.each do |r|
73
87
  sequential_permission_names(clause, "#{r}[#{v}]",
74
88
  @labels["#{r}#{k}"])
75
89
  end
@@ -84,7 +98,7 @@ module IsoDoc
84
98
  hierarchical_figure_names(clause, num)
85
99
  hierarchical_formula_names(clause, num)
86
100
  req_class_paths.each do |k, v|
87
- %w(permission requirement recommendation).each do |r|
101
+ REQS.each do |r|
88
102
  hierarchical_permission_names(clause, num, "#{r}[#{v}]",
89
103
  @labels["#{r}#{k}"])
90
104
  end
@@ -103,51 +117,54 @@ module IsoDoc
103
117
  @anchors[t["id"]] = anchor_struct(lbl, t, label, klass,
104
118
  t["unnumbered"])
105
119
  l = t.at(ns("./label"))&.text and @reqtlabels[l] = t["id"]
120
+ permission_parts(t, label, klass)
106
121
  sequential_permission_children(t, lbl)
107
122
  end
108
123
  end
109
124
 
110
- def initial_anchor_names(d)
111
- @prefacenum = 0
112
- preface_names_numbered(d.at(ns("//preface/abstract")))
113
- preface_names_numbered(d.at(ns("//preface/clause[@type = 'keywords']")))
114
- preface_names_numbered(d.at(ns("//foreword")))
115
- preface_names_numbered(d.at(ns("//introduction")))
116
- preface_names_numbered(d.at(ns("//preface/clause[@type = 'security']")))
117
- preface_names_numbered(d.at(ns("//preface/clause"\
118
- "[@type = 'submitting_orgs']")))
119
- preface_names_numbered(d.at(ns("//submitters")))
120
- d.xpath(ns("//preface/clause[not(@type = 'keywords' or "\
121
- "@type = 'submitting_orgs' or @type = 'security')]")).each do |c|
122
- preface_names_numbered(c)
123
- end
124
- preface_names_numbered(d.at(ns("//acknowledgements")))
125
- sequential_asset_names(d.xpath(ns(
126
- "//preface/abstract | //foreword | //introduction | "\
127
- "//submitters | //acknowledgements | //preface/clause",
128
- )))
125
+ def initial_anchor_names(doc)
126
+ preface_anchor_names(doc)
129
127
  n = Counter.new
130
- n = section_names(d.at(ns("//clause[@type = 'scope']")), n, 1)
131
- n = section_names(d.at(ns("//clause[@type = 'conformance']")), n, 1)
132
- n = section_names(d.at(ns(@klass.norm_ref_xpath)), n, 1)
128
+ n = section_names(doc.at(ns("//clause[@type = 'scope']")), n, 1)
129
+ n = section_names(doc.at(ns("//clause[@type = 'conformance']")), n, 1)
130
+ n = section_names(doc.at(ns(@klass.norm_ref_xpath)), n, 1)
133
131
  n = section_names(
134
- d.at(ns("//sections/terms | //sections/clause[descendant::terms]")),
132
+ doc.at(ns("//sections/terms | //sections/clause[descendant::terms]")),
135
133
  n, 1
136
134
  )
137
- n = section_names(d.at(ns("//sections/definitions")), n, 1)
138
- middle_section_asset_names(d)
139
- clause_names(d, n)
140
- termnote_anchor_names(d)
141
- termexample_anchor_names(d)
135
+ n = section_names(doc.at(ns("//sections/definitions")), n, 1)
136
+ middle_section_asset_names(doc)
137
+ clause_names(doc, n)
138
+ termnote_anchor_names(doc)
139
+ termexample_anchor_names(doc)
140
+ end
141
+
142
+ def preface_anchor_names(doc)
143
+ @prefacenum = 0
144
+ ["//preface/abstract", "//preface/clause[@type = 'keywords']",
145
+ "//foreword", "//introduction", "//preface/clause[@type = 'security']",
146
+ "//preface/clause[@type = 'submitting_orgs']",
147
+ "//submitters"].each do |path|
148
+ preface_names_numbered(doc.at(ns(path)))
149
+ end
150
+ doc.xpath(ns("//preface/clause[not(@type = 'keywords' or "\
151
+ "@type = 'submitting_orgs' or @type = 'security')]"))
152
+ .each { |c| preface_names_numbered(c) }
153
+ preface_names_numbered(doc.at(ns("//acknowledgements")))
154
+ sequential_asset_names(
155
+ doc.xpath(ns("//preface/abstract | //foreword | //introduction | "\
156
+ "//submitters | //acknowledgements | //preface/clause")),
157
+ )
142
158
  end
143
159
 
144
- def middle_section_asset_names(d)
145
- middle_sections = "//clause[@type = 'scope' or @type = 'conformance'] "\
146
- "| //foreword | //introduction | //preface/abstract | "\
147
- "//submitters | //acknowledgements | //preface/clause | "\
160
+ def middle_section_asset_names(doc)
161
+ middle_sections =
162
+ "//clause[@type = 'scope' or @type = 'conformance'] | //foreword | "\
163
+ "//introduction | //preface/abstract | //submitters | "\
164
+ "//acknowledgements | //preface/clause | "\
148
165
  " #{@klass.norm_ref_xpath} | //sections/terms | "\
149
166
  "//sections/definitions | //clause[parent::sections]"
150
- sequential_asset_names(d.xpath(ns(middle_sections)))
167
+ sequential_asset_names(doc.xpath(ns(middle_sections)))
151
168
  end
152
169
 
153
170
  def preface_names_numbered(clause)
@@ -192,7 +209,7 @@ module IsoDoc
192
209
  super
193
210
  return unless @klass.ogc_draft_ref?(ref)
194
211
 
195
- @anchors[ref["id"]] = { xref: @anchors[ref["id"]][:xref] + " (draft)" }
212
+ @anchors[ref["id"]] = { xref: "#{@anchors[ref['id']][:xref]} (draft)" }
196
213
  end
197
214
  end
198
215
  end
@@ -22,11 +22,12 @@ module Metanorma
22
22
  def fonts_manifest
23
23
  {
24
24
  "Lato" => nil,
25
+ "Lato Light" => nil,
25
26
  "Arial" => nil,
26
27
  "STIX Two Math" => nil,
27
28
  "Source Han Sans" => nil,
29
+ "Source Han Sans Normal" => nil,
28
30
  "Fira Code" => nil,
29
- "Courier" => nil,
30
31
  "Courier New" => nil,
31
32
  "Times New Roman" => nil,
32
33
  "Overpass" => nil,
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Ogc
3
- VERSION = "1.3.5".freeze
3
+ VERSION = "1.4.0".freeze
4
4
  end
5
5
  end
@@ -25,8 +25,8 @@ Gem::Specification.new do |spec|
25
25
  spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
26
26
 
27
27
  spec.add_dependency "iso-639"
28
- spec.add_dependency "isodoc", "~> 1.6.0"
29
- spec.add_dependency "metanorma-standoc", "~> 1.9.0"
28
+ spec.add_dependency "isodoc", "~> 1.7.0"
29
+ spec.add_dependency "metanorma-standoc", "~> 1.10.0"
30
30
 
31
31
  spec.add_development_dependency "byebug", "~> 9.1"
32
32
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
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.3.5
4
+ version: 1.4.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: 2021-06-21 00:00:00.000000000 Z
11
+ date: 2021-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: iso-639
@@ -30,28 +30,28 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.6.0
33
+ version: 1.7.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.6.0
40
+ version: 1.7.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: metanorma-standoc
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.9.0
47
+ version: 1.10.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.9.0
54
+ version: 1.10.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: byebug
57
57
  requirement: !ruby/object:Gem::Requirement