metanorma-standoc 2.2.0 → 2.2.1.1

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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/lib/metanorma/standoc/base.rb +12 -0
  3. data/lib/metanorma/standoc/blocks.rb +25 -15
  4. data/lib/metanorma/standoc/cleanup_biblio.rb +14 -8
  5. data/lib/metanorma/standoc/cleanup_reqt.rb +3 -136
  6. data/lib/metanorma/standoc/front.rb +6 -1
  7. data/lib/metanorma/standoc/front_contributor.rb +0 -10
  8. data/lib/metanorma/standoc/macros_inline.rb +1 -1
  9. data/lib/metanorma/standoc/reqt.rb +19 -75
  10. data/lib/metanorma/standoc/section.rb +35 -3
  11. data/lib/metanorma/standoc/utils.rb +9 -43
  12. data/lib/metanorma/standoc/validate.rb +1 -69
  13. data/lib/metanorma/standoc/validate_table.rb +91 -0
  14. data/lib/metanorma/standoc/version.rb +1 -1
  15. data/metanorma-standoc.gemspec +2 -2
  16. data/spec/metanorma/biblio_spec.rb +9 -9
  17. data/spec/metanorma/blocks_spec.rb +20 -266
  18. data/spec/metanorma/cleanup_blocks_spec.rb +0 -168
  19. data/spec/metanorma/macros_concept_spec.rb +1033 -0
  20. data/spec/metanorma/macros_spec.rb +1 -1031
  21. data/spec/metanorma/refs_spec.rb +0 -2
  22. data/spec/metanorma/reqt_spec.rb +130 -0
  23. data/spec/metanorma/section_spec.rb +5 -0
  24. data/spec/metanorma/validate_spec.rb +46 -6
  25. data/spec/vcr_cassettes/bsi16341.yml +80 -52
  26. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +94 -94
  27. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec1.yml +10 -10
  28. data/spec/vcr_cassettes/hide_refs.yml +74 -74
  29. data/spec/vcr_cassettes/isobib_get_123.yml +11 -11
  30. data/spec/vcr_cassettes/isobib_get_123_1.yml +22 -22
  31. data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +30 -30
  32. data/spec/vcr_cassettes/isobib_get_123_2.yml +23 -23
  33. data/spec/vcr_cassettes/isobib_get_123_2001.yml +9 -9
  34. data/spec/vcr_cassettes/isobib_get_124.yml +10 -10
  35. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +30 -60
  36. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +45 -45
  37. data/spec/vcr_cassettes/std-link.yml +11 -11
  38. metadata +10 -7
@@ -1732,7 +1732,6 @@ RSpec.describe Metanorma::Standoc do
1732
1732
  <title type='main' format='text/plain'>Network Configuration Access Control Model</title>
1733
1733
  <uri type='src'>https://www.rfc-editor.org/info/rfc8341</uri>
1734
1734
  <docidentifier type='IETF' primary='true'>RFC 8341</docidentifier>
1735
- <docidentifier type='IETF' scope='anchor'>RFC8341</docidentifier>
1736
1735
  <docidentifier type='DOI'>10.17487/RFC8341</docidentifier>
1737
1736
  <docnumber>RFC8341</docnumber>
1738
1737
  <date type='published'>
@@ -1787,7 +1786,6 @@ RSpec.describe Metanorma::Standoc do
1787
1786
  <uri type='src'>https://www.rfc-editor.org/info/rfc8341</uri>
1788
1787
  <docidentifier type='IETF' primary='true'>RFC 8341</docidentifier>
1789
1788
  <docidentifier type='metanorma'>[1]</docidentifier>
1790
- <docidentifier type='IETF' scope='anchor'>RFC8341</docidentifier>
1791
1789
  <docidentifier type='DOI'>10.17487/RFC8341</docidentifier>
1792
1790
  <docnumber>RFC8341</docnumber>
1793
1791
  <date type='published'>
