metanorma-iso 1.9.4 → 1.10.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ubuntu.yml +41 -0
  3. data/Gemfile +3 -4
  4. data/Makefile +44 -0
  5. data/Rakefile +1 -1
  6. data/bin/rspec +1 -2
  7. data/lib/asciidoctor/iso/basicdoc.rng +32 -5
  8. data/lib/asciidoctor/iso/biblio.rng +2 -0
  9. data/lib/asciidoctor/iso/cleanup.rb +7 -6
  10. data/lib/asciidoctor/iso/front.rb +9 -1
  11. data/lib/asciidoctor/iso/isodoc.rng +430 -76
  12. data/lib/asciidoctor/iso/isostandard-amd.rng +1 -1
  13. data/lib/asciidoctor/iso/isostandard.rng +9 -23
  14. data/lib/asciidoctor/iso/reqt.rng +24 -3
  15. data/lib/asciidoctor/iso/validate.rb +7 -7
  16. data/lib/asciidoctor/iso/validate_section.rb +1 -1
  17. data/lib/isodoc/iso/html/isodoc.css +1 -2
  18. data/lib/isodoc/iso/html/isodoc.scss +1 -1
  19. data/lib/isodoc/iso/html/wordstyle.css +16 -4
  20. data/lib/isodoc/iso/html/wordstyle.scss +16 -4
  21. data/lib/isodoc/iso/i18n.rb +10 -9
  22. data/lib/isodoc/iso/iso.amendment.xsl +200 -20
  23. data/lib/isodoc/iso/iso.international-standard.xsl +200 -20
  24. data/lib/isodoc/iso/presentation_xml_convert.rb +9 -10
  25. data/lib/isodoc/iso/sections.rb +2 -0
  26. data/lib/isodoc/iso/word_cleanup.rb +94 -0
  27. data/lib/isodoc/iso/word_convert.rb +12 -89
  28. data/lib/metanorma/iso/version.rb +1 -1
  29. data/metanorma-iso.gemspec +4 -3
  30. data/spec/asciidoctor/base_spec.rb +685 -178
  31. data/spec/asciidoctor/blank_spec.rb +38 -0
  32. data/spec/asciidoctor/blocks_spec.rb +22 -47
  33. data/spec/asciidoctor/cleanup_spec.rb +34 -20
  34. data/spec/asciidoctor/inline_spec.rb +10 -2
  35. data/spec/asciidoctor/refs_spec.rb +87 -4
  36. data/spec/asciidoctor/section_spec.rb +3 -3
  37. data/spec/isodoc/i18n_spec.rb +29 -15
  38. data/spec/isodoc/inline_spec.rb +56 -26
  39. data/spec/isodoc/section_spec.rb +1 -1
  40. data/spec/isodoc/table_spec.rb +6 -8
  41. data/spec/isodoc/terms_spec.rb +11 -11
  42. data/spec/isodoc/xref_spec.rb +1397 -1376
  43. data/spec/metanorma/processor_spec.rb +4 -1
  44. data/spec/spec_helper.rb +14 -1
  45. data/spec/vcr_cassettes/docrels.yml +783 -0
  46. data/spec/vcr_cassettes/sortrefs.yml +599 -0
  47. metadata +38 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d361028b55729e120ba979ff911c432c4c540c92c5bb8046d9924fa908ac7420
4
- data.tar.gz: 9cabc0515d30da042e63c0728bec5efca3d0600ce05bddf23aa4051cae29bc53
3
+ metadata.gz: 24633dfc813afd54d496d125ac4cc7ffdb4e11b9a2958437033c0cfe57ea7873
4
+ data.tar.gz: b3995300f75025e162a31b28aa2aea9ebfdb3fd791928d622ee9fea264948a63
5
5
  SHA512:
