metanorma-iso 1.3.24 → 1.3.25

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.
@@ -16,8 +16,12 @@ module IsoDoc
16
16
  }
17
17
  end
18
18
 
19
- def status_abbrev(stage, substage, iter, draft)
19
+ def status_abbrev(stage, substage, iter, draft, doctype)
20
20
  return "" unless stage
21
+ if %w(technical-report technical-specification).include?(doctype)
22
+ stage = "DTS" if stage == "DIS"
23
+ stage = "FDTS" if stage == "FDIS"
24
+ end
21
25
  stage += iter if iter
22
26
  stage = "Pre" + stage if draft =~ /^0\./
23
27
  stage
@@ -33,7 +37,8 @@ module IsoDoc
33
37
  set(:statusabbr, status_abbrev(docstatus["abbreviation"] || "??",
34
38
  isoxml&.at(ns("//bibdata/status/substage"))&.text,
35
39
  isoxml&.at(ns("//bibdata/status/iteration"))&.text,
36
- isoxml&.at(ns("//version/draft"))&.text))
40
+ isoxml&.at(ns("//version/draft"))&.text,
41
+ isoxml&.at(ns("//bibdata/ext/doctype"))&.text))
37
42
  unpublished(docstatus.text) and
38
43
  set(:stageabbr, docstatus["abbreviation"])
39
44
  end
@@ -65,6 +70,20 @@ module IsoDoc
65
70
  end
66
71
  end
67
72
 
73
+ def amd_label(lang)
74
+ case lang
75
+ when "en" then "AMENDMENT"
76
+ when "fr" then "AMENDMENT"
77
+ end
78
+ end
79
+
80
+ def corr_label(lang)
81
+ case lang
82
+ when "en" then "TECHNICAL CORRIGENDUM"
83
+ when "fr" then "RECTIFICATIF TECHNIQUE"
84
+ end
85
+ end
86
+
68
87
  def part_title(part, partnum, subpartnum, lang)
69
88
  return "" unless part
70
89
  suffix = @c.encode(part.text, :hexadecimal)
@@ -78,6 +97,14 @@ module IsoDoc
78
97
  "#{part_label(lang)} #{partnum}"
79
98
  end
80
99
 
100
+ def amd_prefix(num, lang)
101
+ "#{amd_label(lang)} #{num}"
102
+ end
103
+
104
+ def corr_prefix(num, lang)
105
+ "#{corr_label(lang)} #{num}"
106
+ end
107
+
81
108
  def compose_title(main, intro, part, partnum, subpartnum, lang)
82
109
  main = main.nil? ? "" : @c.encode(main.text, :hexadecimal)
83
110
  intro &&
@@ -95,6 +122,9 @@ module IsoDoc
95
122
  part = isoxml.at(ns("//bibdata//title[@type='title-part' and @language='en']"))
96
123
  partnumber = isoxml.at(ns("//bibdata//project-number/@part"))
97
124
  subpartnumber = isoxml.at(ns("//bibdata//project-number/@subpart"))
125
+ amdnumber = isoxml.at(ns("//bibdata//project-number/@amendment"))
126
+ corrnumber = isoxml.at(ns("//bibdata//project-number/@corrigendum"))
127
+ amd = isoxml.at(ns("//bibdata//title[@type='title-amd' and @language='en']"))
98
128
 
99
129
  set(:doctitlemain, @c.encode(main ? main.text : "", :hexadecimal))
100
130
  main = compose_title(main, intro, part, partnumber, subpartnumber, "en")
@@ -102,6 +132,9 @@ module IsoDoc
102
132
  set(:doctitleintro, @c.encode(intro ? intro.text : "", :hexadecimal)) if intro
103
133
  set(:doctitlepartlabel, part_prefix(partnumber, subpartnumber, "en"))
104
134
  set(:doctitlepart, @c.encode(part.text, :hexadecimal)) if part
