metanorma-itu 1.2.5 → 1.2.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +62 -0
  3. data/README.adoc +3 -4
  4. data/lib/asciidoctor/itu/basicdoc.rng +50 -3
  5. data/lib/asciidoctor/itu/boilerplate.xml +3 -0
  6. data/lib/asciidoctor/itu/front.rb +58 -3
  7. data/lib/asciidoctor/itu/isodoc.rng +36 -43
  8. data/lib/asciidoctor/itu/itu.rng +1 -0
  9. data/lib/asciidoctor/itu/validate.rb +2 -9
  10. data/lib/isodoc/itu/base_convert.rb +1 -6
  11. data/lib/isodoc/itu/html/_coverpage.css +4 -0
  12. data/lib/isodoc/itu/html/header.html +8 -16
  13. data/lib/isodoc/itu/html/html_itu_intro.html +4 -3
  14. data/lib/isodoc/itu/html/html_itu_titlepage.html +22 -13
  15. data/lib/isodoc/itu/html/htmlstyle.css +789 -769
  16. data/lib/isodoc/itu/html/htmlstyle.scss +7 -8
  17. data/lib/isodoc/itu/html/itu.css +43 -43
  18. data/lib/isodoc/itu/html/itu.scss +44 -43
  19. data/lib/isodoc/itu/html/logo-sp.png +0 -0
  20. data/lib/isodoc/itu/html/word_itu_intro.html +13 -3
  21. data/lib/isodoc/itu/html/word_itu_titlepage.html +128 -5
  22. data/lib/isodoc/itu/html/word_itu_titlepage_sp.html +108 -0
  23. data/lib/isodoc/itu/html/wordstyle.css +37 -37
  24. data/lib/isodoc/itu/html/wordstyle.scss +37 -37
  25. data/lib/isodoc/itu/html_convert.rb +7 -2
  26. data/lib/isodoc/itu/i18n-en.yaml +40 -0
  27. data/lib/isodoc/itu/itu.recommendation-annex.xsl +730 -156
  28. data/lib/isodoc/itu/itu.recommendation.xsl +730 -156
  29. data/lib/isodoc/itu/itu.resolution.xsl +730 -156
  30. data/lib/isodoc/itu/itu.technical-paper.xsl +5268 -0
  31. data/lib/isodoc/itu/itu.technical-report.xsl +5268 -0
  32. data/lib/isodoc/itu/metadata.rb +70 -5
  33. data/lib/isodoc/itu/pdf_convert.rb +2 -0
  34. data/lib/isodoc/itu/presentation_xml_convert.rb +64 -4
  35. data/lib/isodoc/itu/ref.rb +0 -13
  36. data/lib/isodoc/itu/terms.rb +7 -30
  37. data/lib/isodoc/itu/word_cleanup.rb +5 -1
  38. data/lib/isodoc/itu/word_convert.rb +15 -1
  39. data/lib/isodoc/itu/xref.rb +2 -2
  40. data/lib/metanorma/itu/processor.rb +10 -8
  41. data/lib/metanorma/itu/version.rb +1 -1
  42. data/metanorma-itu.gemspec +4 -2
  43. metadata +39 -9
  44. data/.github/workflows/macos.yml +0 -38
  45. data/.github/workflows/ubuntu.yml +0 -56
  46. data/.github/workflows/windows.yml +0 -40
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7f1f27889137eea1b004bc4eee71e47ddbead47e0fbc4674f539189644763b66
4
- data.tar.gz: 88e33a92e6d6b0d0c3742a0a52df0129e0a45282af82ce97c92155a0394b50f0
3
+ metadata.gz: 7a5e5576a553c84c8a975e21c6f7187fb3d959486fb82da54caa4bae59bc70e4
4
+ data.tar.gz: 06e43014128a730fe43d6e602a6a1c83280d09043c458620ecf7c3488e8d29c6
5
5
  SHA512:
6
- metadata.gz: 77ba3c458e943abb302d525427785149c4b782d4e76fab935366a0ce02f643c98f9332c8273bb29018d68b9817d569d2e036ee6040421c1325939e187d934e34
7
- data.tar.gz: 03f051e1d762172800e50bd22cfece8feb04717bfd77a918411b1c22217ebbe3c7522709f923efacc5b8c4ceb922a4378ecb4db7af98a583526db07368c844f4
6
+ metadata.gz: ec9c3c73670e489535e88bb5abed0956a53dcc692d6fbb95b11507b085f3e8e01342be19fd4ee7ab3d55a11d08fe8566cb643670af29e1ef72979f3653f5b5f0
7
+ data.tar.gz: b2996860abd9e0354985b288a2c562b19d8456c0b7b6d4afcdb208f4c29d9efbabc559eb266dcc879fd23569a0fa3542335384d9f7d91567d7de830a6f0ad54a
@@ -0,0 +1,62 @@
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@v2
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
+ - run: bundle exec rake
50
+
51
+ tests-passed:
52
+ needs: rake
53
+ runs-on: ubuntu-latest
54
+ steps:
55
+ - name: Trigger tests passed event
56
+ uses: Sibz/github-status-action@v1
57
+ with:
58
+ authToken: ${{ secrets.METANORMA_CI_PAT_TOKEN || secrets.GITHUB_TOKEN }}
59
+ context: 'tests-passed-successfully'
60
+ description: 'Tests passed successfully'
61
+ state: 'success'
62
+ sha: ${{ github.event.pull_request.head.sha || github.sha }}
@@ -1,16 +1,15 @@
1
1
  = metanorma-itu: Metanorma for ITU
2
2
 
3
3
  image:https://img.shields.io/gem/v/metanorma-itu.svg["Gem Version", link="https://rubygems.org/gems/metanorma-itu"]
4
- image:https://github.com/metanorma/metanorma-itu/workflows/macos/badge.svg["Build Status (macOS)", link="https://github.com/metanorma/metanorma-itu/actions?workflow=macos"]
5
- image:https://github.com/metanorma/metanorma-itu/workflows/ubuntu/badge.svg["Build Status (ubuntu)", link="https://github.com/metanorma/metanorma-itu/actions?workflow=ubuntu"]
6
- image:https://github.com/metanorma/metanorma-itu/workflows/windows/badge.svg["Build Status (Windows)", link="https://github.com/metanorma/metanorma-itu/actions?workflow=windows"]
4
+ image:https://github.com/metanorma/metanorma-itu/workflows/rake/badge.svg["Build Status", link="https://github.com/metanorma/metanorma-itu/actions?workflow=rake"]
7
5
  image:https://codeclimate.com/github/metanorma/metanorma-itu/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/metanorma-itu"]
8
6
  image:https://img.shields.io/github/issues-pr-raw/metanorma/metanorma-itu.svg["Pull Requests", link="https://github.com/metanorma/metanorma-itu/pulls"]
9
7
  image:https://img.shields.io/github/commits-since/metanorma/metanorma-itu/latest.svg["Commits since latest",link="https://github.com/metanorma/metanorma-itu/releases"]
10
8
 
11
9
  == Functionality
12
10
 
13
- This gem processes Metanorma input for generating ITU (ITU-T, ITU-D) documents.
11
+ This gem processes https://www.metanorma.com[Metanorma documents] following a template for generating ITU
12
+ standards and documents.
14
13
 
15
14
  The implementation inherits from https://github.com/metanorma/metanorma-standoc.
16
15
 
@@ -596,6 +596,7 @@
596
596
  <ref name="bookmark"/>
597
597
  <ref name="image"/>
598
598
  <ref name="index"/>
599
+ <ref name="index-xref"/>
599
600
  </choice>
600
601
  </define>
601
602
  <define name="PureTextElement">
@@ -728,15 +729,61 @@
728
729
  </define>
729
730
  <define name="index">
