metanorma-iso 2.0.4 → 2.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -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) }
@@ -1227,7 +1293,72 @@ RSpec.describe Metanorma::ISO do
1227
1293
  INPUT
1228
1294
  expect(File.read("test.err"))
1229
1295
  .not_to include "Only one Symbols and Abbreviated Terms section "\
1230
- "in the standard"
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"
1231
1362
  end
1232
1363
 
1233
1364
  it "Warning if final section is not named Bibliography" do
@@ -1656,12 +1787,7 @@ RSpec.describe Metanorma::ISO do
1656
1787
 
1657
1788
  it "Warn if more than 7 levels of subclause" do
1658
1789
  Asciidoctor.convert(<<~"INPUT", *OPTIONS)
1659
- = Document title
1660
- Author
1661
- :docfile: test.adoc
1662
- :nodoc:
1663
- :no-isobib:
1664
- :language: fr
1790
+ #{VALIDATING_BLANK_HDR}
1665
1791
 
1666
1792
  == Clause
1667
1793
 
@@ -1689,12 +1815,7 @@ RSpec.describe Metanorma::ISO do
1689
1815
 
1690
1816
  it "Do not warn if not more than 7 levels of subclause" do
1691
1817
  Asciidoctor.convert(<<~"INPUT", *OPTIONS)
1692
- = Document title
1693
- Author
1694
- :docfile: test.adoc
1695
- :nodoc:
1696
- :no-isobib:
1697
- :language: fr
1818
+ #{VALIDATING_BLANK_HDR}
1698
1819
 
1699
1820
  == Clause
1700
1821
 
@@ -1729,4 +1850,293 @@ RSpec.describe Metanorma::ISO do
1729
1850
  .to include "Reference ISO8 does not have an associated footnote "\
1730
1851
  "indicating unpublished status"
1731
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
1732
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>