135
+ set(:doctitleamdlabel, amd_prefix(amdnumber, "en")) if amdnumber
136
+ set(:doctitleamd, @c.encode(amd.text, :hexadecimal)) if amd
137
+ set(:doctitlecorrlabel, corr_prefix(corrnumber, "en")) if corrnumber
105
138
  end
106
139
 
107
140
  def subtitle(isoxml, _out)
@@ -110,12 +143,19 @@ module IsoDoc
110
143
  part = isoxml.at(ns("//bibdata//title[@type='title-part' and @language='fr']"))
111
144
  partnumber = isoxml.at(ns("//bibdata//project-number/@part"))
112
145
  subpartnumber = isoxml.at(ns("//bibdata//project-number/@subpart"))
146
+ amdnumber = isoxml.at(ns("//bibdata//project-number/@amendment"))
147
+ corrnumber = isoxml.at(ns("//bibdata//project-number/@corrigendum"))
148
+ amd = isoxml.at(ns("//bibdata//title[@type='title-amd' and @language='fr']"))
149
+
113
150
  set(:docsubtitlemain, @c.encode(main ? main.text : "", :hexadecimal))
114
151
  main = compose_title(main, intro, part, partnumber, subpartnumber, "fr")
115
152
  set(:docsubtitle, main)
116
153
  set(:docsubtitleintro, @c.encode(intro ? intro.text : "", :hexadecimal)) if intro
117
154
  set(:docsubtitlepartlabel, part_prefix(partnumber, subpartnumber, "fr"))
118
155
  set(:docsubtitlepart, @c.encode(part.text, :hexadecimal)) if part
156
+ set(:docsubtitleamdlabel, amd_prefix(amdnumber, "fr")) if amdnumber
157
+ set(:docsubtitleamd, @c.encode(amd.text, :hexadecimal)) if amd
158
+ set(:docsubtitlecorrlabel, corr_prefix(corrnumber, "fr")) if corrnumber
119
159
  end
120
160
 
121
161
  def author(xml, _out)
@@ -3,7 +3,12 @@ require "metanorma/processor"
3
3
  module Metanorma
4
4
  module Iso
5
5
  def self.fonts_used
6
- ["Cambria", "Times New Roman", "Cambria Math", "HanSans", "Courier New"]
6
+ {
7
+ html: ["Cambria", "Times New Roman", "Cambria Math", "HanSans", "Courier New"],
8
+ html_alt: ["Cambria", "Times New Roman", "Cambria Math", "HanSans", "Courier New"],
9
+ doc: ["Cambria", "Times New Roman", "Cambria Math", "HanSans", "Courier New"],
10
+ pdf: ["Cambria", "Times New Roman", "Cambria Math", "HanSans", "Courier New"],
11
+ }
7
12
  end
8
13
 
9
14
  class Processor < Metanorma::Processor
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module ISO
3
- VERSION = "1.3.24".freeze
3
+ VERSION = "1.3.25".freeze
4
4
  end
5
5
  end
