metanorma-iso 1.10.6 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +26 -0
  3. data/Makefile +1 -1
  4. data/lib/asciidoctor/iso/base.rb +2 -69
  5. data/lib/asciidoctor/iso/cleanup.rb +2 -175
  6. data/lib/asciidoctor/iso/converter.rb +2 -17
  7. data/lib/asciidoctor/iso/deprecated.rb +5 -0
  8. data/lib/asciidoctor/iso/front.rb +2 -169
  9. data/lib/asciidoctor/iso/front_id.rb +2 -224
  10. data/lib/asciidoctor/iso/section.rb +2 -48
  11. data/lib/asciidoctor/iso/validate.rb +2 -171
  12. data/lib/asciidoctor/iso/validate_image.rb +2 -96
  13. data/lib/asciidoctor/iso/validate_requirements.rb +2 -110
  14. data/lib/asciidoctor/iso/validate_section.rb +2 -246
  15. data/lib/asciidoctor/iso/validate_style.rb +2 -169
  16. data/lib/asciidoctor/iso/validate_title.rb +2 -104
  17. data/lib/isodoc/iso/html/htmlstyle.css +47 -0
  18. data/lib/isodoc/iso/html/isodoc.css +1326 -0
  19. data/lib/isodoc/iso/html/isodoc.scss +0 -1
  20. data/lib/isodoc/iso/html/style-human.css +1015 -0
  21. data/lib/isodoc/iso/html/style-human.scss +8 -2
  22. data/lib/isodoc/iso/html/style-iso.css +1042 -0
  23. data/lib/isodoc/iso/html/style-iso.scss +9 -2
  24. data/lib/isodoc/iso/html/wordstyle.css +1701 -0
  25. data/lib/isodoc/iso/html_convert.rb +6 -4
  26. data/lib/isodoc/iso/iso.amendment.xsl +2142 -1565
  27. data/lib/isodoc/iso/iso.international-standard.xsl +2142 -1565
  28. data/lib/isodoc/iso/word_convert.rb +2 -0
  29. data/lib/metanorma/iso/base.rb +70 -0
  30. data/lib/{asciidoctor → metanorma}/iso/basicdoc.rng +5 -3
  31. data/lib/{asciidoctor → metanorma}/iso/biblio.rng +7 -5
  32. data/lib/{asciidoctor → metanorma}/iso/boilerplate-fr.xml +0 -0
  33. data/lib/{asciidoctor → metanorma}/iso/boilerplate.xml +0 -0
  34. data/lib/metanorma/iso/cleanup.rb +176 -0
  35. data/lib/metanorma/iso/converter.rb +18 -0
  36. data/lib/metanorma/iso/front.rb +170 -0
  37. data/lib/metanorma/iso/front_id.rb +225 -0
  38. data/lib/{asciidoctor → metanorma}/iso/isodoc.rng +98 -1
  39. data/lib/{asciidoctor → metanorma}/iso/isostandard-amd.rng +0 -0
  40. data/lib/{asciidoctor → metanorma}/iso/isostandard.rnc +0 -0
  41. data/lib/{asciidoctor → metanorma}/iso/isostandard.rng +0 -0
  42. data/lib/{asciidoctor → metanorma}/iso/reqt.rng +0 -0
  43. data/lib/metanorma/iso/section.rb +49 -0
  44. data/lib/metanorma/iso/validate.rb +172 -0
  45. data/lib/metanorma/iso/validate_image.rb +97 -0
  46. data/lib/metanorma/iso/validate_requirements.rb +111 -0
  47. data/lib/metanorma/iso/validate_section.rb +248 -0
  48. data/lib/metanorma/iso/validate_style.rb +170 -0
  49. data/lib/metanorma/iso/validate_title.rb +105 -0
  50. data/lib/metanorma/iso/version.rb +1 -1
  51. data/lib/metanorma-iso.rb +1 -1
  52. data/metanorma-iso.gemspec +1 -1
  53. data/spec/isodoc/ref_spec.rb +4 -2
  54. data/spec/isodoc/xref_spec.rb +18 -18
  55. data/spec/{asciidoctor → metanorma}/amd_spec.rb +1 -1
  56. data/spec/{asciidoctor → metanorma}/base_spec.rb +158 -197
  57. data/spec/{asciidoctor → metanorma}/blank_spec.rb +1 -1
  58. data/spec/{asciidoctor → metanorma}/blocks_spec.rb +1 -1
  59. data/spec/{asciidoctor → metanorma}/cleanup_spec.rb +1 -1
  60. data/spec/{asciidoctor → metanorma}/inline_spec.rb +1 -1
  61. data/spec/{asciidoctor → metanorma}/lists_spec.rb +1 -1
  62. data/spec/{asciidoctor → metanorma}/refs_spec.rb +2 -5
  63. data/spec/{asciidoctor → metanorma}/section_spec.rb +1 -1
  64. data/spec/{asciidoctor → metanorma}/table_spec.rb +1 -1
  65. data/spec/{asciidoctor → metanorma}/validate_spec.rb +28 -3
  66. data/spec/spec_helper.rb +1 -1
  67. metadata +46 -30
  68. data/spec/vcr_cassettes/docrels.yml +0 -393
  69. data/spec/vcr_cassettes/sortrefs.yml +0 -599