730
731
  <element name="index">
731
- <attribute name="primary"/>
732
+ <attribute name="to">
733
+ <data type="IDREF"/>
734
+ </attribute>
735
+ <element name="primary">
736
+ <oneOrMore>
737
+ <ref name="PureTextElement"/>
738
+ </oneOrMore>
739
+ </element>
732
740
  <optional>
733
- <attribute name="secondary"/>
741
+ <element name="secondary">
742
+ <oneOrMore>
743
+ <ref name="PureTextElement"/>
744
+ </oneOrMore>
745
+ </element>
734
746
  </optional>
735
747
  <optional>
736
- <attribute name="tertiary"/>
748
+ <element name="tertiary">
749
+ <oneOrMore>
750
+ <ref name="PureTextElement"/>
751
+ </oneOrMore>
752
+ </element>
737
753
  </optional>
738
754
  </element>
739
755
  </define>
756
+ <define name="index-xref">
757
+ <element name="index-xref">
758
+ <attribute name="also">
759
+ <data type="boolean"/>
760
+ </attribute>
761
+ <element name="primary">
762
+ <oneOrMore>
763
+ <ref name="PureTextElement"/>
764
+ </oneOrMore>
765
+ </element>
766
+ <optional>
767
+ <element name="secondary">
768
+ <oneOrMore>
769
+ <ref name="PureTextElement"/>
770
+ </oneOrMore>
771
+ </element>
772
+ </optional>
773
+ <optional>
774
+ <element name="tertiary">
775
+ <oneOrMore>
776
+ <ref name="PureTextElement"/>
777
+ </oneOrMore>
778
+ </element>
779
+ </optional>
780
+ <element name="target">
781
+ <oneOrMore>
782
+ <ref name="PureTextElement"/>
783
+ </oneOrMore>
784
+ </element>
785
+ </element>
786
+ </define>
740
787
  <!-- bare ID element, used for referencing arbitrary spans of text -->
741
788
  <define name="bookmark">
742
789
  <element name="bookmark">
@@ -1,4 +1,6 @@
1
1
  <boilerplate>
2
+ {% if doctype == "Service Publication" %}
3
+ {% else %}
2
4
  <copyright-statement>
3
5
  <clause>
4
6
  <p>&copy; ITU {{ docyear }}</p>
@@ -40,6 +42,7 @@
40
42
  </clause>
41
43
  {% endif %}
42
44
  </legal-statement>
45
+ {% endif %}
43
46
  </boilerplate>
44
47
 
45
48
 
@@ -116,6 +116,7 @@ module Asciidoctor
116
116
  def metadata_id(node, xml)
117
117
  provisional_id(node, xml)
118
118
  itu_id(node, xml)
119
+ recommendation_id(node, xml)
119
120
  end
120
121
 
121
122
  def provisional_id(node, xml)
@@ -125,16 +126,41 @@ module Asciidoctor
125
126
  end
126
127
  end
127
128
 
128
- def itu_id(node, xml)
129
+ ITULANG = {
130
+ "en" => "E", "fr" => "F", "ar" => "A",
131
+ "es" => "S", "zh" => "C", "ru" => "R"
132
+ }.freeze
133
+
134
+ def itu_id1(node, lang)
129
135
  bureau = node.attr("bureau") || "T"
136
+ id = if doctype(node) == "service-publication"
137
+ @i18n.annex_to_itu_ob_abbrev.sub(/%/, node.attr("docnumber"))
138
+ else
139
+ "ITU-#{bureau} #{node.attr("docnumber")}"
140
+ end
141
+ id + (lang ? "-#{ITULANG[@lang]}" : "")
142
+ end
143
+
144
+ def itu_id(node, xml)
130
145
  return unless node.attr("docnumber")
131
146
  xml.docidentifier **{type: "ITU"} do |i|
