metanorma-iec 1.4.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +4 -32
  3. data/.gitignore +14 -0
  4. data/Gemfile +6 -0
  5. data/Rakefile +1 -1
  6. data/lib/isodoc/iec/base_convert.rb +25 -59
  7. data/lib/isodoc/iec/html/htmlstyle.css +38 -6
  8. data/lib/isodoc/iec/html/htmlstyle.scss +35 -6
  9. data/lib/isodoc/iec/html/isodoc.css +1 -2
  10. data/lib/isodoc/iec/html/isodoc.scss +1 -2
  11. data/lib/isodoc/iec/html/scripts.html +0 -1
  12. data/lib/isodoc/iec/html/wordstyle.css +13 -11
  13. data/lib/isodoc/iec/html/wordstyle.scss +13 -11
  14. data/lib/isodoc/iec/html_convert.rb +2 -1
  15. data/lib/isodoc/iec/iec.international-standard.xsl +724 -330
  16. data/lib/isodoc/iec/presentation_xml_convert.rb +193 -5
  17. data/lib/isodoc/iec/xref.rb +9 -8
  18. data/lib/{asciidoctor → metanorma}/iec/basicdoc.rng +0 -0
  19. data/lib/{asciidoctor → metanorma}/iec/biblio.rng +0 -0
  20. data/lib/metanorma/iec/converter.rb +143 -0
  21. data/lib/{asciidoctor → metanorma}/iec/front.rb +3 -4
  22. data/lib/{asciidoctor → metanorma}/iec/iec.rng +48 -0
  23. data/lib/{asciidoctor → metanorma}/iec/iec_intro_en.xml +0 -0
  24. data/lib/{asciidoctor → metanorma}/iec/iec_intro_fr.xml +0 -0
  25. data/lib/{asciidoctor → metanorma}/iec/isodoc.rng +90 -18
  26. data/lib/{asciidoctor → metanorma}/iec/isostandard.rng +14 -0
  27. data/lib/metanorma/iec/processor.rb +15 -8
  28. data/lib/{asciidoctor → metanorma}/iec/reqt.rng +0 -0
  29. data/lib/metanorma/iec/version.rb +1 -1
  30. data/lib/metanorma-iec.rb +1 -1
  31. data/metanorma-iec.gemspec +3 -3
  32. data/spec/isodoc/iev_spec.rb +462 -120
  33. data/spec/isodoc/postproc_spec.rb +2 -5
  34. data/spec/isodoc/ref_spec.rb +359 -353
  35. data/spec/isodoc/terms_spec.rb +183 -181
  36. data/spec/{asciidoctor → metanorma}/base_spec.rb +1 -5
  37. data/spec/{asciidoctor → metanorma}/blocks_spec.rb +1 -1
  38. data/spec/metanorma/cleanup_spec.rb +374 -0
  39. data/spec/metanorma/iev_spec.rb +248 -0
  40. data/spec/{asciidoctor → metanorma}/inline_spec.rb +1 -1
  41. data/spec/{asciidoctor → metanorma}/lists_spec.rb +1 -1
  42. data/spec/metanorma/processor_spec.rb +139 -44
  43. data/spec/{asciidoctor → metanorma}/section_spec.rb +1 -1
  44. data/spec/{asciidoctor → metanorma}/validate_spec.rb +1 -1
  45. data/spec/spec_helper.rb +12 -14
  46. metadata +26 -26
  47. data/lib/asciidoctor/iec/converter.rb +0 -105
  48. data/spec/asciidoctor/cleanup_spec.rb +0 -345
  49. data/spec/asciidoctor/iev_spec.rb +0 -243