@@ -0,0 +1,105 @@
1
+ require "metanorma-standoc"
2
+
3
+ module Metanorma
4
+ module ISO
5
+ class Converter < Standoc::Converter
6
+ def title_lang_part(doc, part, lang)
7
+ doc.at("//bibdata/title[@type='title-#{part}' and @language='#{lang}']")
8
+ end
9
+
10
+ def title_intro_validate(root)
11
+ title_intro_en = title_lang_part(root, "intro", "en")
12
+ title_intro_fr = title_lang_part(root, "intro", "fr")
13
+ if title_intro_en.nil? && !title_intro_fr.nil?
14
+ @log.add("Style", title_intro_fr, "No English Title Intro!")
15
+ end
16
+ if !title_intro_en.nil? && title_intro_fr.nil?
17
+ @log.add("Style", title_intro_en, "No French Title Intro!")
18
+ end
19
+ end
20
+
21
+ def title_main_validate(root)
22
+ title_main_en = title_lang_part(root, "main", "en")
23
+ title_main_fr = title_lang_part(root, "main", "fr")
24
+ if title_main_en.nil? && !title_main_fr.nil?
25
+ @log.add("Style", title_main_fr, "No English Title!")
26
+ end
27
+ if !title_main_en.nil? && title_main_fr.nil?
28
+ @log.add("Style", title_main_en, "No French Title!")
29
+ end
30
+ end
31
+
32
+ def title_part_validate(root)
33
+ title_part_en = title_lang_part(root, "part", "en")
34
+ title_part_fr = title_lang_part(root, "part", "fr")
35
+ (title_part_en.nil? && !title_part_fr.nil?) &&
36
+ @log.add("Style", title_part_fr, "No English Title Part!")
37
+ (!title_part_en.nil? && title_part_fr.nil?) &&
38
+ @log.add("Style", title_part_en, "No French Title Part!")
39
+ end
40
+
41
+ # ISO/IEC DIR 2, 11.4
42
+ def title_subpart_validate(root)
43
+ docid = root.at("//bibdata/docidentifier[@type = 'ISO']")
44
+ subpart = /-\d+-\d+/.match docid
45
+ iec = root.at("//bibdata/contributor[role/@type = 'publisher']/"\
46
+ "organization[abbreviation = 'IEC' or "\
47
+ "name = 'International Electrotechnical Commission']")
48
+ subpart && !iec and
49
+ @log.add("Style", docid, "Subpart defined on non-IEC document!")
50
+ end
51
+
52
+ # ISO/IEC DIR 2, 11.5.2
53
+ def title_names_type_validate(root)
54
+ doctypes = /International\sStandard | Technical\sSpecification |
55
+ Publicly\sAvailable\sSpecification | Technical\sReport | Guide /xi
56
+ title_main_en = title_lang_part(root, "main", "en")
57
+ !title_main_en.nil? && doctypes.match(title_main_en.text) and
58
+ @log.add("Style", title_main_en, "Main Title may name document type")
59
+ title_intro_en = title_lang_part(root, "intro", "en")
60
+ !title_intro_en.nil? && doctypes.match(title_intro_en.text) and
61
+ @log.add("Style", title_intro_en,
62
+ "Title Intro may name document type")
63
+ end
64
+
65
+ # ISO/IEC DIR 2, 22.2
66
+ def title_first_level_validate(root)
67
+ root.xpath(SECTIONS_XPATH).each do |s|
68
+ title = s&.at("./title")&.text || s.name
69
+ s.xpath("./clause | ./terms | ./references").each do |ss|
70
+ subtitle = ss.at("./title")
71
+ !subtitle.nil? && !subtitle&.text&.empty? or
72
+ @log.add("Style", ss,
73
+ "#{title}: each first-level subclause must have a title")
74
+ end
75
+ end
76
+ end
77
+
78
+ # ISO/IEC DIR 2, 22.2
79
+ def title_all_siblings(xpath, label)
80
+ notitle = false
81
+ withtitle = false
82
+ xpath.each do |s|
83
+ title_all_siblings(s.xpath("./clause | ./terms | ./references"),
84
+ s&.at("./title")&.text || s["id"])
85
+ subtitle = s.at("./title")
86
+ notitle = notitle || (!subtitle || subtitle.text.empty?)
87
+ withtitle = withtitle || (subtitle && !subtitle.text.empty?)
88
+ end
89
+ notitle && withtitle &&
90
+ @log.add("Style", nil,
91
+ "#{label}: all subclauses must have a title, or none")
92
+ end
93
+
94
+ def title_validate(root)
95
+ title_intro_validate(root)
96
+ title_main_validate(root)
97
+ title_part_validate(root)
98
+ title_subpart_validate(root)
99
+ title_names_type_validate(root)
100
+ title_first_level_validate(root)
101
+ title_all_siblings(root.xpath(SECTIONS_XPATH), "(top level)")
102
+ end
103
+ end
104
+ end
105
+ end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module ISO
3
- VERSION = "1.10.6".freeze
3
+ VERSION = "2.0.3".freeze
4
4
  end
