metanorma-bsi 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +6 -0
  3. data/.hound.yml +3 -0
  4. data/.rubocop.yml +14 -0
  5. data/CODE_OF_CONDUCT.md +74 -0
  6. data/Gemfile +7 -0
  7. data/LICENSE +25 -0
  8. data/README.adoc +199 -0
  9. data/Rakefile +8 -0
  10. data/bin/rspec +18 -0
  11. data/lib/asciidoctor/bsi/basicdoc.rng +1131 -0
  12. data/lib/asciidoctor/bsi/biblio.rng +1235 -0
  13. data/lib/asciidoctor/bsi/bsi.rng +120 -0
  14. data/lib/asciidoctor/bsi/bsi_intro_en.xml +105 -0
  15. data/lib/asciidoctor/bsi/cleanup.rb +78 -0
  16. data/lib/asciidoctor/bsi/cleanup_ref.rb +183 -0
  17. data/lib/asciidoctor/bsi/converter.rb +83 -0
  18. data/lib/asciidoctor/bsi/front.rb +67 -0
  19. data/lib/asciidoctor/bsi/isodoc.rng +1870 -0
  20. data/lib/asciidoctor/bsi/isostandard.rng +477 -0
  21. data/lib/asciidoctor/bsi/reqt.rng +194 -0
  22. data/lib/asciidoctor/bsi/validate.rb +224 -0
  23. data/lib/asciidoctor/bsi/validate_list.rb +72 -0
  24. data/lib/asciidoctor/bsi/validate_requirement.rb +163 -0
  25. data/lib/isodoc/bsi/base_convert.rb +91 -0
  26. data/lib/isodoc/bsi/bsi.international-standard.xsl +6540 -0
  27. data/lib/isodoc/bsi/html/html_bsi_intro.html +8 -0
  28. data/lib/isodoc/bsi/html/html_bsi_titlepage.html +50 -0
  29. data/lib/isodoc/bsi/html/htmlstyle.css +968 -0
  30. data/lib/isodoc/bsi/html/htmlstyle.scss +699 -0
  31. data/lib/isodoc/bsi/html_convert.rb +56 -0
  32. data/lib/isodoc/bsi/i18n-en.yaml +56 -0
  33. data/lib/isodoc/bsi/i18n.rb +15 -0
  34. data/lib/isodoc/bsi/init.rb +24 -0
  35. data/lib/isodoc/bsi/metadata.rb +33 -0
  36. data/lib/isodoc/bsi/pdf_convert.rb +17 -0
  37. data/lib/isodoc/bsi/presentation_xml_convert.rb +72 -0
  38. data/lib/isodoc/bsi/sts_convert.rb +30 -0
  39. data/lib/isodoc/bsi/xref.rb +134 -0
  40. data/lib/metanorma-bsi.rb +15 -0
  41. data/lib/metanorma/bsi.rb +6 -0
  42. data/lib/metanorma/bsi/processor.rb +51 -0
  43. data/lib/metanorma/bsi/version.rb +6 -0
  44. data/metanorma-bsi.gemspec +47 -0
  45. data/spec/asciidoctor/base_spec.rb +778 -0
  46. data/spec/asciidoctor/blocks_spec.rb +553 -0
  47. data/spec/asciidoctor/cleanup_spec.rb +547 -0
  48. data/spec/asciidoctor/inline_spec.rb +176 -0
  49. data/spec/asciidoctor/lists_spec.rb +194 -0
  50. data/spec/asciidoctor/refs_spec.rb +318 -0
  51. data/spec/asciidoctor/section_spec.rb +382 -0
  52. data/spec/asciidoctor/validate_spec.rb +858 -0
  53. data/spec/assets/header.html +7 -0
  54. data/spec/assets/html.css +2 -0
  55. data/spec/assets/iso.xml +71 -0
  56. data/spec/assets/rice_image1.png +0 -0
  57. data/spec/assets/word.css +2 -0
  58. data/spec/assets/wordintro.html +4 -0
  59. data/spec/assets/xref_error.adoc +7 -0
  60. data/spec/isodoc/blocks_spec.rb +259 -0
  61. data/spec/isodoc/i18n_spec.rb +442 -0
  62. data/spec/isodoc/inline_spec.rb +287 -0
  63. data/spec/isodoc/iso_spec.rb +116 -0
  64. data/spec/isodoc/metadata_spec.rb +262 -0
  65. data/spec/isodoc/postproc_spec.rb +137 -0
  66. data/spec/isodoc/ref_spec.rb +376 -0
  67. data/spec/isodoc/section_spec.rb +467 -0
  68. data/spec/isodoc/terms_spec.rb +246 -0
  69. data/spec/isodoc/xref_spec.rb +1730 -0
  70. data/spec/metanorma/processor_spec.rb +76 -0
  71. data/spec/spec_helper.rb +291 -0
  72. data/spec/vcr_cassettes/iso-639.yml +182 -0
  73. data/spec/vcr_cassettes/isobib_get_639_1967.yml +136 -0
  74. data/spec/vcr_cassettes/multistandard.yml +352 -0
  75. metadata +343 -0
