metanorma-itu 1.0.10 → 1.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 769b5dfa383417d0e825e49c1fdfc4cbf94cf3beae6664059b726f744f0ce644
4
- data.tar.gz: 747f979885c03d835f9ebac18dd037e39101182ecb7d419516ea43db44cee2ef
3
+ metadata.gz: e0b6bcda9ee8aa042d7647e9b8865c7bac5a07943541e6278ac311ae35b7ecdb
4
+ data.tar.gz: 2c2916e7706336f89a13d65cd63022a0a2288a576957684856134f482ecfa7eb
5
5
  SHA512:
6
- metadata.gz: '099437ac36008d722c6c6e1838f9a59e11bbff63973446b1c8259260c5785497972d92089708df367dfc3cf90eaa5faf2292f5267d38a125494114374e51e6d2'
7
- data.tar.gz: 88a1bca6a28030750b72e438453c8f5aeaaafe8aaff00fef2e616f81b97fd5c7a7218e8f8e4e0a70b48c4226f4c5b99ececcfe4e261f62ea142a04ba43e47b2e
6
+ metadata.gz: 3905f473b483696859238779600e0074eb3fb668cef4898ce288d62be053339426afee23d8c6e32e36c8a706dbe0be0f60c5626181c45f78cea30b2baa9e7a23
7
+ data.tar.gz: 21907c33e9ad329cf2852b10ccce61b9ca407c9fb0e01896a69c60d380d665df3366721cd155db14c48549b1b350c6f74922fe2213f5fdef6c21468a9ad2d586
@@ -6,6 +6,71 @@ module Asciidoctor
6
6
  x.xpath("//*[@inline-header]").each do |h|
7
7
  h.delete("inline-header")
8
8
  end
9
+ insert_missing_sections(x) unless @no_insert_missing_sections
10
+ end
11
+
12
+ def table_cleanup(xmldoc)
13
+ super
14
+ xmldoc.xpath("//thead/tr[1]/th | //thead/tr[1]/td").each do |t|
15
+ text = t.at("./descendant::text()") or next
16
+ text.replace(text.text.titlecase)
17
+ end
18
+ end
19
+
20
+ def insert_missing_sections(x)
21
+ insert_scope(x)
22
+ insert_norm_ref(x)
23
+ insert_terms(x)
24
+ insert_symbols(x)
25
+ insert_conventions(x)
26
+ end
27
+
28
+ def insert_scope(x)
29
+ x.at("./*/sections") or
30
+ x.at("./*/preface | ./*/boilerplate | ./*/bibdata").next =
31
+ "<sections><sentinel/></sections>"
32
+ x.at("./*/sections/*") or x.at("./*/sections") << "<sentinel/>"
33
+ ins = x.at("//sections").children.first
34
+ unless x.at("//sections/clause/title[text() = 'Scope']")
35
+ ins.previous = "<clause><title>Scope</title><p>"\
36
+ "#{@labels['clause_empty']}</p></clause>"
37
+ end
38
+ x&.at("//sentinel")&.remove
39
+ end
40
+
41
+ def insert_norm_ref(x)
42
+ x.at("//bibliography") or x.at("./*/annex[last()] | ./*/sections").next =
43
+ "<bibliography><sentinel/></bibliography>"
44
+ ins = x.at("//bibliography").children.first
45
+ unless x.at("//bibliography/references/title[text() = 'References']")
46
+ ins.previous = "<references><title>References</title><p>"\
47
+ "#{@labels['clause_empty']}</p></references>"
48
+ end
49
+ x&.at("//sentinel")&.remove
50
+ end
51
+
52
+ def insert_terms(x)
53
+ ins = x.at("//sections/clause/title[text() = 'Scope']")
54
+ unless x.at("//sections/terms")
55
+ ins.next = "<terms><title>Definitions</title><p>"\
56
+ "#{@labels['clause_empty']}</p></terms>"
57
+ end
58
+ end
59
+
60
+ def insert_symbols(x)
61
+ ins = x.at("//terms")
62
+ unless x.at("//sections//definitions")
63
+ ins.next = "<definitions><title>Definitions</title><p>"\
64
+ "#{@labels['clause_empty']}</p></definitions>"
65
+ end
66
+ end
67
+
68
+ def insert_conventions(x)
69
+ ins = x.at("//sections//definitions")
70
+ unless x.at("//sections/clause/title[text() = 'Conventions']")
71
+ ins.next = "<clause><title>Conventions</title><p>"\
72
+ "#{@labels['clause_empty']}</p></clause>"
73
+ end
9
74
  end