@@ -0,0 +1,130 @@
1
+ require "spec_helper"
2
+ require "open3"
3
+
4
+ RSpec.describe Metanorma::Standoc do
5
+ it "processes recommendation" do
6
+ input = <<~"INPUT"
7
+ #{ASCIIDOC_BLANK_HDR}
8
+ [.recommendation,identifier="/ogc/recommendation/wfs/2",subject="user;developer, implementer",inherit="/ss/584/2015/level/1; /ss/584/2015/level/2",options="unnumbered",type=verification,model=ogc,tag=X,multilingual-rendering=common]
9
+ ====
10
+ I recommend this
11
+ ====
12
+ INPUT
13
+ output = <<~"OUTPUT"
14
+ #{BLANK_HDR}
15
+ <sections>
16
+ <recommendation id="_" unnumbered="true" type="verification" model="ogc" tag='X' multilingual-rendering='common'>
17
+ <identifier>/ogc/recommendation/wfs/2</identifier>
18
+ <subject>user</subject>
19
+ <subject>developer, implementer</subject>
20
+ <inherit>/ss/584/2015/level/1</inherit>
21
+ <inherit>/ss/584/2015/level/2</inherit>
22
+ <description><p id="_">I recommend this</p>
23
+ </description>
24
+ </recommendation>
25
+ </sections>
26
+ </standard-document>
27
+ OUTPUT
28
+
29
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
30
+ .to be_equivalent_to xmlpp(output)
31
+ end
32
+
33
+ it "applies default requirement model" do
34
+ mock_default_recommendation_model("ogc")
35
+ input = <<~"INPUT"
36
+ #{ASCIIDOC_BLANK_HDR}
37
+
38
+ [[A]]
39
+ [.permission]
40
+ ====
41
+ I permit this
42
+
43
+
44
+ [[B]]
45
+ [.permission]
46
+ =====
47
+ I also permit this
48
+
49
+ . List
50
+ . List
51
+ =====
52
+ ====
53
+ INPUT
54
+
55
+ xml = Nokogiri::XML(Asciidoctor.convert(input, *OPTIONS))
56
+ expect(xml.at("//xmlns:permission[@id = 'A']/@model").text).to eq("ogc")
57
+ expect(xml.at("//xmlns:permission/xmlns:permission/@model").text)
58
+ .to eq("ogc")
59
+ end
60
+
61
+ it "overrides default requirement model" do
62
+ mock_default_recommendation_model("ogc")
63
+ input = <<~"INPUT"
64
+ = Document title
65
+ Author
66
+ :docfile: test.adoc
67
+ :nodoc:
68
+ :novalid:
69
+ :no-isobib:
70
+ :data-uri-image: false
71
+ :requirements-model: default
72
+
73
+ [[A]]
74
+ [.permission]
75
+ ====
76
+ I permit this
77
+
78
+ [[B]]
79
+ [.permission]
80
+ =====
81
+ I also permit this
82
+
83
+ . List
84
+ . List
85
+ =====
86
+ ====
87
+ INPUT
88
+
89
+ xml = Nokogiri::XML(Asciidoctor.convert(input, *OPTIONS))
90
+ expect(xml.at("//xmlns:permission[@id = 'A']/@model").text).to eq("default")
91
+ expect(xml.at("//xmlns:permission/xmlns:permission/@model").text)
92
+ .to eq("default")
93
+ end
94
+
95
+ it "inherits requirement model from parent" do
96
+ mock_default_recommendation_model("ogc")
97
+ input = <<~"INPUT"
98
+
99
+ #{ASCIIDOC_BLANK_HDR}
100
+ [[A]]
101
+ [.permission,model=ogc]
102
+ ====
103
+ I permit this
104
+
105
+ [[B]]
106
+ [.permission,model=default]
107
+ =====
108
+ I also permit this
109
+
110
+ . List
111
+ . List
112
+ =====
113
+ ====
114
+ INPUT
115
+
116
+ xml = Nokogiri::XML(Asciidoctor.convert(input, *OPTIONS))
117
+ expect(xml.at("//xmlns:permission[@id = 'A']/@model").text).to eq("ogc")
118
+ expect(xml.at("//xmlns:permission/xmlns:permission/@model").text)
119
+ .to eq("ogc")
120
+ end
121
+
122
+ private
123
+
124
+ def mock_default_recommendation_model(model)
125
+ allow_any_instance_of(::Metanorma::Standoc::Blocks)
126
+ .to receive(:default_requirement_model).and_return(
127
+ model,
128
+ )
129
+ end
130
+ end
@@ -77,6 +77,8 @@ RSpec.describe Metanorma::Standoc do
77
77
 
78
78
  == Terms and Definitions
79
79
 
80
+ == Acknowledgements
81
+
80
82
  [appendix]
81
83
  == Annex
82
84
 
@@ -175,6 +177,9 @@ RSpec.describe Metanorma::Standoc do
175
177
  <clause id="_" inline-header="false" obligation="normative">
176
178
  <title>Terms and Definitions</title>
177
179
  </clause>