6
- metadata.gz: c570db53cb7e7d27f9bc10ab473ecc31f6d036dec343048f4992e79acc4bdd6a0be3aeaf26abdf56f21501d4af48475557641e81417a873ee5205e47330d20eb
7
- data.tar.gz: 33da49640740fb46d457ddb28a68bbf4d7b64d01e604c003d5ef8846405173274df650ddb0f37833e203a224f344afe18d12f4db67a4c81682c3be50e6b3eee3
6
+ metadata.gz: 1d495eb4e4758f85053f888027b8776048ed4e1c2f1c0ee5f87a5dda4214fcfe85d2d490947633a8889cf9aa8db48dcd42eb319e1ae63abb5cf3901fec9cb789
7
+ data.tar.gz: c4472ab5da3868ccf1331e6ff1879218a5e5e515128f3733d1ef32dcc8b4fec5b5855d5712c03ac950c67b4a7e0ccdf452da1b4fba9c6f61907b9ed40b0867e3
@@ -0,0 +1,41 @@
1
+ name: ubuntu
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+
9
+ jobs:
10
+ build:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v2
14
+
15
+ - name: Setup prerequisites
16
+ run: |
17
+ sudo apt-get update
18
+ sudo apt-get -y install xsltproc
19
+
20
+ - run: make xsd_doc
21
+ env:
22
+ GITHUB_USERNAME: ${{ github.actor }}
23
+ GITHUB_TOKEN: ${{ github.token }}
24
+
25
+ - uses: actions/upload-artifact@master
26
+ with:
27
+ name: xsd_doc
28
+ path: xsd_doc
29
+
30
+ deploy-gh-pages:
31
+ if: github.ref == 'refs/heads/main'
32
+ runs-on: ubuntu-latest
33
+ needs: build
34
+ steps:
35
+ - uses: actions/checkout@master
36
+
37
+ - uses: actions/download-artifact@master
38
+ with:
39
+ name: xsd_doc-ubuntu
40
+ path: xsd_doc
41
+
data/Gemfile CHANGED
@@ -4,11 +4,10 @@ Encoding.default_internal = Encoding::UTF_8
4
4
  source "https://rubygems.org"
5
5
  git_source(:github) { |repo| "https://github.com/#{repo}" }
6
6
 
7
- #gem "asciimath", git: "https://github.com/asciidoctor/asciimath"
7
+ # gem "asciimath", git: "https://github.com/asciidoctor/asciimath"
8
8
 
9
9
  gemspec
10
10
 
11
- if File.exist? 'Gemfile.devel'
12
- eval File.read('Gemfile.devel'), nil, 'Gemfile.devel' # rubocop:disable Security/Eval
11
+ if File.exist? "Gemfile.devel"
12
+ eval File.read("Gemfile.devel"), nil, "Gemfile.devel" # rubocop:disable Security/Eval
13
13
  end
14
-
data/Makefile CHANGED
@@ -8,6 +8,15 @@ SHELL := /bin/bash
8
8
  # Ensure the xml2rfc cache directory exists locally
9
9
  IGNORE := $(shell mkdir -p $(HOME)/.cache/xml2rfc)
10
10
 
11
+ TRANG_RELEASE := https://github.com/relaxng/jing-trang/releases/download/V20181222/trang-20181222.zip
12
+ TOOLS_DIR := ${CURDIR}/tools
13
+ TRANG_JAR := $(TOOLS_DIR)/trang.jar
14
+ XSDVIPATH := $(TOOLS_DIR)/xsdvi.jar
15
+ XSLT_FILE := $(TOOLS_DIR)/xs3pxsl
16
+ XSLT_FILE_MERGE := $(TOOLS_DIR)/xsdmerge.xsl
17
+ RNG_FILE_SRC := lib/asciidoctor/iso/isostandard.rng
18
+ XSD_FILE_DEST := ${CURDIR}/xsd_doc/isostandard.xsd
19
+
11
20
  all: $(TXT) $(HTML) $(XML) $(NITS)
12
21
 
13
22
  clean:
@@ -37,3 +46,38 @@ clean:
37
46
  open:
38
47
  open *.txt
39
48
 
