mn-requirements 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/metanorma/default/cleanup.rb +1 -1
- data/lib/metanorma/default/isodoc.rb +33 -21
- data/lib/metanorma/default/utils.rb +5 -0
- data/lib/metanorma/modspec/cleanup.rb +1 -1
- data/lib/metanorma/modspec/isodoc.rb +31 -11
- data/lib/metanorma/modspec/reqt_label.rb +11 -6
- data/lib/metanorma/modspec/table_cleanup.rb +6 -4
- data/lib/metanorma/requirements/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75b1df8d56f422dda0f7d9ad8118a4ec48dd57c2d05994b84119e5f8bbf2d5cd
|
4
|
+
data.tar.gz: 436b0b873cdba89c706bbd549ad4aa4bbfd23ff551a017af10b611f340f6f9af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1bec02a150e493a2fa71fedeaa42c9d1167c13022a82106c6ab91974e26a0ae6e96088b879d21afc2fbc9bc83d44c88af982579ad3bc2ddfb74a56c7658a50ec
|
7
|
+
data.tar.gz: b508da3936b44d98d437c4c7c27b46515a55bcb01671c1040cd282f6472013b7c6426b8c0703ce476ba482671dc7222487ab12d10c5c7efc02f7372ca701dd50
|
@@ -6,13 +6,33 @@ module Metanorma
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def recommendation_label(elem, type, xrefs)
|
9
|
-
|
10
|
-
|
9
|
+
label, title = recommendation_labels(elem)
|
10
|
+
type = "<span class='fmt-element-name'>#{type}</span>"
|
11
|
+
num = xrefs.anchor(elem["id"], :label, false)
|
12
|
+
num &&= "<semx element='autonum' source='#{elem['id']}'>#{num}</semx>"
|
13
|
+
ret = "#{type} #{num}".strip
|
14
|
+
label || title and
|
15
|
+
ret += recommendation_label_add(elem, label, title)
|
16
|
+
ret
|
17
|
+
end
|
18
|
+
|
19
|
+
def recommendation_label_add(elem, label, title)
|
20
|
+
r = recommendation_label_caption_delim
|
21
|
+
label and
|
22
|
+
r += "<semx element='identifier' source='#{elem['id']}'>#{label}</semx>"
|
23
|
+
label && title and r += ". "
|
24
|
+
title and
|
25
|
+
r += "<semx element='title' source='#{elem['id']}'>#{title}</semx>"
|
26
|
+
r
|
27
|
+
end
|
28
|
+
|
29
|
+
def recommendation_label_caption_delim
|
30
|
+
"<span class='fmt-caption-delim'>:<br/></span>"
|
11
31
|
end
|
12
32
|
|
13
33
|
def reqt_metadata_node?(node)
|
14
34
|
%w(identifier title subject classification tag value
|
15
|
-
inherit name).include? node.name
|
35
|
+
inherit name fmt-name fmt-xref-label fmt-title).include? node.name
|
16
36
|
end
|
17
37
|
|
18
38
|
def requirement_render1(node)
|
@@ -25,35 +45,27 @@ module Metanorma
|
|
25
45
|
out
|
26
46
|
end
|
27
47
|
|
48
|
+
def recommendation_header(_node, out)
|
49
|
+
out
|
50
|
+
end
|
51
|
+
|
28
52
|
def recommendation_base(node, klass)
|
29
53
|
out = node.document.create_element(klass)
|
30
54
|
node.attributes.each do |k, v|
|
31
55
|
out[k] = v
|
32
56
|
end
|
57
|
+
n = node.at(ns("./fmt-name")) and out << n
|
58
|
+
n = node.at(ns("./fmt-xref-label")) and out << n
|
33
59
|
out
|
34
60
|
end
|
35
61
|
|
36
62
|
def recommendation_labels(node)
|
37
|
-
[node.at(ns("./identifier")), node.at(ns("./title"))
|
38
|
-
node.at(ns("./name"))]
|
63
|
+
[node.at(ns("./identifier")), node.at(ns("./title"))]
|
39
64
|
.map do |n|
|
40
|
-
n&.children
|
65
|
+
to_xml(n&.children)
|
41
66
|
end
|
42
67
|
end
|
43
68
|
|
44
|
-
def recommendation_header(node, out)
|
45
|
-
label, title, name = recommendation_labels(node)
|
46
|
-
ret = name ? [name] : []
|
47
|
-
if label || title
|
48
|
-
ret << ":" unless ret.empty?
|
49
|
-
ret += ["<br/>", label]
|
50
|
-
ret << ". " if label && title
|
51
|
-
ret << title
|
52
|
-
end
|
53
|
-
out << "<name>#{l10n(ret.compact.join)}</name>"
|
54
|
-
out
|
55
|
-
end
|
56
|
-
|
57
69
|
def recommendation_attributes1(node, out)
|
58
70
|
oblig = node["obligation"] and
|
59
71
|
out << l10n("#{@labels['default']['obligation']}: #{oblig}")
|
@@ -70,14 +82,14 @@ module Metanorma
|
|
70
82
|
end
|
71
83
|
|
72
84
|
def recommendation_attr_parse(node, label)
|
73
|
-
l10n("#{label}: #{node.children
|
85
|
+
l10n("#{label}: #{to_xml(node.children)}")
|
74
86
|
end
|
75
87
|
|
76
88
|
def recommendation_attr_keyvalue(node, key, value)
|
77
89
|
tag = node.at(ns("./#{key}")) or return nil
|
78
90
|
value = node.at(ns("./#{value}")) or return nil
|
79
91
|
l10n("#{Metanorma::Utils.strict_capitalize_first tag.text}: " \
|
80
|
-
"#{value.children
|
92
|
+
"#{to_xml(value.children)}")
|
81
93
|
end
|
82
94
|
|
83
95
|
def recommendation_attributes(node, out)
|
@@ -34,7 +34,7 @@ module Metanorma
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def recommendation_header(reqt, out)
|
37
|
-
n =
|
37
|
+
n = reqt.at(ns("./fmt-name"))
|
38
38
|
x = if reqt.ancestors("requirement, recommendation, permission").empty?
|
39
39
|
<<~THEAD
|
40
40
|
<thead><tr><th scope='colgroup' colspan='2'><p class='#{recommend_name_class(reqt)}'>#{n}</p></th></tr></thead>
|
@@ -47,10 +47,11 @@ module Metanorma
|
|
47
47
|
out
|
48
48
|
end
|
49
49
|
|
50
|
+
=begin
|
50
51
|
def recommendation_name(node, _out)
|
51
52
|
ret = ""
|
52
|
-
name = node.at(ns("./name")) and ret += name.children.to_xml
|
53
|
-
title = node.at(ns("./title"))
|
53
|
+
name = node.at(ns("./fmt-name")) and ret += name.children.to_xml
|
54
|
+
title = node.at(ns("./fmt-title"))
|
54
55
|
return ret unless title &&
|
55
56
|
node.ancestors("requirement, recommendation, permission").empty?
|
56
57
|
|
@@ -58,6 +59,25 @@ module Metanorma
|
|
58
59
|
ret += title.children.to_xml
|
59
60
|
l10n(ret)
|
60
61
|
end
|
62
|
+
=end
|
63
|
+
|
64
|
+
def recommendation_label_add(elem, _label, title)
|
65
|
+
title or return ""
|
66
|
+
r = recommendation_label_caption_delim
|
67
|
+
title and
|
68
|
+
r += "<semx element='title' source='#{elem['id']}'>#{title}</semx>"
|
69
|
+
r
|
70
|
+
end
|
71
|
+
|
72
|
+
def recommendation_label_caption_delim
|
73
|
+
"<span class='fmt-caption-delim'>: </span>"
|
74
|
+
end
|
75
|
+
|
76
|
+
def recommendation_labels(node)
|
77
|
+
node.ancestors("requirement, recommendation, permission").empty? or
|
78
|
+
return [nil, nil]
|
79
|
+
super
|
80
|
+
end
|
61
81
|
|
62
82
|
def recommendation_attributes(node, out)
|
63
83
|
ins = out.add_child("<tbody></tbody>").first
|
@@ -72,7 +92,7 @@ module Metanorma
|
|
72
92
|
label = node.at(ns("./identifier")) or return
|
73
93
|
ret = <<~OUTPUT
|
74
94
|
<tr><th>#{@labels['modspec']['identifier']}</th>
|
75
|
-
<td><tt><modspec-ident>#{label.children
|
95
|
+
<td><tt><modspec-ident>#{to_xml(label.children)}</modspec-ident></tt></td>
|
76
96
|
OUTPUT
|
77
97
|
out.add_child(ret)
|
78
98
|
end
|
@@ -120,7 +140,7 @@ module Metanorma
|
|
120
140
|
def recommendation_attributes1_inherit(node, head)
|
121
141
|
node.xpath(ns("./inherit")).each do |i|
|
122
142
|
head << [@labels["modspec"]["dependency"],
|
123
|
-
recommendation_id(i.children
|
143
|
+
recommendation_id(to_xml(i.children))]
|
124
144
|
end
|
125
145
|
head
|
126
146
|
end
|
@@ -129,7 +149,7 @@ module Metanorma
|
|
129
149
|
%w(indirect-dependency implements).each do |x|
|
130
150
|
node.xpath(ns("./classification[tag][value]")).each do |c|
|
131
151
|
c.at(ns("./tag")).text.casecmp(x).zero? or next
|
132
|
-
xref = recommendation_id(c.at(ns("./value")).children
|
152
|
+
xref = recommendation_id(to_xml(c.at(ns("./value")).children)) and
|
133
153
|
head << [@labels["modspec"][x.delete("-")], xref]
|
134
154
|
end
|
135
155
|
end
|
@@ -146,9 +166,9 @@ module Metanorma
|
|
146
166
|
|
147
167
|
d = node.at(ns("./component[@class = 'step']"))
|
148
168
|
d = d.replace("<ol class='steps'><li#{id_attr(d)}>" \
|
149
|
-
"#{d.children
|
169
|
+
"#{to_xml(d.children)}</li></ol>").first
|
150
170
|
node.xpath(ns("./component[@class = 'step']")).each do |f|
|
151
|
-
f = f.replace("<li#{id_attr(f)}>#{f.children
|
171
|
+
f = f.replace("<li#{id_attr(f)}>#{to_xml(f.children)}</li>").first
|
152
172
|
d << f
|
153
173
|
end
|
154
174
|
node
|
@@ -203,7 +223,7 @@ module Metanorma
|
|
203
223
|
recommend_class(node.parent) == "recommend" and
|
204
224
|
lbl = "statement"
|
205
225
|
out << "<tr><th>#{@labels['modspec'][lbl]}</th>" \
|
206
|
-
"<td>#{node.children
|
226
|
+
"<td>#{to_xml(node.children)}</td></tr>"
|
207
227
|
out
|
208
228
|
end
|
209
229
|
|
@@ -220,8 +240,8 @@ module Metanorma
|
|
220
240
|
node.xpath(ns("./dt")).each do |dt|
|
221
241
|
dd = dt.next_element
|
222
242
|
dd&.name == "dd" or next
|
223
|
-
out.add_child("<tr><th>#{dt.children
|
224
|
-
"<td>#{dd.children
|
243
|
+
out.add_child("<tr><th>#{to_xml(dt.children)}</th>" \
|
244
|
+
"<td>#{to_xml(dd.children)}</td></tr>")
|
225
245
|
end
|
226
246
|
out
|
227
247
|
end
|
@@ -27,10 +27,11 @@ module Metanorma
|
|
27
27
|
def recommendation_label_xref(elem, label, xrefs, type)
|
28
28
|
id = @reqtlabels[label]
|
29
29
|
number = xrefs.anchor(id, :modspec, false)
|
30
|
-
number.nil? and return type
|
30
|
+
number.nil? and return "<span class='fmt-element-name'>#{type}</span>"
|
31
31
|
elem.ancestors("requirement, recommendation, permission").empty? and
|
32
32
|
return number
|
33
|
-
"<xref target='#{id}'>#{number}</xref>"
|
33
|
+
#"<xref target='#{id}'>#{number}</xref>"
|
34
|
+
number
|
34
35
|
end
|
35
36
|
|
36
37
|
def init_lookups(doc)
|
@@ -103,7 +104,8 @@ module Metanorma
|
|
103
104
|
|
104
105
|
def recommendation_link_test(ident)
|
105
106
|
test = @reqt_links_test[ident&.strip] or return nil
|
106
|
-
"<xref target='#{test[:id]}'>#{test[:lbl]}</xref>"
|
107
|
+
#"<xref target='#{test[:id]}'>#{test[:lbl]}</xref>"
|
108
|
+
test[:lbl]
|
107
109
|
end
|
108
110
|
|
109
111
|
# we have not implemented multiple levels of nesting of classes
|
@@ -155,12 +157,15 @@ module Metanorma
|
|
155
157
|
|
156
158
|
def recommendation_link_class(ident)
|
157
159
|
test = @reqt_links_class[ident&.strip] or return nil
|
158
|
-
"<xref target='#{test[:id]}'>#{test[:lbl]}</xref>"
|
160
|
+
#"<xref target='#{test[:id]}'>#{test[:lbl]}</xref>"
|
161
|
+
test[:lbl]
|
159
162
|
end
|
160
163
|
|
161
164
|
def recommendation_id(ident)
|
162
165
|
test = @reqt_ids[ident&.strip] or return ident&.strip
|
163
|
-
"
|
166
|
+
#require "debug"; binding.b if test.include?("<xref")
|
167
|
+
#"<xref target='#{test[:id]}'>#{test[:lbl]}</xref>"
|
168
|
+
test[:lbl]
|
164
169
|
end
|
165
170
|
|
166
171
|
def recommendation_backlinks_test(node, id, ret)
|
@@ -185,7 +190,7 @@ module Metanorma
|
|
185
190
|
.xpath(ns("//requirement//xref | //permission//xref | " \
|
186
191
|
"//recommendation//xref"))).each do |x|
|
187
192
|
@reqt_id_base[x["target"]] or next # is a modspec requirement
|
188
|
-
x.children = x.children.
|
193
|
+
x.children = to_xml(x.children).delete_prefix(@modspecidentifierbase)
|
189
194
|
end
|
190
195
|
end
|
191
196
|
|
@@ -46,7 +46,7 @@ module Metanorma
|
|
46
46
|
hdr = th.text
|
47
47
|
th.children = @i18n.inflect(hdr, number: "pl")
|
48
48
|
td = th.next_element
|
49
|
-
res = [td.children
|
49
|
+
res = [to_xml(td.children)]
|
50
50
|
res += gather_consec_table_rows(trow, hdr)
|
51
51
|
td.children = res.join("<br/>")
|
52
52
|
end
|
@@ -55,7 +55,7 @@ module Metanorma
|
|
55
55
|
ret = []
|
56
56
|
trow.xpath("./following-sibling::xmlns:tr").each do |r|
|
57
57
|
r.at(ns("./th[text() = '#{hdr}']")) or break
|
58
|
-
ret << r.remove.at(ns("./td")).children
|
58
|
+
ret << to_xml(r.remove.at(ns("./td")).children)
|
59
59
|
end
|
60
60
|
ret
|
61
61
|
end
|
@@ -65,6 +65,8 @@ module Metanorma
|
|
65
65
|
x = t.at(ns("./thead/tr")) or next
|
66
66
|
x.at(ns("./th")).children =
|
67
67
|
requirement_table_nested_cleanup_hdr(node)
|
68
|
+
f = x.at(ns("./td/fmt-name")) and
|
69
|
+
f.replace(f.children)
|
68
70
|
t.parent.parent.replace(x)
|
69
71
|
end
|
70
72
|
table
|
@@ -78,7 +80,7 @@ module Metanorma
|
|
78
80
|
|
79
81
|
def strip_id_base(elem, base)
|
80
82
|
base.nil? and return elem.children
|
81
|
-
elem.children.
|
83
|
+
to_xml(elem.children).delete_prefix(base)
|
82
84
|
end
|
83
85
|
|
84
86
|
def truncate_id_base_in_reqt1(table, base)
|
@@ -94,7 +96,7 @@ module Metanorma
|
|
94
96
|
# any xrefs not yet expanded out to rendering need to be expanded out,
|
95
97
|
# so that the identifier instances they contain can be truncated
|
96
98
|
def expand_xrefs_in_reqt(table)
|
97
|
-
table.xpath(ns(".//xref[not(@style)][
|
99
|
+
table.xpath(ns(".//xref[not(@style)][string-length() = 0]"))
|
98
100
|
.each do |x|
|
99
101
|
ref = @xrefs.anchor(x["target"], :xref, false) or next
|
100
102
|
x << ref
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mn-requirements
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.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: 2024-08
|
11
|
+
date: 2024-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: isodoc-i18n
|