metanorma-iec 1.0.3 → 1.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '08369dfaab9066548f5aad7c5011c358f56f6c1f1f704173de19afc0df4a6a51'
4
- data.tar.gz: 8995d08b8a4a9c6569af60204a6964cc5e6ebcd0e57dfde55c26d2f030040661
3
+ metadata.gz: a536ad5ae8feafb5364a940423a83411ad986dcc162c53f323ab249f446bb47a
4
+ data.tar.gz: 76f4ed5012cac79543dedf0ff9013d55964d1e04058d1d7a7fb6feb290976a11
5
5
  SHA512:
6
- metadata.gz: 7038a4915d5f370122494500b39fefdb530310eb7c57a420f61eab9ae6c1bdd8ba5aa9a1ece06e4e4d63f41f76aefdf78943768c28061ea3db896e819180318d
7
- data.tar.gz: e6906b0c4ee3debfd9ffa0fde700c4df213b7451c6ee3a60db8eb3a67b6da67656c9de1e43d5d3d8475dd0109753e714014962a1ec8063b5985cc2efe1ba213f
6
+ metadata.gz: 4b28d85a7b1b8629e5f793df2111a6a8c94e6162232de29f936fa501450a0d7c47ab4195a917933507f39c23cc51821149d6ed742998888709d0bbd60db18cb4
7
+ data.tar.gz: effe98054f3f3cfa8961aebf19cf378399f88196f6cf3ffad9866cb1576314edf5d9c6fd09f5016c8bd19ebc2ffe0c48bd51330e7f5ee65a93f211525e75975a
@@ -49,11 +49,17 @@
49
49
  </define>
50
50
  <define name="stage">
51
51
  <element name="stage">
52
+ <optional>
53
+ <attribute name="abbreviation"/>
54
+ </optional>
52
55
  <text/>
53
56
  </element>
54
57
  </define>
55
58
  <define name="substage">
56
59
  <element name="substage">
60
+ <optional>
61
+ <attribute name="abbreviation"/>
62
+ </optional>
57
63
  <text/>
58
64
  </element>
59
65
  </define>
@@ -452,9 +458,14 @@
452
458
  <attribute name="bibitemid">
453
459
  <data type="IDREF"/>
454
460
  </attribute>
455
- <zeroOrMore>
456
- <ref name="locality"/>
457
- </zeroOrMore>
461
+ <choice>
462
+ <zeroOrMore>
463
+ <ref name="locality"/>
464
+ </zeroOrMore>
465
+ <zeroOrMore>
466
+ <ref name="localityStack"/>
467
+ </zeroOrMore>
468
+ </choice>
458
469
  <optional>
459
470
  <ref name="date"/>
460
471
  </optional>
@@ -469,6 +480,25 @@
469
480
  <ref name="BibItemLocality"/>
470
481
  </element>
471
482
  </define>
483
+ <define name="localityStack">
484
+ <element name="localityStack">
485
+ <zeroOrMore>
486
+ <ref name="locality"/>
487
+ </zeroOrMore>
488
+ </element>
489
+ </define>
490
+ <define name="sourceLocality">
491
+ <element name="sourceLocality">
492
+ <ref name="BibItemLocality"/>
493
+ </element>
494
+ </define>
495
+ <define name="sourceLocalityStack">
496
+ <element name="sourceLocalityStack">
497
+ <zeroOrMore>
498
+ <ref name="sourceLocality"/>
499
+ </zeroOrMore>
500
+ </element>
501
+ </define>
472
502
  <define name="BibItemLocality">
473
503
  <attribute name="type">
474
504
  <ref name="LocalityType"/>
@@ -1028,12 +1058,30 @@
1028
1058
  <attribute name="type">
1029
1059
  <ref name="DocRelationType"/>
1030
1060
  </attribute>
1061
+ <optional>
1062
+ <element name="description">
1063
+ <ref name="FormattedString"/>
1064
+ </element>
1065
+ </optional>
1031
1066
  <element name="bibitem">
1032
1067
  <ref name="BibliographicItem"/>
1033
1068
  </element>