132
- i << "ITU-#{bureau} "\
133
- "#{node.attr("docnumber")}"
147
+ i << itu_id1(node, false)
148
+ end
149
+ xml.docidentifier **{type: "ITU-lang"} do |i|
150
+ i << itu_id1(node, true)
134
151
  end
135
152
  xml.docnumber { |i| i << node.attr("docnumber") }
136
153
  end
137
154
 
155
+ def recommendation_id(node, xml)
156
+ return unless node.attr("recommendationnumber")
157
+ node.attr("recommendationnumber").split("/").each do |s|
158
+ xml.docidentifier **{type: "ITU-Recommendation"} do |i|
159
+ i << s
160
+ end
161
+ end
162
+ end
163
+
138
164
  def metadata_series(node, xml)
139
165
  node.attr("series") and
140
166
  xml.series **{ type: "main" } do |s|
@@ -178,12 +204,41 @@ module Asciidoctor
178
204
  end
179
205
  end
180
206
 
207
+ # also used in tech paper
208
+ def metadata_techreport(node, xml)
209
+ a = node.attr("meeting") and xml.meeting a
210
+ a = node.attr("meeting-date") and metadata_meeting_date(a, xml)
211
+ a = node.attr("intended-type") and xml.intended_type a
212
+ a = node.attr("source") and xml.source a
213
+ end
214
+
215
+ def metadata_meeting_date(a, xml)
216
+ xml.meeting_date do |m|
217
+ d = a.split("/")
218
+ if d.size > 1
219
+ m.from d[0]
220
+ m.to d[1]
221
+ else
222
+ m.on d[0]
223
+ end
224
+ end
225
+ end
226
+
227
+ def personal_role(node, c, suffix)
228
+ if node.attr("role#{suffix}")&.downcase == "rapporteur"
229
+ c.role "raporteur", **{ type: "editor" }
230
+ else
231
+ super
232
+ end
233
+ end
234
+
181
235
  def metadata_ext(node, xml)
182
236
  metadata_doctype(node, xml)
183
237
  metadata_committee(node, xml)
184
238
  metadata_ics(node, xml)
185
239
  metadata_recommendationstatus(node, xml)
186
240
  metadata_ip_notice(node, xml)
241
+ metadata_techreport(node, xml)
187
242
  structured_id(node, xml)
188
243
  end
189
244
  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">
@@ -47,6 +55,13 @@
47
55
  <param name="pattern">\i\c*|\c+#\c+</param>
48
56
  </data>
49
57
  </attribute>
58
+ <optional>
59
+ <attribute name="to">
60
+ <data type="string">
61
+ <param name="pattern">\i\c*|\c+#\c+</param>
62
+ </data>
63
+ </attribute>
64
+ </optional>
50
65
  <optional>
51
66
  <attribute name="type">
52
67
  <ref name="ReferenceFormat"/>
@@ -141,6 +156,11 @@
141
156
  <data type="boolean"/>
142
157
  </attribute>
143
158
  </optional>
159
+ <optional>
160
+ <attribute name="key">
161
+ <data type="boolean"/>
162
+ </attribute>
163
+ </optional>
144
164
  <oneOrMore>
145
165
  <ref name="dt"/>
146
166
  <ref name="dd"/>
@@ -233,6 +253,9 @@
233
253
  <data type="boolean"/>
234
254
  </attribute>
235
255
  </optional>
256
+ <optional>
257
+ <ref name="colgroup"/>
258
+ </optional>
236
259
  <optional>
237
260
  <ref name="tname"/>
238
261
  </optional>
@@ -751,6 +774,18 @@
751
774
  </define>
752
775
  </include>
753
776
  <!-- end overrides -->
777
+ <define name="colgroup">
778
+ <element name="colgroup">
779
+ <oneOrMore>
780
+ <ref name="col"/>
781
+ </oneOrMore>
782
+ </element>
783
+ </define>
784
+ <define name="col">
785
+ <element name="col">
786
+ <attribute name="width"/>
787
+ </element>
788
+ </define>
754
789
  <define name="TextElement" combine="choice">
