metanorma-iso 2.0.2 → 2.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/lib/isodoc/iso/html/html_iso_titlepage.html +1 -1
  4. data/lib/isodoc/iso/html/isodoc.css +1 -2
  5. data/lib/isodoc/iso/html/isodoc.scss +0 -1
  6. data/lib/isodoc/iso/html/word_iso_titlepage.html +1 -1
  7. data/lib/isodoc/iso/html/wordstyle.css +20 -0
  8. data/lib/isodoc/iso/html/wordstyle.scss +20 -0
  9. data/lib/isodoc/iso/i18n-en.yaml +29 -2
  10. data/lib/isodoc/iso/i18n-fr.yaml +27 -3
  11. data/lib/isodoc/iso/i18n-ru.yaml +45 -0
  12. data/lib/isodoc/iso/i18n-zh-Hans.yaml +27 -3
  13. data/lib/isodoc/iso/i18n.rb +1 -0
  14. data/lib/isodoc/iso/init.rb +1 -2
  15. data/lib/isodoc/iso/iso.amendment.xsl +1752 -807
  16. data/lib/isodoc/iso/iso.international-standard.xsl +1752 -807
  17. data/lib/isodoc/iso/metadata.rb +12 -2
  18. data/lib/isodoc/iso/presentation_xml_convert.rb +58 -21
  19. data/lib/metanorma/iso/basicdoc.rng +5 -3
  20. data/lib/metanorma/iso/biblio.rng +5 -3
  21. data/lib/metanorma/iso/boilerplate-fr.xml +3 -3
  22. data/lib/metanorma/iso/boilerplate-ru.xml +39 -0
  23. data/lib/metanorma/iso/boilerplate.xml +3 -3
  24. data/lib/metanorma/iso/cleanup.rb +42 -11
  25. data/lib/metanorma/iso/front.rb +1 -1
  26. data/lib/metanorma/iso/front_id.rb +1 -0
  27. data/lib/metanorma/iso/isodoc.rng +73 -3
  28. data/lib/metanorma/iso/processor.rb +14 -7
  29. data/lib/metanorma/iso/validate.rb +30 -2
  30. data/lib/metanorma/iso/validate_image.rb +3 -3
  31. data/lib/metanorma/iso/validate_list.rb +107 -0
  32. data/lib/metanorma/iso/validate_section.rb +42 -34
  33. data/lib/metanorma/iso/validate_style.rb +32 -2
  34. data/lib/metanorma/iso/validate_title.rb +13 -1
  35. data/lib/metanorma/iso/version.rb +1 -1
  36. data/spec/isodoc/amd_spec.rb +10 -5
  37. data/spec/isodoc/i18n_spec.rb +350 -9
  38. data/spec/isodoc/inline_spec.rb +127 -10
  39. data/spec/isodoc/metadata_spec.rb +153 -3
  40. data/spec/isodoc/postproc_spec.rb +3 -4
  41. data/spec/isodoc/section_spec.rb +1 -0
  42. data/spec/isodoc/terms_spec.rb +4 -4
  43. data/spec/isodoc/xref_spec.rb +18 -18
  44. data/spec/metanorma/base_spec.rb +434 -375
  45. data/spec/metanorma/cleanup_spec.rb +11 -11
  46. data/spec/metanorma/refs_spec.rb +333 -65
  47. data/spec/metanorma/section_spec.rb +15 -20
  48. data/spec/metanorma/validate_spec.rb +449 -14
  49. data/spec/spec_helper.rb +6 -4
  50. data/spec/vcr_cassettes/docrels.yml +211 -16
  51. data/spec/vcr_cassettes/withdrawn_iso.yml +301 -0
  52. metadata +6 -3
  53. data/spec/vcr_cassettes/sortrefs.yml +0 -599
@@ -733,6 +733,17 @@ RSpec.describe Metanorma::ISO do
733
733
  .to include "space between number and degrees/minutes/seconds"
734
734
  end
735
735
 
736
+ it "Style warning if hyphen instead of minus sign" do
737
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
738
+ #{VALIDATING_BLANK_HDR}
739
+
740
+ == Clause
741
+ -2
742
+ INPUT
743
+ expect(File.read("test.err"))
744
+ .to include "hyphen instead of minus sign U+2212"
745
+ end
746
+
736
747
  it "Style warning if no space between number and SI unit" do
