metanorma-itu 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/.hound.yml +3 -0
  3. data/.rubocop.yml +10 -0
  4. data/.travis.yml +17 -0
  5. data/CODE_OF_CONDUCT.md +74 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE +25 -0
  8. data/README.adoc +72 -0
  9. data/Rakefile +6 -0
  10. data/appveyor.yml +29 -0
  11. data/lib/asciidoctor/itu.rb +7 -0
  12. data/lib/asciidoctor/itu/biblio.rng +949 -0
  13. data/lib/asciidoctor/itu/converter.rb +164 -0
  14. data/lib/asciidoctor/itu/front.rb +182 -0
  15. data/lib/asciidoctor/itu/isodoc.rng +1132 -0
  16. data/lib/asciidoctor/itu/isostandard.rng +801 -0
  17. data/lib/asciidoctor/itu/itu.rng +223 -0
  18. data/lib/asciidoctor/itu/reqt.rng +162 -0
  19. data/lib/asciidoctor/itu/validate.rb +55 -0
  20. data/lib/isodoc/itu.rb +11 -0
  21. data/lib/isodoc/itu/base_convert.rb +210 -0
  22. data/lib/isodoc/itu/html/Logo_ITU.jpg +0 -0
  23. data/lib/isodoc/itu/html/header.html +162 -0
  24. data/lib/isodoc/itu/html/html_itu_intro.html +42 -0
  25. data/lib/isodoc/itu/html/html_itu_titlepage.html +144 -0
  26. data/lib/isodoc/itu/html/htmlstyle.scss +1167 -0
  27. data/lib/isodoc/itu/html/itu-document-comb.png +0 -0
  28. data/lib/isodoc/itu/html/itu.scss +707 -0
  29. data/lib/isodoc/itu/html/logo.png +0 -0
  30. data/lib/isodoc/itu/html/scripts.html +82 -0
  31. data/lib/isodoc/itu/html/scripts.pdf.html +70 -0
  32. data/lib/isodoc/itu/html/word_itu_intro.html +246 -0
  33. data/lib/isodoc/itu/html/word_itu_titlepage.html +283 -0
  34. data/lib/isodoc/itu/html/wordstyle.scss +1237 -0
  35. data/lib/isodoc/itu/html_convert.rb +72 -0
  36. data/lib/isodoc/itu/i18n-en.yaml +2 -0
  37. data/lib/isodoc/itu/metadata.rb +100 -0
  38. data/lib/isodoc/itu/pdf_convert.rb +70 -0
  39. data/lib/isodoc/itu/word_convert.rb +115 -0
  40. data/lib/metanorma-itu.rb +8 -0
  41. data/lib/metanorma/itu.rb +11 -0
  42. data/lib/metanorma/itu/processor.rb +43 -0
  43. data/lib/metanorma/itu/version.rb +5 -0
  44. data/metanorma-itu.gemspec +44 -0
  45. metadata +327 -0