49
+
50
+ $(XSDVIPATH):
51
+ mkdir -p $(dir $@); \
52
+ curl -sSL https://sourceforge.net/projects/xsdvi/files/latest/download > $(dir $@)/xsdvi.zip; \
53
+ unzip -p $(dir $@)/xsdvi.zip dist/lib/xercesImpl.jar > $(dir $@)/xercesImpl.jar; \
54
+ curl -sSL https://github.com/metanorma/xsdvi/releases/download/v1.0/xsdvi-1.0.jar > $@
55
+
56
+ $(XSLT_FILE):
57
+ mkdir -p $(dir $@)
58
+ curl -sSL https://raw.githubusercontent.com/metanorma/xs3p/main/xsl/xs3p.xsl > $@
59
+
60
+ $(XSLT_FILE_MERGE):
61
+ mkdir -p $(dir $@)
62
+ curl -sSL https://raw.githubusercontent.com/metanorma/xs3p/main/xsl/xsdmerge.xsl > $@
63
+
64
+ $(TRANG_JAR):
65
+ mkdir -p $(dir $@); \
66
+ cd $(dir $@); \
67
+ curl -sSL $(TRANG_RELEASE) > trang.zip; \
68
+ unzip -p trang.zip trang-20181222/trang.jar > $@
69
+
70
+
71
+ $(XSD_FILE_DEST): $(TRANG_JAR)
72
+ mkdir -p $(dir $@); \
73
+ java -jar $< $(RNG_FILE_SRC) $@
74
+
75
+ xsd_doc: $(XSD_FILE_DEST) $(XSDVIPATH) $(XSLT_FILE) $(XSLT_FILE_MERGE)
76
+ mkdir -p $@/diagrams; \
77
+ cd $@; \
78
+ java -jar $(XSDVIPATH) $< -rootNodeName all -oneNodeOnly -outputPath diagrams; \
79
+ xsltproc --nonet --stringparam rootxsd iso-standard --output $@.tmp $(XSLT_FILE_MERGE) $<;\
80
+ xsltproc --nonet --param title "'Metanorma XML Schema Documentation, ISO Standard'" \
81
+ --output index.html $(XSLT_FILE) $@.tmp;\
82
+ rm $@.tmp
83
+
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rspec/core/rake_task"
3
- require 'isodoc/gem_tasks'
3
+ require "isodoc/gem_tasks"
4
4
 
5
5
  IsoDoc::GemTasks.install
6
6
  RSpec::Core::RakeTask.new(:spec)
data/bin/rspec CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
-
2
+
3
3
  # This file was generated by Bundler.
4
4
  #
5
5
  # The application 'rspec' is installed as part of a gem, and
@@ -15,4 +15,3 @@ require "rubygems"
15
15
  require "bundler/setup"
16
16
 
17
17
  load Gem.bin_path("rspec-core", "rspec")
18
-
@@ -1,5 +1,5 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
2
+ <grammar xmlns="http://relaxng.org/ns/structure/1.0" xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
3
3
  <include href="biblio.rng">
4
4
  <start>
5
5
  <ref name="document"/>
@@ -19,6 +19,7 @@
19
19
  </define>
20
20
  <define name="bibdata">
21
21
  <element name="bibdata">
22
+ <a:documentation>Document attributes</a:documentation>
22
23
  <ref name="BibData"/>
23
24
  </element>
24
25
  </define>
@@ -104,10 +105,12 @@
104
105
  </define>
105
106
  <define name="paragraph">
106
107
  <element name="p">
108
+ <a:documentation>Paragraph</a:documentation>
107
109
  <ref name="ParagraphType"/>
108
110
  </element>
109
111
  </define>
110
112
  <define name="Alignments">
113
+ <a:documentation>Text alignment</a:documentation>
111
114
  <choice>
112
115
  <value>left</value>
113
116
  <value>right</value>
@@ -215,6 +218,7 @@
215
218
  </define>
216
219
  <define name="quote">
217
220
  <element name="quote">
221
+ <a:documentation>Block quotes</a:documentation>
218
222
  <attribute name="id">
219
223
  <data type="ID"/>
220
224
  </attribute>
@@ -249,6 +253,7 @@
249
253
  </define>
250
254
  <define name="sourcecode">