737
748
  Asciidoctor.convert(<<~"INPUT", *OPTIONS)
738
749
  #{VALIDATING_BLANK_HDR}
@@ -754,6 +765,61 @@ RSpec.describe Metanorma::ISO do
754
765
  expect(File.read("test.err")).to include "non-standard unit"
755
766
  end
756
767
 
768
+ it "Style warning if and/or used" do
769
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
770
+ #{VALIDATING_BLANK_HDR}
771
+
772
+ == Clause
773
+ 7 and/or 8
774
+ INPUT
775
+ expect(File.read("test.err")).to include "Use 'either x or y, or both'"
776
+ end
777
+
778
+ it "Style warning if & used" do
779
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
780
+ #{VALIDATING_BLANK_HDR}
781
+
782
+ == Clause
783
+ 7 & 8
784
+ INPUT
785
+ expect(File.read("test.err")).to include "Avoid ampersand in ordinary text"
786
+ end
787
+
788
+ it "Style warning if full stop used in title or caption" do
789
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
790
+ #{VALIDATING_BLANK_HDR}
791
+
792
+ == Clause.
793
+
794
+ .Table.
795
+ |===
796
+ | A |B
797
+ |===
798
+
799
+ === Clause 2.
800
+
801
+ .Figure.
802
+ ....
803
+ Z
804
+ ....
805
+
806
+ .Other Figure
807
+ ....
808
+ A
809
+ ....
810
+ INPUT
811
+ expect(File.read("test.err"))
812
+ .to include "No full stop at end of title or caption: Clause."
813
+ expect(File.read("test.err"))
814
+ .to include "No full stop at end of title or caption: Clause 2."
815
+ expect(File.read("test.err"))
816
+ .to include "No full stop at end of title or caption: Table."
817
+ expect(File.read("test.err"))
818
+ .to include "No full stop at end of title or caption: Figure."
819
+ expect(File.read("test.err"))
820
+ .not_to include "No full stop at end of title or caption: Other Figure."
821
+ end
822
+
757
823
  # can't test: our asciidoc template won't allow this to be generated
758
824
  # it "Style warning if foreword contains subclauses" do
759
825
  # expect { Asciidoctor.convert(<<~"INPUT", *OPTIONS) }
@@ -812,8 +878,7 @@ RSpec.describe Metanorma::ISO do
812
878
  INPUT
813
879
  expect(File.read("test.err"))
814
880
  .not_to include "Symbols and Abbreviated Terms can only contain "\
815
- "a definition list"
816
-
881
+ "a definition list"
817
882
  end
818
883
 
819
884
  it "Warning if missing foreword" do
@@ -1204,6 +1269,97 @@ RSpec.describe Metanorma::ISO do
1204
1269
  .to include "Only annexes and references can follow terms and clauses"
1205
1270
  end
1206
1271
 
