metanorma-iec 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -43,6 +43,9 @@
43
43
  <ref name="ics"/>
44
44
  </zeroOrMore>
45
45
  <ref name="structuredidentifier"/>
46
+ <optional>
47
+ <ref name="stagename"/>
48
+ </optional>
46
49
  </define>
47
50
  <define name="bdate">
48
51
  <element name="date">
@@ -511,4 +514,9 @@
511
514
  </oneOrMore>
512
515
  </element>
513
516
  </define>
517
+ <define name="stagename">
518
+ <element name="stagename">
519
+ <text/>
520
+ </element>
521
+ </define>
514
522
  </grammar>
@@ -72,6 +72,124 @@ module IsoDoc
72
72
  obl = l10n("(#{@norm_annex_lbl})") if clause["obligation"] == "normative"
73
73
  l10n("<b>#{@annex_lbl} #{num}</b><br/><br/>#{obl}")
74
74
  end
75
+
76
+ def convert1(docxml, filename, dir)
77
+ id = docxml&.at(ns("//bibdata/docnumber"))&.text
78
+ @is_iev = id == "60050"
79
+ id = docxml&.at(ns("//bibdata/docidentifier[@type = 'iso']"))&.text
80
+ m = /60050-(\d+)/.match(id) and @iev_part = m[1]
81
+ super
82
+ end
83
+
84
+ def introduction(isoxml, out)
85
+ return super unless @is_iev
86
+ f = isoxml.at(ns("//introduction")) || return
87
+ title_attr = { class: "IntroTitle" }
88
+ page_break(out)
89
+ out.div **{ class: "Section3", id: f["id"] } do |div|
90
+ clause_name(nil, @labels["introduction_iev"], div, title_attr)
91
+ f.elements.each do |e|
92
+ parse(e, div) unless e.name == "title"
93
+ end
94
+ end
95
+ end
96
+
97
+ def introduction_names(clause)
98
+ return super unless @is_iev
99
+ end
100
+
101
+ def bibliography(isoxml, out)
102
+ return super unless @is_iev
103
+ end
104
+
105
+ def biblio_list(f, div, biblio)
106
+ return super unless @is_iev
107
+ i = 0
108
+ f.children.each do |b|
109
+ parse(b, div) unless %w(title bibitem).include? b.name
110
+ end
111
+ end
112
+
113
+ def terms_parse(node, out)
114
+ return super unless @is_iev
115
+ page_break(out)
116
+ out.div **attr_code(id: node["id"]) do |div|
117
+ out.p(**{ class: "zzSTDTitle2" }) do |p|
118
+ p.b do |b|
119
+ b << "#{anchor(node['id'], :label)} "
120
+ node&.at(ns("./title"))&.children&.each { |c2| parse(c2, b) }
121
+ end
122
+ end
123
+ node.children.reject { |c1| c1.name == "title" }.each do |c1|
124
+ parse(c1, div)
125
+ end
126
+ end
127
+ end
128
+
129
+ def initial_anchor_names(d)
130
+ super
131
+ return unless @is_iev
132
+ terms_iev_names(d)
133
+ middle_section_asset_names(d)
134
+ termnote_anchor_names(d)
135
+ termexample_anchor_names(d)
136
+ end
137
+
138
+ def terms_iev_names(d)
139
+ d.xpath(ns("//sections/clause/terms")).each_with_index do |t, i|
140
+ num = "#{@iev_part}-%02d" % [i+1]
141
+ @anchors[t["id"]] =
142
+ { label: num, xref: l10n("#{@labels["section_iev"]}-#{num}"), level: 2,
143
+ type: "clause" }
144
+ t.xpath(ns("./term")).each_with_index do |c, i|
145
+ num2 = "%02d" % [i+1]
146
+ section_names1(c, "#{num}-#{num2}", 3)
147
+ end
148
+ end
149
+ end
150
+
151
+ def textcleanup(docxml)
152
+ return super unless @is_iev
153
+ docxml.
154
+ gsub(/\[TERMREF\]\s*/, l10n("#{@source_lbl}: ")).
155
+ gsub(/\s*\[MODIFICATION\]\s*\[\/TERMREF\]/, l10n(", #{@modified_lbl} [/TERMREF]")).
156
+ gsub(/\s*\[\/TERMREF\]\s*/, l10n("")).
157
+ gsub(/\s*\[MODIFICATION\]/, l10n(", #{@modified_lbl} &mdash; "))
158
+ end
159
+
160
+ def set_termdomain(termdomain)
161
+ return super unless @is_iev
162
+ end
163
+
164
+ def term_suffix(node, out)
165
+ return unless @is_iev
166
+ domain = node&.at(ns("../domain"))&.text
167
+ return unless domain
168
+ out << ", &lt;#{domain}&gt;"
169
+ end
170
+
171
+ def deprecated_term_parse(node, out)
172
+ out.p **{ class: "DeprecatedTerms", style:"text-align:left;" } do |p|
173
+ p << l10n("#{@deprecated_lbl}: ")
174
+ node.children.each { |c| parse(c, p) }
175
+ term_suffix(node, p)
176
+ end
177
+ end
178
+
179
+ def admitted_term_parse(node, out)
180
+ out.p **{ class: "AltTerms", style:"text-align:left;" } do |p|
181
+ node.children.each { |c| parse(c, p) }
182
+ term_suffix(node, p)
183
+ end
184
+ end
185
+
186
+ def term_parse(node, out)
187
+ return super unless @is_iev
188
+ out.p **{ class: "Terms", style:"text-align:left;" } do |p|
189
+ node.children.each { |c| parse(c, p) }
190
+ term_suffix(node, p)
191
+ end
192
+ end
75
193
  end