@@ -0,0 +1,223 @@
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">
3
+ <!--
4
+ Currently we inherit from a namespaced grammar, isostandard. Until we inherit from isodoc,
5
+ we cannot have a new default namespace: we will end up with a grammar with two different
6
+ namespaces, one for isostandard and one for csand additions. And we do not want that.
7
+ -->
8
+ <include href="isostandard.rng">
9
+ <start>
10
+ <ref name="itu"/>
11
+ </start>
12
+ <define name="figure">
13
+ <element name="figure">
14
+ <attribute name="id">
15
+ <data type="ID"/>
16
+ </attribute>
17
+ <optional>
18
+ <ref name="tname"/>
19
+ </optional>
20
+ <choice>
21
+ <ref name="image"/>
22
+ <ref name="pre"/>
23
+ <oneOrMore>
24
+ <ref name="subfigure"/>
25
+ </oneOrMore>
26
+ </choice>
27
+ <zeroOrMore>
28
+ <ref name="fn"/>
29
+ </zeroOrMore>
30
+ <optional>
31
+ <ref name="dl"/>
32
+ </optional>
33
+ <zeroOrMore>
34
+ <ref name="note"/>
35
+ </zeroOrMore>
36
+ </element>
37
+ </define>
38
+ <define name="subfigure">
39
+ <element name="figure">
40
+ <attribute name="id">
41
+ <data type="ID"/>
42
+ </attribute>
43
+ <optional>
44
+ <ref name="tname"/>
45
+ </optional>
46
+ <choice>
47
+ <ref name="image"/>
48
+ <ref name="pre"/>
49
+ </choice>
50
+ </element>
51
+ </define>
52
+ <define name="DocumentType">
53
+ <choice>
54
+ <value>recommendation</value>
55
+ <value>recommendation-supplement</value>
56
+ <value>recommendation-amendment</value>
57
+ <value>recommendation-corrigendum</value>
58
+ <value>recommendation-errata</value>
59
+ <value>recommendation-annex</value>
60
+ <value>focus-group</value>
61
+ <value>implementers-guide</value>
62
+ <value>technical-paper</value>
63
+ <value>technical-report</value>
64
+ <value>joint-itu-iso-iec</value>
65
+ </choice>
66
+ </define>
67
+ <define name="editorialgroup">
68
+ <element name="editorialgroup">
69
+ <ref name="bureau"/>
70
+ <ref name="group"/>
71
+ <optional>
72
+ <ref name="subgroup"/>
73
+ </optional>
74
+ <optional>
75
+ <ref name="workgroup"/>
76
+ </optional>
77
+ </element>
78
+ </define>
79
+ <define name="workgroup">
80
+ <element name="workgroup">
81
+ <ref name="ItuGroup"/>
82
+ </element>
83
+ </define>
84
+ <define name="BibDataExtensionType">
85
+ <optional>
86
+ <ref name="doctype"/>
87
+ </optional>
88
+ <ref name="editorialgroup"/>
89
+ <zeroOrMore>
90
+ <ref name="ics"/>
91
+ </zeroOrMore>
92
+ <zeroOrMore>
93
+ <ref name="bkeyword"/>
94
+ </zeroOrMore>
95
+ <optional>
96
+ <ref name="recommendationstatus"/>
97
+ </optional>
98
+ </define>
99
+ </include>
100
+ <define name="recommendationstatus">
101
+ <element name="recommendationstatus">
102
+ <element name="from">
103
+ <ref name="ISO8601Date"/>
104
+ </element>
105
+ <element name="to">
106
+ <ref name="ISO8601Date"/>
107
+ </element>
108
+ <optional>
109
+ <ref name="approvalstage"/>
110
+ </optional>
111
+ </element>
112
+ </define>
113
+ <define name="approvalstage">
114
+ <element name="approvalstage">
115
+ <attribute name="process">
116
+ <choice>
117
+ <value>tap</value>
118
+ <value>aap</value>
119
+ </choice>
120
+ </attribute>
121
+ <choice>
122
+ <value>determined</value>
123
+ <value>in-force</value>
124
+ <value>a</value>
125
+ <value>lc</value>
126
+ <value>ac</value>
127
+ <value>lj</value>
128
+ <value>aj</value>
129
+ <value>na</value>
130
+ <value>ar</value>
131
+ <value>ri</value>
132
+ <value>at</value>
133
+ <value>sg</value>
134
+ <value>c</value>
135
+ <value>tap</value>
136
+ </choice>
137
+ </element>
138
+ </define>
139
+ <define name="bkeyword">
140
+ <element name="keyword">
141
+ <text/>
142
+ </element>
143
+ </define>
144
+ <define name="bureau">
145
+ <element name="bureau">
146
+ <choice>
147
+ <value>T</value>
148
+ <value>D</value>
149
+ <value>R</value>
150
+ </choice>
151
+ </element>
152
+ </define>
153
+ <define name="group">
154
+ <element name="group">
155
+ <ref name="ItuGroup"/>
156
+ </element>
157
+ </define>
158
+ <define name="subgroup">
159
+ <element name="subgroup">
160
+ <ref name="ItuGroup"/>
161
+ </element>
162
+ </define>
163
+ <define name="ItuGroup">
164
+ <optional>
165
+ <attribute name="type">
166
+ <choice>
167
+ <value>tsag</value>
168
+ <value>study-group</value>
169
+ <value>work-group</value>
170
+ </choice>
171
+ </attribute>
172
+ </optional>
173
+ <ref name="tname"/>
174
+ <optional>
175
+ <ref name="groupacronym"/>
176
+ </optional>
177
+ <optional>
178
+ <ref name="groupperiod"/>
179
+ </optional>
180
+ </define>
181
+ <define name="groupacronym">
182
+ <element name="acronym">
183
+ <text/>
184
+ </element>
185
+ </define>
186
+ <define name="groupperiod">
187
+ <element name="period">
188
+ <ref name="groupperiodstart"/>
189
+ <optional>
190
+ <ref name="groupperiodend"/>
191
+ </optional>
192
+ </element>
193
+ </define>
194
+ <define name="groupperiodstart">
195
+ <element name="start">
196
+ <data type="gYear"/>
197
+ </element>
198
+ </define>
199
+ <define name="groupperiodend">
200
+ <element name="end">
201
+ <data type="gYear"/>
202
+ </element>
203
+ </define>
204
+ <define name="itu">
205
+ <element name="itu-standard">
206
+ <ref name="bibdata"/>
207
+ <zeroOrMore>
208
+ <ref name="termdocsource"/>
209
+ </zeroOrMore>
210
+ <optional>
211
+ <ref name="boilerplate"/>
212
+ </optional>
213
+ <ref name="preface"/>
214
+ <oneOrMore>
215
+ <ref name="sections"/>
216
+ </oneOrMore>
217
+ <zeroOrMore>
218
+ <ref name="annex"/>
219
+ </zeroOrMore>
220
+ <ref name="bibliography"/>
221
+ </element>
222
+ </define>
223
+ </grammar>
@@ -0,0 +1,162 @@
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">
3
+ <!--
4
+ Presupposes isodoc.rnc, is included in it
5
+ include "isodoc.rnc" { }
6
+ -->
7
+ <define name="requirement">
8
+ <element name="requirement">
9
+ <ref name="RequirementType"/>
10
+ </element>
11
+ </define>
12
+ <define name="recommendation">
13
+ <element name="recommendation">
14
+ <ref name="RequirementType"/>
15
+ </element>
16
+ </define>
17
+ <define name="permission">
18
+ <element name="permission">
19
+ <ref name="RequirementType"/>
20
+ </element>
21
+ </define>
22
+ <define name="RequirementType">
23
+ <optional>
24
+ <attribute name="obligation">
25
+ <ref name="ObligationType"/>
26
+ </attribute>
27
+ </optional>
28
+ <optional>
29
+ <attribute name="unnumbered">
30
+ <data type="boolean"/>
31
+ </attribute>
32
+ </optional>
33
+ <attribute name="id">
34
+ <data type="ID"/>
35
+ </attribute>
36
+ <optional>
37
+ <attribute name="filename"/>
38
+ </optional>
39
+ <optional>
40
+ <ref name="reqtitle"/>
41
+ </optional>
42
+ <optional>
43
+ <ref name="label"/>
44
+ </optional>
45
+ <optional>
46
+ <ref name="subject"/>
47
+ </optional>
48
+ <optional>
49
+ <ref name="reqinherit"/>
50
+ </optional>
51
+ <zeroOrMore>
52
+ <ref name="classification"/>
53
+ </zeroOrMore>
54
+ <zeroOrMore>
55
+ <choice>
56
+ <ref name="measurementtarget"/>
57
+ <ref name="specification"/>
58
+ <ref name="verification"/>
59
+ <ref name="import"/>
60
+ <ref name="description"/>
61
+ </choice>
62
+ </zeroOrMore>
63
+ <optional>
64
+ <ref name="reqt_references"/>
65
+ </optional>
66
+ <zeroOrMore>
67
+ <choice>
68
+ <ref name="requirement"/>
69
+ <ref name="recommendation"/>
70
+ <ref name="permission"/>
71
+ </choice>
72
+ </zeroOrMore>
73
+ </define>
74
+ <define name="reqtitle">
75
+ <element name="title">
76
+ <ref name="FormattedString"/>
77
+ </element>
78
+ </define>
79
+ <define name="label">
80
+ <element name="label">
81
+ <text/>
82
+ </element>
83
+ </define>
84
+ <define name="subject">
85
+ <element name="subject">
86
+ <text/>
87
+ </element>
88
+ </define>
89
+ <define name="reqinherit">
90
+ <element name="subject">
91
+ <text/>
92
+ </element>
93
+ </define>
94
+ <define name="measurementtarget">
95
+ <element name="measurement-target">
96
+ <ref name="RequirementSubpart"/>
97
+ </element>
98
+ </define>
99
+ <define name="specification">
100
+ <element name="specification">
101
+ <ref name="RequirementSubpart"/>
102
+ </element>
103
+ </define>
104
+ <define name="verification">
105
+ <element name="verification">
106
+ <ref name="RequirementSubpart"/>
107
+ </element>
108
+ </define>
109
+ <define name="import">
110
+ <element name="import">
111
+ <ref name="RequirementSubpart"/>
112
+ </element>
113
+ </define>
114
+ <define name="description">
115
+ <element name="description">
116
+ <ref name="RequirementSubpart"/>
117
+ </element>
118
+ </define>
119
+ <define name="reqt_references">
120
+ <element name="references">
121
+ <oneOrMore>
122
+ <ref name="bibitem"/>
123
+ </oneOrMore>
124
+ </element>
125
+ </define>
126
+ <define name="RequirementSubpart">
127
+ <optional>
128
+ <attribute name="type"/>
129
+ </optional>
130
+ <optional>
131
+ <attribute name="exclude">
132
+ <data type="boolean"/>
133
+ </attribute>
134
+ </optional>
135
+ <oneOrMore>
136
+ <ref name="BasicBlock"/>
137
+ </oneOrMore>
138
+ </define>
139
+ <define name="ObligationType">
140
+ <choice>
141
+ <value>requirement</value>
142
+ <value>recommendation</value>
143
+ <value>permission</value>
144
+ </choice>
145
+ </define>
146
+ <define name="classification">
147
+ <element name="classification">
148
+ <ref name="classification_tag"/>
149
+ <ref name="classification_value"/>
150
+ </element>
151
+ </define>
152
+ <define name="classification_tag">
153
+ <element name="tag">
154
+ <text/>
155
+ </element>
156
+ </define>
157
+ <define name="classification_value">
158
+ <element name="value">
159
+ <text/>
160
+ </element>
161
+ </define>
162
+ </grammar>
@@ -0,0 +1,55 @@
1
+ module Asciidoctor
2
+ module ITU
3
+ class Converter < Standoc::Converter
4
+ def bibdata_validate(doc)
5
+ doctype_validate(doc)
6
+ stage_validate(doc)
7
+ end
8
+
9
+ def doctype_validate(xmldoc)
10
+ doctype = xmldoc&.at("//bibdata/ext/doctype")&.text
11
+ %w(recommendation recommendation-supplement recommendation-amendment
12
+ recommendation-corrigendum recommendation-errata recommendation-annex
13
+ focus-group implementers-guide technical-paper technical-report
14
+ joint-itu-iso-iec).include? doctype or
15
+ warn "Document Attributes: #{doctype} is not a recognised document type"
16
+ end
17
+
18
+ def stage_validate(xmldoc)
19
+ stage = xmldoc&.at("//bibdata/status/stage")&.text
20
+ %w(in-force superseded in-force-prepublished withdrawn).include? stage or
21
+ warn "Document Attributes: #{stage} is not a recognised status"
22
+ end
23
+
24
+ def content_validate(doc)
25
+ super
26
+ approval_validate(doc)
27
+ itu_identifier_validate(doc)
28
+ bibdata_validate(doc.root)
29
+ end
30
+
31
+ def approval_validate(xmldoc)
32
+ s = xmldoc.at("//bibdata/recommendationstatus") || return
33
+ process = s.at("./@process").text
34
+ if process == "aap" and %w(determined in-force).include? s.text
35
+ warn "Recommendation Status #{s.text} inconsistent with AAP"
36
+ end
37
+ if process == "tap" and !%w(determined in-force).include? s.text
38
+ warn "Recommendation Status #{s.text} inconsistent with TAP"
39
+ end
40
+ end
41
+
42
+ def itu_identifier_validate(xmldoc)
43
+ s = xmldoc.xpath("//bibdata/docidentifier[@type = 'ITU']").each do |x|
44
+ /^ITU-[RTF] [AD-VX-Z]\.[0-9]+$/.match x.text or
45
+ warn "#{x.text} does not match ITU document identifier conventions"
46
+ end
47
+ end
48
+
49
+ end
50
+ end
51
+ end
52
+
53
+ DocumentType =
54
+ "recommendation" | "recommendation-supplement" | "recommendation-amendment" | "recommendation-corrigendum" | "recommendation-errata" |
55
+ "recommendation-annex" | "focus-group" | "implementers-guide" | "technical-paper" | "technical-report" | "joint-itu-iso-iec"
data/lib/isodoc/itu.rb ADDED
@@ -0,0 +1,11 @@
1
+ require "isodoc/itu/metadata"
2
+ require "isodoc/itu/base_convert"
3
+ require "isodoc/itu/html_convert"
4
+ require "isodoc/itu/pdf_convert"
5
+ require "isodoc/itu/word_convert"
6
+
7
+ module IsoDoc
8
+ module ITU
9
+
10
+ end
11
+ end