1272
+ it "No warning if there are two Symbols sections in a Vocabulary document" do
1273
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
1274
+ = Document title
1275
+ Author
1276
+ :docfile: test.adoc
1277
+ :nodoc:
1278
+ :no-isobib:
1279
+ :docsubtype: vocabulary
1280
+
1281
+ == Scope
1282
+
1283
+ == Terms and definitions
1284
+
1285
+ == A Clause
1286
+
1287
+ [heading=symbols and abbreviated terms]
1288
+ == Terms related to clinical psychology
1289
+
1290
+ [heading=symbols and abbreviated terms]
1291
+ == Symbols related to clinical psychology
1292
+
1293
+ INPUT
1294
+ expect(File.read("test.err"))
1295
+ .not_to include "Only one Symbols and Abbreviated Terms section "\
1296
+ "in the standard"
1297
+ end
1298
+
1299
+ it "Warn if single terms section in vocabulary document not named properly" do
1300
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
1301
+ = Document title
1302
+ Author
1303
+ :docfile: test.adoc
1304
+ :nodoc:
1305
+ :no-isobib:
1306
+ :docsubtype: vocabulary
1307
+
1308
+ == Scope
1309
+ [heading=terms and definitions]
1310
+ == Terms and redefinitions
1311
+
1312
+ INPUT
1313
+ expect(File.read("test.err"))
1314
+ .to include "Single terms clause in vocabulary document should have normal Terms and definitions heading"
1315
+ expect(File.read("test.err"))
1316
+ .not_to include "Multiple terms clauses in vocabulary document should have 'Terms related to' heading"
1317
+ end
1318
+
1319
+
1320
+ it "Warn if vocabulary document contains Symbols section outside annex" do
1321
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
1322
+ = Document title
1323
+ Author
1324
+ :docfile: test.adoc
1325
+ :nodoc:
1326
+ :no-isobib:
1327
+ :docsubtype: vocabulary
1328
+
1329
+ == Scope
1330
+
1331
+ == Terms and definitions
1332
+
1333
+ == A Clause
1334
+
1335
+ [heading=symbols and abbreviated terms]
1336
+ == Terms related to clinical psychology
1337
+
1338
+ INPUT
1339
+ expect(File.read("test.err"))
1340
+ .to include "In vocabulary documents, Symbols and Abbreviated Terms are only permitted in annexes"
1341
+ end
1342
+
1343
+ it "Warning if multiple terms section in vocabulary document not named properly" do
1344
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
1345
+ = Document title
1346
+ Author
1347
+ :docfile: test.adoc
1348
+ :nodoc:
1349
+ :no-isobib:
1350
+ :docsubtype: vocabulary
1351
+
1352
+ == Terms and definitions
1353
+
1354
+ [heading=terms and definitions]
1355
+ == Terms related to fish
1356
+
1357
+ INPUT
1358
+ expect(File.read("test.err"))
1359
+ .not_to include "Single terms clause in vocabulary document should have normal Terms and definitions heading"
1360
+ expect(File.read("test.err"))
1361
+ .to include "Multiple terms clauses in vocabulary document should have 'Terms related to' heading"
1362
+ end
1207
1363
 
1208
1364
  it "Warning if final section is not named Bibliography" do
1209
1365
  Asciidoctor.convert(<<~"INPUT", *OPTIONS)
@@ -1631,12 +1787,7 @@ RSpec.describe Metanorma::ISO do
1631
1787
 
1632
1788
  it "Warn if more than 7 levels of subclause" do
1633
1789
  Asciidoctor.convert(<<~"INPUT", *OPTIONS)
1634
- = Document title
1635
- Author
1636
- :docfile: test.adoc
1637
- :nodoc:
1638
- :no-isobib:
1639
- :language: fr
1790
+ #{VALIDATING_BLANK_HDR}
1640
1791
 
1641
1792
  == Clause
1642
1793
 
@@ -1664,12 +1815,7 @@ RSpec.describe Metanorma::ISO do
1664
1815
 
1665
1816
  it "Do not warn if not more than 7 levels of subclause" do
1666
1817
  Asciidoctor.convert(<<~"INPUT", *OPTIONS)
1667
- = Document title
1668
- Author
1669
- :docfile: test.adoc
1670
- :nodoc:
1671
- :no-isobib:
1672
- :language: fr
1818
+ #{VALIDATING_BLANK_HDR}
1673
1819
 
1674
1820
  == Clause
1675
1821
 
@@ -1704,4 +1850,293 @@ RSpec.describe Metanorma::ISO do
1704
1850
  .to include "Reference ISO8 does not have an associated footnote "\
1705
1851
  "indicating unpublished status"
1706
1852
  end