251
255
  <element name="sourcecode">
256
+ <a:documentation>Source code, a pre-formatted source snippet to be rendered in monospace font, and with spaces preserved</a:documentation>
252
257
  <attribute name="id">
253
258
  <data type="ID"/>
254
259
  </attribute>
@@ -624,6 +629,9 @@
624
629
  <choice>
625
630
  <ref name="PureTextElement"/>
626
631
  <ref name="stem"/>
632
+ <ref name="eref"/>
633
+ <ref name="xref"/>
634
+ <ref name="hyperlink"/>
627
635
  </choice>
628
636
  </zeroOrMore>
629
637
  </element>
@@ -634,6 +642,9 @@
634
642
  <choice>
635
643
  <ref name="PureTextElement"/>
636
644
  <ref name="stem"/>
645
+ <ref name="eref"/>
646
+ <ref name="xref"/>
647
+ <ref name="hyperlink"/>
637
648
  </choice>
638
649
  </zeroOrMore>
639
650
  </element>
@@ -641,7 +652,12 @@
641
652
  <define name="tt">
642
653
  <element name="tt">
643
654
  <zeroOrMore>
644
- <ref name="PureTextElement"/>
655
+ <choice>
656
+ <ref name="PureTextElement"/>
657
+ <ref name="eref"/>
658
+ <ref name="xref"/>
659
+ <ref name="hyperlink"/>
660
+ </choice>
645
661
  </zeroOrMore>
646
662
  </element>
647
663
  </define>
@@ -822,7 +838,9 @@
822
838
  <attribute name="alt"/>
823
839
  </optional>
824
840
  <ref name="CitationType"/>
825
- <text/>
841
+ <oneOrMore>
842
+ <ref name="PureTextElement"/>
843
+ </oneOrMore>
826
844
  </define>
827
845
  <define name="hyperlink">
828
846
  <element name="link">
@@ -835,7 +853,9 @@
835
853
  <optional>
836
854
  <attribute name="alt"/>
837
855
  </optional>
838
- <text/>
856
+ <oneOrMore>
857
+ <ref name="PureTextElement"/>
858
+ </oneOrMore>
839
859
  </element>
840
860
  </define>
841
861
  <define name="xref">
@@ -849,7 +869,9 @@
849
869
  <optional>
850
870
  <attribute name="alt"/>
851
871
  </optional>
852
- <text/>
872
+ <oneOrMore>
873
+ <ref name="PureTextElement"/>
874
+ </oneOrMore>
853
875
  </element>
854
876
  </define>
855
877
  <define name="fn">
@@ -1030,6 +1052,7 @@
1030
1052
  </define>
1031
1053
  <define name="ul">
1032
1054
  <element name="ul">
1055
+ <a:documentation>Unordered list</a:documentation>
1033
1056
  <attribute name="id">
1034
1057
  <data type="ID"/>
1035
1058
  </attribute>
@@ -1043,6 +1066,7 @@
1043
1066
  </define>
1044
1067
  <define name="li">
1045
1068
  <element name="li">
1069
+ <a:documentation>List item</a:documentation>
1046
1070
  <optional>
1047
1071
  <attribute name="id">
1048
1072
  <data type="ID"/>
@@ -1080,6 +1104,7 @@
1080
1104
  </define>
1081
1105
  <define name="dl">
1082
1106
  <element name="dl">
1107
+ <a:documentation>Definition list</a:documentation>
1083
1108
  <attribute name="id">
1084
1109
  <data type="ID"/>
1085
1110
  </attribute>
@@ -1094,6 +1119,7 @@
1094
1119
  </define>
1095
1120
  <define name="dt">
1096
1121
  <element name="dt">
1122
+ <a:documentation>Definition term</a:documentation>
1097
1123
  <zeroOrMore>
1098
1124
  <ref name="TextElement"/>
1099
1125
  </zeroOrMore>
@@ -1101,6 +1127,7 @@
1101
1127
  </define>
1102
1128
  <define name="dd">
1103
1129
  <element name="dd">
