metanorma-itu 1.2.4 → 1.2.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) 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 +32 -0
  5. data/lib/asciidoctor/itu/boilerplate.xml +3 -0
  6. data/lib/asciidoctor/itu/converter.rb +3 -2
  7. data/lib/asciidoctor/itu/front.rb +74 -15
  8. data/lib/asciidoctor/itu/isodoc.rng +29 -44
  9. data/lib/asciidoctor/itu/itu.rng +61 -0
  10. data/lib/asciidoctor/itu/validate.rb +2 -9
  11. data/lib/isodoc/itu/base_convert.rb +1 -6
  12. data/lib/isodoc/itu/html/_coverpage.css +8 -1
  13. data/lib/isodoc/itu/html/_coverpage.scss +4 -0
  14. data/lib/isodoc/itu/html/header.html +8 -16
  15. data/lib/isodoc/itu/html/html_itu_intro.html +4 -3
  16. data/lib/isodoc/itu/html/html_itu_titlepage.html +30 -13
  17. data/lib/isodoc/itu/html/htmlstyle.css +782 -759
  18. data/lib/isodoc/itu/html/htmlstyle.scss +7 -8
  19. data/lib/isodoc/itu/html/itu.css +43 -43
  20. data/lib/isodoc/itu/html/itu.scss +44 -43
  21. data/lib/isodoc/itu/html/logo-sp.png +0 -0
  22. data/lib/isodoc/itu/html/word_itu_intro.html +29 -3
  23. data/lib/isodoc/itu/html/word_itu_titlepage.html +143 -4
  24. data/lib/isodoc/itu/html/word_itu_titlepage_sp.html +108 -0
  25. data/lib/isodoc/itu/html/wordstyle.css +37 -37
  26. data/lib/isodoc/itu/html/wordstyle.scss +37 -37
  27. data/lib/isodoc/itu/html_convert.rb +7 -2
  28. data/lib/isodoc/itu/i18n-en.yaml +42 -0
  29. data/lib/isodoc/itu/itu.recommendation-annex.xsl +921 -180
  30. data/lib/isodoc/itu/itu.recommendation.xsl +921 -180
  31. data/lib/isodoc/itu/itu.resolution.xsl +921 -180
  32. data/lib/isodoc/itu/itu.technical-paper.xsl +5184 -0
  33. data/lib/isodoc/itu/itu.technical-report.xsl +5184 -0
  34. data/lib/isodoc/itu/metadata.rb +79 -4
  35. data/lib/isodoc/itu/pdf_convert.rb +2 -0
  36. data/lib/isodoc/itu/presentation_xml_convert.rb +68 -0
  37. data/lib/isodoc/itu/ref.rb +0 -13
  38. data/lib/isodoc/itu/terms.rb +7 -30
  39. data/lib/isodoc/itu/word_cleanup.rb +5 -1
  40. data/lib/isodoc/itu/word_convert.rb +15 -1
  41. data/lib/isodoc/itu/xref.rb +2 -2
  42. data/lib/metanorma/itu/fonts_manifest.yaml +4 -0
  43. data/lib/metanorma/itu/processor.rb +0 -8
  44. data/lib/metanorma/itu/version.rb +1 -1
  45. data/metanorma-itu.gemspec +3 -1
  46. metadata +38 -7
  47. data/.github/workflows/macos.yml +0 -38
  48. data/.github/workflows/ubuntu.yml +0 -56
  49. data/.github/workflows/windows.yml +0 -40
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5ba47f749671a89645723abe98c885b11763bc82af7f2ae51dd61bf258c6c020
4
- data.tar.gz: d7d9ca77cb3378430bb1c9d93c3027609c2f4154e4387178f394536f505742f0
3
+ metadata.gz: 4a55d05a3d934a812b372c286512e5fb68669e934fdf564af21ec47695680374
4
+ data.tar.gz: c4a84f598551512a1dcd029c5af2b765a8ffa133f2d8f88df6e4b2fe04ff6bce
5
5
  SHA512:
6
- metadata.gz: 1587f02fd05eade3ee88febabfb053f0a295e982bf1285b067d99d81eba1a34c593ee4971ad6e3c909424193a8852ba0f4061ecf4c5c5622416289006f7d1a53
7
- data.tar.gz: 85573c130621858588e1f0910a10d99ff874c930acf191b793abaea98c63d17492de7ab95bc402f2dab2ff22844e0763d7d3f69f568e19d173109fde53a71ae2
6
+ metadata.gz: f5b9e4c6265927997e40bb3178040efde32681cf159a1a33e560b02c0e982b8de2efa5851f161425860e487bb455eeac848c76b14d5823100bd2c5ffd7f8a310
7
+ data.tar.gz: 2e2b8bab79a9085704a8fab36944fe0670ca37758e156e4fac20e67cb713f7337b0cc13a23042296e28ac313c1152cc6ca48212be033ccfffdfb074fbe30f074
@@ -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">
@@ -737,6 +738,37 @@
737
738
  </optional>
738
739
  </element>
739
740
  </define>
741
+ <define name="index-xref">
742
+ <element name="index-xref">
743
+ <attribute name="also">
744
+ <data type="boolean"/>
745
+ </attribute>
746
+ <element name="primary">
747
+ <oneOrMore>
748
+ <ref name="PureTextElement"/>
749
+ </oneOrMore>
750
+ </element>
751
+ <optional>
752
+ <element name="secondary">
753
+ <oneOrMore>
754
+ <ref name="PureTextElement"/>
755
+ </oneOrMore>
756
+ </element>
757
+ </optional>
758
+ <optional>
759
+ <element name="tertiary">
760
+ <oneOrMore>
761
+ <ref name="PureTextElement"/>
762
+ </oneOrMore>
763
+ </element>
764
+ </optional>
765
+ <element name="target">
766
+ <oneOrMore>
767
+ <ref name="PureTextElement"/>
768
+ </oneOrMore>
769
+ </element>
770
+ </element>
771
+ </define>
740
772
  <!-- bare ID element, used for referencing arbitrary spans of text -->
741
773
  <define name="bookmark">
742
774
  <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
 
@@ -60,8 +60,9 @@ module Asciidoctor
60
60
  nil, false, "#{@filename}.html")
61
61
  doc_converter(node).convert(@filename + ".presentation.xml",
62
62
  nil, false, "#{@filename}.doc")
63
- pdf_converter(node)&.convert(@filename + ".presentation.xml",
64
- nil, false, "#{@filename}.pdf")
63
+ node.attr("no-pdf") or
64
+ pdf_converter(node)&.convert(@filename + ".presentation.xml",
65
+ nil, false, "#{@filename}.pdf")
65
66
  end
66
67
 
67
68
  def validate(doc)
@@ -34,32 +34,34 @@ module Asciidoctor
34
34
  type = /^annex/.match(k) ? "annex" : "main"
35
35
  xml.title **attr_code(language: lang, format: "text/plain",
36
36
  type: type) do |t|
37
- t << v
37
+ t << Asciidoctor::Standoc::Utils::asciidoc_sub(v)
38
38
  end
39
39
  end
40
40
  end
41
41
 
42
42
  def title(node, xml)
43
43
  super
44
- subtitle_english(node, xml)
45
- subtitle_otherlangs(node, xml)
44
+ %w(subtitle amendment-title corrigendum-title).each do |t|
45
+ other_title_english(node, xml, t)
46
+ other_title_otherlangs(node, xml, t)
47
+ end
46
48
  end
47
49
 
48
- def subtitle_english(node, xml)
49
- at = { language: "en", format: "text/plain", type: "subtitle" }
50
- a = node.attr("subtitle") || node.attr("subtitle-en")
50
+ def other_title_english(node, xml, type)
51
+ at = { language: "en", format: "text/plain", type: type.sub(/-title/, "") }
52
+ a = node.attr(type) || node.attr("#{type}-en")
51
53
  xml.title **attr_code(at) do |t|