76
194
  end
77
195
  end
@@ -285,14 +285,17 @@ div.figure > img {
285
285
  */
286
286
 
287
287
  .document-type-band {
288
- @include docBand(2, 100%, 180px);
288
+ @include docBand($order: 2, $offset: 180px);
289
+
290
+ .document-type {
291
+ top: 20px;
292
+ }
289
293
  }
290
294
 
291
295
  .document-stage-band {
292
296
  @include docBand(1, 210px);
293
297
  }
294
298
 
295
- p.document-type,
296
299
  p.document-stage {
297
300
  @include docBandTitle(210px);
298
301
  }
@@ -1,3 +1,5 @@
1
1
  introduction: INTRODUCTION
2
+ introduction_iev: INTRODUCTION<br/>Principles and rules followed
2
3
  foreword: FOREWORD
3
4
  IEC: INTERNATIONAL ELECTROTECHNICAL COMMISSION
5
+ section_iev: Section
@@ -1,3 +1,5 @@
1
1
  introduction: INTRODUCTION
2
+ introduction_iev: INTRODUCTION<br/>Principes d’établissement et règles suivies
2
3
  foreword: AVANT-PROPOS
3
4
  IEC: COMMISSION ELECTROTECHNIQUE INTERNATIONALE
5
+ section_iev: Section
@@ -4,66 +4,17 @@ require "metanorma-iso"
4
4
  module IsoDoc
5
5
  module Iec
6
6
  class Metadata < IsoDoc::Iso::Metadata
7
- STAGE_ABBRS = {
8
- "00" => {"00" => "PWI"},
9
- "10" => {"00" => "PNW"},
10
- "20" => {"00" => "ANW", "98" => "CAN", "99" => "ACD"},
11
- "30" => {"00" => "CD", "20" => "CD", "92" => "BWG", "97" => "MERGED", "98" => "DREJ", "99" => "A2CD"},
12
- "35" => {"00" => "CD", "20" => "CD", "91" => "CDM", "92" => "ACD", "99" => "ACDV"},
13
- "40" => {"00" => "CCDV", "20" => "CCDV", "91" => "CDVM", "92" => "NCDV", "93" => "NADIS", "95" => "ADISSB", "99" => "ADIS"},
14
- "50" => {"00" => "RFDIS", "20" => "CFDIS", "92" => "NFDIS", "95" => "APUBSB", "99" => "APUB"},
15
- "60" => {"00" => "BPUB", "60" => "PPUB"},
16
- "90" => {"00" => "RR", "92" => "RR"},
17
- "92" => {"00" => "AMW", "20" => "AMW"},
18
- "95" => {"00" => "WPUB", "99" => "WPUB"},
19
- "99" => {"00" => "DELPUB", "60" => "DELPUB"},
20
- }.freeze
21
-
22
- def stage_abbr(stage)
23
- ret = STAGE_ABBRS.dig(stage, "00") || "??"
24
- ret = "PPUB" if stage == "60"
25
- ret
26
- end
27
-
28
- def status_abbrev1(stage, substage, iter, doctype, draft)
29
- return "" unless stage
30
- abbr = STAGE_ABBRS.dig(stage, substage) || "??"
31
- if stage == "35" && substage == "92"
32
- iter = (iter.to_i + 1) % "02"
33
- end
34
- case doctype
35
- when "technical-report"
36
- stage = "ADTR" if stage == "40" && substage == "99"
37
- stage = "CDTR" if stage == "50" && substage == "20"
38
- stage = "DTRM" if stage == "50" && substage == "92"
39
- when "technical-specification"
40
- stage = "ADTS" if stage == "40" && substage == "99"
41
- stage = "CDTS" if stage == "50" && substage == "20"
42
- stage = "DTSM" if stage == "50" && substage == "92"
43
- when "interpretation-sheet"
44
- stage = "RDISH" if stage == "50" && substage == "00"
45
- stage = "CDISH" if stage == "50" && substage == "20"
46
- when "publicly-available-specification"
47
- stage = "CDPAS" if stage == "50" && substage == "20"
48
- end
49
- abbr = abbr.sub(/CD$/, "#{iter}CD") if iter
50
- abbr
51
- end
52
-
53
7
  def docstatus(isoxml, _out)
54
8
  docstatus = isoxml.at(ns("//bibdata/status/stage"))
9
+ substage = isoxml.at(ns("//bibdata/status/substage"))
55
10
  set(:unpublished, false)
56
11
  if docstatus
57
12
  set(:stage, docstatus.text)
58
13
  set(:stage_int, docstatus.text.to_i)
59
14
  set(:unpublished, unpublished(docstatus.text))
60
- set(:statusabbr, status_abbrev1(docstatus.text,
61
- isoxml&.at(ns("//bibdata/status/substage"))&.text,
62
- isoxml&.at(ns("//bibdata/status/iteration"))&.text,
63
- isoxml&.at(ns("//bibdata/ext/doctype"))&.text,
64
- isoxml&.at(ns("//version/draft"))&.text))
15
+ set(:statusabbr, substage["abbreviation"])
65
16
  unpublished(docstatus.text) and
66
- set(:stageabbr, stage_abbr(docstatus.text))
17
+ set(:stageabbr, docstatus["abbreviation"])
67
18
  end
68
19
  revdate = isoxml.at(ns("//version/revision-date"))
69
20
  set(:revdate, revdate&.text)
@@ -1,6 +1,6 @@
1
1
  module Metanorma
2
2
  module Iec
3
- VERSION = "1.0.3"
3
+ VERSION = "1.0.4"
4
4
  end
5
5
  end
6
6
 
@@ -123,8 +123,8 @@ RSpec.describe Asciidoctor::Iec do
123
123
  <language>en</language>
124
124
  <script>Latn</script>
125
125
  <status>
126
- <stage>10</stage>
127
- <substage>20</substage>
126
+ <stage abbreviation="NWIP">10</stage>
127
+ <substage abbreviation="??">20</substage>
128
128
  <iteration>3</iteration>
129
129
  </status>
130
130
  <copyright>
@@ -159,6 +159,7 @@ RSpec.describe Asciidoctor::Iec do
159
159
  <structuredidentifier>
160
160
  <project-number part="1">IEC 1000</project-number>
161
161
  </structuredidentifier>
162
+ <stagename>New work item proposal</stagename>
162
163
  </ext>
163
164
  </bibdata>
164
165
  #{UNPUBLISHED_BOILERPLATE}
@@ -234,8 +235,8 @@ RSpec.describe Asciidoctor::Iec do
234
235
  <language>el</language>
235
236
  <script>Grek</script>
236
237
  <status>
237
- <stage>30</stage>
238
- <substage>99</substage>
238
+ <stage abbreviation="CD">30</stage>
239
+ <substage abbreviation="A22CD">99</substage>
239
240
  <iteration>2</iteration>
240
241
  </status>
241
242
  <copyright>
@@ -274,6 +275,7 @@ RSpec.describe Asciidoctor::Iec do
274
275
  <structuredidentifier>
275
276
  <project-number part="1" subpart="1">ISO/IEC/IETF 1000</project-number>
276
277
  </structuredidentifier>
278
+ <stagename>Committee draft</stagename>
277
279
  </ext>
278
280
  </bibdata>
279
281
  #{UNPUBLISHED_BOILERPLATE.sub(/IEC #{Date.today.year}/, "ISO/IEC/IETF 2001")}
@@ -355,8 +357,8 @@ RSpec.describe Asciidoctor::Iec do
355
357
  <language>en</language>
356
358
  <script>Latn</script>
357
359
  <status>
358
- <stage>50</stage>
359
- <substage>00</substage>
360
+ <stage abbreviation="FDIS">50</stage>
361
+ <substage abbreviation="RFDIS">00</substage>
360
362
  </status>
361
363
  <copyright>
362
364
  <from>#{Date.today.year}</from>
@@ -377,6 +379,7 @@ RSpec.describe Asciidoctor::Iec do
377
379
  <structuredidentifier>
378
380
  <project-number>IEC 1000</project-number>
379
381
  </structuredidentifier>
382
+ <stagename>Final draft international standard</stagename>
380
383
  </ext>
381
384
  </bibdata>
382
385
  #{UNPUBLISHED_BOILERPLATE}
@@ -418,8 +421,8 @@ OUTPUT
418
421
  <language>en</language>
419
422
  <script>Latn</script>
420
423
  <status>
421
- <stage>60</stage>
422
- <substage>60</substage>
424
+ <stage abbreviation="PPUB">60</stage>
425
+ <substage abbreviation="PPUB">60</substage>
423
426
  </status>
424
427
  <copyright>
425
428
  <from>#{Date.today.year}</from>
@@ -440,6 +443,7 @@ OUTPUT
440
443
  <structuredidentifier>
441
444
  <project-number>IEC 1000</project-number>
442
445
  </structuredidentifier>
446
+ <stagename>International standard</stagename>
443
447
  </ext>
444
448
  </bibdata>
445
449
  #{BOILERPLATE}
@@ -482,8 +486,8 @@ OUTPUT
482
486
  <language>en</language>
483
487
  <script>Latn</script>
484
488
  <status>
485
- <stage>60</stage>
486
- <substage>00</substage>
489
+ <stage abbreviation="PPUB">60</stage>
490
+ <substage abbreviation="BPUB">00</substage>
487
491
  </status>
488
492
  <copyright>
489
493
  <from>#{Date.today.year}</from>
@@ -504,6 +508,7 @@ OUTPUT
504
508
  <structuredidentifier>
505
509
  <project-number>IEC 1000</project-number>
506
510
  </structuredidentifier>
511
+ <stagename>International standard</stagename>
507
512
  </ext>
508
513
  </bibdata>
509
514
  #{BOILERPLATE}
@@ -352,7 +352,7 @@ RSpec.describe Asciidoctor::Iec do
352
352
  #{BLANK_HDR}
353
353
  <sections>
354
354
  <quote id="_">
355
- <source type="inline" bibitemid="ISO7301" citeas=""><locality type="section"><referenceFrom>1</referenceFrom></locality></source>
355
+ <source type="inline" bibitemid="ISO7301" citeas=""><localityStack><locality type="section"><referenceFrom>1</referenceFrom></locality></localityStack></source>
356
356
  <author>ISO</author>
357
357
  <p id="_">Block quotation</p>
358
358
  </quote>
@@ -429,7 +429,11 @@ RSpec.describe Asciidoctor::Iec do
429
429
  <term id="_">
430
430
  <preferred>Term1</preferred>
431
431
  <termsource status="identical">
432
- <origin bibitemid="ISO2191" type="inline" citeas=""><locality type="section"><referenceFrom>1</referenceFrom></locality></origin>
432
+ <origin bibitemid="ISO2191" type="inline" citeas="">
433
+ <localityStack>
434
+ <locality type="section"><referenceFrom>1</referenceFrom></locality>
435
+ </localityStack>
436
+ </origin>
433
437
  </termsource>
434
438
  </term>
435
439
  </terms>
@@ -457,7 +461,11 @@ RSpec.describe Asciidoctor::Iec do
457
461
  <term id="_">
458
462
  <preferred>Term1</preferred>
459
463
  <termsource status="modified">
460
- <origin bibitemid="ISO2191" type="inline" citeas=""><locality type="section"><referenceFrom>1</referenceFrom></locality></origin>
464
+ <origin bibitemid="ISO2191" type="inline" citeas="">
465
+ <localityStack>
466
+ <locality type="section"><referenceFrom>1</referenceFrom></locality>
467
+ </localityStack>
468
+ </origin>
461
469
  <modification>
462
470
  <p id="_">with adjustments</p>
463
471
  </modification>
@@ -163,7 +163,11 @@ RSpec.describe Asciidoctor::Iec do
163
163
  <term id="_">
164
164
  <preferred>Term1</preferred>
165
165
  <termsource status="identical">
166
- <origin bibitemid="ISO2191" type="inline" citeas=""><locality type="section"><referenceFrom>1</referenceFrom></locality></origin>
166
+ <origin bibitemid="ISO2191" type="inline" citeas="">
167
+ <localityStack>
168
+ <locality type="section"><referenceFrom>1</referenceFrom></locality>
169
+ </localityStack>
170
+ </origin>
167
171
  </termsource>
168
172
  </term>
169
173
  </terms>
@@ -0,0 +1,161 @@
1
+ require "spec_helper"
2
+ require "fileutils"
3
+
4
+ RSpec.describe Asciidoctor::Iec do
5
+ it "generates reference boilerplate for IEV" do
6
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
7
+ = Document title
8
+ Author
9
+ :docfile: test.adoc
10
+ :nodoc:
11
+ :novalid:
12
+ :no-isobib:
13
+ :docnumber: 60050
14
+
15
+ [bibliography]
16
+ == Normative References
17
+
18
+ * [[[A,B]]], _TITLE_
19
+ INPUT
20
+ <?xml version='1.0' encoding='UTF-8'?>
21
+ <iec-standard xmlns='https://www.metanorma.org/ns/iec'>
22
+ <bibdata type='standard'>
23
+ <docidentifier type='iso'>IEC 60050 ED 1</docidentifier>
24
+ <docnumber>60050</docnumber>
25
+ <contributor>
26
+ <role type='author'/>
27
+ <organization>
28
+ <name>International Electrotechnical Commission</name>
29
+ <abbreviation>IEC</abbreviation>
30
+ </organization>
31
+ </contributor>
32
+ <contributor>
33
+ <role type='publisher'/>
34
+ <organization>
35
+ <name>International Electrotechnical Commission</name>
36
+ <abbreviation>IEC</abbreviation>
37
+ </organization>
38
+ </contributor>
39
+ <language>en</language>
40
+ <script>Latn</script>
41
+ <status>
42
+ <stage abbreviation="PPUB">60</stage>
43
+ <substage abbreviation="PPUB">60</substage>
44
+ </status>
45
+ <copyright>
46
+ <from>2020</from>
47
+ <owner>
48
+ <organization>
49
+ <name>International Electrotechnical Commission</name>
50
+ <abbreviation>IEC</abbreviation>
51
+ </organization>
52
+ </owner>
53
+ </copyright>
54
+ <ext>
55
+ <doctype>article</doctype>
56
+ <editorialgroup>
57
+ <technical-committee/>
58
+ <subcommittee/>
59
+ <workgroup/>
60
+ </editorialgroup>
61
+ <structuredidentifier>
62
+ <project-number>IEC 60050</project-number>
63
+ </structuredidentifier>
64
+ <stagename>International standard</stagename>
65
+ </ext>
66
+ </bibdata>
67
+ #{BOILERPLATE}
68
+ <sections> </sections>
69
+ <bibliography>
70
+ <references id='_' obligation='informative'>
71
+ <title>Normative References</title>
72
+ <p id='_'>There are no normative references in this document.</p>
73
+ <bibitem id='A'>
74
+ <formattedref format='application/x-isodoc+xml'>
75
+ <em>TITLE</em>
76
+ </formattedref>
77
+ <docidentifier>B</docidentifier>
78
+ </bibitem>
79
+ </references>
80
+ </bibliography>
81
+ </iec-standard>
82
+ OUTPUT
83
+ end
84
+
85
+ it "generates terms boilerplate for IEV" do
86
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
87
+ = Document title
88
+ Author
89
+ :docfile: test.adoc
90
+ :nodoc:
91
+ :novalid:
92
+ :no-isobib:
93
+ :docnumber: 60050
94
+
95
+ == Terms and definitions
96
+ === General
97
+ ==== Term 1
98
+ INPUT
99
+ <iec-standard xmlns='https://www.metanorma.org/ns/iec'>
100
+ <bibdata type='standard'>
101
+ <docidentifier type='iso'>IEC 60050 ED 1</docidentifier>
102
+ <docnumber>60050</docnumber>
103
+ <contributor>
104
+ <role type='author'/>
105
+ <organization>
106
+ <name>International Electrotechnical Commission</name>
107
+ <abbreviation>IEC</abbreviation>
108
+ </organization>
109
+ </contributor>
110
+ <contributor>
111
+ <role type='publisher'/>
112
+ <organization>
113
+ <name>International Electrotechnical Commission</name>
114
+ <abbreviation>IEC</abbreviation>
115
+ </organization>
116
+ </contributor>
117
+ <language>en</language>
118
+ <script>Latn</script>
119
+ <status>
120
+ <stage abbreviation="PPUB">60</stage>
121
+ <substage abbreviation="PPUB">60</substage>
122
+ </status>
123
+ <copyright>
124
+ <from>2020</from>
125
+ <owner>
126
+ <organization>
127
+ <name>International Electrotechnical Commission</name>
128
+ <abbreviation>IEC</abbreviation>
129
+ </organization>
130
+ </owner>
131
+ </copyright>
132
+ <ext>
133
+ <doctype>article</doctype>
134
+ <editorialgroup>
135
+ <technical-committee/>
136
+ <subcommittee/>
137
+ <workgroup/>
138
+ </editorialgroup>
139
+ <structuredidentifier>
140
+ <project-number>IEC 60050</project-number>
141
+ </structuredidentifier>
142
+ <stagename>International standard</stagename>
143
+ </ext>
144
+ </bibdata>
145
+ #{BOILERPLATE}
146
+ <sections>
147
+ <clause id='_' obligation='normative'>
148
+ <title>Terms and definitions</title>
149
+ <terms id='_' obligation='normative'>
150
+ <title>General</title>
151
+ <term id='_'>
152
+ <preferred>Term 1</preferred>
153
+ </term>
154
+ </terms>
155
+ </clause>
156
+ </sections>
157
+ </iec-standard>
158
+
159
+ OUTPUT
160
+ end
161
+ end