@@ -0,0 +1,318 @@
1
+ require "spec_helper"
2
+ require "fileutils"
3
+
4
+ RSpec.describe Asciidoctor::ISO do
5
+ it "validates amendment document against distinct ISO XML schema" do
6
+ FileUtils.rm_f "test.err"
7
+ Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)
8
+ = Document title
9
+ Author
10
+ :docfile: test.adoc
11
+ :nodoc:
12
+ :no-isobib:
13
+ :doctype: amendment
14
+
15
+ [change=mid-air]
16
+ == Para
17
+ INPUT
18
+ expect(File.read("test.err")).to include 'value of attribute "change" is invalid; must be equal to'
19
+ end
20
+
21
+ it "processes amendment sections" do
22
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
23
+ #{AMD_BLANK_HDR}
24
+ == Foreword
25
+
26
+ Text
27
+
28
+ == Introduction
29
+
30
+ === Introduction Subsection
31
+
32
+ == Scope
33
+
34
+ Text
35
+
36
+ == Acknowledgements
37
+
38
+ == Normative References
39
+
40
+ == Terms and Definitions
41
+
42
+ === Term1
43
+
44
+ == Terms, Definitions, Symbols and Abbreviated Terms
45
+
46
+ === Normal Terms
47
+
48
+ ==== Term2
49
+
50
+ === Symbols and Abbreviated Terms
51
+
52
+ == Symbols and Abbreviated Terms
53
+
54
+ == Clause 4
55
+
56
+ === Introduction
57
+
58
+ === Clause 4.2
59
+
60
+ == Terms and Definitions
61
+
62
+ [appendix]
63
+ == Annex
64
+
65
+ === Annex A.1
66
+
67
+ [%appendix]
68
+ === Appendix 1
69
+
70
+ == Bibliography
71
+
72
+ === Bibliography Subsection
73
+ INPUT
74
+ #{BLANK_HDR.sub(%r{<doctype>article</doctype>}, "<doctype>amendment</doctype>")}
75
+ <sections>
76
+ <clause id='_' obligation='normative'>
77
+ <title>Foreword</title>
78
+ <p id='_'>Text</p>
79
+ </clause>
80
+ <clause id='_' obligation='normative'>
81
+ <title>Introduction</title>
82
+ <clause id='_' obligation='normative'>
83
+ <title>Introduction Subsection</title>
84
+ </clause>
85
+ </clause>
86
+ <clause id='_' obligation='normative'>
87
+ <title>Scope</title>
88
+ <p id='_'>Text</p>
89
+ </clause>
90
+ <clause id='_' obligation='normative'>
91
+ <title>Acknowledgements</title>
92
+ </clause>
93
+ <clause id='_' obligation='normative'>
94
+ <title>Normative References</title>
95
+ </clause>
96
+ <clause id='_' obligation='normative'>
97
+ <title>Terms and Definitions</title>
98
+ <clause id='_' obligation='normative'>
99
+ <title>Term1</title>
100
+ </clause>
101
+ </clause>
102
+ <clause id='_' obligation='normative'>
103
+ <title>Terms, Definitions, Symbols and Abbreviated Terms</title>
104
+ <clause id='_' obligation='normative'>
105
+ <title>Normal Terms</title>
106
+ <clause id='_' obligation='normative'>
107
+ <title>Term2</title>
108
+ </clause>
109
+ </clause>
110
+ <clause id='_' obligation='normative'>
111
+ <title>Symbols and Abbreviated Terms</title>
112
+ </clause>
113
+ </clause>
114
+ <clause id='_' obligation='normative'>
115
+ <title>Symbols and Abbreviated Terms</title>
116
+ </clause>
117
+ <clause id='_' obligation='normative'>
118
+ <title>Clause 4</title>
119
+ <clause id='_' obligation='normative'>
120
+ <title>Introduction</title>
121
+ </clause>
122
+ <clause id='_' obligation='normative'>
123
+ <title>Clause 4.2</title>
124
+ </clause>
125
+ </clause>
126
+ <clause id='_' obligation='normative'>
127
+ <title>Terms and Definitions</title>
128
+ </clause>
129
+ <clause id='_' obligation='normative'>
130
+ <title>Bibliography</title>
131
+ <clause id='_' obligation='normative'>
132
+ <title>Bibliography Subsection</title>
133
+ </clause>
134
+ </clause>
135
+ </sections>
136
+ <annex id='_' obligation='normative'>
137
+ <title>Annex</title>
138
+ <clause id='_' obligation='normative'>
139
+ <title>Annex A.1</title>
140
+ </clause>
141
+ <appendix id='_' obligation='normative'>
142
+ <title>Appendix 1</title>
143
+ </appendix>
144
+ </annex>
145
+ </iso-standard>
146
+
147
+ OUTPUT
148
+ end
149
+
150
+ it "processes section attributes" do
151
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
152
+ #{AMD_BLANK_HDR}
153
+ [change=delete,locality="clause=introduction,paragraph=4-7",inline-header="true"]
154
+ == Clause 1
155
+
156
+ INPUT
157
+ #{BLANK_HDR.sub(%r{<doctype>article</doctype>}, "<doctype>amendment</doctype>")}
158
+ <sections><clause id="_" obligation="normative" change="delete" locality="clause=introduction,paragraph=4-7">
159
+ <title>Clause 1</title>
160
+ </clause>
161
+ </sections>
162
+ </iso-standard>
163
+ OUTPUT
164
+ end
165
+
166
+ it "processes default metadata, amendment" do
167
+ expect(xmlpp(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true).sub(%r{<boilerplate>.*</boilerplate>}m, ""))).to be_equivalent_to xmlpp(<<~"OUTPUT")
168
+ = Document title
169
+ Author
170
+ :docfile: test.adoc
171
+ :nodoc:
172
+ :novalid:
173
+ :no-isobib:
174
+ :docnumber: 17301
175
+ :partnumber: 1
176
+ :edition: 2
177
+ :revdate: 2000-01-01
178
+ :draft: 0.3.4
179
+ :technical-committee: TC
180
+ :technical-committee-number: 1
181
+ :technical-committee-type: A
182
+ :subcommittee: SC
183
+ :subcommittee-number: 2
184
+ :subcommittee-type: B
185
+ :workgroup: WG
186
+ :workgroup-number: 3
187
+ :workgroup-type: C
188
+ :technical-committee_2: TC1
189
+ :technical-committee-number_2: 11
190
+ :technical-committee-type_2: A1
191
+ :subcommittee_2: SC1
192
+ :subcommittee-number_2: 21
193
+ :subcommittee-type_2: B1
194
+ :workgroup_2: WG1
195
+ :workgroup-number_2: 31
196
+ :workgroup-type_2: C1
197
+ :secretariat: SECRETARIAT
198
+ :docstage: 10
199
+ :docsubstage: 20
200
+ :iteration: 3
201
+ :language: en
202
+ :title-intro-en: Introduction
203
+ :title-main-en: Main Title -- Title
204
+ :title-part-en: Title Part
205
+ :title-intro-fr: Introduction Française
206
+ :title-main-fr: Titre Principal
207
+ :title-part-fr: Part du Titre
208
+ :library-ics: 1,2,3
209
+ :copyright-year: 2017
210
+ :updates: ISO 17301-1:2016
211
+ :created-date: 2016-05-01
212
+ :amendment-number: 1
213
+ :title-amendment-en: Mass fraction of extraneous matter, milled rice (nonglutinous), sample dividers and recommendations relating to storage and transport conditions
214
+ :title-amendment-fr: Fraction massique de matière étrangère, riz usiné (non gluant), diviseurs d’échantillon et recommandations relatives aux conditions d’entreposage et de transport
215
+ :doctype: amendment
216
+ :updates-document-type: international-standard
217
+ INPUT
218
+ <iso-standard xmlns='https://www.metanorma.org/ns/iso'>
219
+ <bibdata type='standard'>
220
+ <title language='en' format='text/plain' type='main'>Introduction — Main Title — Title — Title Part — Mass fraction of
221
+ extraneous matter, milled rice (nonglutinous), sample dividers and
222
+ recommendations relating to storage and transport conditions</title>
223
+ <title language='en' format='text/plain' type='title-intro'>Introduction</title>
224
+ <title language='en' format='text/plain' type='title-main'>Main Title — Title</title>
225
+ <title language='en' format='text/plain' type='title-part'>Title Part</title>
226
+ <title language='en' format='text/plain' type='title-amd'>
227
+ Mass fraction of extraneous matter, milled rice (nonglutinous), sample
228
+ dividers and recommendations relating to storage and transport conditions
229
+ </title>
230
+ <title language='fr' format='text/plain' type='main'>
231
+ Introduction Française — Titre Principal — Part du Titre — Fraction
232
+ massique de matière étrangère, riz usiné (non gluant), diviseurs
233
+ d’échantillon et recommandations relatives aux conditions d’entreposage et
234
+ de transport
235
+ </title>
236
+ <title language='fr' format='text/plain' type='title-intro'>Introduction Française</title>
237
+ <title language='fr' format='text/plain' type='title-main'>Titre Principal</title>
238
+ <title language='fr' format='text/plain' type='title-part'>Part du Titre</title>
239
+ <title language='fr' format='text/plain' type='title-amd'>
240
+ Fraction massique de matière étrangère, riz usiné (non gluant), diviseurs
241
+ d’échantillon et recommandations relatives aux conditions d’entreposage et
242
+ de transport
243
+ </title>
244
+ <docidentifier type='iso'>ISO/PreNWIP3 17301-1:2016/Amd.1</docidentifier>
245
+ <docidentifier type='iso-with-lang'>ISO/PreNWIP3 17301-1:2016/Amd.1(E)</docidentifier>
246
+ <docidentifier type='iso-reference'>ISO/PreNWIP3 17301-1:2016/Amd.1:2017(E)</docidentifier>
247
+ <docnumber>17301</docnumber>
248
+ <date type='created'>
249
+ <on>2016-05-01</on>
250
+ </date>
251
+ <contributor>
252
+ <role type='author'/>
253
+ <organization>
254
+ <name>International Organization for Standardization</name>
255
+ <abbreviation>ISO</abbreviation>
256
+ </organization>
257
+ </contributor>
258
+ <contributor>
259
+ <role type='publisher'/>
260
+ <organization>
261
+ <name>International Organization for Standardization</name>
262
+ <abbreviation>ISO</abbreviation>
263
+ </organization>
264
+ </contributor>
265
+ <edition>2</edition>
266
+ <version>
267
+ <revision-date>2000-01-01</revision-date>
268
+ <draft>0.3.4</draft>
269
+ </version>
270
+ <language>en</language>
271
+ <script>Latn</script>
272
+ <status>
273
+ <stage abbreviation='NWIP'>10</stage>
274
+ <substage>20</substage>
275
+ <iteration>3</iteration>
276
+ </status>
277
+ <copyright>
278
+ <from>2017</from>
279
+ <owner>
280
+ <organization>
281
+ <name>International Organization for Standardization</name>
282
+ <abbreviation>ISO</abbreviation>
283
+ </organization>
284
+ </owner>
285
+ </copyright>
286
+ <ext>
287
+ <doctype>amendment</doctype>
288
+ <editorialgroup>
289
+ <technical-committee number='1' type='A'>TC</technical-committee>
290
+ <technical-committee number='11' type='A1'>TC1</technical-committee>
291
+ <subcommittee number='2' type='B'>SC</subcommittee>
292
+ <subcommittee number='21' type='B1'>SC1</subcommittee>
293
+ <workgroup number='3' type='C'>WG</workgroup>
294
+ <workgroup number='31' type='C1'>WG1</workgroup>
295
+ <secretariat>SECRETARIAT</secretariat>
296
+ </editorialgroup>
297
+ <ics>
298
+ <code>1</code>
299
+ </ics>
300
+ <ics>
301
+ <code>2</code>
302
+ </ics>
303
+ <ics>
304
+ <code>3</code>
305
+ </ics>
306
+ <structuredidentifier>
307
+ <project-number part='1' amendment='1' origyr='2016-05-01'>17301</project-number>
308
+ </structuredidentifier>
309
+ <stagename>New work item proposal</stagename>
310
+ <updates-document-type>international-standard</updates-document-type>
311
+ </ext>
312
+ </bibdata>
313
+ <sections/>
314
+ </iso-standard>
315
+ OUTPUT
316
+ end
317
+
318
+ end
@@ -187,13 +187,14 @@ RSpec.describe Asciidoctor::ISO do
187
187
  :script: Grek