5
5
  end
data/lib/metanorma-iso.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require "asciidoctor" unless defined? Asciidoctor::Converter
2
- require_relative "asciidoctor/iso/converter"
2
+ require_relative "metanorma/iso/converter"
3
3
  require_relative "metanorma/iso/version"
4
4
  require_relative "isodoc/iso/html_convert"
5
5
  require_relative "isodoc/iso/word_convert"
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.test_files = `git ls-files -- {spec}/*`.split("\n")
30
30
  spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
31
31
 
32
- spec.add_dependency "metanorma-standoc", "~> 1.11.0"
32
+ spec.add_dependency "metanorma-standoc", "~> 2.0.0"
33
33
  spec.add_dependency "mnconvert", "~> 1.14"
34
34
  spec.add_dependency "ruby-jing"
35
35
  spec.add_dependency "tokenizer", "~> 0.3.0"
@@ -272,6 +272,7 @@ RSpec.describe IsoDoc do
272
272
  </note>
273
273
  <bibitem id="ISO3696" type="standard">
274
274
  <title format="text/plain">Water for analytical laboratory use</title>
275
+ <docidentifier type='metanorma-ordinal'>[1]</docidentifier>
275
276
  <docidentifier type="ISO">ISO 3696</docidentifier>
276
277
  <contributor>