1034
- <zeroOrMore>
1035
- <ref name="locality"/>
1036
- </zeroOrMore>
1069
+ <choice>
1070
+ <zeroOrMore>
1071
+ <ref name="locality"/>
1072
+ </zeroOrMore>
1073
+ <zeroOrMore>
1074
+ <ref name="localityStack"/>
1075
+ </zeroOrMore>
1076
+ </choice>
1077
+ <choice>
1078
+ <zeroOrMore>
1079
+ <ref name="sourceLocality"/>
1080
+ </zeroOrMore>
1081
+ <zeroOrMore>
1082
+ <ref name="sourceLocalityStack"/>
1083
+ </zeroOrMore>
1084
+ </choice>
1037
1085
  </element>
1038
1086
  </define>
1039
1087
  <define name="version">
@@ -1,5 +1,6 @@
1
1
  require "asciidoctor"
2
2
  require "metanorma-iso"
3
+ require_relative "./front.rb"
3
4
 
4
5
  module Asciidoctor
5
6
  module Iec
@@ -9,51 +10,9 @@ module Asciidoctor
9
10
 
10
11
  register_for "iec"
11
12
 
12
- def metadata_author(node, xml)
13
- publishers = node.attr("publisher") || "IEC"
14
- publishers.split(/,[ ]?/).each do |p|
15
- xml.contributor do |c|
16
- c.role **{ type: "author" }
17
- c.organization { |a| organization(a, p) }
18
- end
19
- end
20
- end
21
-
22
- def metadata_publisher(node, xml)
23
- publishers = node.attr("publisher") || "IEC"
24
- publishers.split(/,[ ]?/).each do |p|
25
- xml.contributor do |c|
26
- c.role **{ type: "publisher" }
27
- c.organization { |a| organization(a, p) }
28
- end
29
- end
30
- end
31
-
32
- def metadata_copyright(node, xml)
33
- publishers = node.attr("publisher") || "IEC"
34
- publishers.split(/,[ ]?/).each do |p|
35
- xml.copyright do |c|
36
- c.from (node.attr("copyright-year") || Date.today.year)
37
- c.owner do |owner|
38
- owner.organization { |o| organization(o, p) }
39
- end
40
- end
41
- end
42
- end
43
-
44
- def iso_id(node, xml)
45
- return unless node.attr("docnumber")
46
- part, subpart = node&.attr("partnumber")&.split(/-/)
47
- dn = add_id_parts(node.attr("docnumber"), part, subpart)
48
- dn = id_stage_prefix(dn, node)
49
- dn = id_edition_suffix(dn, node)
50
- xml.docidentifier dn, **attr_code(type: "iso")
51
- end
52
-
53
- def id_edition_suffix(dn, node)
54
- ed = node.attr("edition") || 1
55
- dn += " ED #{ed}"
56
- dn
13
+ def init(node)
14
+ super
15
+ @is_iev = node.attr("docnumber") == "60050"
57
16
  end
58
17
 
59
18
  def boilerplate_file(x_orig)
@@ -79,91 +38,6 @@ module Asciidoctor
79
38
  File.join(File.dirname(__FILE__), "iec.rng"))
80
39
  end
81
40
 
