metanorma-ogc 1.3.8 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -20,9 +20,10 @@ module IsoDoc
20
20
  end
21
21
  end
22
22
 
23
- def recommendation_header(r)
24
- h = r.add_child("<thead><tr><th scope='colgroup' colspan='2'></th></tr></thead>")
25
- 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")))
26
27
  end
27
28
 
28
29
  def recommendation_name(node, out)
@@ -45,20 +46,53 @@ module IsoDoc
45
46
  end
46
47
 
47
48
  def recommendation_attributes1(node)
48
- 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)
49
58
  oblig = node["obligation"] and out << ["Obligation", oblig]
50
- 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]
51
61
  node.xpath(ns("./inherit")).each do |i|
52
62
  out << ["Dependency", i.remove.children]
53
63
  end
54
- node.xpath(ns("./classification")).each do |c|
55
- 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]
56
85
  end
57
86
  out
58
87
  end
59
88
 
60
89
  def rec_subj(node)
61
- 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
62
96
  end
63
97
 
64
98
  def recommendation_attr_keyvalue(node, key, value)
@@ -76,7 +110,8 @@ module IsoDoc
76
110
  end
77
111
 
78
112
  def preserve_in_nested_table?(node)
79
- return true if %w(recommendation requirement permission table).include?(node.name)
113
+ return true if %w(recommendation requirement permission
114
+ table).include?(node.name)
80
115
 
81
116
  false
82
117
  end
@@ -105,6 +140,7 @@ module IsoDoc
105
140
  def recommendation_base(node, klass)
106
141
  node.name = "table"
107
142
  node["class"] = klass
143
+ node["type_original"] = node["type"]
108
144
  node["type"] = recommend_class(node)
109
145
  end
110
146
 
@@ -119,6 +155,7 @@ module IsoDoc
119
155
 
120
156
  requirement_component_parse(n, b)
121
157
  end
158
+ node.delete("type_original")
122
159
  end
123
160
 
124
161
  def recommendation_to_table(docxml)
@@ -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.8".freeze
3
+ VERSION = "1.4.0".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.3.8
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-08-02 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