10
75
 
11
76
  def cleanup(xmldoc)
@@ -19,7 +84,7 @@ module Asciidoctor
19
84
  next unless n.text?
20
85
  n.replace(HTMLEntities.new.encode(
21
86
  n.text.gsub(/\u2019|\u2018|\u201a|\u201b/, "'").
22
- gsub(/\u201c|\u201d|\u201e|\u201f/, '"'), :basic))
87
+ gsub(/\u201c|\u201d|\u201e|\u201f/, '"'), :basic))
23
88
  end
24
89
  xmldoc
25
90
  end
@@ -48,7 +113,8 @@ module Asciidoctor
48
113
 
49
114
  def pub_class(bib)
50
115
  return 1 if bib.at("#{PUBLISHER}[abbreviation = 'ITU']")
51
- return 1 if bib.at("#{PUBLISHER}[name = 'International Telecommunication Union']")
116
+ return 1 if bib.at("#{PUBLISHER}[name = 'International "\
117
+ "Telecommunication Union']")
52
118
  return 2 if bib.at("#{PUBLISHER}[abbreviation = 'ISO']")
53
119
  return 2 if bib.at("#{PUBLISHER}[name = 'International Organization "\
54
120
  "for Standardization']")
@@ -56,7 +122,8 @@ module Asciidoctor
56
122
  return 3 if bib.at("#{PUBLISHER}[name = 'International "\
57
123
  "Electrotechnical Commission']")
58
124
  return 4 if bib.at("./docidentifier[@type][not(@type = 'DOI' or "\
59
- "@type = 'metanorma' or @type = 'ISSN' or @type = 'ISBN')]")
125
+ "@type = 'metanorma' or @type = 'ISSN' or @type = "\
126
+ "'ISBN')]")
60
127
  5
61
128
  end
62
129
 
@@ -73,8 +140,8 @@ module Asciidoctor
73
140
  def sort_biblio_key(bib)
74
141
  pubclass = pub_class(bib)
75
142
  num = bib&.at("./docnumber")&.text
76
- id = bib&.at("./docidentifier[not(@type = 'DOI' or "\
77
- "@type = 'metanorma' or @type = 'ISSN' or @type = 'ISBN')]")
143
+ id = bib&.at("./docidentifier[not(@type = 'DOI' or @type = "\
144
+ "'metanorma' or @type = 'ISSN' or @type = 'ISBN')]")
78
145
  metaid = bib&.at("./docidentifier[@type = 'metanorma']")&.text
79
146
  abbrid = metaid unless /^\[\d+\]$/.match(metaid)
80
147
  type = id['type'] if id
@@ -29,6 +29,8 @@ module Asciidoctor
29
29
  def init(node)
30
30
  super
31
31
  @smartquotes = node.attr("smartquotes") == "true"
32
+ @no_insert_missing_sections = doctype(node) != "recommendation" ||
33
+ node.attr("legacy-do-not-insert-missing-sections")
32
34
  end
33
35
 
34
36
  def makexml(node)
@@ -63,6 +65,7 @@ module Asciidoctor
63
65
  word_converter(node).convert filename unless node.attr("nodoc")
64
66
  pdf_converter(node).convert filename unless node.attr("nodoc")
65
67
  end
68
+ @log.write(@filename + ".err") unless @novalid
66
69
  @files_to_delete.each { |f| FileUtils.rm f }
67
70
  ret
68
71
  end
@@ -146,11 +149,11 @@ module Asciidoctor
146
149
  end
147
150
 
148
151
  def html_extract_attributes(node)
