metanorma-iso 1.5.7 → 1.5.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/macos.yml +9 -1
  3. data/.github/workflows/rake.yml +66 -0
  4. data/.github/workflows/ubuntu.yml +8 -0
  5. data/.github/workflows/windows.yml +7 -0
  6. data/README.adoc +5 -6
  7. data/lib/asciidoctor/iso/basicdoc.rng +4 -11
  8. data/lib/asciidoctor/iso/boilerplate-fr.xml +40 -0
  9. data/lib/asciidoctor/iso/boilerplate.xml +1 -0
  10. data/lib/asciidoctor/iso/cleanup.rb +38 -0
  11. data/lib/asciidoctor/iso/front.rb +9 -15
  12. data/lib/asciidoctor/iso/isodoc.rng +27 -50
  13. data/lib/asciidoctor/iso/isostandard.rng +8 -1
  14. data/lib/asciidoctor/iso/validate.rb +1 -1
  15. data/lib/asciidoctor/iso/validate_section.rb +9 -0
  16. data/lib/isodoc/iso/html/header.html +12 -24
  17. data/lib/isodoc/iso/html/style-human.css +5 -1
  18. data/lib/isodoc/iso/html/style-iso.css +5 -1
  19. data/lib/isodoc/iso/i18n-en.yaml +4 -0
  20. data/lib/isodoc/iso/i18n-fr.yaml +5 -0
  21. data/lib/isodoc/iso/i18n-zh-Hans.yaml +5 -0
  22. data/lib/isodoc/iso/i18n.rb +10 -11
  23. data/lib/isodoc/iso/iso.amendment.xsl +732 -138
  24. data/lib/isodoc/iso/iso.international-standard.xsl +732 -138
  25. data/lib/isodoc/iso/metadata.rb +19 -19
  26. data/lib/metanorma-iso.rb +1 -0
  27. data/lib/metanorma/iso/processor.rb +1 -1
  28. data/lib/metanorma/iso/version.rb +1 -1
  29. data/metanorma-iso.gemspec +1 -1
  30. data/spec/asciidoctor-iso/amd_spec.rb +7 -7
  31. data/spec/asciidoctor-iso/base_spec.rb +144 -18
  32. data/spec/asciidoctor-iso/cleanup_spec.rb +4 -4
  33. data/spec/asciidoctor-iso/refs_spec.rb +174 -143
  34. data/spec/asciidoctor-iso/validate_spec.rb +52 -15
  35. data/spec/assets/xref_error.adoc +7 -0
  36. data/spec/isodoc/amd_spec.rb +191 -17
  37. data/spec/isodoc/blocks_spec.rb +2 -1
  38. data/spec/isodoc/i18n_spec.rb +13 -13
  39. data/spec/isodoc/inline_spec.rb +2 -2
  40. data/spec/isodoc/iso_spec.rb +2 -2
  41. data/spec/isodoc/metadata_spec.rb +170 -19
  42. data/spec/isodoc/postproc_spec.rb +3 -3
  43. data/spec/isodoc/ref_spec.rb +5 -5
  44. data/spec/isodoc/section_spec.rb +2 -2
  45. data/spec/isodoc/table_spec.rb +1 -1
  46. data/spec/isodoc/terms_spec.rb +1 -1
  47. data/spec/isodoc/xref_spec.rb +11 -11
  48. data/spec/metanorma/processor_spec.rb +1 -1
  49. data/spec/spec_helper.rb +22 -2
  50. metadata +7 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e4e243a2452352cf57ead226a133917dfd0cd0d7f618109e07355777ac10354b
4
- data.tar.gz: d7a8f18735dce09f5fdb1f8be436b7314f265a508ca5c4e878e1ae6c28f4df39
3
+ metadata.gz: 8fa41b9ff5a061ea7bf8428ec4cd1a692867c877462f4fd1b7bf1ae1b0dd2a9f
4
+ data.tar.gz: 7e99d7041d2a295b48057be5ea7505ce05be4b40739ce4ffa3ffc4b94149aabc
5
5
  SHA512:
6
- metadata.gz: fa1a2af192f51f4cda4a52b85b8a83aec9656fe36f890fd4e322d13e9d8db4587be47bbbb0b56b1680af139a1c3582d3a0304160517f5c582fb2f937791fa621
7
- data.tar.gz: ba1a5714584f972567677d83ca2ffc7326b3f86319e9cc4bdfd458ed1d5fa6e09bf4fa0b175c9c0c035537a9d9d1090e3c5f6cbaeb70bd963b055f9da18ff872
6
+ metadata.gz: e7ee3745f439ae3aae5664e6440aed30d94f5e02b4691754fc39cc8ed58fa9bd8e8b80063d9d7889c4e36e8edc9e056f1bef761f471af4742bab8d8465d6a8d7
7
+ data.tar.gz: a8f78935bf25b08a0cf56872384d0dcabd71d7ea8e996bf87d54db1f7045811b6e064953773b93d0d4f560a38f4fff16b4efd96814f01ac1eefbd4ae4e214d04
@@ -29,9 +29,17 @@ jobs:
29
29
  uses: actions/setup-ruby@v1
30
30
  with:
31
31
  ruby-version: ${{ matrix.ruby }}
32
+ - name: Cache gems
33
+ uses: actions/cache@preview
34
+ with:
35
+ path: vendor/bundle
36
+ key: ${{ runner.os }}-${{ matrix.ruby }}-gem-${{ hashFiles('Gemfile') }}
37
+ restore-keys: |
38
+ ${{ runner.os }}-${{ matrix.ruby }}-gem-
32
39
  - name: Update gems
33
40
  run: |
34
- sudo gem install bundler --force
41
+ gem install bundler
42
+ bundle config --local path vendor/bundle
35
43
  bundle install --jobs 4 --retry 3
36
44
  - name: Install PlantUML
37
45
  run: |
@@ -0,0 +1,66 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ name: rake
4
+
5
+ on:
6
+ push:
7
+ branches: [ master, main ]
8
+ tags: [ v* ]
9
+ pull_request:
10
+
11
+ jobs:
12
+ rake:
13
+ name: Test on Ruby ${{ matrix.ruby }} ${{ matrix.os }}
14
+ runs-on: ${{ matrix.os }}
15
+ continue-on-error: ${{ matrix.experimental }}
16
+ strategy:
17
+ fail-fast: false
18
+ matrix:
19
+ ruby: [ '2.6', '2.5', '2.4' ]
20
+ os: [ ubuntu-latest, windows-latest, macos-latest ]
21
+ experimental: [ false ]
22
+ include:
23
+ - ruby: '2.7'
24
+ os: 'ubuntu-latest'
25
+ experimental: true
26
+ - ruby: '2.7'
27
+ os: 'windows-latest'
28
+ experimental: true
29
+ - ruby: '2.7'
30
+ os: 'macos-latest'
31
+ experimental: true
32
+ steps:
33
+ - uses: actions/checkout@master
34
+
35
+ - uses: ruby/setup-ruby@v1
36
+ with:
37
+ ruby-version: ${{ matrix.ruby }}
38
+
39
+ - uses: actions/cache@v1
40
+ with:
41
+ path: vendor/bundle
42
+ key: bundle-${{ matrix.os }}-${{ matrix.ruby }}-${{ hashFiles('**/*.gemspec') }}
43
+ restore-keys: bundle-${{ matrix.os }}-${{ matrix.ruby }}
44
+
45
+ - run: bundle config set path 'vendor/bundle'
46
+
47
+ - run: bundle install --jobs 4 --retry 3
48
+
49
+ - name: install plantuml ubuntu
50
+ if: matrix.os == 'ubuntu-latest'
51
+ uses: nick-invision/retry@v1
52
+ with:
53
+ polling_interval_seconds: 5
54
+ timeout_minutes: 5
55
+ max_attempts: 3
56
+ command: >
57
+ sudo apt-get update -y && sudo bash -c
58
+ "curl -L https://github.com/metanorma/plantuml-install/raw/master/ubuntu.sh | bash"
59
+
60
+ - if: matrix.os == 'macos-latest'
61
+ run: brew install plantuml
62
+
63
+ - if: matrix.os == 'windows-latest'
64
+ run: cinst -y plantuml
65
+
66
+ - run: bundle exec rake
@@ -29,9 +29,17 @@ jobs:
29
29
  uses: actions/setup-ruby@v1