82
- STAGE_CODES = {
83
- "PNW" => "1000",
84
- "ANW" => "2000",
85
- "CAN" => "2098",
86
- "ACD" => "2099",
87
- "CD" => "3020",
88
- "BWG" => "3092",
89
- "A2CD" => "3099",
90
- "2CD" => "3520",
91
- "3CD" => "3520",
92
- "4CD" => "3520",
93
- "5CD" => "3520",
94
- "6CD" => "3520",
95
- "7CD" => "3520",
96
- "8CD" => "3520",
97
- "9CD" => "3520",
98
- "CDM" => "3591",
99
- "A3CD" => "3592",
100
- "A4CD" => "3592",
101
- "A5CD" => "3592",
102
- "A6CD" => "3592",
103
- "A7CD" => "3592",
104
- "A8CD" => "3592",
105
- "A9CD" => "3592",
106
- "ACDV" => "3599",
107
- "CCDV" => "4020",
108
- "CDVM" => "4091",
109
- "NCDV" => "4092",
110
- "NADIS" => "4093",
111
- "ADIS" => "4099",
112
- "ADTR" => "4099",
113
- "ADTS" => "4099",
114
- "RDISH" => "5000",
115
- "RFDIS" => "5000",
116
- "CDISH" => "5020",
117
- "CDPAS" => "5020",
118
- "CDTR" => "5020",
119
- "CDTS" => "5020",
120
- "CFDIS" => "5020",
121
- "DTRM" => "5092",
122
- "DTSM" => "5092",
123
- "NDTR" => "5092",
124
- "NDTS" => "5092",
125
- "NFDIS" => "5092",
126
- "APUB" => "5099",
127
- "BPUB" => "6000",
128
- "PPUB" => "6060",
129
- "RR" => "9092",
130
- "AMW" => "9220",
131
- "WPUB" => "9599",
132
- "DELPUB" => "9960",
133
- }.freeze
134
-
135
- DOC_STAGE = {
136
- "00": "PWI",
137
- "10": "NWIP",
138
- "20": "WD",
139
- "30": "CD",
140
- "40": "CDV",
141
- "50": "FDIS",
142
- }.freeze
143
-
144
- def get_stage(node)
145
- stage = node.attr("status") || node.attr("docstage") || "60"
146
- m = /([0-9])CD$/.match(stage) and
147
- node.set_attr("iteration", m[1])
148
- STAGE_CODES[stage] and stage = STAGE_CODES[stage][0..1]
149
- stage
150
- end
151
-
152
- def get_substage(node)
153
- st = node.attr("status") || node.attr("docstage")
154
- stage = get_stage(node)
155
- node.attr("docsubstage") ||
156
- ( stage == "60" ? "60" :
157
- STAGE_CODES[st] ? STAGE_CODES[st][2..3] :
158
- "00" )
159
- end
160
-
161
- def id_stage_abbr(stage, substage, node)
162
- abbr = DOC_STAGE[stage.to_sym] || ""
163
- abbr = node.attr("iteration") + abbr if node.attr("iteration")
164
- abbr
165
- end
166
-
167
41
  def load_yaml(lang, script)
168
42
  y = if @i18nyaml then YAML.load_file(@i18nyaml)
169
43
  elsif lang == "en"
@@ -187,6 +61,16 @@ module Asciidoctor
187
61
  node.nil? ? IsoDoc::Iec::WordConvert.new({}) :
188
62
  IsoDoc::Iec::WordConvert.new(doc_extract_attributes(node))
189
63
  end
64
+
65
+ def norm_ref_preface(f)
66
+ return super unless @is_iev
67
+ f.at("./title").next =
68
+ "<p>#{@norm_empty_pref}</p>"
69
+ end
70
+
71
+ def term_defs_boilerplate(div, source, term, preface, isodoc)
72
+ return super unless @is_iev
73
+ end
190
74
  end
191
75
  end
192
76
  end