277
278
  <role type="publisher"/>
@@ -294,6 +295,7 @@ RSpec.describe IsoDoc do
294
295
  </bibitem>
295
296
  <bibitem id="ref11">
296
297
  <title>Internet Calendaring and Scheduling Core Object Specification (iCalendar)</title>
298
+ <docidentifier type='metanorma-ordinal'>[2]</docidentifier>
297
299
  <docidentifier type="IETF">IETF RFC 10</docidentifier>
298
300
  </bibitem>
299
301
  <bibitem id="ref12">
@@ -361,7 +363,7 @@ RSpec.describe IsoDoc do
361
363
  <p>
362
364
  <span class="note_label">NOTE</span>&#160; This is another annotation of document ISSN.</p>
363
365
  </div>
364
- <p class="Biblio" id="ISO3696">[3]&#160; ISO 3696,
366
+ <p class="Biblio" id="ISO3696">[1]&#160; ISO 3696,
365
367
  <i>Water for analytical laboratory use</i></p>
366
368
  <p class="Biblio" id="ref10">[10]&#160; <span style="font-variant:small-caps;">Standard No I.C.C 167</span>
367
369
  .
@@ -369,7 +371,7 @@ RSpec.describe IsoDoc do
369
371
  (see
370
372
  <a href="http://www.icc.or.at">http://www.icc.or.at</a>
371
373
  )</p>
372
- <p class="Biblio" id="ref11">[5]&#160; IETF RFC 10,
374
+ <p class="Biblio" id="ref11">[2]&#160; IETF RFC 10,
373
375
  <i>Internet Calendaring and Scheduling Core Object Specification (iCalendar)</i></p>
374
376
  <p class="Biblio" id="ref12">Citn&#160; IETF RFC 20, CitationWorks. 2019.
375
377
  <i>How to cite a reference</i>
@@ -1373,7 +1373,7 @@ RSpec.describe IsoDoc do
1373
1373
  <title depth="1">1
1374
1374
  <tab/>
1375
1375
  Scope</title>
1376
- <ol id="N">
1376
+ <ol id="N" type="alphabet">
1377
1377
  <li>
1378
1378
  <p>A</p>
1379
1379
  </li>
@@ -1388,12 +1388,12 @@ RSpec.describe IsoDoc do
1388
1388
  Widgets</title>
1389
1389
  <clause id="widgets1" inline-header="true">
1390
1390
  <title>3.1</title>
1391
- <ol id="note1">
1391
+ <ol id="note1" type="alphabet">
1392
1392
  <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different
1393
1393
  types of kernel.
1394
1394
  </p>
1395
1395
  </ol>
1396
- <ol id="note2">
1396
+ <ol id="note2" type="alphabet">
1397
1397
  <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83a">These results are based on a study carried out on three different
1398
1398
  types of kernel.
1399
1399
  </p>
@@ -1407,7 +1407,7 @@ RSpec.describe IsoDoc do
1407
1407
  <br/>(informative)</title>
1408
1408
  <clause id="annex1a" inline-header="true">
1409
1409
  <title>A.1</title>
1410
- <ol id="AN">
1410
+ <ol id="AN" type="alphabet">
1411
1411
  <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different
1412
1412
  types of kernel.
1413
1413
  </p>
@@ -1415,12 +1415,12 @@ RSpec.describe IsoDoc do
1415
1415
  </clause>
1416
1416
  <clause id="annex1b" inline-header="true">
1417
1417
  <title>A.2</title>
1418
- <ol id="Anote1">
1418
+ <ol id="Anote1" type="alphabet">
1419
1419
  <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different
1420
1420
  types of kernel.
1421
1421
  </p>
1422
1422
  </ol>
1423
- <ol id="Anote2">
1423
+ <ol id="Anote2" type="alphabet">
1424
1424
  <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83a">These results are based on a study carried out on three different