30
30
  with:
31
31
  ruby-version: ${{ matrix.ruby }}
32
+ - name: Cache gems
33
+ uses: actions/cache@preview
34
+ with:
35
+ path: vendor/bundle
36
+ key: ${{ runner.os }}-${{ matrix.ruby }}-gem-${{ hashFiles('Gemfile') }}
37
+ restore-keys: |
38
+ ${{ runner.os }}-${{ matrix.ruby }}-gem-
32
39
  - name: Update gems
33
40
  run: |
34
41
  gem install bundler
42
+ bundle config --local path vendor/bundle
35
43
  bundle install --jobs 4 --retry 3
36
44
  - name: Install PlantUML
37
45
  uses: nick-invision/retry@v1
@@ -29,6 +29,13 @@ jobs:
29
29
  uses: actions/setup-ruby@v1
30
30
  with:
31
31
  ruby-version: ${{ matrix.ruby }}
32
+ - name: Cache gems
33
+ uses: actions/cache@preview
34
+ with:
35
+ path: vendor/bundle
36
+ key: ${{ runner.os }}-${{ matrix.ruby }}-gem-${{ hashFiles('Gemfile') }}
37
+ restore-keys: |
38
+ ${{ runner.os }}-${{ matrix.ruby }}-gem-
32
39
  - name: Update gems
33
40
  shell: pwsh
34
41
  run: |
@@ -1,22 +1,18 @@
1
1
  = Metanorma-ISO: Metanorma processor for ISO standards
2
2
 
3
3
  image:https://img.shields.io/gem/v/metanorma-iso.svg["Gem Version", link="https://rubygems.org/gems/metanorma-iso"]
4
- image:https://github.com/metanorma/metanorma-iso/workflows/macos/badge.svg["Build Status (macOS)", link="https://github.com/metanorma/metanorma-iso/actions?workflow=macos"]
5
- image:https://github.com/metanorma/metanorma-iso/workflows/ubuntu/badge.svg["Build Status (ubuntu)", link="https://github.com/metanorma/metanorma-iso/actions?workflow=ubuntu"]
6
- image:https://github.com/metanorma/metanorma-iso/workflows/windows/badge.svg["Build Status (Windows)", link="https://github.com/metanorma/metanorma-iso/actions?workflow=windows"]
4
+ image:https://github.com/metanorma/metanorma-iso/workflows/rake/badge.svg["Build Status", link="https://github.com/metanorma/metanorma-iso/actions?workflow=rake"]
7
5
  image:https://codeclimate.com/github/metanorma/metanorma-iso/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/metanorma-iso"]
8
6
  image:https://img.shields.io/github/issues-pr-raw/metanorma/metanorma-iso.svg["Pull Requests", link="https://github.com/metanorma/metanorma-iso/pulls"]
9
7
  image:https://img.shields.io/github/commits-since/metanorma/metanorma-iso/latest.svg["Commits since latest",link="https://github.com/metanorma/metanorma-iso/releases"]
10
8
 
11
- _Formerly known as_ `asciidoctor-iso`.
12
-
13
9
  == Functionality and Approach
14
10
 
15
11
  For the conceptual underpinnings of this gem, and the other gems in the Metanorma suite, see the https://github.com/metanorma/metanorma-model-standoc/blob/master/README.adoc[metanorma-standoc README].
16
12
 
17
13
  == Outputs
18
14
 
19
- This gem processes Metanorma documents following a template for generating ISO
15
+ This gem processes https://www.metanorma.com[Metanorma documents] following a template for generating ISO
20
16
  International Standards. The following outputs are generated.
21
17
 
22
18
  * The XML representation of the document, intended as a document model for ISO