188
188
  :publisher: IEC,IETF,ISO
189
189
  :copyright-year: 2001
190
+ :doctype: technical-report
190
191
  INPUT
191
192
  <?xml version="1.0" encoding="UTF-8"?>
192
193
  <iso-standard xmlns="https://www.metanorma.org/ns/iso">
193
194
  <bibdata type="standard">
194
- <docidentifier type="iso">ISO/IEC/IETF 1000-1-1:2001</docidentifier>
195
- <docidentifier type='iso-with-lang'>ISO/IEC/IETF 1000-1-1:2001(X)</docidentifier>
196
- <docidentifier type='iso-reference'>ISO/IEC/IETF 1000-1-1:2001(X)</docidentifier>
195
+ <docidentifier type="iso">ISO/IEC/IETF/TR 1000-1-1:2001</docidentifier>
196
+ <docidentifier type='iso-with-lang'>ISO/IEC/IETF/TR 1000-1-1:2001(X)</docidentifier>
197
+ <docidentifier type='iso-reference'>ISO/IEC/IETF/TR 1000-1-1:2001(X)</docidentifier>
197
198
  <docidentifier type="iso-tc">2000</docidentifier>
198
199
  <docidentifier type="iso-tc">2003</docidentifier>
199
200
  <docnumber>1000</docnumber>