52
54
  t << Asciidoctor::Standoc::Utils::asciidoc_sub(a)
53
55
  end
54
56
  end
55
57
 
56
- def subtitle_otherlangs(node, xml)
58
+ def other_title_otherlangs(node, xml, type)
57
59
  node.attributes.each do |k, v|
58
- next unless /^subtitle-(?<lang>.+)$/ =~ k
59
- next if lang == "en"
60
- xml.title **attr_code(language: lang, format: "text/plain",
61
- type: "subtitle") do |t|
62
- t << v
60
+ next unless m = /^#{type}-(?<lang>.+)$/.match(k)
61
+ next if m[:lang] == "en"
62
+ xml.title **attr_code(language: m[:lang], format: "text/plain",
63
+ type: type.sub(/-title/, "")) do |t|
64
+ t << Asciidoctor::Standoc::Utils::asciidoc_sub(v)
63
65
  end
64
66
  end
65
67
  end
@@ -114,6 +116,7 @@ module Asciidoctor
114
116
  def metadata_id(node, xml)
115
117
  provisional_id(node, xml)
116
118
  itu_id(node, xml)
119
+ recommendation_id(node, xml)
117
120
  end
118
121
 
119
122
  def provisional_id(node, xml)
@@ -123,16 +126,41 @@ module Asciidoctor
123
126
  end
124
127
  end
125
128
 
126
- 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)
127
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)
128
145
  return unless node.attr("docnumber")
129
146
  xml.docidentifier **{type: "ITU"} do |i|
130
- i << "ITU-#{bureau} "\
131
- "#{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)
132
151
  end
133
152
  xml.docnumber { |i| i << node.attr("docnumber") }
134
153
  end
135
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
+
136
164
  def metadata_series(node, xml)
137
165
  node.attr("series") and
138
166
  xml.series **{ type: "main" } do |s|
@@ -171,6 +199,36 @@ module Asciidoctor
171
199
  i.bureau node.attr("bureau") || "T"
172
200
  i.docnumber node.attr("docnumber")
173
201
  a = node.attr("annexid") and i.annexid a
202
+ a = node.attr("amendment-number") and i.amendment a
203
+ a = node.attr("corrigendum-number") and i.corrigendum a
204
+ end
205
+ end
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
174
232
  end
175
233
  end
176
234
 
@@ -180,6 +238,7 @@ module Asciidoctor
180
238
  metadata_ics(node, xml)
181
239
  metadata_recommendationstatus(node, xml)
182
240
  metadata_ip_notice(node, xml)
241
+ metadata_techreport(node, xml)
183
242
  structured_id(node, xml)
184
243
  end
185
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">
@@ -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>
@@ -142,6 +149,11 @@
142
149
  <data type="boolean"/>
143
150
  </attribute>
144
151
  </optional>
152
+ <optional>
153
+ <attribute name="key">
154
+ <data type="boolean"/>
155
+ </attribute>
156
+ </optional>
145
157
  <oneOrMore>
146
158
  <ref name="dt"/>
147
159
  <ref name="dd"/>
@@ -234,6 +246,9 @@
234
246
  <data type="boolean"/>
235
247
  </attribute>
236
248
  </optional>
249
+ <optional>
250
+ <ref name="colgroup"/>
251
+ </optional>
237
252
  <optional>
238
253
  <ref name="tname"/>
239
254
  </optional>
@@ -752,6 +767,18 @@
752
767
  </define>
753
768
  </include>
754
769
  <!-- end overrides -->
770
+ <define name="colgroup">
771
+ <element name="colgroup">
772
+ <oneOrMore>
773
+ <ref name="col"/>
774
+ </oneOrMore>
775
+ </element>
776
+ </define>
777
+ <define name="col">
778
+ <element name="col">
779
+ <attribute name="width"/>
780
+ </element>
781
+ </define>
755
782
  <define name="TextElement" combine="choice">