@@ -79,3 +75,6 @@ See https://www.metanorma.com/author/iso/[The ISO flavor of Metanorma].
79
75
  * Example documents are avalable at the https://github.com/metanorma/mn-samples-iso[mn-samples-iso] repository.
80
76
  * Document templates are available at the https://github.com/metanorma/mn-templates-iso[mn-templates-iso] repository.
81
77
 
78
+ == Notes
79
+
80
+ Metanorma-ISO was formerly published as `asciidoctor-iso`.
@@ -158,17 +158,7 @@
158
158
  <data type="ID"/>
159
159
  </attribute>
160
160
  <oneOrMore>
161
- <choice>
162
- <ref name="formula"/>
163
- <ref name="ul"/>
164
- <ref name="ol"/>
165
- <ref name="dl"/>
166
- <ref name="quote"/>
167
- <ref name="sourcecode"/>
168
- <ref name="paragraph"/>
169
- <ref name="table"/>
170
- <ref name="figure"/>
171
- </choice>
161
+ <ref name="paragraph"/>
172
162
  </oneOrMore>
173
163
  </element>
174
164
  </define>
@@ -1028,6 +1018,9 @@
1028
1018
  <value>alphabet_upper</value>
1029
1019
  </choice>
1030
1020
  </attribute>
1021
+ <optional>
1022
+ <attribute name="start"/>
1023
+ </optional>
1031
1024
  <oneOrMore>
1032
1025
  <ref name="li"/>
1033
1026
  </oneOrMore>
@@ -0,0 +1,40 @@
1
+ <boilerplate>
2
+ <copyright-statement>
3
+ <clause>
4
+ <title>DOCUMENT PROTÉGÉ PAR COPYRIGHT</title>
5
+ <p id="boilerplate-year">&copy; {{ agency }} {{ docyear }}</p>
6
+
7
+ <p id="boilerplate-message">
8
+ Droits de reproduction réservés. Sauf indication contraire, aucune partie de cette publication ne
9
+ peut être reproduite ni utilisée sous quelque forme que ce soit et par aucun procédé, électronique
10
+ ou mécanique, y compris la photocopie, l’affichage sur l’internet ou sur un Intranet, sans
11
+ autorisation écrite préalable. Les demandes d’autorisation peuvent être adressées à l’ISO à
12
+ l’adresse ci-après ou au comité membre de l’ISO dans le pays du demandeur.
13
+ </p>
14
+
15
+ <p id="boilerplate-address" align="left">
16
+ ISO copyright office<br/>
17
+ Ch. de Blandonnet 8 &#x2022; CP 401<br/>
18
+ CH-1214 Vernier, Geneva, Switzerland<br/>
19
+ Tel.&nbsp;&nbsp;+ 41 22 749 01 11<br/>
20
+ Fax&nbsp;&nbsp;+ 41 22 749 09 47<br/>
21
+ Email: copyright@iso.org<br/>
22
+ Website: www.iso.org
23
+ </p>
24
+ <p id="boilerplate-place">
25
+ Publié en Suisse
26
+ </p>
27
+ </clause>
28
+ </copyright-statement>
29
+
30
+ {% if unpublished %}
31
+ <license-statement>
32
+ <clause>
33
+ <title>Avertissement</title>
34
+
35
+ <p>Ce document n'est pas une Norme internationale de l'ISO. Il est distribué pour examen et observations. Il est susceptible de modification sans préavis et ne peut être cité comme Norme internationale.</p>
36
+ <p>Les destinataires du présent projet sont invités à présenter, avec leurs observations, notification des droits de propriété dont ils auraient éventuellement connaissance et à fournir une documentation explicative.</p>
37
+ </clause>
38
+ </license-statement>
39
+ {% endif %}
40
+ </boilerplate>
@@ -1,6 +1,7 @@
1
1
  <boilerplate>
2
2
  <copyright-statement>
3
3
  <clause>
4
+ <title>COPYRIGHT PROTECTED DOCUMENT</title>
4
5
  <p id="boilerplate-year">
5
6
  &copy; {{ agency }} {{ docyear }}
6
7
  </p>
@@ -124,6 +124,44 @@ module Asciidoctor
124
124
  h.delete('inline-header')