1853
+
1854
+ it "Warn if no colon or full stop before list" do
1855
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
1856
+ #{VALIDATING_BLANK_HDR}
1857
+
1858
+ == Clause
1859
+
1860
+ X
1861
+
1862
+ * A very long
1863
+ * B list
1864
+ * C
1865
+ INPUT
1866
+ expect(File.read("test.err"))
1867
+ .to include "All lists must be preceded by colon or full stop"
1868
+ end
1869
+
1870
+ it "Do not warn if colon or full stop before list" do
1871
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
1872
+ #{VALIDATING_BLANK_HDR}
1873
+
1874
+ == Clause
1875
+
1876
+ X.
1877
+
1878
+ * A very long
1879
+ * B list
1880
+ * C
1881
+
1882
+ X:
1883
+
1884
+ . A very long
1885
+ . B list
1886
+ . C
1887
+ INPUT
1888
+ expect(File.read("test.err"))
1889
+ .not_to include "All lists must be preceded by colon or full stop"
1890
+ end
1891
+
1892
+ it "Warn of list punctuation after colon" do
1893
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
1894
+ #{VALIDATING_BLANK_HDR}
1895
+
1896
+ == Clause
1897
+
1898
+ X:
1899
+
1900
+ * this is;
1901
+ * another broken up;
1902
+ * Sentence.
1903
+
1904
+ X:
1905
+
1906
+ . this is
1907
+ . another broken up;
1908
+ . sentence
1909
+
1910
+ X:
1911
+
1912
+ . sentence.
1913
+
1914
+ X:
1915
+
1916
+ . This is.
1917
+ . Another broken up.
1918
+ . Sentence.
1919
+ INPUT
1920
+ expect(File.read("test.err"))
1921
+ .to include "List entry of broken up sentence must start with lowercase letter: Sentence."
1922
+ expect(File.read("test.err"))
1923
+ .not_to include "List entry of broken up sentence must start with lowercase letter: another broken up;."
1924
+ expect(File.read("test.err"))
1925
+ .to include "List entry of broken up sentence must end with semicolon: this is"
1926
+ expect(File.read("test.err"))
1927
+ .to include "Final list entry of broken up sentence must end with full stop: sentence"
1928
+ expect(File.read("test.err"))
1929
+ .not_to include "Final list entry of broken up sentence must end with full stop: sentence."
1930
+ expect(File.read("test.err"))
1931
+ .not_to include "List entry of broken up sentence must start with lowercase letter: Another broken up."
1932
+ expect(File.read("test.err"))
1933
+ .not_to include "List entry of broken up sentence must end with semicolon: This is."
1934
+ end
1935
+
1936
+ it "Warn of list punctuation after full stop" do
1937
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
1938
+ #{VALIDATING_BLANK_HDR}
1939
+
1940
+ == Clause
1941
+
1942
+ X.
1943
+
1944
+ * This is;
1945
+ * Another broken up.
1946
+ * sentence.
1947
+
1948
+ INPUT
1949
+ expect(File.read("test.err"))
1950
+ .to include "List entry of separate sentences must end with full stop: This is;"
1951
+ expect(File.read("test.err"))
1952
+ .not_to include "List entry of separate sentences must end with full stop: Another broken up."
1953
+ expect(File.read("test.err"))
1954
+ .to include "List entry of separate sentences must start with uppercase letter: sentence."
1955
+ end
1956
+
1957
+ it "Skips punctuation check for short entries in lists" do
1958
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
1959
+ #{VALIDATING_BLANK_HDR}
1960
+
1961
+ == Clause
1962
+
1963
+ X.
1964
+
1965
+ * This is
1966
+ * Another
1967
+ * sentence
1968
+
1969
+ INPUT
1970
+ expect(File.read("test.err"))
1971
+ .not_to include "List entry after full stop must end with full stop: This is"
1972
+ end
1973
+
1974
+ it "Skips punctuation check for lists within tables" do
1975
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
1976
+ #{VALIDATING_BLANK_HDR}
1977
+
1978
+ == Clause
1979
+
1980
+ |===
1981
+ | A
1982
+ a|
1983
+ * This is
1984
+ * Another
1985
+ * sentence
1986
+ |===
1987
+
1988
+ INPUT
1989
+ expect(File.read("test.err"))
1990
+ .not_to include "List entry after full stop must end with full stop: This is"
1991
+ end
1992
+
1993
+ it "Warn if more than one ordered lists in a clause" do
1994
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
1995
+ #{VALIDATING_BLANK_HDR}
1996
+
1997
+ == Clause
1998
+
1999
+ . A
2000
+ .. B
2001
+ ... C
2002
+
2003
+ a
2004
+
2005
+ . A
2006
+ .. B
2007
+
2008
+ a
2009
+
2010
+ . B
2011
+
2012
+ INPUT
2013
+ expect(File.read("test.err"))
2014
+ .to include "More than 1 ordered list in a numbered clause"
2015
+
2016
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
2017
+ #{VALIDATING_BLANK_HDR}
2018
+
2019
+ == Clause
2020
+
2021
+ . A
2022
+ .. B
2023
+ ... C
2024
+
2025
+ === Clause
2026
+ a
2027
+
2028
+ . A
2029
+ .. B
2030
+
2031
+ a
2032
+
2033
+ INPUT
2034
+ expect(File.read("test.err"))
2035
+ .not_to include "More than 1 ordered list in a numbered clause"
2036
+ end
2037
+
2038
+ it "Warn if list more than four levels deep" do
2039
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
2040
+ #{VALIDATING_BLANK_HDR}
2041
+
2042
+ == Clause
2043
+
2044
+ . A
2045
+ .. B
2046
+ ... C
2047
+ .... D
2048
+
2049
+ INPUT
2050
+ expect(File.read("test.err"))
2051
+ .not_to include "List more than four levels deep"
2052
+
2053
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
2054
+ #{VALIDATING_BLANK_HDR}
2055
+
2056
+ == Clause
2057
+
2058
+ . A
2059
+ .. B
2060
+ ... C
2061
+ .... D
2062
+ ..... E
2063
+
2064
+ INPUT
2065
+ expect(File.read("test.err"))
2066
+ .to include "List more than four levels deep"
2067
+
2068
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
2069
+ #{VALIDATING_BLANK_HDR}
2070
+
2071
+ == Clause
2072
+
2073
+ * A
2074
+ ** B
2075
+ *** C
2076
+ **** D
2077
+ ***** E
2078
+
2079
+ INPUT
2080
+ expect(File.read("test.err"))
2081
+ .to include "List more than four levels deep"
2082
+
2083
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
2084
+ #{VALIDATING_BLANK_HDR}
2085
+
2086
+ == Clause
2087
+
2088
+ * A
2089
+ .. B
2090
+ *** C
2091
+ .... D
2092
+ ***** E
2093
+
2094
+ INPUT
2095
+ expect(File.read("test.err"))
2096
+ .to include "List more than four levels deep"
2097
+ end
2098
+
2099
+ it "warn if term clause crossreferences non-term reference" do
2100
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
2101
+ #{VALIDATING_BLANK_HDR}
2102
+
2103
+ == Terms and definitions
2104
+
2105
+ [[b]]
2106
+ === Term 1
2107
+ <<b>>
2108
+ <<c>>
2109
+
2110
+ [[c]]
2111
+ == Clause
2112
+
2113
+ INPUT
2114
+ expect(File.read("test.err"))
2115
+ .to include "non-terms clauses cannot cross-reference terms clause (c)"
2116
+ expect(File.read("test.err"))
2117
+ .not_to include "non-terms clauses cannot cross-reference terms clause (b)"
2118
+ end
2119
+
2120
+
2121
+ it "warn if non-term clause crossreferences term reference" do
2122
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
2123
+ #{VALIDATING_BLANK_HDR}
2124
+
2125
+ == Terms and definitions
2126
+
2127
+ [[b]]
2128
+ === Term 1
2129
+ <<b>>
2130
+ <<c>>
2131
+
2132
+ == Clause
2133
+ <<b>>
2134
+ <<c>>
2135
+
2136
+ INPUT
2137
+ expect(File.read("test.err"))
2138
+ .to include "only terms clauses can cross-reference terms clause (b)"
2139
+ expect(File.read("test.err"))
2140
+ .not_to include "only terms clauses can cross-reference terms clause (c)"
2141
+ end
1707
2142
  end
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require "vcr"
2
-
2
+
3
3
  VCR.configure do |config|
4
4
  config.cassette_library_dir = "spec/vcr_cassettes"
5
5
  config.hook_into :webmock
@@ -51,7 +51,9 @@ def strip_guid(xml)
51
51
  end
52
52
 
53
53
  def metadata(hash)
54
- Hash[hash.sort].delete_if { |_, v| v.nil? || v.respond_to?(:empty?) && v.empty? }
54
+ hash.sort.to_h.delete_if do |_, v|
55
+ v.nil? || (v.respond_to?(:empty?) && v.empty?)
56
+ end
55
57
  end
56
58
 
57
59
  def xmlpp(xml)
@@ -216,11 +218,11 @@ TERM_BOILERPLATE = <<~TERM.freeze
216
218
  <ul id="_">
217
219
  <li>
218
220
  <p id="_">ISO Online browsing platform: available at
219
- <link target="http://www.iso.org/obp"/></p>
221
+ <link target="http://www.iso.org/obp"/>.</p>
220
222
  </li>
221
223
  <li>
222
224
  <p id="_">IEC Electropedia: available at
223
- <link target="http://www.electropedia.org"/>
225
+ <link target="http://www.electropedia.org"/>.
224
226
  </p>
225
227
  </li>
226
228
  </ul>