@@ -270,7 +271,7 @@ RSpec.describe Asciidoctor::ISO do
270
271
  </owner>
271
272
  </copyright>
272
273
  <ext>
273
- <doctype>article</doctype>
274
+ <doctype>technical-report</doctype>
274
275
  <editorialgroup>
275
276
  <technical-committee/>
276
277
  <subcommittee/>
@@ -298,12 +299,13 @@ RSpec.describe Asciidoctor::ISO do
298
299
  :docnumber: 1000
299
300
  :docstage: 50
300
301
  :language: fr
302
+ :doctype: technical-specification
301
303
  INPUT
302
304
  <iso-standard xmlns="https://www.metanorma.org/ns/iso">
303
305
  <bibdata type="standard">
304
- <docidentifier type="iso">ISO/FDIS 1000</docidentifier>
305
- <docidentifier type='iso-with-lang'>ISO/FDIS 1000(F)</docidentifier>
306
- <docidentifier type='iso-reference'>ISO/FDIS 1000(F)</docidentifier>
306
+ <docidentifier type="iso">ISO/FDTS TS 1000</docidentifier>
307
+ <docidentifier type='iso-with-lang'>ISO/FDTS TS 1000(F)</docidentifier>
308
+ <docidentifier type='iso-reference'>ISO/FDTS TS 1000(F)</docidentifier>
307
309
  <docnumber>1000</docnumber>
308
310
  <contributor>
309
311
  <role type="author"/>
@@ -323,7 +325,7 @@ RSpec.describe Asciidoctor::ISO do
323
325
  <language>fr</language>
324
326
  <script>Latn</script>
325
327
  <status>
326
- <stage abbreviation="FDIS">50</stage>
328
+ <stage abbreviation="FDTS">50</stage>
327
329
  <substage>00</substage>
328
330
  </status>
329
331
  <copyright>
@@ -336,7 +338,7 @@ RSpec.describe Asciidoctor::ISO do
336
338
  </owner>
337
339
  </copyright>
338
340
  <ext>
339
- <doctype>article</doctype>
341
+ <doctype>technical-specification</doctype>
340
342
  <editorialgroup>
341
343
  <technical-committee/>
342
344
  <subcommittee/>
@@ -345,7 +347,7 @@ RSpec.describe Asciidoctor::ISO do
345
347
  <structuredidentifier>
346
348
  <project-number>ISO 1000</project-number>
347
349
  </structuredidentifier>
348
- <stagename>Final draft international standard</stagename>
350
+ <stagename>Final draft technical standard</stagename>
349
351
  </ext>
350
352
  </bibdata>
351
353
  <sections/>