149
- super.merge(hierarchical_assets: node.attr("hierarchical-assets"))
152
+ super.merge(hierarchical_assets: node.attr("hierarchical-object-numbering"))
150
153
  end
151
154
 
152
155
  def doc_extract_attributes(node)
153
- super.merge(hierarchical_assets: node.attr("hierarchical-assets"))
156
+ super.merge(hierarchical_assets: node.attr("hierarchical-object-numbering"))
154
157
  end
155
158
 
156
159
  def html_converter(node)
@@ -9,4 +9,8 @@ external_terms_boilerplate:
9
9
  no_terms_boilerplate:
10
10
  None.
11
11
  symbols_boilerplate:
12
- "This Recommendation uses the following abbreviations:"
12
+ "This Recommendation uses the following abbreviations and acronyms:"
13
+ norm_empty_pref:
14
+ None.
15
+ clause_empty:
16
+ None.
@@ -645,6 +645,11 @@
645
645
  <optional>
646
646
  <attribute name="script"/>
647
647
  </optional>
648
+ <optional>
649
+ <attribute name="inline-header">
650
+ <data type="boolean"/>
651
+ </attribute>
652
+ </optional>
648
653
  <optional>
649
654
  <attribute name="obligation">
650
655
  <choice>
@@ -12,13 +12,13 @@ module Asciidoctor
12
12
  recommendation-corrigendum recommendation-errata recommendation-annex
13
13
  focus-group implementers-guide technical-paper technical-report
14
14
  joint-itu-iso-iec).include? doctype or
15
- warn "Document Attributes: #{doctype} is not a recognised document type"
15
+ @log.add("Document Attributes", nil, "#{doctype} is not a recognised document type")
16
16
  end
17
17
 
18
18
  def stage_validate(xmldoc)
19
19
  stage = xmldoc&.at("//bibdata/status/stage")&.text
20
20
  %w(in-force superseded in-force-prepublished withdrawn draft).include? stage or
21
- warn "Document Attributes: #{stage} is not a recognised status"
21
+ @log.add("Document Attributes", nil, "#{stage} is not a recognised status")
22
22
  end
23
23
 
24
24
  def content_validate(doc)
@@ -27,38 +27,107 @@ module Asciidoctor
27
27
  itu_identifier_validate(doc)
28
28
  bibdata_validate(doc.root)
29
29
  termdef_style(doc.root)
30
+ title_validate1(doc.root)
31
+ requirement_validate(doc.root)
32
+ numbers_validate(doc.root)
33
+ end
34
+
35
+ # Editing Guidelines 6.3
36
+ def title_validate1(xmldoc)
37
+ t = xmldoc.at("//bibdata/title")&.text
38
+ xmldoc.xpath("//bibdata/series/title").each do |s|
39
+ series = s.text.sub(/^[A-Z]: /, "")
40
+ t.downcase.include?(series.downcase) and
41
+ @log.add("Document Attributes", nil, "Title includes series name #{series}")
42
+ end
43
+ end
44
+
45
+ def extract_text(node)
46
+ return "" if node.nil?
47
+ node1 = Nokogiri::XML.fragment(node.to_s)
48
+ node1.xpath("//link | //locality").each(&:remove)
49
+ ret = ""
50
+ node1.traverse { |x| ret += x.text if x.text? }
51
+ ret
52
+ end
53
+
54
+ # Editing Guidelines 7
55
+ def requirement_validate(xmldoc)
56
+ xmldoc.xpath("//preface/*").each do |c|
57
+ extract_text(c).split(/\.\s+/).each do |t|
58
+ /\b(shall|must)\b/i.match(t) and
59
+ @log.add("Style", c, "Requirement possibly in preface: #{t.strip}")
60
+ end
61
+ end
62
+ end
63
+
64
+ # Editing Guidelines 9.4.3
65
+ def numbers_validate(xmldoc)
66
+ xmldoc.xpath("//clause | //preface/* | //annex").each do |x|
67
+ xx = x.dup
68
+ xx.xpath("./clause").each { |c| c.remove }
69
+ style_two_regex_not_prev(x, extract_text(xx),
70
+ /^(?<num>-?[0-9][0-9,. ]{3,})$/,
71
+ %r{(\bISO|\bIEC|\bIEEE/)$},
72
+ "number not broken up in threes by apostrophe")
73
+ end
74
+ end
75
+
76
+ def style_two_regex_not_prev(n, text, re, re_prev, warning)
77
+ return if text.nil?
78
+ arr = text.split(/\W+/)
79
+ arr.each_index do |i|
80
+ m = re.match arr[i]
81
+ m_prev = i.zero? ? nil : re_prev.match(arr[i - 1])
82
+ if !m.nil? && m_prev.nil?
83
+ @log.add("Style", n, "#{warning}: #{m[:num]}")
84
+ end
85
+ end
30
86
  end