125
125
  end
126
126
  end
127
+
128
+ def boilerplate_file(xmldoc)
129
+ file = @lang == "fr" ? "boilerplate-fr.xml" : "boilerplate.xml"
130
+ File.join(@libdir, file)
131
+ end
132
+
133
+ def footnote_cleanup(xmldoc)
134
+ unpub_footnotes(xmldoc)
135
+ super
136
+ end
137
+
138
+ def unpub_footnotes(xmldoc)
139
+ xmldoc.xpath("//bibitem/note[@type = 'Unpublished-Status']").each do |n|
140
+ id = n.parent["id"]
141
+ e = xmldoc.at("//eref[@bibitemid = '#{id}']") or next
142
+ e.next = n.dup
143
+ e.next.name = "fn"
144
+ e.next.delete("format")
145
+ e.next.delete("type")
146
+ end
147
+ end
148
+
149
+ def bibitem_cleanup(xmldoc)
150
+ super
151
+ unpublished_note(xmldoc)
152
+ end
153
+
154
+ def unpublished_note(xmldoc)
155
+ xmldoc.xpath("//bibitem[not(note[@type = 'Unpublished-Status'])]").each do |b|
156
+ next if pub_class(b) > 2
157
+ next unless s = b.at("./status/stage") and s.text.to_i < 60
158
+ id = b.at("docidentifier").text
159
+ b.at("./language | ./script | ./abstract | ./status").previous = <<~NOTE
160
+ <note type="Unpublished-Status">
161
+ <p>#{@i18n.under_preparation.sub(/%/, id)}</p></note>
162
+ NOTE
163
+ end
164
+ end
127
165
  end
128
166
  end
129
167
  end
@@ -18,18 +18,9 @@ module Asciidoctor
18
18
  xml.updates_document_type a
19
19
  end
20
20
 
21
- def organization(org, orgname)
22
- if ["ISO",
23
- "International Organization for Standardization"].include? orgname
24
- org.name "International Organization for Standardization"
25
- org.abbreviation "ISO"
26
- elsif ["IEC",
27
- "International Electrotechnical Commission"].include? orgname
28
- org.name "International Electrotechnical Commission"
29
- org.abbreviation "IEC"
30
- else
31
- org.name orgname
32
- end
21
+ def org_abbrev
22
+ { "International Organization for Standardization" => "ISO",
23
+ "International Electrotechnical Commission" => "IEC" }
33
24
  end
34
25
 
35
26
  def metadata_author(node, xml)
@@ -37,7 +28,7 @@ module Asciidoctor
37
28
  csv_split(publishers).each do |p|
38
29
  xml.contributor do |c|
39
30
  c.role **{ type: "author" }
40
- c.organization { |a| organization(a, p) }
31
+ c.organization { |a| organization(a, p, node, !node.attr("publisher")) }
41
32
  end
42
33
  end
43
34
  end
@@ -47,7 +38,7 @@ module Asciidoctor
47
38
  csv_split(publishers).each do |p|
48
39
  xml.contributor do |c|
49
40
  c.role **{ type: "publisher" }
50
- c.organization { |a| organization(a, p) }
41
+ c.organization { |a| organization(a, p, node, !node.attr("publisher")) }
51
42
  end
52
43
  end
53
44
  end
@@ -58,7 +49,10 @@ module Asciidoctor
58
49
  xml.copyright do |c|
59
50
  c.from (node.attr("copyright-year") || Date.today.year)
60
51
  c.owner do |owner|
61
- owner.organization { |o| organization(o, p) }
52
+ owner.organization do |o|
53
+ organization(o, p, node,
54
+ !(node.attr("copyright-holder") || node.attr("publisher")))
55
+ end
62
56
  end
63
57
  end
64
58
  end
@@ -24,6 +24,14 @@
24
24
  <start>
25
25
  <ref name="standard-document"/>
26
26
  </start>
27
+ <define name="doctype">
28
+ <element name="doctype">
29
+ <optional>
30
+ <attribute name="abbreviation"/>
31
+ </optional>
32
+ <ref name="DocumentType"/>
33
+ </element>
34
+ </define>
27
35
  <define name="hyperlink">