1130
+ <a:documentation>Definition description</a:documentation>
1104
1131
  <zeroOrMore>
1105
1132
  <ref name="paragraph-with-footnote"/>
1106
1133
  </zeroOrMore>
@@ -76,12 +76,14 @@
76
76
  <define name="script">
77
77
  <a:documentation>ISO-639</a:documentation>
78
78
  <element name="script">
79
+ <a:documentation>ISO-639</a:documentation>
79
80
  <text/>
80
81
  </element>
81
82
  </define>
82
83
  <define name="edition">
83
84
  <a:documentation>ISO-15924: Latn</a:documentation>
84
85
  <element name="edition">
86
+ <a:documentation>ISO-15924: Latn</a:documentation>
85
87
  <optional>
86
88
  <attribute name="number"/>
87
89
  </optional>
@@ -8,7 +8,7 @@ module Asciidoctor
8
8
  module ISO
9
9
  class Converter < Standoc::Converter
10
10
  PRE_NORMREF_FOOTNOTES = "//preface//fn | "\
11
- "//clause[@type = 'scope']//fn".freeze
11
+ "//clause[@type = 'scope']//fn".freeze
12
12
 
13
13
  NORMREF_FOOTNOTES =
14
14
  "//references[@normative = 'true']//fn".freeze
@@ -41,7 +41,7 @@ module Asciidoctor
41
41
  xmldoc.xpath("//bibdata/contributor[role/@type = 'publisher']"\
42
42
  "/organization").each do |x|
43
43
  x1 = x.at("abbreviation")&.text || x.at("name")&.text
44
- x1 == "ISO" and prefix.unshift("ISO") or prefix << x1
44
+ (x1 == "ISO" and prefix.unshift("ISO")) or prefix << x1
45
45
  end
46
46
  prefix
47
47
  end
@@ -64,14 +64,15 @@ module Asciidoctor
64
64
  super
65
65
  end
66
66
 
67
- TERM_CLAUSE = "//sections//terms | "\
67
+ TERM_CLAUSE =
68
+ "//sections//terms | "\
68
69
  "//sections//clause[descendant::terms][not(descendant::definitions)]"
69
- .freeze
70
+ .freeze
70
71
 
71
72
  PUBLISHER = "./contributor[role/@type = 'publisher']/organization".freeze
72
73
 
73
74
  OTHERIDS = "@type = 'DOI' or @type = 'metanorma' or @type = 'ISSN' or "\
74
- "@type = 'ISBN'".freeze
75
+ "@type = 'ISBN'".freeze
75
76
 
76
77
  def pub_class(bib)
77
78
  return 1 if bib.at("#{PUBLISHER}[abbreviation = 'ISO']")
@@ -111,7 +112,7 @@ module Asciidoctor
111
112
  bib&.at("./title")&.text || bib&.at("./formattedref")&.text
112
113
  "#{pubclass} :: #{type} :: "\
113
114
  "#{num.nil? ? abbrid : sprintf('%09d', num.to_i)} :: "\
114
- "#{partid} :: #{id&.text} :: #{title}"
115
+ "#{sprintf('%09d', partid.to_i)} :: #{id&.text} :: #{title}"
115
116
  end
116
117
 
117
118
  def sections_cleanup(xml)
@@ -116,7 +116,7 @@ module Asciidoctor
116
116
 
117
117
  xml.title(**attr_code(at.merge(type: "title-amd"))) do |t1|
118
118
  t1 << Metanorma::Utils::asciidoc_sub(
119
- node.attr("title-amendment-#{lang}")
119
+ node.attr("title-amendment-#{lang}"),
120
120
  )
121
121
  end
122
122
  end
@@ -144,6 +144,14 @@ module Asciidoctor
144
144
  title_amd(node, xml, lang, at) if @amd
145
145
  end
146
146
  end
147
+
148
+ def relaton_relations
149
+ super + %w(obsoletes)
150
+ end
151
+
152
+ def relaton_relation_descriptions
153
+ super.merge("amends" => "updates")
154
+ end
147
155
  end
148
156
  end
149
157
  end