metanorma-standoc 2.1.5 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/lib/metanorma/standoc/base.rb +13 -0
  3. data/lib/metanorma/standoc/blocks.rb +26 -17
  4. data/lib/metanorma/standoc/cleanup.rb +1 -1
  5. data/lib/metanorma/standoc/cleanup_biblio.rb +210 -0
  6. data/lib/metanorma/standoc/cleanup_block.rb +6 -4
  7. data/lib/metanorma/standoc/cleanup_maths.rb +2 -15
  8. data/lib/metanorma/standoc/cleanup_ref.rb +22 -13
  9. data/lib/metanorma/standoc/cleanup_reqt.rb +3 -103
  10. data/lib/metanorma/standoc/cleanup_symbols.rb +1 -1
  11. data/lib/metanorma/standoc/cleanup_text.rb +10 -8
  12. data/lib/metanorma/standoc/cleanup_xref.rb +1 -2
  13. data/lib/metanorma/standoc/converter.rb +2 -0
  14. data/lib/metanorma/standoc/front.rb +1 -1
  15. data/lib/metanorma/standoc/front_contributor.rb +0 -10
  16. data/lib/metanorma/standoc/inline.rb +8 -4
  17. data/lib/metanorma/standoc/isodoc.rng +6 -1
  18. data/lib/metanorma/standoc/macros.rb +1 -180
  19. data/lib/metanorma/standoc/macros_inline.rb +194 -0
  20. data/lib/metanorma/standoc/ref_sect.rb +2 -2
  21. data/lib/metanorma/standoc/ref_utility.rb +1 -1
  22. data/lib/metanorma/standoc/reqt.rb +19 -75
  23. data/lib/metanorma/standoc/reqt.rng +1 -1
  24. data/lib/metanorma/standoc/section.rb +35 -3
  25. data/lib/metanorma/standoc/utils.rb +9 -43
  26. data/lib/metanorma/standoc/validate.rb +1 -69
  27. data/lib/metanorma/standoc/validate_table.rb +91 -0
  28. data/lib/metanorma/standoc/version.rb +1 -1
  29. data/metanorma-standoc.gemspec +4 -5
  30. data/spec/metanorma/{refs_dl_spec.rb → biblio_spec.rb} +90 -7
  31. data/spec/metanorma/blocks_spec.rb +31 -267
  32. data/spec/metanorma/cleanup_blocks_spec.rb +0 -171
  33. data/spec/metanorma/inline_spec.rb +4 -0
  34. data/spec/metanorma/macros_concept_spec.rb +1033 -0
  35. data/spec/metanorma/macros_spec.rb +2 -1030
  36. data/spec/metanorma/refs_spec.rb +0 -2
  37. data/spec/metanorma/reqt_spec.rb +130 -0
  38. data/spec/metanorma/section_spec.rb +5 -0
  39. data/spec/metanorma/validate_spec.rb +46 -6
  40. data/spec/vcr_cassettes/bsi16341.yml +80 -52
  41. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +94 -94
  42. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec1.yml +12 -12
  43. data/spec/vcr_cassettes/hide_refs.yml +70 -70
  44. data/spec/vcr_cassettes/isobib_get_123.yml +11 -11
  45. data/spec/vcr_cassettes/isobib_get_123_1.yml +23 -23
  46. data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +35 -35
  47. data/spec/vcr_cassettes/isobib_get_123_2.yml +22 -22
  48. data/spec/vcr_cassettes/isobib_get_123_2001.yml +13 -13
  49. data/spec/vcr_cassettes/isobib_get_124.yml +11 -11
  50. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +34 -64
  51. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +45 -45
  52. data/spec/vcr_cassettes/std-link.yml +12 -12
  53. metadata +15 -11
  54. data/lib/metanorma/standoc/cleanup_ref_dl.rb +0 -113
@@ -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