28
36
  <element name="link">
29
37
  <attribute name="target">
@@ -42,7 +50,6 @@
42
50
  </define>
43
51
  <define name="xref">
44
52
  <element name="xref">
45
- <!-- attribute target { xsd:IDREF }, -->
46
53
  <attribute name="target">
47
54
  <data type="string">
48
55
  <param name="pattern">\i\c*|\c+#\c+</param>
@@ -64,6 +71,11 @@
64
71
  </choice>
65
72
  </attribute>
66
73
  </optional>
74
+ <optional>
75
+ <attribute name="droploc">
76
+ <data type="boolean"/>
77
+ </attribute>
78
+ </optional>
67
79
  <text/>
68
80
  </element>
69
81
  </define>
@@ -137,6 +149,11 @@
137
149
  <data type="boolean"/>
138
150
  </attribute>
139
151
  </optional>
152
+ <optional>
153
+ <attribute name="key">
154
+ <data type="boolean"/>
155
+ </attribute>
156
+ </optional>
140
157
  <oneOrMore>
141
158
  <ref name="dt"/>
142
159
  <ref name="dd"/>
@@ -859,6 +876,13 @@
859
876
  </define>
860
877
  <define name="standard-document">
861
878
  <element name="standard-document">
879
+ <attribute name="version"/>
880
+ <attribute name="type">
881
+ <choice>
882
+ <value>semantic</value>
883
+ <value>presentation</value>
884
+ </choice>
885
+ </attribute>
862
886
  <ref name="bibdata"/>
863
887
  <optional>
864
888
  <ref name="boilerplate"/>
@@ -880,7 +904,7 @@
880
904
  <oneOrMore>
881
905
  <choice>
882
906
  <ref name="content"/>
883
- <ref name="preface_abstract"/>
907
+ <ref name="abstract"/>
884
908
  <ref name="foreword"/>
885
909
  <ref name="introduction"/>
886
910
  <ref name="acknowledgements"/>
@@ -1153,49 +1177,7 @@
1153
1177
  </define>
1154
1178
  <define name="annex">
1155
1179
  <element name="annex">
1156
- <optional>
1157
- <attribute name="id">
1158
- <data type="ID"/>
1159
- </attribute>
1160
- </optional>
1161
- <optional>
1162
- <attribute name="language"/>
1163
- </optional>
1164
- <optional>
1165
- <attribute name="script"/>
1166
- </optional>
1167
- <optional>
1168
- <attribute name="inline-header">
1169
- <data type="boolean"/>
1170
- </attribute>
1171
- </optional>
1172
- <attribute name="obligation">
1173
- <choice>
1174
- <value>normative</value>
1175
- <value>informative</value>
1176
- </choice>
1177
- </attribute>
1178
- <optional>
1179
- <ref name="section-title"/>
1180
- </optional>
1181
- <group>
1182
- <group>
1183
- <zeroOrMore>
1184
- <ref name="BasicBlock"/>
1185
- </zeroOrMore>
1186
- <zeroOrMore>
1187
- <ref name="note"/>
1188
- </zeroOrMore>
1189
- </group>
1190
- <zeroOrMore>
1191
- <choice>
1192
- <ref name="annex-subsection"/>
1193
- <ref name="terms"/>
1194
- <ref name="definitions"/>
1195
- <ref name="references"/>
1196
- </choice>
1197
- </zeroOrMore>
1198
- </group>
1180
+ <ref name="Annex-Section"/>
1199
1181
  </element>
1200
1182
  </define>
1201
1183
  <define name="terms">
@@ -1481,11 +1463,6 @@
1481
1463
  </optional>
1482
1464
  </element>
1483
1465
  </define>
1484
- <define name="preface_abstract">
1485
- <element name="abstract">
1486
- <ref name="Basic-Section"/>
1487
- </element>
1488
- </define>
1489
1466
  <define name="term-clause">
1490
1467
  <element name="clause">
1491
1468
  <optional>