755
790
  <ref name="concept"/>
756
791
  </define>
@@ -1164,49 +1199,7 @@
1164
1199
  </define>
1165
1200
  <define name="annex">
1166
1201
  <element name="annex">
1167
- <optional>
1168
- <attribute name="id">
1169
- <data type="ID"/>
1170
- </attribute>
1171
- </optional>
1172
- <optional>
1173
- <attribute name="language"/>
1174
- </optional>
1175
- <optional>
1176
- <attribute name="script"/>
1177
- </optional>
1178
- <optional>
1179
- <attribute name="inline-header">
1180
- <data type="boolean"/>
1181
- </attribute>
1182
- </optional>
1183
- <attribute name="obligation">
1184
- <choice>
1185
- <value>normative</value>
1186
- <value>informative</value>
1187
- </choice>
1188
- </attribute>
1189
- <optional>
1190
- <ref name="section-title"/>
1191
- </optional>
1192
- <group>
1193
- <group>
1194
- <zeroOrMore>
1195
- <ref name="BasicBlock"/>
1196
- </zeroOrMore>
1197
- <zeroOrMore>
1198
- <ref name="note"/>
1199
- </zeroOrMore>
1200
- </group>
1201
- <zeroOrMore>
1202
- <choice>
1203
- <ref name="annex-subsection"/>
1204
- <ref name="terms"/>
1205
- <ref name="definitions"/>
1206
- <ref name="references"/>
1207
- </choice>
1208
- </zeroOrMore>
1209
- </group>
1202
+ <ref name="Annex-Section"/>
1210
1203
  </element>
1211
1204
  </define>
1212
1205
  <define name="terms">
@@ -41,6 +41,7 @@
41
41
  <value>technical-report</value>
42
42
  <value>joint-itu-iso-iec</value>
43
43
  <value>resolution</value>
44
+ <value>service-publication</value>
44
45
  </choice>
45
46
  </define>
46
47
  <define name="editorialgroup">
@@ -11,7 +11,7 @@ module Asciidoctor
11
11
  %w(recommendation recommendation-supplement recommendation-amendment
12
12
  recommendation-corrigendum recommendation-errata recommendation-annex
13
13
  focus-group implementers-guide technical-paper technical-report
14
- joint-itu-iso-iec).include? doctype or
14
+ joint-itu-iso-iec service-publication).include? doctype or
15
15
  @log.add("Document Attributes", nil,
16
16
  "#{doctype} is not a recognised document type")
17
17
  end
@@ -67,15 +67,8 @@ module Asciidoctor
67
67
  end
68
68
 
69
69
  # Editing Guidelines 9.4.3
70
+ # Supplanted by rendering
70
71
  def numbers_validate(xmldoc)
71
- xmldoc.xpath("//clause | //preface/* | //annex").each do |x|
72
- xx = x.dup
73
- xx.xpath("./clause").each { |c| c.remove }
74
- style_two_regex_not_prev(x, extract_text(xx),
75
- /^(?<num>-?[0-9][0-9,. ]{3,})$/,
76
- %r{(\bISO|\bIEC|\bIEEE/)$},
77
- "number not broken up in threes by apostrophe")
78
- end
79
72
  end
80
73
 
81
74
  def style_two_regex_not_prev(n, text, re, re_prev, warning)
@@ -23,12 +23,6 @@ module IsoDoc
23
23
  end
24
24
  end
25
25
 
26
- def bracket_opt(b)
27
- return b if b.nil?
28
- return b if /^\[.+\]$/.match(b)
29
- "[#{b}]"
30
- end
31
-
32
26
  def clausedelim
33
27
  ""
34
28
  end
@@ -133,6 +127,7 @@ module IsoDoc
133
127
 
134
128
  def info(isoxml, out)
135
129
  @meta.ip_notice_received isoxml, out
130
+ @meta.techreport isoxml, out
136
131
  super
137
132
  end
138
133