@@ -1,345 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe Asciidoctor::Iec do
4
- before(:all) do
5
- @blank_hdr = blank_hdr_gen
6
- end
7
-
8
- it "moves note from TC/SC officers to metadata" do
9
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
10
- #{ASCIIDOC_BLANK_HDR}
11
- == {blank}
12
-
13
- [NOTE]
14
- .Note from TC/SC Officers
15
- ====
16
- This FDIS is the result of the discussion between the IEC SC21A experts WG 3 during the meeting held in
17
- Chicago (USA) on April 9th
18
-
19
- This document is also of interest for ISO/ TC114/ WG1 Requirements for Watch batteries
20
- ====
21
- INPUT
22
- <iec-standard xmlns="https://www.metanorma.org/ns/iec" type="semantic" version="#{Metanorma::Iec::VERSION}">
23
- <bibdata type="standard">
24
- <contributor>
25
- <role type="author"/>
26
- <organization>
27
- <name>International Electrotechnical Commission</name>
28
- <abbreviation>IEC</abbreviation>
29
- </organization>
30
- </contributor>
31
- <contributor>
32
- <role type="publisher"/>
33
- <organization>
34
- <name>International Electrotechnical Commission</name>
35
- <abbreviation>IEC</abbreviation>
36
- </organization>
37
- </contributor>
38
- <language>en</language>
39
- <script>Latn</script>
40
- <status>
41
- <stage abbreviation="PPUB">60</stage>
42
- <substage abbreviation="PPUB">60</substage>
43
- </status>
44
- <copyright>
45
- <from>#{Time.new.year}</from>
46
- <owner>
47
- <organization>
48
- <name>International Electrotechnical Commission</name>
49
- <abbreviation>IEC</abbreviation>
50
- </organization>
51
- </owner>
52
- </copyright>
53
- <ext>
54
- <doctype>article</doctype>
55
- <horizontal>false</horizontal>
56
- <editorialgroup>
57
- <technical-committee/>
58
- <subcommittee/>
59
- <workgroup/>
60
- </editorialgroup>
61
- <stagename>International standard</stagename>
62
- <tc-sc-officers-note>
63
- <p id='_'>
64
- This FDIS is the result of the discussion between the IEC SC21A
65
- experts WG 3 during the meeting held in Chicago (USA) on April 9th
66
- </p>
67
- <p id='_'>
68
- This document is also of interest for ISO/ TC114/ WG1 Requirements for
69
- Watch batteries
70
- </p>
71
- </tc-sc-officers-note>
72
- </ext>
73
- </bibdata>
74
- #{boilerplate(Nokogiri::XML(BLANK_HDR + "</iec-standard>"))}
75
- <sections>
76
- <clause id="_" inline-header="false" obligation="normative">
77
-
78
- </clause>
79
- </sections>
80
- </iec-standard>
81
- OUTPUT
82
- end
83
-
84
- it "removes empty text elements" do
85
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
86
- #{ASCIIDOC_BLANK_HDR}
87
- == {blank}
88
- INPUT
89
- #{@blank_hdr}
90
- <sections>
91
- <clause id="_" inline-header="false" obligation="normative">
92
-
93
- </clause>
94
- </sections>
95
- </iec-standard>
96
- OUTPUT
97
- end
98
-
99
- it "keeps any initial boilerplate from terms and definitions" do
100
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
101
- #{ASCIIDOC_BLANK_HDR}
102
- == Terms and Definitions
103
-
104
- I am boilerplate
105
-
106
- * So am I
107
-
108
- === Time
109
-
110
- This paragraph is extraneous
111
- INPUT
112
- #{@blank_hdr}
113
- <sections>
114
- <terms id="_" obligation="normative"><title>Terms and definitions</title>
115
- <p id="_">For the purposes of this document,
116
- the following terms and definitions apply.</p>
117
- #{TERMS_BOILERPLATE}
118
- <p id='_'>I am boilerplate</p>
119
- <ul id='_'>
120
- <li>
121
- <p id='_'>So am I</p>
122
- </li>
123
- </ul>
124
- <term id="term-time">
125
- <preferred><expression><name>Time</name></expression></preferred>
126
- <definition><verbaldefinition><p id="_">This paragraph is extraneous</p></verbaldefinition></definition>
127
- </term></terms>
128
- </sections>
129
- </iec-standard>
130
- OUTPUT
131
- end
132
-
133
- it "strips type from xrefs" do
134
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
135
- #{ASCIIDOC_BLANK_HDR}
136
- <<iso216>>
137
-
138
- [bibliography]
139
- == Clause
140
- * [[[iso216,ISO 216]]], _Reference_
141
- INPUT
142
- #{@blank_hdr}
143
- <preface>
144
- <foreword id="_" obligation="informative">
145
- <title>FOREWORD</title>
146
- <p id="_">
147
- <eref type="inline" bibitemid="iso216" citeas="ISO 216"/>
148
- </p>
149
- </foreword></preface><sections>
150
- </sections><bibliography><references id="_" obligation="informative" normative="false">
151
- <title>Bibliography</title>
152
- <bibitem id="iso216" type="standard">
153
- <title format="text/plain">Reference</title>
154
- <docidentifier>ISO 216</docidentifier>
155
- <docnumber>216</docnumber>
156
- <contributor>
157
- <role type="publisher"/>
158
- <organization>
159
- <name>International Organization for Standardization</name>
160
- <abbreviation>ISO</abbreviation>
161
- </organization>
162
- </contributor>
163
- </bibitem>
164
- </references></bibliography>
165
- </iec-standard>
166
- OUTPUT
167
- end
168
-
169
- it "removes extraneous material from Normative References" do
170
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
171
- #{ASCIIDOC_BLANK_HDR}
172
- [bibliography]
173
- == Normative References
174
-
175
- This is extraneous information
176
-
177
- * [[[iso216,ISO 216]]], _Reference_
178
- INPUT
179
- #{@blank_hdr}
180
- <sections></sections>
181
- <bibliography><references id="_" obligation="informative" normative="true"><title>Normative references</title>
182
- <p id="_">The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.</p>
183
- <bibitem id="iso216" type="standard">
184
- <title format="text/plain">Reference</title>
185
- <docidentifier>ISO 216</docidentifier>
186
- <docnumber>216</docnumber>
187
- <contributor>
188
- <role type="publisher"/>
189
- <organization>
190
- <name>International Organization for Standardization</name>
191
- <abbreviation>ISO</abbreviation>
192
- </organization>
193
- </contributor>
194
- </bibitem>
195
- </references>
196
- </bibliography>
197
- </iec-standard>
198
- OUTPUT
199
- end
200
-
201
- it "inserts IDs into paragraphs" do
202
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
203
- #{ASCIIDOC_BLANK_HDR}
204
- Paragraph
205
- INPUT
206
- #{@blank_hdr}
207
- <sections>
208
- <p id="_">Paragraph</p>
209
- </sections>
210
- </iec-standard>
211
- OUTPUT
212
- end
213
-
214
- it "inserts IDs into notes" do
215
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
216
- #{ASCIIDOC_BLANK_HDR}
217
- [example]
218
- ====
219
- NOTE: This note has no ID
220
- ====
221
- INPUT
222
- #{@blank_hdr}
223
- <sections>
224
- <example id="_">
225
- <note id="_">
226
- <p id="_">This note has no ID</p>
227
- </note>
228
- </example>
229
- </sections>
230
- </iec-standard>
231
- OUTPUT
232
- end
233
-
234
- it "moves footnotes inside figures" do
235
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
236
- #{ASCIIDOC_BLANK_HDR}
237
- image::spec/examples/rice_images/rice_image1.png[]
238
-
239
- footnote:[This is a footnote to a figure]
240
-
241
- footnote:[This is another footnote to a figure]
242
- INPUT
243
- #{@blank_hdr}
244
- <sections><figure id="_">
245
- <image src="spec/examples/rice_images/rice_image1.png" id="_" mimetype="image/png" height="auto" width="auto"/>
246
- <fn reference="a">
247
- <p id="_">This is a footnote to a figure</p>
248
- </fn><fn reference="b">
249
- <p id="_">This is another footnote to a figure</p>
250
- </fn></figure>
251
-
252
- </sections>
253
-
254
- </iec-standard>
255
- OUTPUT
256
- end
257
-
258
- it "defaults section obligations" do
259
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
260
- #{ASCIIDOC_BLANK_HDR}
261
-
262
- == Clause
263
- Text
264
-
265
- [appendix]
266
- == Clause
267
-
268
- Text
269
- INPUT
270
- #{@blank_hdr}
271
- <sections><clause id="_" inline-header="false" obligation="normative">
272
- <title>Clause</title>
273
- <p id="_">Text</p>
274
- </clause>
275
- </sections><annex id="_" inline-header="false" obligation="normative">
276
- <title>Clause</title>
277
- <p id="_">Text</p>
278
- </annex>
279
- </iec-standard>
280
- OUTPUT
281
- end
282
-
283
- it "extends clause levels past 5" do
284
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
285
- #{ASCIIDOC_BLANK_HDR}
286
-
287
- == Clause1
288
-
289
- === Clause2
290
-
291
- ==== Clause3
292
-
293
- ===== Clause4
294
-
295
- ====== Clause 5
296
-
297
- [level=6]
298
- ====== Clause 6
299
-
300
- [level=7]
301
- ====== Clause 7A
302
-
303
- [level=7]
304
- ====== Clause 7B
305
-
306
- [level=6]
307
- ====== Clause 6B
308
-
309
- ====== Clause 5B
310
-
311
- INPUT
312
- #{@blank_hdr}
313
- <sections>
314
- <clause id="_" inline-header="false" obligation="normative">
315
- <title>Clause1</title>
316
- <clause id="_" inline-header="false" obligation="normative">
317
- <title>Clause2</title>
318
- <clause id="_" inline-header="false" obligation="normative">
319
- <title>Clause3</title>
320
- <clause id="_" inline-header="false" obligation="normative"><title>Clause4</title><clause id="_" inline-header="false" obligation="normative">
321
- <title>Clause 5</title>
322
- <clause id="_" inline-header="false" obligation="normative">
323
- <title>Clause 6</title>
324
- <clause id="_" inline-header="false" obligation="normative">
325
- <title>Clause 7A</title>
326
- </clause><clause id="_" inline-header="false" obligation="normative">
327
- <title>Clause 7B</title>
328
- </clause></clause><clause id="_" inline-header="false" obligation="normative">
329
- <title>Clause 6B</title>
330
- </clause></clause>
331
-
332
-
333
-
334
-
335
- <clause id="_" inline-header="false" obligation="normative">
336
- <title>Clause 5B</title>
337
- </clause></clause>
338
- </clause>
339
- </clause>
340
- </clause>
341
- </sections>
342
- </iec-standard>
343
- OUTPUT
344
- end
345
- end
@@ -1,243 +0,0 @@
1
- require "spec_helper"
2
- require "fileutils"
3
-
4
- RSpec.describe Asciidoctor::Iec do
5
- before(:all) do
6
- @boilerplate = boilerplate(Nokogiri::XML(BLANK_HDR + "</iec-standard>"))
7
- end
8
-
9
-
10
-
11
- it "generates reference boilerplate for IEV" do
12
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", *OPTIONS)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
13
- = Document title
14
- Author
15
- :docfile: test.adoc
16
- :nodoc:
17
- :novalid:
18
- :no-isobib:
19
- :docnumber: 60050
20
-
21
- [bibliography]
22
- == Normative References
23
-
24
- * [[[A,B]]], _TITLE_
25
- INPUT
26
- <?xml version='1.0' encoding='UTF-8'?>
27
- <iec-standard xmlns='https://www.metanorma.org/ns/iec' type="semantic" version="#{Metanorma::Iec::VERSION}">
28
- <bibdata type='standard'>
29
- <docidentifier type='ISO'>IEC 60050 ED 1</docidentifier>
30
- <docnumber>60050</docnumber>
31
- <contributor>
32
- <role type='author'/>
33
- <organization>
34
- <name>International Electrotechnical Commission</name>
35
- <abbreviation>IEC</abbreviation>
36
- </organization>
37
- </contributor>
38
- <contributor>
39
- <role type='publisher'/>
40
- <organization>
41
- <name>International Electrotechnical Commission</name>
42
- <abbreviation>IEC</abbreviation>
43
- </organization>
44
- </contributor>
45
- <language>en</language>
46
- <script>Latn</script>
47
- <status>
48
- <stage abbreviation="PPUB">60</stage>
49
- <substage abbreviation="PPUB">60</substage>
50
- </status>
51
- <copyright>
52
- <from>#{Time.now.year}</from>
53
- <owner>
54
- <organization>
55
- <name>International Electrotechnical Commission</name>
56
- <abbreviation>IEC</abbreviation>
57
- </organization>
58
- </owner>
59
- </copyright>
60
- <ext>
61
- <doctype>article</doctype>
62
- <horizontal>false</horizontal>
63
- <editorialgroup>
64
- <technical-committee/>
65
- <subcommittee/>
66
- <workgroup/>
67
- </editorialgroup>
68
- <structuredidentifier>
69
- <project-number>IEC 60050</project-number>
70
- </structuredidentifier>
71
- <stagename>International standard</stagename>
72
- </ext>
73
- </bibdata>
74
- #{@boilerplate}
75
- <sections> </sections>
76
- <bibliography>
77
- <references id='_' obligation='informative' normative="true">
78
- <title>Normative references</title>
79
- <p id='_'>There are no normative references in this document.</p>
80
- <bibitem id='A'>
81
- <formattedref format='application/x-isodoc+xml'>
82
- <em>TITLE</em>
83
- </formattedref>
84
- <docidentifier>B</docidentifier>
85
- </bibitem>
86
- </references>
87
- </bibliography>
88
- </iec-standard>
89
- OUTPUT
90
- end
91
-
92
- it "generates terms boilerplate for IEV" do
93
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", *OPTIONS)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
94
- = Document title
95
- Author
96
- :docfile: test.adoc
97
- :nodoc:
98
- :novalid:
99
- :no-isobib:
100
- :docnumber: 60050
101
-
102
- == Terms and definitions
103
- === General
104
- ==== Term 1
105
- INPUT
106
- <iec-standard xmlns='https://www.metanorma.org/ns/iec' type="semantic" version="#{Metanorma::Iec::VERSION}">
107
- <bibdata type='standard'>
108
- <docidentifier type='ISO'>IEC 60050 ED 1</docidentifier>
109
- <docnumber>60050</docnumber>
110
- <contributor>
111
- <role type='author'/>
112
- <organization>
113
- <name>International Electrotechnical Commission</name>
114
- <abbreviation>IEC</abbreviation>
115
- </organization>
116
- </contributor>
117
- <contributor>
118
- <role type='publisher'/>
119
- <organization>
120
- <name>International Electrotechnical Commission</name>
121
- <abbreviation>IEC</abbreviation>
122
- </organization>
123
- </contributor>
124
- <language>en</language>
125
- <script>Latn</script>
126
- <status>
127
- <stage abbreviation="PPUB">60</stage>
128
- <substage abbreviation="PPUB">60</substage>
129
- </status>
130
- <copyright>
131
- <from>#{Time.now.year}</from>
132
- <owner>
133
- <organization>
134
- <name>International Electrotechnical Commission</name>
135
- <abbreviation>IEC</abbreviation>
136
- </organization>
137
- </owner>
138
- </copyright>
139
- <ext>
140
- <doctype>article</doctype>
141
- <horizontal>false</horizontal>
142
- <editorialgroup>
143
- <technical-committee/>
144
- <subcommittee/>
145
- <workgroup/>
146
- </editorialgroup>
147
- <structuredidentifier>
148
- <project-number>IEC 60050</project-number>
149
- </structuredidentifier>
150
- <stagename>International standard</stagename>
151
- </ext>
152
- </bibdata>
153
- #{@boilerplate}
154
- <sections>
155
- <clause id='_' obligation='normative'>
156
- <title>Terms and definitions</title>
157
- <terms id='_' obligation='normative'>
158
- <title>General</title>
159
- <term id='term-term-1'>
160
- <preferred><expression><name>Term 1</name></expression></preferred>
161
- </term>
162
- </terms>
163
- </clause>
164
- </sections>
165
- </iec-standard>
166
-
167
- OUTPUT
168
- end
169
-
170
- it "uses IEV introduction title" do
171
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", *OPTIONS)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
172
- = Document title
173
- Author
174
- :docfile: test.adoc
175
- :nodoc:
176
- :novalid:
177
- :no-isobib:
178
- :docnumber: 60050
179
-
180
- == Introduction
181
-
182
- Text
183
- INPUT
184
- <?xml version='1.0' encoding='UTF-8'?>
185
- <iec-standard xmlns='https://www.metanorma.org/ns/iec' type="semantic" version="#{Metanorma::Iec::VERSION}">
186
- <bibdata type='standard'>
187
- <docidentifier type='ISO'>IEC 60050 ED 1</docidentifier>
188
- <docnumber>60050</docnumber>
189
- <contributor>
190
- <role type='author'/>
191
- <organization>
192
- <name>International Electrotechnical Commission</name>
193
- <abbreviation>IEC</abbreviation>
194
- </organization>
195
- </contributor>
196
- <contributor>
197
- <role type='publisher'/>
198
- <organization>
199
- <name>International Electrotechnical Commission</name>
200
- <abbreviation>IEC</abbreviation>
201
- </organization>
202
- </contributor>
203
- <language>en</language>
204
- <script>Latn</script>
205
- <status>
206
- <stage abbreviation='PPUB'>60</stage>
207
- <substage abbreviation='PPUB'>60</substage>
208
- </status>
209
- <copyright>
210
- <from>#{Time.now.year}</from>
211
- <owner>
212
- <organization>
213
- <name>International Electrotechnical Commission</name>
214
- <abbreviation>IEC</abbreviation>
215
- </organization>
216
- </owner>
217
- </copyright>
218
- <ext>
219
- <doctype>article</doctype>
220
- <horizontal>false</horizontal>
221
- <editorialgroup>
222
- <technical-committee/>
223
- <subcommittee/>
224
- <workgroup/>
225
- </editorialgroup>
226
- <structuredidentifier>
227
- <project-number>IEC 60050</project-number>
228
- </structuredidentifier>
229
- <stagename>International standard</stagename>
230
- </ext>
231
- </bibdata>
232
- #{@boilerplate}
233
- <preface>
234
- <introduction id='_' obligation='informative'>
235
- <title>INTRODUCTION&lt;br/&gt;Principles and rules followed</title>
236
- <p id='_'>Text</p>
237
- </introduction>
238
- </preface>
239
- <sections> </sections>
240
- </iec-standard>
241
- OUTPUT
242
- end
243
- end