metanorma-ogc 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/asciidoctor/ogc/converter.rb +1 -1
- data/lib/asciidoctor/ogc/front.rb +1 -1
- data/lib/asciidoctor/ogc/isodoc.rng +4 -1
- data/lib/isodoc/ogc/base_convert.rb +31 -22
- data/lib/isodoc/ogc/html_convert.rb +1 -0
- data/lib/isodoc/ogc/ogc.abstract-specification-topic.xsl +252 -118
- data/lib/isodoc/ogc/ogc.best-practice.xsl +252 -118
- data/lib/isodoc/ogc/ogc.change-request-supporting-document.xsl +252 -118
- data/lib/isodoc/ogc/ogc.community-practice.xsl +252 -118
- data/lib/isodoc/ogc/ogc.community-standard.xsl +252 -118
- data/lib/isodoc/ogc/ogc.discussion-paper.xsl +252 -118
- data/lib/isodoc/ogc/ogc.engineering-report.xsl +252 -118
- data/lib/isodoc/ogc/ogc.other.xsl +252 -118
- data/lib/isodoc/ogc/ogc.policy.xsl +252 -118
- data/lib/isodoc/ogc/ogc.reference-model.xsl +252 -118
- data/lib/isodoc/ogc/ogc.release-notes.xsl +252 -118
- data/lib/isodoc/ogc/ogc.standard.xsl +252 -118
- data/lib/isodoc/ogc/ogc.test-suite.xsl +252 -118
- data/lib/isodoc/ogc/ogc.user-guide.xsl +252 -118
- data/lib/isodoc/ogc/ogc.white-paper.xsl +250 -116
- data/lib/isodoc/ogc/presentation_xml_convert.rb +8 -2
- data/lib/isodoc/ogc/reqt.rb +90 -101
- data/lib/isodoc/ogc/word_convert.rb +1 -0
- data/lib/metanorma/ogc/version.rb +1 -1
- metadata +2 -2
@@ -1,4 +1,5 @@
|
|
1
1
|
require_relative "init"
|
2
|
+
require_relative "reqt"
|
2
3
|
require "isodoc"
|
3
4
|
require "uuidtools"
|
4
5
|
|
@@ -79,7 +80,7 @@ module IsoDoc
|
|
79
80
|
end
|
80
81
|
|
81
82
|
def recommendation1(f, type)
|
82
|
-
type =
|
83
|
+
type = recommendation_class_label(f)
|
83
84
|
label = f&.at(ns("./label"))&.text
|
84
85
|
if inject_crossreference_reqt?(f, label)
|
85
86
|
n = @xrefs.anchor(@xrefs.reqtlabels[label], :xref, false)
|
@@ -98,7 +99,7 @@ module IsoDoc
|
|
98
99
|
@xrefs.reqtlabels[label]
|
99
100
|
end
|
100
101
|
|
101
|
-
def
|
102
|
+
def recommendation_class_label(node)
|
102
103
|
case node["type"]
|
103
104
|
when "verification" then @i18n.get["#{node.name}test"]
|
104
105
|
when "class" then @i18n.get["#{node.name}class"]
|
@@ -130,6 +131,11 @@ module IsoDoc
|
|
130
131
|
end
|
131
132
|
end
|
132
133
|
|
134
|
+
def block(docxml)
|
135
|
+
super
|
136
|
+
recommendation_to_table(docxml)
|
137
|
+
end
|
138
|
+
|
133
139
|
include Init
|
134
140
|
end
|
135
141
|
end
|
data/lib/isodoc/ogc/reqt.rb
CHANGED
@@ -2,7 +2,7 @@ require "isodoc"
|
|
2
2
|
|
3
3
|
module IsoDoc
|
4
4
|
module Ogc
|
5
|
-
|
5
|
+
class PresentationXMLConvert < IsoDoc::PresentationXMLConvert
|
6
6
|
def recommend_class(node)
|
7
7
|
return "recommendtest" if node["type"] == "verification"
|
8
8
|
return "recommendtest" if node["type"] == "abstracttest"
|
@@ -11,52 +11,41 @@ module IsoDoc
|
|
11
11
|
"recommend"
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
15
|
-
|
16
|
-
|
17
|
-
"#{keep_style(node)}")
|
14
|
+
def recommendation_class(node)
|
15
|
+
node["type"] == "recommendtest" ?
|
16
|
+
"RecommendationTestTitle" : "RecommendationTitle"
|
18
17
|
end
|
19
18
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
def recommendation_class(node)
|
24
|
-
%w(verification abstracttest).include?(node["type"]) ?
|
25
|
-
"RecommendationTestTitle" : "RecommendationTitle"
|
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")))
|
26
22
|
end
|
27
23
|
|
28
|
-
def recommendation_name(node, out
|
29
|
-
|
30
|
-
|
31
|
-
|
24
|
+
def recommendation_name(node, out)
|
25
|
+
b = out.add_child("<p class='#{recommendation_class(node)}'></p>").first
|
26
|
+
if name = node&.at(ns("./name"))&.remove
|
27
|
+
name.children.each { |n| b << n }
|
32
28
|
b << l10n(":")
|
33
|
-
recommendation_name1(title, node, label, b)
|
34
29
|
end
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
b << " "
|
40
|
-
title.children.each { |n| parse(n,b) }
|
30
|
+
if title = node&.at(ns("./title"))&.remove
|
31
|
+
b << l10n(" ") if name
|
32
|
+
title.children.each { |n| b << n }
|
33
|
+
end
|
41
34
|
end
|
42
35
|
|
43
36
|
def recommend_title(node, out)
|
44
|
-
label = node
|
45
|
-
out.tr
|
46
|
-
|
47
|
-
|
48
|
-
label.children.each { |n| parse(n, p) }
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
37
|
+
label = node&.at(ns("./label"))&.remove or return
|
38
|
+
b = out.add_child("<tr><td colspan='2'><p></p></td></tr>")
|
39
|
+
p = b.at(ns(".//p"))
|
40
|
+
p << label.children
|
52
41
|
end
|
53
42
|
|
54
43
|
def recommendation_attributes1(node)
|
55
44
|
out = []
|
56
45
|
oblig = node["obligation"] and out << ["Obligation", oblig]
|
57
|
-
subj = node&.at(ns("./subject"))&.
|
46
|
+
subj = node&.at(ns("./subject"))&.remove&.children and out << [rec_subj(node), subj]
|
58
47
|
node.xpath(ns("./inherit")).each do |i|
|
59
|
-
out <<
|
48
|
+
out << ["Dependency", i.remove.children]
|
60
49
|
end
|
61
50
|
node.xpath(ns("./classification")).each do |c|
|
62
51
|
line = recommendation_attr_keyvalue(c, "tag", "value") and out << line
|
@@ -65,103 +54,103 @@ module IsoDoc
|
|
65
54
|
end
|
66
55
|
|
67
56
|
def rec_subj(node)
|
68
|
-
|
69
|
-
"Target Type" : "Subject"
|
70
|
-
end
|
71
|
-
|
72
|
-
def recommendation_attr_parse(node, label)
|
73
|
-
text = noko do |xml|
|
74
|
-
node.children.each { |n| parse(n, xml) }
|
75
|
-
end.join
|
76
|
-
[label, text]
|
57
|
+
node["type"] == "recommendclass" ? "Target Type" : "Subject"
|
77
58
|
end
|
78
59
|
|
79
60
|
def recommendation_attr_keyvalue(node, key, value)
|
80
|
-
tag = node
|
81
|
-
value = node.at(ns("./#{value}"))
|
82
|
-
|
61
|
+
tag = node&.at(ns("./#{key}"))&.remove
|
62
|
+
value = node.at(ns("./#{value}"))&.remove
|
63
|
+
tag && value or return nil
|
64
|
+
node.remove
|
65
|
+
[tag.text.capitalize, value.children]
|
83
66
|
end
|
84
67
|
|
85
68
|
def recommendation_attributes(node, out)
|
86
69
|
recommendation_attributes1(node).each do |i|
|
87
|
-
out.tr
|
88
|
-
tr.td **REQ_TBL_ATTR do |td|
|
89
|
-
td << i[0]
|
90
|
-
end
|
91
|
-
tr.td **REQ_TBL_ATTR do |td|
|
92
|
-
td << i[1]
|
93
|
-
end
|
94
|
-
end
|
70
|
+
out.add_child("<tr><td>#{i[0]}</td><td>#{i[1]}</td></tr>")
|
95
71
|
end
|
96
72
|
end
|
97
73
|
|
98
|
-
def
|
99
|
-
|
74
|
+
def preserve_in_nested_table?(node)
|
75
|
+
return true if %w(recommendation requirement permission table).include?(node.name)
|
76
|
+
false
|
100
77
|
end
|
101
78
|
|
102
79
|
def requirement_component_parse(node, out)
|
80
|
+
node.remove
|
103
81
|
return if node["exclude"] == "true"
|
104
82
|
node.elements.size == 1 && node.first_element_child.name == "dl" and
|
105
83
|
return reqt_dl(node.first_element_child, out)
|
106
|
-
out.tr
|
107
|
-
|
108
|
-
merge(reqt_component_attrs(node)) do |td|
|
109
|
-
node.children.each { |n| parse(n, td) }
|
110
|
-
end
|
111
|
-
end
|
84
|
+
b = out.add_child("<tr><td colspan='2'></td></tr>").first
|
85
|
+
b.at(ns(".//td")) << (preserve_in_nested_table?(node) ? node : node.children)
|
112
86
|
end
|
113
87
|
|
114
88
|
def reqt_dl(node, out)
|
115
89
|
node.xpath(ns("./dt")).each do |dt|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
dd.children.each { |n| parse(n, td) }
|
123
|
-
end
|
124
|
-
end
|
90
|
+
dd = dt&.next_element
|
91
|
+
dt.remove
|
92
|
+
dd&.name == "dd" or next
|
93
|
+
b = out.add_child("<tr><td></td><td></td></tr>")
|
94
|
+
b.at(ns(".//td[1]")) << dt.children
|
95
|
+
b.at(ns(".//td[2]")) << dd.remove.children
|
125
96
|
end
|
126
97
|
end
|
127
98
|
|
128
|
-
def
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
recommendation_name(node, td, label)
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
99
|
+
def recommendation_base(node, klass)
|
100
|
+
node.name = "table"
|
101
|
+
node["class"] = klass
|
102
|
+
node["type"] = recommend_class(node)
|
136
103
|
end
|
137
104
|
|
138
|
-
def recommendation_parse1(node,
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
end
|
105
|
+
def recommendation_parse1(node, klass)
|
106
|
+
recommendation_base(node, klass)
|
107
|
+
recommendation_header(node)
|
108
|
+
b = node.add_child("<tbody></tbody>").first
|
109
|
+
recommend_title(node, b)
|
110
|
+
recommendation_attributes(node, b)
|
111
|
+
node.elements.each do |n|
|
112
|
+
next if %w(thead tbody).include?(n.name)
|
113
|
+
requirement_component_parse(n, b)
|
148
114
|
end
|
149
115
|
end
|
150
116
|
|
151
|
-
def
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
117
|
+
def recommendation_to_table(docxml)
|
118
|
+
docxml.xpath(ns("//recommendation")).each do |r|
|
119
|
+
recommendation_parse1(r, "recommendation")
|
120
|
+
end
|
121
|
+
docxml.xpath(ns("//requirement")).each do |r|
|
122
|
+
recommendation_parse1(r, "requirement")
|
123
|
+
end
|
124
|
+
docxml.xpath(ns("//permission")).each do |r|
|
125
|
+
recommendation_parse1(r, "permission")
|
126
|
+
end
|
127
|
+
requirement_table_cleanup(docxml)
|
128
|
+
end
|
129
|
+
|
130
|
+
# table nested in table: merge label and caption into a single row
|
131
|
+
def requirement_table_cleanup1(x, y)
|
132
|
+
x.delete("colspan")
|
133
|
+
x.delete("scope")
|
134
|
+
y.delete("colspan")
|
135
|
+
y.delete("scope")
|
136
|
+
x.name = "td"
|
137
|
+
p = x.at(ns("./p[@class = 'RecommendationTitle']")) and
|
138
|
+
p.delete("class")
|
139
|
+
x.parent << y.dup
|
140
|
+
y.parent.remove
|
141
|
+
end
|
142
|
+
|
143
|
+
def requirement_table_cleanup(docxml)
|
144
|
+
docxml.xpath(ns("//table[@type = 'recommendclass']/tbody/tr/td/table")).each do |t|
|
145
|
+
x = t.at(ns("./thead")) and x.replace(x.children)
|
146
|
+
x = t.at(ns("./tbody")) and x.replace(x.children)
|
147
|
+
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']"))
|
150
|
+
requirement_table_cleanup1(x, y)
|
151
|
+
end
|
152
|
+
t.parent.parent.replace(t.children)
|
153
|
+
end
|
165
154
|
end
|
166
155
|
end
|
167
156
|
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.2.
|
4
|
+
version: 1.2.2
|
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-08-
|
11
|
+
date: 2020-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: metanorma-standoc
|