31
87
 
32
88
  def approval_validate(xmldoc)
33
89
  s = xmldoc.at("//bibdata/ext/recommendationstatus/approvalstage") || return
34
90
  process = s["process"]
35
91
  if process == "aap" and %w(determined in-force).include? s.text
36
- warn "Recommendation Status #{s.text} inconsistent with AAP"
92
+ @log.add("Document Attributes", nil, "Recommendation Status #{s.text} inconsistent with AAP")
37
93
  end
38
94
  if process == "tap" and !%w(determined in-force).include? s.text
39
- warn "Recommendation Status #{s.text} inconsistent with TAP"
95
+ @log.add("Document Attributes", nil, "Recommendation Status #{s.text} inconsistent with TAP")
40
96
  end
41
97
  end
42
98
 
43
99
  def itu_identifier_validate(xmldoc)
44
100
  s = xmldoc.xpath("//bibdata/docidentifier[@type = 'ITU']").each do |x|
45
101
  /^ITU-[RTF] [AD-VX-Z]\.[0-9]+$/.match(x.text) or
46
- warn("#{x.text} does not match ITU document identifier conventions")
102
+ @log.add("Style", nil, "#{x.text} does not match ITU document identifier conventions")
47
103
  end
48
104
  end
49
105
 
106
+ def section_validate(doc)
107
+ super
108
+ section_check(doc.root)
109
+ end
110
+
111
+ # Editing Guidelines 7.2, 7.3
112
+ def section_check(xmldoc)
113
+ xmldoc.at("//bibdata/abstract") or
114
+ @log.add("Style", nil, "No Summary has been provided")
115
+ xmldoc.at("//bibdata/keywords") or
116
+ @log.add("Style", nil, "No Keywords have been provided")
117
+ end
118
+
50
119
  def termdef_style(xmldoc)
51
120
  xmldoc.xpath("//term").each do |t|
52
121
  para = t.at("./definition") || return
53
122
  term = t.at("./preferred").text
54
- termdef_warn(term, /^[A-Z][a-z]+/, term, "term is not lowercase")
55
- termdef_warn(para.text, /^[a-z]/, term, "term definition does not start with capital")
56
- termdef_warn(para.text, /[^.]$/, term, "term definition does not end with period")
123
+ termdef_warn(term, /^[A-Z][a-z]+/, t, term, "term is not lowercase")
124
+ termdef_warn(para.text, /^[a-z]/, t, term, "term definition does not start with capital")
125
+ termdef_warn(para.text, /[^.]$/, t, term, "term definition does not end with period")
57
126
  end
58
127
  end
59
128
 
60
- def termdef_warn(text, re, term, msg)
61
- re.match(text) && warn("ITU style: #{term}: #{msg}")
129
+ def termdef_warn(text, re, t, term, msg)
130
+ re.match(text) && @log.add("Style", t, "#{term}: #{msg}")
62
131
  end
63
132
  end
64
133
  end
@@ -47,12 +47,6 @@ module IsoDoc
47
47
  l10n("#{@note_lbl} #{n[:label]} &ndash; ")
48
48
  end
49
49
 