1425
1425
  types of kernel.
1426
1426
  </p>
@@ -1513,7 +1513,7 @@ RSpec.describe IsoDoc do
1513
1513
  <sections>
1514
1514
  <clause id='scope' type='scope' displayorder='2'>
1515
1515
  <title depth='1'>1<tab/>Scope</title>
1516
- <ol id='N1'>
1516
+ <ol id='N1' type="alphabet">
1517
1517
  <li id='N'>
1518
1518
  <p>A</p>
1519
1519
  </li>
@@ -1523,12 +1523,12 @@ RSpec.describe IsoDoc do
1523
1523
  <clause id='widgets' displayorder='4'>
1524
1524
  <title depth='1'>3<tab/>Widgets</title>
1525
1525
  <clause inline-header="true" id='widgets1'><title>3.1</title>
1526
- <ol id='note1l'>
1526
+ <ol id='note1l' type="alphabet">
1527
1527
  <li id='note1'>
1528
1528
  <p>A</p>
1529
1529
  </li>
1530
1530
  </ol>
1531
- <ol id='note2l'>
1531
+ <ol id='note2l' type="alphabet">
1532
1532
  <li id='note2'>
1533
1533
  <p>A</p>
1534
1534
  </li>
@@ -1538,19 +1538,19 @@ RSpec.describe IsoDoc do
1538
1538
  </sections>
1539
1539
  <annex id='annex1' displayorder='5'><title><strong>Annex A</strong><br/>(informative)</title>
1540
1540
  <clause inline-header="true" id='annex1a'><title>A.1</title>
1541
- <ol id='ANl'>
1541
+ <ol id='ANl' type="alphabet">
1542
1542
  <li id='AN'>
1543
1543
  <p>A</p>
1544
1544
  </li>
1545
1545
  </ol>
1546
1546
  </clause>
1547
1547
  <clause inline-header="true" id='annex1b'><title>A.2</title>
1548
- <ol id='Anote1l'>
1548
+ <ol id='Anote1l' type="alphabet">
1549
1549
  <li id='Anote1'>
1550
1550
  <p>A</p>
1551
1551
  </li>
1552
1552
  </ol>
1553
- <ol id='Anote2l'>
1553
+ <ol id='Anote2l' type="alphabet">
1554
1554
  <li id='Anote2'>
1555
1555
  <p>A</p>
1556
1556
  </li>
@@ -1633,22 +1633,22 @@ RSpec.describe IsoDoc do
1633
1633
  <sections>
1634
1634
  <clause id='scope' type='scope' displayorder='2'>
1635
1635
  <title depth='1'>1<tab/>Scope</title>
1636
- <ol id='N1'>
1636
+ <ol id='N1' type="alphabet">
1637
1637
  <li id='N'>
1638
1638
  <p>A</p>
1639
- <ol>
1639
+ <ol type="arabic">
1640
1640
  <li id='note1'>
1641
1641
  <p>A</p>
1642
- <ol>
1642
+ <ol type="roman">
1643
1643
  <li id='note2'>
1644
1644
  <p>A</p>
1645
- <ol>
1645
+ <ol type="alphabet_upper">
1646
1646
  <li id='AN'>
1647
1647
  <p>A</p>
1648
- <ol>
1648
+ <ol type="roman_upper">
1649
1649
  <li id='Anote1'>
1650
1650
  <p>A</p>
1651
- <ol>
1651
+ <ol type="alphabet">
1652
1652
  <li id='Anote2'>
1653
1653
  <p>A</p>
1654
1654
  </li>
@@ -1,6 +1,6 @@
1
1
  require "spec_helper"
2
2
 
3
- RSpec.describe Asciidoctor::ISO do
3
+ RSpec.describe Metanorma::ISO do
4
4
  it "processes amendment sections" do
5
5
  expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", *OPTIONS)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
6
6
  #{AMD_BLANK_HDR}