756
783
  <ref name="concept"/>
757
784
  </define>
@@ -1165,49 +1192,7 @@
1165
1192
  </define>
1166
1193
  <define name="annex">
1167
1194
  <element name="annex">
1168
- <optional>
1169
- <attribute name="id">
1170
- <data type="ID"/>
1171
- </attribute>
1172
- </optional>
1173
- <optional>
1174
- <attribute name="language"/>
1175
- </optional>
1176
- <optional>
1177
- <attribute name="script"/>
1178
- </optional>
1179
- <optional>
1180
- <attribute name="inline-header">
1181
- <data type="boolean"/>
1182
- </attribute>
1183
- </optional>
1184
- <attribute name="obligation">
1185
- <choice>
1186
- <value>normative</value>
1187
- <value>informative</value>
1188
- </choice>
1189
- </attribute>
1190
- <optional>
1191
- <ref name="section-title"/>
1192
- </optional>
1193
- <group>
1194
- <group>
1195
- <zeroOrMore>
1196
- <ref name="BasicBlock"/>
1197
- </zeroOrMore>
1198
- <zeroOrMore>
1199
- <ref name="note"/>
1200
- </zeroOrMore>
1201
- </group>
1202
- <zeroOrMore>
1203
- <choice>
1204
- <ref name="annex-subsection"/>
1205
- <ref name="terms"/>
1206
- <ref name="definitions"/>
1207
- <ref name="references"/>
1208
- </choice>
1209
- </zeroOrMore>
1210
- </group>
1195
+ <ref name="Annex-Section"/>
1211
1196
  </element>
1212
1197
  </define>
1213
1198
  <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">
@@ -68,6 +69,16 @@
68
69
  <text/>
69
70
  </element>
70
71
  </optional>
72
+ <optional>
73
+ <element name="amendment">
74
+ <data type="int"/>
75
+ </element>
76
+ </optional>
77
+ <optional>
78
+ <element name="corrigendum">
79
+ <data type="int"/>
80
+ </element>
81
+ </optional>
71
82
  </element>
72
83
  </define>
73
84
  <define name="BibDataExtensionType">
@@ -84,6 +95,18 @@
84
95
  <optional>
85
96
  <ref name="ipnoticereceived"/>
86
97
  </optional>
98
+ <optional>
99
+ <ref name="meeting"/>
100
+ </optional>
101
+ <optional>
102
+ <ref name="meeting-date"/>
103
+ </optional>
104
+ <optional>
105
+ <ref name="intended-type"/>
106
+ </optional>
107
+ <optional>
108
+ <ref name="ext_source"/>
109
+ </optional>
87
110
  <optional>
88
111
  <ref name="structuredidentifier"/>
89
112
  </optional>
@@ -103,6 +126,44 @@
103
126
  </element>
104
127
  </define>
105
128
  </include>
129
+ <define name="meeting">
130
+ <element name="meeting">
131
+ <text/>
132
+ </element>
133
+ </define>
134
+ <define name="meeting-date">
135
+ <element name="meeting-date">
136
+ <choice>
137
+ <group>
138
+ <element name="from">
139
+ <ref name="ISO8601Date"/>
140
+ </element>
141
+ <optional>
142
+ <element name="to">
143
+ <ref name="ISO8601Date"/>
144
+ </element>
145
+ </optional>
146
+ </group>
147
+ <element name="on">
148
+ <ref name="ISO8601Date"/>
149
+ </element>
150
+ </choice>
151
+ </element>
152
+ </define>
153
+ <define name="intended-type">
154
+ <element name="intended-type">
155
+ <choice>
156
+ <value>R</value>
157
+ <value>C</value>
158
+ <value>TD</value>
159
+ </choice>
160
+ </element>
161
+ </define>
162
+ <define name="ext_source">
163
+ <element name="source">
164
+ <text/>
165
+ </element>
166
+ </define>
106
167
  <define name="TextElement" combine="choice">
107
168
  <choice>
108
169
  <ref name="add"/>