@@ -0,0 +1,220 @@
1
+ module Asciidoctor
2
+ module Iec
3
+ class Converter < ISO::Converter
4
+ def metadata_author(node, xml)
5
+ publishers = node.attr("publisher") || "IEC"
6
+ publishers.split(/,[ ]?/).each do |p|
7
+ xml.contributor do |c|
8
+ c.role **{ type: "author" }
9
+ c.organization { |a| organization(a, p) }
10
+ end
11
+ end
12
+ end
13
+
14
+ def metadata_publisher(node, xml)
15
+ publishers = node.attr("publisher") || "IEC"
16
+ publishers.split(/,[ ]?/).each do |p|
17
+ xml.contributor do |c|
18
+ c.role **{ type: "publisher" }
19
+ c.organization { |a| organization(a, p) }
20
+ end
21
+ end
22
+ end
23
+
24
+ def metadata_copyright(node, xml)
25
+ publishers = node.attr("publisher") || "IEC"
26
+ publishers.split(/,[ ]?/).each do |p|
27
+ xml.copyright do |c|
28
+ c.from (node.attr("copyright-year") || Date.today.year)
29
+ c.owner do |owner|
30
+ owner.organization { |o| organization(o, p) }
31
+ end
32
+ end
33
+ end
34
+ end
35
+
36
+ def iso_id(node, xml)
37
+ return unless node.attr("docnumber")
38
+ part, subpart = node&.attr("partnumber")&.split(/-/)
39
+ dn = add_id_parts(node.attr("docnumber"), part, subpart)
40
+ dn = id_stage_prefix(dn, node)
41
+ dn = id_edition_suffix(dn, node)
42
+ xml.docidentifier dn, **attr_code(type: "iso")
43
+ end
44
+
45
+ def id_edition_suffix(dn, node)
46
+ ed = node.attr("edition") || 1
47
+ dn += " ED #{ed}"
48
+ dn
49
+ end
50
+
51
+ STAGE_CODES = {
52
+ "PNW" => "1000",
53
+ "ANW" => "2000",
54
+ "CAN" => "2098",
55
+ "ACD" => "2099",
56
+ "CD" => "3020",
57
+ "BWG" => "3092",
58
+ "A2CD" => "3099",
59
+ "2CD" => "3520",
60
+ "3CD" => "3520",
61
+ "4CD" => "3520",
62
+ "5CD" => "3520",
63
+ "6CD" => "3520",
64
+ "7CD" => "3520",
65
+ "8CD" => "3520",
66
+ "9CD" => "3520",
67
+ "CDM" => "3591",
68
+ "A3CD" => "3592",
69
+ "A4CD" => "3592",
70
+ "A5CD" => "3592",
71
+ "A6CD" => "3592",
72
+ "A7CD" => "3592",
73
+ "A8CD" => "3592",
74
+ "A9CD" => "3592",
75
+ "ACDV" => "3599",
76
+ "CCDV" => "4020",
77
+ "CDVM" => "4091",
78
+ "NCDV" => "4092",
79
+ "NADIS" => "4093",
80
+ "ADIS" => "4099",
81
+ "ADTR" => "4099",
82
+ "ADTS" => "4099",
83
+ "RDISH" => "5000",
84
+ "RFDIS" => "5000",
85
+ "CDISH" => "5020",
86
+ "CDPAS" => "5020",
87
+ "CDTR" => "5020",
88
+ "CDTS" => "5020",
89
+ "CFDIS" => "5020",
90
+ "DTRM" => "5092",
91
+ "DTSM" => "5092",
92
+ "NDTR" => "5092",
93
+ "NDTS" => "5092",
94
+ "NFDIS" => "5092",
95
+ "APUB" => "5099",
96
+ "BPUB" => "6000",
97
+ "PPUB" => "6060",
98
+ "RR" => "9092",
99
+ "AMW" => "9220",
100
+ "WPUB" => "9599",
101
+ "DELPUB" => "9960",
102
+ }.freeze
103
+
104
+ DOC_STAGE = {
105
+ "00": "PWI",
106
+ "10": "NWIP",
107
+ "20": "WD",
108
+ "30": "CD",
109
+ "40": "CDV",
110
+ "50": "FDIS",
111
+ "60": "PPUB",
112
+ "90": "RR",
113
+ "92": "AMW",
114
+ "95": "WPUB",
115
+ "99": "DELPUB",
116
+ }.freeze
117
+
118
+ STAGE_ABBRS = {
119
+ "00" => {"00" => "PWI"},
120
+ "10" => {"00" => "PNW"},
121
+ "20" => {"00" => "ANW", "98" => "CAN", "99" => "ACD"},
122
+ "30" => {"00" => "CD", "20" => "CD", "92" => "BWG", "97" => "MERGED", "98" => "DREJ", "99" => "A2CD"},
123
+ "35" => {"00" => "CD", "20" => "CD", "91" => "CDM", "92" => "ACD", "99" => "ACDV"},
124
+ "40" => {"00" => "CCDV", "20" => "CCDV", "91" => "CDVM", "92" => "NCDV", "93" => "NADIS", "95" => "ADISSB", "99" => "ADIS"},
125
+ "50" => {"00" => "RFDIS", "20" => "CFDIS", "92" => "NFDIS", "95" => "APUBSB", "99" => "APUB"},
126
+ "60" => {"00" => "BPUB", "60" => "PPUB"},
127
+ "90" => {"00" => "RR", "92" => "RR"},
128
+ "92" => {"00" => "AMW", "20" => "AMW"},
129
+ "95" => {"00" => "WPUB", "99" => "WPUB"},
130
+ "99" => {"00" => "DELPUB", "60" => "DELPUB"},
131
+ }.freeze
132
+
133
+ STAGE_NAMES = {
134
+ "00": "Preliminary work item",
135
+ "10": "New work item proposal",
136
+ "20": "Working draft",
137
+ "30": "Committee draft",
138
+ "35": "Committee draft",
139
+ "40": "Committed draft for vote",
140
+ "50": "Final draft international standard",
141
+ "60": "International standard",
142
+ "90": "Review",
143
+ "92": "Review",
144
+ "95": "Withdrawal",
145
+ "99": "Deleted",
146
+ }.freeze
147
+
148
+ def status_abbrev1(stage, substage, iter, doctype, draft)
149
+ return "" unless stage
150
+ abbr = STAGE_ABBRS.dig(stage, substage) || "??"
151
+ if stage == "35" && substage == "92"
152
+ iter = (iter.to_i + 1) % "02"
153
+ end
154
+ case doctype
155
+ when "technical-report"
156
+ stage = "ADTR" if stage == "40" && substage == "99"
157
+ stage = "CDTR" if stage == "50" && substage == "20"
158
+ stage = "DTRM" if stage == "50" && substage == "92"
159
+ when "technical-specification"
160
+ stage = "ADTS" if stage == "40" && substage == "99"
161
+ stage = "CDTS" if stage == "50" && substage == "20"
162
+ stage = "DTSM" if stage == "50" && substage == "92"
163
+ when "interpretation-sheet"
164
+ stage = "RDISH" if stage == "50" && substage == "00"
165
+ stage = "CDISH" if stage == "50" && substage == "20"
166
+ when "publicly-available-specification"
167
+ stage = "CDPAS" if stage == "50" && substage == "20"
168
+ end
169
+ abbr = abbr.sub(/CD$/, "#{iter}CD") if iter
170
+ abbr
171
+ end
172
+
173
+ def stage_abbr(stage, substage)
174
+ return "PPUB" if stage == "60"
175
+ DOC_STAGE[stage.to_sym] || "??"
176
+ end
177
+
178
+ def stage_name(stage, substage)
179
+ STAGE_NAMES[stage.to_sym]
180
+ end
181
+
182
+ def get_stage(node)
183
+ stage = node.attr("status") || node.attr("docstage") || "60"
184
+ m = /([0-9])CD$/.match(stage) and
185
+ node.set_attr("iteration", m[1])
186
+ STAGE_CODES[stage] and stage = STAGE_CODES[stage][0..1]
187
+ stage
188
+ end
189
+
190
+ def get_substage(node)
191
+ st = node.attr("status") || node.attr("docstage")
192
+ stage = get_stage(node)
193
+ node.attr("docsubstage") ||
194
+ ( stage == "60" ? "60" :
195
+ STAGE_CODES[st] ? STAGE_CODES[st][2..3] :
196
+ "00" )
197
+ end
198
+
199
+ def id_stage_abbr(stage, substage, node)
200
+ return "" if stage == "60"
201
+ abbr = DOC_STAGE[stage.to_sym] || ""
202
+ abbr = node.attr("iteration") + abbr if node.attr("iteration")
203
+ abbr
204
+ end
205
+
206
+ def metadata_status(node, xml)
207
+ stage = get_stage(node)
208
+ substage = get_substage(node)
209
+ xml.status do |s|
210
+ s.stage stage, **attr_code(abbreviation: stage_abbr(stage, substage))
211
+ s.substage substage,
212
+ **attr_code(abbreviation: status_abbrev1(stage, substage,
213
+ node.attr("iteration"),
214
+ doctype(node),node.attr("draft")))
215
+ node.attr("iteration") && (s.iteration node.attr("iteration"))
216
+ end
217
+ end
218
+ end
219
+ end
220
+ end