@@ -0,0 +1,382 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe Asciidoctor::BSI do
4
+ before(:all) do
5
+ @blank_hdr = blank_hdr_gen
6
+ end
7
+
8
+ it "processes sections" do
9
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :bsi, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
10
+ #{ASCIIDOC_BLANK_HDR}
11
+ .Foreword
12
+
13
+ Text
14
+
15
+ == Introduction
16
+
17
+ === Introduction Subsection
18
+
19
+ == Scope
20
+
21
+ Text
22
+
23
+ == Normative References
24
+
25
+ == Terms and Definitions
26
+
27
+ === Term1
28
+
29
+ == Terms, Definitions, Symbols and Abbreviated Terms
30
+
31
+ === Normal Terms
32
+
33
+ ==== Term2
34
+
35
+ === Symbols and Abbreviated Terms
36
+
37
+ == Symbols and Abbreviated Terms
38
+
39
+ == Clause 4
40
+
41
+ === Introduction
42
+
43
+ === Clause 4.2
44
+
45
+ == Terms and Definitions
46
+
47
+ [appendix]
48
+ == Annex
49
+
50
+ === Annex A.1
51
+
52
+ [%appendix]
53
+ === Appendix 1
54
+
55
+ == Bibliography
56
+
57
+ === Bibliography Subsection
58
+ INPUT
59
+ #{@blank_hdr}
60
+ <preface><foreword id="_" obligation="informative">
61
+ <title>FOREWORD</title>
62
+ <p id="_">Text</p>
63
+ </foreword><introduction id="_" obligation="informative">
64
+ <title>INTRODUCTION</title><clause id="_" inline-header="false" obligation="informative">
65
+ <title>Introduction Subsection</title>
66
+ </clause>
67
+ </introduction></preface><sections>
68
+ <clause id="_" obligation="normative" type="scope" inline-header='false'>
69
+ <title>Scope</title>
70
+ <p id="_">Text</p>
71
+ </clause>
72
+
73
+ <terms id="_" obligation="normative">
74
+ <title>Terms and definitions</title>
75
+ <p id="_">For the purposes of this British Standard, the following terms and definitions apply.</p>
76
+ #{TERMS_BOILERPLATE}
77
+ <term id="term-term1">
78
+ <preferred>Term1</preferred>
79
+ </term>
80
+ </terms>
81
+ <clause id="_" obligation="normative"><title>Terms, definitions, symbols and abbreviated terms</title><terms id="_" obligation="normative">
82
+ <title>Normal Terms</title>
83
+ <p id='_'>For the purposes of this British Standard, the following terms and definitions apply.</p>
84
+ <p id='_'>
85
+ ISO and IEC maintain terminological databases for use in
86
+ standardization at the following addresses:
87
+ </p>
88
+ <ul id='_'>
89
+ <li>
90
+ <p id='_'>
91
+ IEC Electropedia: available at
92
+ <link target='http://www.electropedia.org'/>
93
+ </p>
94
+ </li>
95
+ <li>
96
+ <p id='_'>
97
+ ISO Online browsing platform: available at
98
+ <link target='http://www.iso.org/obp'/>
99
+ </p>
100
+ </li>
101
+ </ul>
102
+ <term id="term-term2">
103
+ <preferred>Term2</preferred>
104
+ </term>
105
+ </terms>
106
+ <definitions id="_" obligation="normative"><title>Symbols and abbreviated terms</title></definitions></clause>
107
+ <definitions id="_" obligation="normative"><title>Symbols and abbreviated terms</title></definitions>
108
+ <clause id="_" inline-header="false" obligation="normative"><title>Clause 4</title><clause id="_" inline-header="false" obligation="normative">
109
+ <title>Introduction</title>
110
+ </clause>
111
+ <clause id="_" inline-header="false" obligation="normative">
112
+ <title>Clause 4.2</title>
113
+ </clause></clause>
114
+ <clause id="_" inline-header="false" obligation="normative">
115
+ <title>Terms and Definitions</title>
116
+ </clause>
117
+
118
+
119
+ </sections><annex id="_" inline-header="false" obligation="normative">
120
+ <title>Annex</title>
121
+ <clause id="_" inline-header="false" obligation="normative">
122
+ <title>Annex A.1</title>
123
+ </clause>
124
+ <appendix id="_" inline-header="false" obligation="normative">
125
+ <title>Appendix 1</title>
126
+ </appendix></annex><bibliography><references id="_" obligation="informative" normative="true">
127
+ <title>Normative references</title><p id="_">There are no normative references in this document.</p>
128
+ </references><clause id="_" obligation="informative">
129
+ <title>Bibliography</title>
130
+ <references id="_" obligation="informative" normative="false">
131
+ <title>Bibliography Subsection</title>
132
+ <p id='_'>
133
+ For dated references, only the edition cited applies. For undated
134
+ references, the latest edition of the referenced document (including
135
+ any amendments) applies.
136
+ </p>
137
+ </references>
138
+ </clause>
139
+ </bibliography>
140
+ </bsi-standard>
141
+ OUTPUT
142
+ end
143
+
144
+ it "processes sections with title attributes" do
145
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :bsi, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
146
+ #{ASCIIDOC_BLANK_HDR}
147
+ .Foreword
148
+
149
+ Text
150
+
151
+ [heading=introduction]
152
+ == Εισαγωγή
153
+
154
+ === Introduction Subsection
155
+
156
+ [heading=scope]
157
+ == Σκοπός
158
+
159
+ Text
160
+
161
+ [heading=normative references]
162
+ == Κανονιστικές Παραπομπές
163
+
164
+ [heading=terms and definitions]
165
+ == Όροι και Ορισμοί
166
+
167
+ === Term1
168
+
169
+ [heading="terms, definitions, symbols and abbreviated terms"]
170
+ == Όροι, Ορισμοί, Σύμβολα και Συντομογραφίες
171
+
172
+ === Normal Terms
173
+
174
+ ==== Term2
175
+
176
+ [heading=symbols and abbreviated terms]
177
+ === Σύμβολα και Συντομογραφίες
178
+
179
+ [heading=symbols and abbreviated terms]
180
+ == Σύμβολα και Συντομογραφίες
181
+
182
+ == Clause 4
183
+
184
+ === Introduction
185
+
186
+ === Clause 4.2
187
+
188
+ [appendix]
189
+ == Annex
190
+
191
+ === Annex A.1
192
+
193
+ [%appendix]
194
+ === Appendx 1
195
+
196
+ [heading=bibliography]
197
+ == Βιβλιογραφία
198
+
199
+ === Bibliography Subsection
200
+ INPUT
201
+ #{@blank_hdr}
202
+ <preface>
203
+ <foreword id="_" obligation="informative">
204
+ <title>FOREWORD</title>
205
+ <p id="_">Text</p>
206
+ </foreword>
207
+ <introduction id="_" obligation="informative">
208
+ <title>INTRODUCTION</title><clause id="_" inline-header="false" obligation="informative">
209
+ <title>Introduction Subsection</title>
210
+ </clause>
211
+ </introduction>
212
+ </preface>
213
+ <sections>
214
+ <clause id="_" obligation="normative" type="scope" inline-header='false'>
215
+ <title>Scope</title>
216
+ <p id="_">Text</p>
217
+ </clause>
218
+ <terms id="_" obligation="normative">
219
+ <title>Terms and definitions</title>
220
+ <p id="_">For the purposes of this British Standard, the following terms and definitions apply.</p>
221
+ #{TERMS_BOILERPLATE}
222
+ <term id="term-term1">
223
+ <preferred>Term1</preferred>
224
+ </term>
225
+ </terms>
226
+ <clause id='_' obligation='normative'>
227
+ <title>Terms, definitions, symbols and abbreviated terms</title>
228
+ <terms id='_' obligation='normative'>
229
+ <title>Normal Terms</title>
230
+ <p id='_'>For the purposes of this British Standard, the following terms and definitions apply.</p>
231
+ <p id='_'>
232
+ ISO and IEC maintain terminological databases for use in
233
+ standardization at the following addresses:
234
+ </p>
235
+ <ul id='_'>
236
+ <li>
237
+ <p id='_'>
238
+ IEC Electropedia: available at
239
+ <link target='http://www.electropedia.org'/>
240
+ </p>
241
+ </li>
242
+ <li>
243
+ <p id='_'>
244
+ ISO Online browsing platform: available at
245
+ <link target='http://www.iso.org/obp'/>
246
+ </p>
247
+ </li>
248
+ </ul>
249
+ <term id='term-term2'>
250
+ <preferred>Term2</preferred>
251
+ </term>
252
+ </terms>
253
+ <definitions id='_' obligation="normative">
254
+ <title>Symbols and abbreviated terms</title>
255
+ </definitions>
256
+ </clause>
257
+ <definitions id='_' obligation="normative">
258
+ <title>Symbols and abbreviated terms</title>
259
+ </definitions>
260
+ <clause id='_' inline-header='false' obligation='normative'>
261
+ <title>Clause 4</title>
262
+ <clause id='_' inline-header='false' obligation='normative'>
263
+ <title>Introduction</title>
264
+ </clause>
265
+ <clause id='_' inline-header='false' obligation='normative'>
266
+ <title>Clause 4.2</title>
267
+ </clause>
268
+ </clause>
269
+ </sections>
270
+ <annex id='_' inline-header='false' obligation='normative'>
271
+ <title>Annex</title>
272
+ <clause id='_' inline-header='false' obligation='normative'>
273
+ <title>Annex A.1</title>
274
+ </clause>
275
+ <appendix id='_' inline-header='false' obligation='normative'>
276
+ <title>Appendx 1</title>
277
+ </appendix>
278
+ </annex>
279
+ <bibliography>
280
+ <references id='_' obligation='informative' normative="true">
281
+ <title>Normative references</title>
282
+ <p id="_">There are no normative references in this document.</p>
283
+ </references>
284
+ <clause id='_' obligation='informative'>
285
+ <title>Bibliography</title>
286
+ <references id='_' obligation='informative' normative="false">
287
+ <title>Bibliography Subsection</title>
288
+ <p id='_'>
289
+ For dated references, only the edition cited applies. For undated
290
+ references, the latest edition of the referenced document (including
291
+ any amendments) applies.
292
+ </p>
293
+ </references>
294
+ </clause>
295
+ </bibliography>
296
+ </bsi-standard>
297
+ OUTPUT
298
+ end
299
+
300
+ it "processes section obligations" do
301
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :bsi, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
302
+ #{ASCIIDOC_BLANK_HDR}
303
+ [obligation=informative]
304
+ == Clause 1
305
+
306
+ === Clause 1a
307
+
308
+ [obligation=normative]
309
+ == Clause 2
310
+
311
+ [appendix,obligation=informative]
312
+ == Annex
313
+ INPUT
314
+ #{@blank_hdr}
315
+ <sections><clause id="_" inline-header="false" obligation="informative">
316
+ <title>Clause 1</title>
317
+ <clause id="_" inline-header="false" obligation="informative">
318
+ <title>Clause 1a</title>
319
+ </clause>
320
+ </clause>
321
+ <clause id="_" inline-header="false" obligation="normative">
322
+ <title>Clause 2</title>
323
+ </clause>
324
+ </sections><annex id="_" inline-header="false" obligation="informative">
325
+ <title>Annex</title>
326
+ </annex>
327
+ </bsi-standard>
328
+ OUTPUT
329
+ end
330
+
331
+ it "processes inline headers" do
332
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :bsi, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
333
+ #{ASCIIDOC_BLANK_HDR}
334
+ == Clause 1
335
+
336
+ [%inline-header]
337
+ === Clause 1a
338
+
339
+ [appendix]
340
+ == Annex A
341
+
342
+ [%inline-header]
343
+ === Clause Aa
344
+ INPUT
345
+ #{@blank_hdr}
346
+ <sections><clause id="_" inline-header="false" obligation="normative">
347
+ <title>Clause 1</title>
348
+ <clause id="_" inline-header="true" obligation="normative">
349
+ <title>Clause 1a</title>
350
+ </clause>
351
+ </clause>
352
+ </sections><annex id="_" inline-header="false" obligation="normative">
353
+ <title>Annex A</title>
354
+ <clause id="_" inline-header="true" obligation="normative">
355
+ <title>Clause Aa</title>
356
+ </clause>
357
+ </annex>
358
+ </bsi-standard>
359
+ OUTPUT
360
+ end
361
+
362
+ it "processes blank headers" do
363
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :bsi, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
364
+ #{ASCIIDOC_BLANK_HDR}
365
+ == Clause 1
366
+
367
+ === {blank}
368
+
369
+ INPUT
370
+ #{@blank_hdr}
371
+ <sections>
372
+ <clause id="_" inline-header="false" obligation="normative">
373
+ <title>Clause 1</title>
374
+ <clause id="_" inline-header="false" obligation="normative">
375
+ </clause>
376
+ </clause>
377
+ </sections>
378
+ </bsi-standard>
379
+ OUTPUT
380
+ end
381
+
382
+ end
@@ -0,0 +1,858 @@
1
+ require "spec_helper"
2
+ require "fileutils"
3
+
4
+ RSpec.describe Asciidoctor::BSI do
5
+ context "when xref_error.adoc compilation" do
6
+ around do |example|
7
+ FileUtils.rm_f "spec/assets/xref_error.err"
8
+ example.run
9
+ Dir["spec/assets/xref_error*"].each do |file|
10
+ next if file.match?(/adoc$/)
11
+
12
+ FileUtils.rm_f(file)
13
+ end
14
+ end
15
+
16
+ it "generates error file" do
17
+ expect do
18
+ mock_pdf
19
+ Metanorma::Compile.new
20
+ .compile("spec/assets/xref_error.adoc", type: "bsi", no_install_fonts: true)
21
+ end.to(change { File.exist?("spec/assets/xref_error.err") }
22
+ .from(false).to(true))
23
+ end
24
+ end
25
+
26
+ it "Warns of illegal doctype" do
27
+ FileUtils.rm_f "test.err"
28
+ Asciidoctor.convert(<<~"INPUT", backend: :bsi, header_footer: true)
29
+ = Document title
30
+ Author
31
+ :docfile: test.adoc
32
+ :nodoc:
33
+ :no-isobib:
34
+ :doctype: pizza
35
+
36
+ text
37
+ INPUT
38
+ expect(File.read("test.err"))
39
+ .to include "pizza is not a recognised document type"
40
+ end
41
+
42
+ it "No style warning if decimal point" do
43
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
44
+ #{VALIDATING_BLANK_HDR}
45
+
46
+ == Clause
47
+ 8.1
48
+ INPUT
49
+ expect(File.read("test.err")).not_to include "possible decimal point"
50
+ end
51
+
52
+ it "Style warning if decimal comma" do
53
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
54
+ #{VALIDATING_BLANK_HDR}
55
+
56
+ == Clause
57
+ 8,1
58
+ INPUT
59
+ expect(File.read("test.err")).to include "possible decimal comma"
60
+ end
61
+
62
+ it "warns that code of practice may contain requirement" do
63
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
64
+ = Document title
65
+ Author
66
+ :docfile: test.adoc
67
+ :nodoc:
68
+ :no-isobib:
69
+ :doctype: code-of-practice
70
+
71
+ == Random clause
72
+
73
+ The widget shall not be larger than 15 cm.
74
+ INPUT
75
+ expect(File.read("test.err"))
76
+ .to include "Code Of Practice clause may contain requirement"
77
+
78
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
79
+ = Document title
80
+ Author
81
+ :docfile: test.adoc
82
+ :nodoc:
83
+ :no-isobib:
84
+ :doctype: technical-report
85
+
86
+ == Random clause
87
+
88
+ The widget is required not to be larger than 15 cm.
89
+ INPUT
90
+ expect(File.read("test.err"))
91
+ .not_to include "Technical Report clause may contain requirement"
92
+ end
93
+
94
+ it "warns that specification may contain requirement in informative text" do
95
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
96
+ = Document title
97
+ Author
98
+ :docfile: test.adoc
99
+ :nodoc:
100
+ :no-isobib:
101
+ :doctype: specification
102
+
103
+ == Random clause
104
+
105
+ The widget is not be larger than 15 cm.
106
+
107
+ NOTE: the widget shall not be good.
108
+
109
+ [appendix,obligation=informative]
110
+ == Annex
111
+
112
+ The widget should not be good
113
+ INPUT
114
+ expect(File.read("test.err"))
115
+ .to include "Specification clause may contain requirement"
116
+ expect(File.read("test.err"))
117
+ .not_to include "Specification clause may contain recommendation"
118
+ end
119
+
120
+ it "warns that specification may contain recommendation, permission "\
121
+ "or possibility in normative text" do
122
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
123
+ = Document title
124
+ Author
125
+ :docfile: test.adoc
126
+ :nodoc:
127
+ :no-isobib:
128
+ :doctype: specification
129
+
130
+ == Random clause
131
+
132
+ The widget should be larger than 15 cm.
133
+
134
+ The widget can be larger than 15 cm.
135
+
136
+ [appendix,obligation=normative]
137
+ == Annex
138
+
139
+ The widget may not be good
140
+ INPUT
141
+ expect(File.read("test.err"))
142
+ .not_to include "Specification clause may contain requirement"
143
+ expect(File.read("test.err"))
144
+ .to include "Specification clause may contain recommendation"
145
+ expect(File.read("test.err"))
146
+ .to include "Specification clause may contain permission"
147
+ expect(File.read("test.err"))
148
+ .to include "Specification clause may contain possibility"
149
+ end
150
+
151
+ it "warns that guide may contain recommendation in informative text" do
152
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
153
+ = Document title
154
+ Author
155
+ :docfile: test.adoc
156
+ :nodoc:
157
+ :no-isobib:
158
+ :doctype: guide
159
+
160
+ == Random clause
161
+
162
+ The widget is not be larger than 15 cm.
163
+
164
+ NOTE: the widget shall not be good.
165
+
166
+ [appendix,obligation=informative]
167
+ == Annex
168
+
169
+ The widget should not be good
170
+ INPUT
171
+ expect(File.read("test.err"))
172
+ .to include "Guide clause may contain requirement"
173
+ expect(File.read("test.err"))
174
+ .to include "Guide clause may contain recommendation"
175
+ end
176
+
177
+ it "warns that guide contains normative annexes" do
178
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
179
+ = Document title
180
+ Author
181
+ :docfile: test.adoc
182
+ :nodoc:
183
+ :no-isobib:
184
+ :doctype: guide
185
+
186
+ [appendix,obligation=informative]
187
+ == Annex 1
188
+
189
+ [appendix,obligation=normative]
190
+ == Annex
191
+ INPUT
192
+ expect(File.read("test.err"))
193
+ .to include "Guide contains normative annex: Annex"
194
+ expect(File.read("test.err"))
195
+ .not_to include "Guide contains normative annex: Annex 1"
196
+ end
197
+
198
+ it "warns of ambiguous word 'must'" do
199
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
200
+ = Document title
201
+ Author
202
+ :docfile: test.adoc
203
+ :nodoc:
204
+ :no-isobib:
205
+ :doctype: technical-report
206
+
207
+ == Random clause
208
+
209
+ The widget must be larger than 15 cm.
210
+ INPUT
211
+ expect(File.read("test.err"))
212
+ .to include "text contains ambiguous 'must'"
213
+ end
214
+
215
+ it "warns of superscript ordinals" do
216
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
217
+ = Document title
218
+ Author
219
+ :docfile: test.adoc
220
+ :nodoc:
221
+ :no-isobib:
222
+ :doctype: technical-report
223
+
224
+ == Random clause
225
+
226
+ This is the 22^nd^ rule
227
+ INPUT
228
+ expect(File.read("test.err"))
229
+ .to include "text contains ordinal superscript"
230
+ end
231
+
232
+ it "warns of Non-approved reference in Normative References" do
233
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
234
+ #{VALIDATING_BLANK_HDR}
235
+
236
+ [bibliography]
237
+ == Normative References
238
+ * [[[XYZ,IESO 121]]] _Standard_
239
+ INPUT
240
+ expect(File.read("test.err"))
241
+ .to include "reference other than BSI, CEN, CENELEC, ISO, IEC "\
242
+ "not expected as normative"
243
+ end
244
+
245
+ it "warns of withdrawn standards in Normative References" do
246
+ VCR.use_cassette "isobib_get_639_1967" do
247
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
248
+ = Document title
249
+ Author
250
+ :docfile: test.adoc
251
+ :nodoc:
252
+ :no-isobib-cache:
253
+
254
+ [bibliography]
255
+ == Normative References
256
+ * [[[XYZ,ISO 639:1967]]] _Standard_
257
+ INPUT
258
+ expect(File.read("test.err"))
259
+ .to include "Do not cite withdrawn standards"
260
+ end
261
+ end
262
+
263
+ it "warns of withdrawn standards in Normative References" do
264
+ mock_fdis
265
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
266
+ = Document title
267
+ Author
268
+ :docfile: test.adoc
269
+ :nodoc:
270
+ :no-isobib-cache:
271
+
272
+ [bibliography]
273
+ == Normative References
274
+ * [[[XYZ,ISO/FDIS 17664-1]]] _Standard_
275
+ INPUT
276
+ expect(File.read("test.err"))
277
+ .to include "Do not cite unpublished standards"
278
+ end
279
+
280
+ it "Warning if main title contains document type" do
281
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
282
+ = Document title
283
+ Author
284
+ :docfile: test.adoc
285
+ :nodoc:
286
+ :title-main-en: A British Standard on Widgets
287
+ :no-isobib:
288
+
289
+ INPUT
290
+ expect(File.read("test.err"))
291
+ .to include "Main Title may name document type"
292
+ end
293
+
294
+ it "Warning if intro title contains document type" do
295
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
296
+ = Document title
297
+ Author
298
+ :docfile: test.adoc
299
+ :nodoc:
300
+ :title-intro-en: A British Standard on Widgets
301
+ :no-isobib:
302
+
303
+ INPUT
304
+ expect(File.read("test.err"))
305
+ .to include "Title Intro may name document type"
306
+ end
307
+
308
+ it "Warning if term definition starts with upper case character" do
309
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
310
+ #{VALIDATING_BLANK_HDR}
311
+ == Terms and Definitions
312
+
313
+ === Term
314
+
315
+ Part of the specialized vocabulary of a particular field.
316
+ INPUT
317
+ expect(File.read("test.err"))
318
+ .to include "term definition starts with upper case character"
319
+ end
320
+
321
+ it "Warning if term definition is circular" do
322
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
323
+ #{VALIDATING_BLANK_HDR}
324
+ == Terms and Definitions
325
+
326
+ === Vocabulary
327
+
328
+ Part of the specialized vocabulary of a particular field.
329
+ INPUT
330
+ expect(File.read("test.err"))
331
+ .to include "term definition may be circular"
332
+ end
333
+
334
+ it "Warning if symbol definition is circular" do
335
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
336
+ #{VALIDATING_BLANK_HDR}
337
+ == Symbols and Abbreviated Terms
338
+
339
+ stem:[a_1]:: the notion of the dimension of a particular field
340
+ a:: Part of the list of the dimension of a particular field.
341
+ V:: part of the V of a particular field
342
+ X:: Part of the notion of a particular field
343
+ INPUT
344
+ expect(File.read("test.err"))
345
+ .to include "a: symbol definition ends with period"
346
+ expect(File.read("test.err"))
347
+ .to include "a1: symbol definition starts with article"
348
+ expect(File.read("test.err"))
349
+ .to include "V: symbol definition may be circular"
350
+ expect(File.read("test.err"))
351
+ .to include "X: symbol definition starts with upper case character"
352
+ end
353
+
354
+ it "Warning if annexes do not appear in citation order" do
355
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
356
+ #{VALIDATING_BLANK_HDR}
357
+
358
+ <<a3>>
359
+ <<a2>>
360
+ <<a1>>
361
+
362
+ [[a1]]
363
+ [appendix]
364
+ == First annex
365
+
366
+ [[a2]]
367
+ [appendix]
368
+ == Second annex
369
+
370
+ [[a3]]
371
+ [appendix]
372
+ == Third annex
373
+ INPUT
374
+ expect(File.read("test.err"))
375
+ .to include "First annex should be annex #3"
376
+ expect(File.read("test.err"))
377
+ .to include "Third annex should be annex #1"
378
+ end
379
+
380
+ it "Warning if annexes not cited properly" do
381
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
382
+ = Document title
383
+ Author
384
+ :docfile: test.adoc
385
+ :nodoc:
386
+ :no-isobib:
387
+ :doctype: specification
388
+
389
+ <<a1>> shall be cited.
390
+ People should cite <<a1>>.
391
+ <<a2>> should be cited.
392
+ You may cite <<a2>> at length.
393
+
394
+ [[a1]]
395
+ [appendix,obligation=normative]
396
+ == First annex
397
+
398
+ [[a2]]
399
+ [appendix,obligation=informative]
400
+ == Second annex
401
+
402
+ INPUT
403
+ expect(File.read("test.err"))
404
+ .to include "Specification must cite normative annex as requirement: People should cite"
405
+ expect(File.read("test.err"))
406
+ .to include "Specification must cite informative annex as recommendation or statement: You may cite"
407
+
408
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
409
+ = Document title
410
+ Author
411
+ :docfile: test.adoc
412
+ :nodoc:
413
+ :no-isobib:
414
+ :doctype: code-of-practice
415
+
416
+ <<a1>> shall be cited.
417
+ People should cite <<a1>>.
418
+ <<a2>> should be cited.
419
+ You may cite <<a2>> at length.
420
+
421
+ [[a1]]
422
+ [appendix,obligation=normative]
423
+ == First annex
424
+
425
+ [[a2]]
426
+ [appendix,obligation=informative]
427
+ == Second annex
428
+
429
+ INPUT
430
+ expect(File.read("test.err"))
431
+ .to include "Code Of Practice must cite normative annex as recommendation: XREF shall be cited"
432
+ expect(File.read("test.err"))
433
+ .to include "Code Of Practice must cite informative annex as statement: People should cite"
434
+ end
435
+
436
+ it "Warn if more than 5 levels of subclause" do
437
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
438
+ = Document title
439
+ Author
440
+ :docfile: test.adoc
441
+ :nodoc:
442
+ :no-isobib:
443
+
444
+ == Clause
445
+
446
+ === Clause
447
+
448
+ ==== Clause
449
+
450
+ ===== Clause
451
+
452
+ ====== Clause
453
+
454
+ [level=6]
455
+ ====== Clause
456
+
457
+ INPUT
458
+ expect(File.read("test.err"))
459
+ .to include "Exceeds the maximum clause depth of 5"
460
+ end
461
+
462
+ it "Warn if more than three ordered lists in a clause" do
463
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
464
+ = Document title
465
+ Author
466
+ :docfile: test.adoc
467
+ :nodoc:
468
+ :no-isobib:
469
+
470
+ == Clause
471
+
472
+ . A
473
+ .. B
474
+ ... C
475
+
476
+ a
477
+
478
+ . A
479
+ .. B
480
+
481
+ a
482
+
483
+ . B
484
+
485
+ INPUT
486
+ expect(File.read("test.err"))
487
+ .not_to include "More than 3 ordered lists in a numbered clause"
488
+
489
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
490
+ = Document title
491
+ Author
492
+ :docfile: test.adoc
493
+ :nodoc:
494
+ :no-isobib:
495
+
496
+ == Clause
497
+
498
+ . A
499
+ .. B
500
+ ... C
501
+
502
+ a
503
+
504
+ . A
505
+ .. B
506
+
507
+ a
508
+
509
+ . B
510
+ .. C
511
+
512
+ a
513
+
514
+ . C
515
+
516
+ INPUT
517
+ expect(File.read("test.err"))
518
+ .to include "More than 3 ordered lists in a numbered clause"
519
+
520
+ end
521
+
522
+ it "Warn if nothing before list" do
523
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
524
+ = Document title
525
+ Author
526
+ :docfile: test.adoc
527
+ :nodoc:
528
+ :no-isobib:
529
+
530
+ == Clause
531
+
532
+ . A
533
+ .. B
534
+ ... C
535
+ INPUT
536
+ expect(File.read("test.err"))
537
+ .to include "All lists must be preceded by introductory phrase"
538
+ end
539
+
540
+ it "Warn if no introductory text before list" do
541
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
542
+ = Document title
543
+ Author
544
+ :docfile: test.adoc
545
+ :nodoc:
546
+ :no-isobib:
547
+
548
+ == Clause
549
+
550
+ NOTE: X
551
+
552
+ * A
553
+ * B
554
+ * C
555
+ INPUT
556
+ expect(File.read("test.err"))
557
+ .to include "All lists must be preceded by introductory phrase"
558
+ end
559
+
560
+ it "Do not warn if introductory text before list" do
561
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
562
+ = Document title
563
+ Author
564
+ :docfile: test.adoc
565
+ :nodoc:
566
+ :no-isobib:
567
+
568
+ == Clause
569
+
570
+ X
571
+
572
+ * A
573
+ * B
574
+ * C
575
+ INPUT
576
+ expect(File.read("test.err"))
577
+ .not_to include "All lists must be preceded by introductory phrase"
578
+ end
579
+
580
+ it "Warn if no colon or full stop before list" do
581
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
582
+ = Document title
583
+ Author
584
+ :docfile: test.adoc
585
+ :nodoc:
586
+ :no-isobib:
587
+
588
+ == Clause
589
+
590
+ X
591
+
592
+ * A
593
+ * B
594
+ * C
595
+ INPUT
596
+ expect(File.read("test.err"))
597
+ .to include "All lists must be preceded by colon or full stop"
598
+ end
599
+
600
+ it "Do not warn if colon or full stop before list" do
601
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
602
+ = Document title
603
+ Author
604
+ :docfile: test.adoc
605
+ :nodoc:
606
+ :no-isobib:
607
+
608
+ == Clause
609
+
610
+ X.
611
+
612
+ * A
613
+ * B
614
+ * C
615
+
616
+ X:
617
+
618
+ . A
619
+ . B
620
+ . C
621
+ INPUT
622
+ expect(File.read("test.err"))
623
+ .not_to include "All lists must be preceded by colon or full stop"
624
+ end
625
+
626
+ it "Warn of list punctuation after colon" do
627
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
628
+ = Document title
629
+ Author
630
+ :docfile: test.adoc
631
+ :nodoc:
632
+ :no-isobib:
633
+
634
+ == Clause
635
+
636
+ X:
637
+
638
+ * this is;
639
+ * another;
640
+ * Sentence.
641
+
642
+ X:
643
+
644
+ . this is
645
+ . another;
646
+ . sentence
647
+
648
+ X:
649
+
650
+ . sentence.
651
+ INPUT
652
+ expect(File.read("test.err"))
653
+ .to include "List entry after colon must start with lowercase letter: Sentence."
654
+ expect(File.read("test.err"))
655
+ .not_to include "List entry after colon must start with lowercase letter: another;."
656
+ expect(File.read("test.err"))
657
+ .to include "List entry after colon must end with semicolon: this is"
658
+ expect(File.read("test.err"))
659
+ .to include "Final list entry after colon must end with full stop: sentence"
660
+ expect(File.read("test.err"))
661
+ .not_to include "Final list entry after colon must end with full stop: sentence."
662
+ end
663
+
664
+ it "Warn of list punctuation after full stop" do
665
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
666
+ = Document title
667
+ Author
668
+ :docfile: test.adoc
669
+ :nodoc:
670
+ :no-isobib:
671
+
672
+ == Clause
673
+
674
+ X.
675
+
676
+ * This is;
677
+ * Another.
678
+ * sentence.
679
+
680
+ INPUT
681
+ expect(File.read("test.err"))
682
+ .to include "List entry after full stop must end with full stop: This is;"
683
+ expect(File.read("test.err"))
684
+ .not_to include "List entry after full stop must end with full stop: Another."
685
+ expect(File.read("test.err"))
686
+ .to include "List entry after full stop must start with uppercase letter: sentence."
687
+ end
688
+
689
+ it "Warn of provisions in admonitions" do
690
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
691
+ = Document title
692
+ Author
693
+ :docfile: test.adoc
694
+ :nodoc:
695
+ :no-isobib:
696
+
697
+ == Clause
698
+
699
+ [WARNING]
700
+ --
701
+ This shall be bad. This can be bad. This should be bad. This may be bad.
702
+ --
703
+
704
+ INPUT
705
+ expect(File.read("test.err"))
706
+ .to include "admonition may contain requirement"
707
+ expect(File.read("test.err"))
708
+ .to include "admonition may contain recommendation"
709
+ expect(File.read("test.err"))
710
+ .to include "admonition may contain permission"
711
+ expect(File.read("test.err"))
712
+ .to include "admonition may contain possibility"
713
+ end
714
+
715
+ it "warns that example may contain requirement" do
716
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
717
+ #{VALIDATING_BLANK_HDR}
718
+
719
+ == Terms and Definitions
720
+
721
+ === Term
722
+
723
+ [example]
724
+ This shall be bad. This can be bad. This should be bad. This may be bad.
725
+ INPUT
726
+ expect(File.read("test.err"))
727
+ .to include "Example may contain requirement"
728
+ expect(File.read("test.err"))
729
+ .not_to include "Example may contain recommendation"
730
+ end
731
+
732
+ it "warns of incorrect spacing around plus-minus sign" do
733
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
734
+ #{VALIDATING_BLANK_HDR}
735
+
736
+ === Term
737
+
738
+ 9 ± 2
739
+ 2±9
740
+ INPUT
741
+ expect(File.read("test.err"))
742
+ .to include "no space before plus-minus sign: 2±9"
743
+ expect(File.read("test.err"))
744
+ .to include "space after plus-minus sign: 9 ± 2"
745
+ end
746
+
747
+ it "warns of nested subscripts" do
748
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
749
+ #{VALIDATING_BLANK_HDR}
750
+
751
+ === Term
752
+
753
+ stem:[D_{1_max}]
754
+ stem:[D^{1^max}]
755
+ INPUT
756
+ expect(File.read("test.err"))
757
+ .to include "Nested subscript"
758
+ expect(File.read("test.err"))
759
+ .to include "Nested superscript"
760
+ end
761
+
762
+ it "warns of empty table data cells" do
763
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
764
+ #{VALIDATING_BLANK_HDR}
765
+
766
+ === Term
767
+
768
+ |===
769
+ | | A
770
+
771
+ | B | C
772
+ |===
773
+ INPUT
774
+ expect(File.read("test.err"))
775
+ .to include "Empty table cell"
776
+ end
777
+
778
+ it "warns of empty table header cells" do
779
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
780
+ #{VALIDATING_BLANK_HDR}
781
+
782
+ === Term
783
+
784
+ |===
785
+ | C | A
786
+
787
+ | B |
788
+ |===
789
+ INPUT
790
+ expect(File.read("test.err"))
791
+ .to include "Empty table cell"
792
+ end
793
+
794
+ it "does not warn of no empty table cells" do
795
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
796
+ #{VALIDATING_BLANK_HDR}
797
+
798
+ === Term
799
+
800
+ |===
801
+ | C | A
802
+
803
+ | B | X
804
+ |===
805
+ INPUT
806
+ expect(File.read("test.err"))
807
+ .not_to include "Empty table cell"
808
+
809
+ end
810
+
811
+
812
+ end
813
+
814
+ private
815
+
816
+ def mock_fdis
817
+ expect(RelatonIso::IsoBibliography).to receive(:get)
818
+ .with("ISO/FDIS 17664-1", nil, lang: "en", title: "<em>Standard</em>", usrlbl: nil) do
819
+ RelatonIsoBib::XMLParser.from_xml(<<~"OUTPUT")
820
+ <bibitem id="x" type="standard">
821
+ <fetched>#{Date.today}</fetched>
822
+ <title format="text/plain" language="fr" script="Latn" type="title-intro">Traitement de produits de soins de santé</title>
823
+ <title format="text/plain" language="fr" script="Latn" type="title-main">Informations relatives au traitement des dispositifs médicaux à fournir par le fabricant du dispositif</title>
824
+ <title format="text/plain" language="fr" script="Latn" type="title-part">Partie 1: Titre manque</title>
825
+ <title format="text/plain" language="fr" script="Latn" type="main">Traitement de produits de soins de santé — Informations relatives au traitement des dispositifs médicaux à fournir par le fabricant du dispositif — Partie 1: Titre manque</title>
826
+ <uri type="src">https://www.iso.org/standard/81720.html</uri>
827
+ <uri type="rss">https://www.iso.org/contents/data/standard/08/17/81720.detail.rss</uri>
828
+ <docidentifier type="ISO">ISO/FDIS 17664-1</docidentifier>
829
+ <docidentifier type="URN">urn:iso:std:iso-fdis:17664:-1:stage-50.00:ed-1:fr</docidentifier>
830
+ <docnumber>17664</docnumber>
831
+ <contributor>
832
+ <role type="publisher"/>
833
+ <organization>
834
+ <name>International Organization for Standardization</name>
835
+ <abbreviation>ISO</abbreviation>
836
+ <uri>www.iso.org</uri>
837
+ </organization>
838
+ </contributor>
839
+ <edition>1</edition>
840
+ <language>en</language>
841
+ <language>fr</language>
842
+ <script>Latn</script>
843
+ <status>
844
+ <stage>50</stage>
845
+ <substage>00</substage>
846
+ </status>
847
+ <copyright>
848
+ <from>unknown</from>
849
+ <owner>
850
+ <organization>
851
+ <name>ISO/FDIS</name>
852
+ </organization>
853
+ </owner>
854
+ </copyright>
855
+ </bibitem>
856
+ OUTPUT
857
+ end
858
+ end