180
+ <clause id='_' inline-header='false' obligation='normative'>
181
+ <title>Acknowledgements</title>
182
+ </clause>
178
183
  </sections><annex id="_" inline-header="false" obligation="normative">
179
184
  <title>Annex</title>
180
185
  <clause id="_" inline-header="false" obligation="normative">
@@ -30,7 +30,9 @@ RSpec.describe Metanorma::Standoc do
30
30
  [[abc]]
31
31
  == Clause 2
32
32
  INPUT
33
- expect { Asciidoctor.convert(input, *OPTIONS) }.to raise_error(SystemExit)
33
+ expect do
34
+ Asciidoctor.convert(input, *OPTIONS)
35
+ end.to raise_error(SystemExit)
34
36
  rescue SystemExit
35
37
  end
36
38
  expect(File.read("test.err"))
@@ -387,7 +389,9 @@ RSpec.describe Metanorma::Standoc do
387
389
  {{<<def>>,term}}
388
390
  {{<<ghi>>,term}}
389
391
  INPUT
390
- expect { Asciidoctor.convert(input, *OPTIONS) }.to raise_error(SystemExit)
392
+ expect do
393
+ Asciidoctor.convert(input, *OPTIONS)
394
+ end.to raise_error(SystemExit)
391
395
  rescue SystemExit
392
396
  end
393
397
  expect(File.read("test.err"))
@@ -420,7 +424,9 @@ RSpec.describe Metanorma::Standoc do
420
424
  related:see[<<def>>,term]
421
425
  related:see[<<ghi>>,term]
422
426
  INPUT
423
- expect { Asciidoctor.convert(input, *OPTIONS) }.to raise_error(SystemExit)
427
+ expect do
428
+ Asciidoctor.convert(input, *OPTIONS)
429
+ end.to raise_error(SystemExit)
424
430
  rescue SystemExit
425
431
  end
426
432
  expect(File.read("test.err"))
@@ -448,7 +454,9 @@ RSpec.describe Metanorma::Standoc do
448
454
  [[abc]]
449
455
  == Clause 2
450
456
  INPUT
451
- expect { Asciidoctor.convert(input, *OPTIONS) }.to raise_error(SystemExit)
457
+ expect do
458
+ Asciidoctor.convert(input, *OPTIONS)
459
+ end.to raise_error(SystemExit)
452
460
  rescue SystemExit
453
461
  end
454
462
  expect(File.read("test.err"))
@@ -470,7 +478,9 @@ RSpec.describe Metanorma::Standoc do
470
478
  == Normative references
471
479
  * [[[A,1]]]
472
480
  INPUT
473
- expect { Asciidoctor.convert(input, *OPTIONS) }.to raise_error(SystemExit)
481
+ expect do
482
+ Asciidoctor.convert(input, *OPTIONS)
483
+ end.to raise_error(SystemExit)
474
484
  rescue SystemExit
475
485
  end
476
486
  expect(File.read("test.err"))
@@ -493,7 +503,6 @@ RSpec.describe Metanorma::Standoc do
493
503
  [cols="1,1,1,1"]
494
504
  |===
495
505
  3.2+| a | a
496
-
497
506
  | a
498
507
  | a | a | a | a
499
508
  |===
@@ -507,6 +516,37 @@ RSpec.describe Metanorma::Standoc do
507
516
  .not_to include "Table exceeds maximum number of columns defined"
508
517
  expect(File.read("test.err"))
509
518
  .not_to include "Table rows in table are inconsistent: check rowspan"
519
+ expect(File.read("test.err"))
520
+ .not_to include "Table rows in table cannot go outside thead: check rowspan"
521
+ end
522
+
523
+ it "warns if rowspan goes across thead" do
524
+ FileUtils.rm_f "test.xml"
525
+ FileUtils.rm_f "test.err"
526
+ begin
527
+ input = <<~INPUT
528
+ = Document title
529
+ Author
530
+ :docfile: test.adoc
531
+ :nodoc:
532
+
533
+ == Clause
534
+
535
+ [cols="1,1,1,1",headerrows=2]
536
+ |===
537
+ 3.3+| a | a
538
+
539
+ | a
540
+ | a | a | a | a
541
+ |===
542
+ INPUT
543
+ expect do
544
+ Asciidoctor.convert(input, *OPTIONS)
545
+ end.to raise_error(SystemExit)
546
+ rescue SystemExit
547
+ end
548
+ expect(File.read("test.err"))
549
+ .to include "Table rows in table cannot go outside thead: check rowspan"
510
550
  end
511
551
 
512
552
  xit "warns and aborts if columns out of bounds against colgroup" do