50
- def formula_where(dl, out)
51
- return unless dl
52
- out.p { |p| p << l10n("#{@where_lbl}:") }
53
- parse(dl, out)
54
- end
55
-
56
50
  def prefix_container(container, linkend, _target)
57
51
  l10n("#{linkend} #{@labels["in"]} #{anchor(container, :xref)}")
58
52
  end
@@ -1,8 +1,8 @@
1
- <div class="document-stage-band" id='{{ stage | downcase | replace: " ", "-" }}-band'>
1
+ <div class="document-stage-band" id="{{ stage | downcase | replace: ' ', '-' }}-band">
2
2
  <p class="document-stage">{{ stage }}</p>
3
3
  </div>
4
4
 
5
- <div class="document-type-band" id='{{ doctype | downcase | replace: " ", "-" }}-band'>
5
+ <div class="document-type-band" id="{{ doctype | downcase | replace: ' ', '-' }}-band">
6
6
  <p class="document-type">ITU {{ doctype }}</p>
7
7
  </div>
8
8
 
@@ -465,6 +465,12 @@ a.footnote-number {
465
465
  @include formulaBlock(#f6f6f6);
466
466
  }
467
467
 
468
+ dl.formula_dl {
469
+ background-color: #f6f6f6;
470
+ margin-left: 1.4cm;
471
+ margin-right: 1.4cm;
472
+ }
473
+
468
474
 
469
475
  .contact-info {
470
476
  padding: 2em;
@@ -714,6 +714,10 @@ p.Formula, li.Formula, div.Formula
714
714
  mso-fareast-font-family:$bodyfont;
715
715
  mso-bidi-font-family:$bodyfont;
716
716
  mso-ansi-language:EN-GB;}
717
+ table.formula_dl {
718
+ margin-left:1.4cm;
719
+ margin-right:1.4cm;
720
+ }
717
721
  /* definition list */
718
722
  p.enumlev1, li.enumlev1, div.enumlev1
719
723
  {mso-style-name:enumlev1;
@@ -11,3 +11,5 @@ formula: Equation
11
11
  inequality: Inequality
12
12
  annex_subclause: Clause
13
13
  in: in
14
+ where: "where:"
15
+ blankclause: This clause is intentionally left blank.
@@ -92,7 +92,7 @@ module IsoDoc
92
92
  isoxml.xpath(ns("//bibdata/keyword")).each do |kw|
93
93
  keywords << kw.text
94
94
  end
95
- set(:keywords, keywords)
95
+ set(:keywords, keywords.sort)
96
96
  end
97
97
 
98
98
  def ip_notice_received(isoxml, _out)
@@ -11,9 +11,6 @@ module IsoDoc
11
11
  out.div do |div|
12
12
  num = num + 1
13
13
  clause_name(num, @normref_lbl, div, nil)
14
- f.elements.reject do |e|
15
- %w(reference title bibitem note).include? e.name
16
- end.each { |e| parse(e, div) }
17
14
  biblio_list(f, div, false)
18
15
  end
19
16
  num
@@ -65,13 +62,21 @@ module IsoDoc
65
62
 
66
63
  def render_identifiers(ids)
67
64
  ids.map do |id|
68
- (id["type"] == "ITU" ?
69
- titlecase(id.parent&.at(ns("./ext/doctype"))&.text ||
70
- "recommendation") + " " : "") +
71
- docid_prefix(id["type"], id.text.sub(/^\[/, "").sub(/\]$/, ""))
65
+ id["type"] == "ITU" ? doctype_title(id) :
66
+ docid_prefix(id["type"], id.text.sub(/^\[/, "").sub(/\]$/, ""))
72
67
  end.join(" | ")
73
68
  end
74
69
 
70
+ def doctype_title(id)
71
+ type = id.parent&.at(ns("./ext/doctype"))&.text || "recommendation"
72
+ if type == "recommendation" &&
73
+ /^(?<prefix>ITU-[A-Z] [A-Z])[ .-]Sup[a-z]*\.[ ]?(?<num>\d+)$/ =~ id.text
74
+ "#{prefix}-series Recommendations – Supplement #{num}"
75
+ else
76
+ "#{titlecase(type)} #{docid_prefix(id["type"], id.text.sub(/^\[/, '').sub(/\]$/, ''))}"
77
+ end
78
+ end
79
+
75
80
  def reference_format_start(b, r)
76
81
  id = multi_bibitem_ref_code(b)
77
82
  r << render_identifiers(id)
@@ -67,14 +67,15 @@ module IsoDoc
67
67
  "-"
68
68
  end
69
69
 
70
- def middle_section_asset_names(d)
71
- return super unless @hierarchical_assets
72
- middle_sections = "//clause[title = 'Scope'] | "\
70
+ MIDDLE_SECTIONS = "//clause[title = 'Scope'] | "\
73
71
  "//foreword | //introduction | //acknowledgements | "\
74
72
  "//references[title = 'References' or title = 'references'] | "\
75
73
  "//sections/terms | //preface/clause | "\
76
- "//sections/definitions | //clause[parent::sections]"
77
- d.xpath(ns(middle_sections)).each do |c|
74
+ "//sections/definitions | //clause[parent::sections]".freeze
75
+
76
+ def middle_section_asset_names(d)
77
+ return super unless @hierarchical_assets
78
+ d.xpath(ns(MIDDLE_SECTIONS)).each do |c|
78
79
  hierarchical_asset_names(c, @anchors[c["id"]][:label])
79
80
  end
80
81
  end
@@ -111,6 +112,16 @@ module IsoDoc
111
112
  t["unnumbered"])
112
113
  end
113
114
  end
115
+
116
+ def sequential_formula_names(clause)
117
+ clause&.first&.xpath(ns(MIDDLE_SECTIONS))&.each do |c|
118
+ if c["id"] && @anchors[c["id"]]
119
+ hierarchical_formula_names(c, @anchors[c["id"]][:label] || @anchors[c["id"]][:xref] || "???")
120
+ else
121
+ hierarchical_formula_names(c, "???")
122
+ end
123
+ end
124
+ end
114
125
  end
115
126
  end
116
127
  end
data/lib/metanorma/itu.rb CHANGED
@@ -3,10 +3,7 @@ require "metanorma/itu/processor"
3
3
 
4
4
  module Metanorma
5
5
  module ITU
6
-
7
6
  ORGANIZATION_NAME_SHORT = "ITU"
8
7
  ORGANIZATION_NAME_LONG = "International Telecommunication Union"
9
- DOCUMENT_NAMESPACE = "https://open.ribose.com/standards/itu"
10
-
11
8
  end
12
9
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module ITU
3
- VERSION = "1.0.10"
3
+ VERSION = "1.0.11"
4
4
  end
5
5
  end
@@ -38,7 +38,6 @@ Gem::Specification.new do |spec|
38
38
  spec.add_development_dependency "rubocop", "= 0.54.0"
39
39
  spec.add_development_dependency "simplecov", "~> 0.15"
40
40
  spec.add_development_dependency "timecop", "~> 0.9"
41
- spec.add_development_dependency "metanorma", "~> 0.3.0"
42
41
  spec.add_development_dependency "vcr", "~> 5.0.0"
43
42
  spec.add_development_dependency "webmock"
44
43
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-itu
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.10
4
+ version: 1.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-05 00:00:00.000000000 Z
11
+ date: 2020-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htmlentities
@@ -192,20 +192,6 @@ dependencies:
192
192
  - - "~>"
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0.9'
195
- - !ruby/object:Gem::Dependency
196
- name: metanorma
197
- requirement: !ruby/object:Gem::Requirement
198
- requirements:
199
- - - "~>"
200
- - !ruby/object:Gem::Version
201
- version: 0.3.0
202
- type: :development
203
- prerelease: false
204
- version_requirements: !ruby/object:Gem::Requirement
205
- requirements:
206
- - - "~>"
207
- - !ruby/object:Gem::Version
208
- version: 0.3.0
209
195
  - !ruby/object:Gem::Dependency
210
196
  name: vcr
211
197
  requirement: !ruby/object:Gem::Requirement