metanorma-itu 2.7.6 → 2.8.0

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.
@@ -84,15 +84,17 @@ module IsoDoc
84
84
 
85
85
  def norm_ref_entry_code(_ordinal, idents, _ids, _standard, datefn, _bib)
86
86
  ret = (idents[:metanorma] || idents[:ordinal] || idents[:sdo]).to_s
87
- ret.empty? and return ret
88
- /^\[.+\]$/.match?(ret) or ret = "[#{ret}]"
87
+ ret.empty? and return ""
88
+ ret = ret.sub(/^\[(.+)\]$/, "\\1")
89
+ ret = "[#{esc ret}]"
89
90
  ret += datefn
90
91
  ret.gsub("-", "‑").gsub(/ /, " ")
91
92
  end
92
93
 
93
94
  def biblio_ref_entry_code(_ordinal, idents, _id, _standard, datefn, _bib)
94
95
  ret = (idents[:metanorma] || idents[:ordinal] || idents[:sdo]).to_s
95
- /^\[.+\]$/.match?(ret) or ret = "[#{ret}]"
96
+ ret = ret.sub(/^\[(.+)\]$/, "\\1")
97
+ ret = "[#{esc ret}]"
96
98
  ret += datefn
97
99
  ret.empty? and return ret
98
100
  ret.gsub("-", "‑").gsub(/ /, " ")
@@ -52,7 +52,7 @@ module IsoDoc
52
52
  end
53
53
 
54
54
  def termsource_label(elem, sources)
55
- elem.replace(sources)
55
+ elem.replace(@i18n.l10n(sources))
56
56
  end
57
57
 
58
58
  def eref1(elem)
@@ -96,10 +96,10 @@ module IsoDoc
96
96
  { unnumb: elem["unnumbered"] }
97
97
  )
98
98
  if elem["unnumbered"] != "true"
99
- #@anchors[elem["id"]][:label] = sublabel
100
- @anchors[elem["id"]][:xref] = @anchors[elem.parent["id"]][:xref] +
99
+ p = elem.at("./ancestor::xmlns:figure")
100
+ @anchors[elem["id"]][:xref] = @anchors[p["id"]][:xref] +
101
101
  delim_wrap("-") + semx(elem, sublabel)
102
- x = @anchors[elem.parent["id"]][:container] and
102
+ x = @anchors[p["id"]][:container] and
103
103
  @anchors[elem["id"]][:container] = x
104
104
  end
105
105
  end
@@ -869,7 +869,7 @@ depending on whether the items exist as independent documents, or are parts of a
869
869
  </zeroOrMore>
870
870
  </element>
871
871
  </define>
872
- <define name="BibItemType" combine="choice">
872
+ <define name="BibItemType">
873
873
  <a:documentation>Type of bibliographic item.
874
874
  The value list complies with the types provided in ISO 690:2021.
875
875
  NOTE: These values represent a strict superset to BibTeX
@@ -152,3 +152,5 @@ module Metanorma
152
152
  end
153
153
  end
154
154
  end
155
+
156
+ require_relative "log"
@@ -18,8 +18,7 @@ module Metanorma
18
18
  end
19
19
 
20
20
  def title_defaultlang(node, xml)
21
- a = node.attr("title") || node.attr("title-#{@lang}") ||
22
- node.attr("doctitle")
21
+ a = node.attr("title") || node.attr("title-#{@lang}") or return
23
22
  add_title_xml(xml, a, @lang, "main")
24
23
  if a = node.attr("annextitle") || node.attr("annextitle-#{@lang}")
25
24
  add_title_xml(xml, a, @lang, "annex")
@@ -38,6 +37,7 @@ module Metanorma
38
37
  def title(node, xml)
39
38
  title_defaultlang(node, xml)
40
39
  title_otherlangs(node, xml)
40
+ title_fallback(node, xml)
41
41
  %w(subtitle amendment-title corrigendum-title collection-title
42
42
  slogan-title).each do |t|
43
43
  other_title_defaultlang(node, xml, t)
@@ -311,17 +311,28 @@ and is intended to be referenced by a callout within the source code</a:document
311
311
  </ref>
312
312
  </optional>
313
313
  <choice>
314
- <a:documentation>Content of the figure</a:documentation>
315
- <ref name="image"/>
314
+ <a:documentation>Content of the figure </a:documentation>
315
+ <ref name="image">
316
+ <a:documentation>by default the content of a figure is a media file</a:documentation>
317
+ </ref>
316
318
  <ref name="video"/>
317
319
  <ref name="audio"/>
318
- <ref name="pre"/>
320
+ <ref name="pre">
321
+ <a:documentation>figures can contain ASCII art</a:documentation>
322
+ </ref>
319
323
  <oneOrMore>
320
- <ref name="paragraph-with-footnote"/>
324
+ <ref name="paragraph-with-footnote">
325
+ <a:documentation>figures can contain discursive art</a:documentation>
326
+ </ref>
321
327
  </oneOrMore>
322
328
  <zeroOrMore>
323
- <ref name="figure"/>
329
+ <ref name="figure">
330
+ <a:documentation>subfigures, nested directly within a figure</a:documentation>
331
+ </ref>
324
332
  </zeroOrMore>
333
+ <ref name="table">
334
+ <a:documentation>Table is understood in this context to be a tabular arrangement of subfigures</a:documentation>
335
+ </ref>
325
336
  </choice>
326
337
  <zeroOrMore>
327
338
  <ref name="fn">
@@ -354,17 +365,28 @@ and is intended to be referenced by a callout within the source code</a:document
354
365
  </ref>
355
366
  </optional>
356
367
  <choice>
357
- <a:documentation>Content of the figure</a:documentation>
358
- <ref name="image-no-id"/>
368
+ <a:documentation>Content of the figure </a:documentation>
369
+ <ref name="image-no-id">
370
+ <a:documentation>by default the content of a figure is a media file</a:documentation>
371
+ </ref>
359
372
  <ref name="video-no-id"/>
360
373
  <ref name="audio-no-id"/>
361
- <ref name="pre-no-id"/>
374
+ <ref name="pre-no-id">
375
+ <a:documentation>figures can contain ASCII art</a:documentation>
376
+ </ref>
362
377
  <oneOrMore>
363
- <ref name="paragraph-with-footnote-no-id"/>
378
+ <ref name="paragraph-with-footnote-no-id">
379
+ <a:documentation>figures can contain discursive art</a:documentation>
380
+ </ref>
364
381
  </oneOrMore>
365
382
  <zeroOrMore>
366
- <ref name="figure-no-id"/>
383
+ <ref name="figure-no-id">
384
+ <a:documentation>subfigures, nested directly within a figure</a:documentation>
385
+ </ref>
367
386
  </zeroOrMore>
387
+ <ref name="table-no-id">
388
+ <a:documentation>Table is understood in this context to be a tabular arrangement of subfigures</a:documentation>
389
+ </ref>
368
390
  </choice>
369
391
  <zeroOrMore>
370
392
  <ref name="fn">
@@ -876,6 +898,9 @@ titlecase, or lowercase</a:documentation>
876
898
  <data type="boolean"/>
877
899
  </attribute>
878
900
  </optional>
901
+ <ref name="LocalizedStringAttributes">
902
+ <a:documentation>Specify language of bibitem, can be used to render it with language-specific bibliographic style</a:documentation>
903
+ </ref>
879
904
  <ref name="ReducedBibliographicItem"/>
880
905
  </element>
881
906
  </define>
@@ -2,13 +2,6 @@
2
2
  <grammar ns='https://www.metanorma.org/ns/standoc' xmlns="http://relaxng.org/ns/structure/1.0">
3
3
  <include href="relaton-itu.rng"/>
4
4
  <include href="isodoc.rng">
5
- <define name="OlAttributes" combine="interleave">
6
- <optional>
7
- <attribute name="class">
8
- <value>steps</value>
9
- </attribute>
10
- </optional>
11
- </define>
12
5
  <define name="Clause-Section">
13
6
  <ref name="Section-Attributes"/>
14
7
  <optional>
@@ -35,4 +28,11 @@
35
28
  </group>
36
29
  </define>
37
30
  </include>
31
+ <define name="OlAttributes" combine="interleave">
32
+ <optional>
33
+ <attribute name="class">
34
+ <value>steps</value>
35
+ </attribute>
36
+ </optional>
37
+ </define>
38
38
  </grammar>
@@ -0,0 +1,47 @@
1
+ module Metanorma
2
+ module Itu
3
+ class Converter
4
+ ITU_LOG_MESSAGES = {
5
+ # rubocop:disable Naming/VariableNumber
6
+ "ITU_1": { category: "Document Attributes",
7
+ error: "%s is not a recognised document type",
8
+ severity: 2 },
9
+ "ITU_2": { category: "Document Attributes",
10
+ error: "%s is not a recognised status",
11
+ severity: 2 },
12
+ "ITU_3": { category: "Document Attributes",
13
+ error: "Title includes series name %s",
14
+ severity: 2 },
15
+ "ITU_4": { category: "Style",
16
+ error: "Requirement possibly in preface: %s",
17
+ severity: 2 },
18
+ "ITU_6": { category: "Document Attributes",
19
+ error: "Recommendation Status %s inconsistent with AAP",
20
+ severity: 2 },
21
+ "ITU_7": { category: "Document Attributes",
22
+ error: "Recommendation Status %s inconsistent with TAP",
23
+ severity: 2 },
24
+ "ITU_8": { category: "Style",
25
+ error: "%s does not match ITU document identifier conventions",
26
+ severity: 2 },
27
+ "ITU_9": { category: "Style",
28
+ error: "Unnumbered clause out of place",
29
+ severity: 2 },
30
+ "ITU_10": { category: "Style",
31
+ error: "No Summary has been provided",
32
+ severity: 2 },
33
+ "ITU_11": { category: "Style",
34
+ error: "No Keywords have been provided",
35
+ severity: 2 },
36
+ "ITU_12": { category: "Style",
37
+ error: "(terms) %s: %s",
38
+ severity: 2 },
39
+ }.freeze
40
+ # rubocop:enable Naming/VariableNumber
41
+
42
+ def log_messages
43
+ super.merge(ITU_LOG_MESSAGES)
44
+ end
45
+ end
46
+ end
47
+ end
@@ -12,16 +12,14 @@ module Metanorma
12
12
  focus-group implementers-guide technical-paper technical-report
13
13
  joint-itu-iso-iec service-publication
14
14
  contribution).include? @doctype or
15
- @log.add("Document Attributes", nil,
16
- "#{@doctype} is not a recognised document type")
15
+ @log.add("ITU_1", nil, params: [@doctype])
17
16
  end
18
17
 
19
18
  def stage_validate(xmldoc)
20
19
  stage = xmldoc&.at("//bibdata/status/stage")&.text
21
20
  %w(in-force superseded in-force-prepublished withdrawn
22
21
  draft).include? stage or
23
- @log.add("Document Attributes", nil,
24
- "#{stage} is not a recognised status")
22
+ @log.add("ITU_2", nil, params: [stage])
25
23
  end
26
24
 
27
25
  def content_validate(doc)
@@ -41,8 +39,7 @@ module Metanorma
41
39
  xmldoc.xpath("//bibdata/series/title").each do |s|
42
40
  series = s.text.sub(/^[A-Z]: /, "")
43
41
  t.downcase.include?(series.downcase) and
44
- @log.add("Document Attributes", nil,
45
- "Title includes series name #{series}")
42
+ @log.add("ITU_3", nil, params: [series])
46
43
  end
47
44
  end
48
45
 
@@ -61,8 +58,7 @@ module Metanorma
61
58
  xmldoc.xpath("//preface/*").each do |c|
62
59
  extract_text(c).split(/\.\s+/).each do |t|
63
60
  /\b(shall|must)\b/i.match(t) and
64
- @log.add("Style", c,
65
- "Requirement possibly in preface: #{t.strip}")
61
+ @log.add("ITU_4", c, params: [t.strip])
66
62
  end
67
63
  end
68
64
  end
@@ -71,35 +67,33 @@ module Metanorma
71
67
  # Supplanted by rendering
72
68
  def numbers_validate(xmldoc); end
73
69
 
74
- def style_two_regex_not_prev(node, text, regex, regex_prev, warning)
75
- text.nil? and return
76
- arr = text.split(/\W+/)
77
- arr.each_index do |i|
78
- m_prev = i.zero? ? nil : regex_prev.match(arr[i - 1])
79
- if !regex.match?(arr[i]) && m_prev.nil?
80
- @log.add("Style", node, "#{warning}: #{m[:num]}")
81
- end
82
- end
83
- end
70
+ # def style_two_regex_not_prev(node, text, regex, regex_prev, warning)
71
+ # text.nil? and return
72
+ # arr = text.split(/\W+/)
73
+ # arr.each_index do |i|
74
+ # m_prev = i.zero? ? nil : regex_prev.match(arr[i - 1])
75
+ # if !regex.match?(arr[i]) && m_prev.nil?
76
+ # @log.add("Style", node, "#{warning}: #{m[:num]}")
77
+ # # ID = ITU_5
78
+ # end
79
+ # end
80
+ # end
84
81
 
85
82
  def approval_validate(xmldoc)
86
83
  s = xmldoc.at("//bibdata/ext/recommendationstatus/approvalstage") or
87
84
  return
88
85
  process = s["process"]
89
86
  (process == "aap") && %w(determined in-force).include?(s.text) and
90
- @log.add("Document Attributes", nil,
91
- "Recommendation Status #{s.text} inconsistent with AAP")
87
+ @log.add("ITU_6", nil, params: [s.text])
92
88
  (process == "tap") && !%w(determined in-force).include?(s.text) and
93
- @log.add("Document Attributes", nil,
94
- "Recommendation Status #{s.text} inconsistent with TAP")
89
+ @log.add("ITU_7", nil, params: [s.text])
95
90
  end
96
91
 
97
92
  def itu_identifier_validate(xmldoc)
98
93
  xmldoc.xpath("//bibdata/docidentifier[@type = 'ITU']").each do |x|
99
94
  /^SG \d+/.match?(x.text) ||
100
95
  /^ITU-[RTD] [AD-VX-Z]\.\d+(\.\d+)?$/.match?(x.text) or
101
- @log.add("Style", nil, "#{x.text} does not match ITU document " \
102
- "identifier conventions")
96
+ @log.add("ITU_8", nil, params: [x.text])
103
97
  end
104
98
  end
105
99
 
@@ -114,16 +108,16 @@ module Metanorma
114
108
  next if (@doctype == "resolution") && (c.parent.name == "sections") &&
115
109
  !c.at("./preceding-sibling::clause")
116
110
 
117
- @log.add("Style", c, "Unnumbered clause out of place")
111
+ @log.add("ITU_9", c)
118
112
  end
119
113
  end
120
114
 
121
115
  # Editing Guidelines 7.2, 7.3
122
116
  def section_check(xmldoc)
123
117
  xmldoc.at("//bibdata/abstract") or
124
- @log.add("Style", nil, "No Summary has been provided")
118
+ @log.add("ITU_10", nil)
125
119
  xmldoc.at("//bibdata/keyword") or
126
- @log.add("Style", nil, "No Keywords have been provided")
120
+ @log.add("ITU_11", nil)
127
121
  end
128
122
 
129
123
  def termdef_style(xmldoc)
@@ -131,15 +125,15 @@ module Metanorma
131
125
  para = t.at("./definition/verbal-definition") || return
132
126
  term = t.at("./preferred//name").text
133
127
  termdef_warn(term, /^[A-Z][a-z]+/, t, term, "term is not lowercase")
134
- termdef_warn(para.text, /^[a-z]/, t, term,
128
+ termdef_warn(para.text.strip, /^[a-z]/, t, term,
135
129
  "term definition does not start with capital")
136
- termdef_warn(para.text, /[^.]$/, t, term,
130
+ termdef_warn(para.text.strip, /[^.]\z/, t, term,
137
131
  "term definition does not end with period")
138
132
  end
139
133
  end
140
134
 
141
135
  def termdef_warn(text, regex, node, term, msg)
142
- regex.match(text) && @log.add("Style", node, "#{term}: #{msg}")
136
+ regex.match(text) && @log.add("ITU_12", node, params: [term, msg])
143
137
  end
144
138
  end
145
139
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Itu
3
- VERSION = "2.7.6".freeze
3
+ VERSION = "2.8.0".freeze
4
4
  end
5
5
  end
@@ -1,3 +1,3 @@
1
1
  template:
2
2
  # skip authoritative identifier, it is inserted in front of formattedref within metanorma
3
- standard: "<em>{{ title }}</em> ,_{{ edition | capitalize_first }} . {{ extent }}."
3
+ standard: "<em>{{ title }}</em> ,_{{ edition | capitalize_first }} $$$ {{ extent }}"
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.require_paths = ["lib"]
26
26
  spec.required_ruby_version = Gem::Requirement.new(">= 3.1.0")
27
27
 
28
- spec.add_dependency "metanorma-standoc", "~> 3.1.0"
28
+ spec.add_dependency "metanorma-standoc", "~> 3.2.0"
29
29
  spec.add_dependency "pubid"
30
30
  spec.add_dependency "twitter_cldr", ">= 3.0.0"
31
31
  spec.add_dependency "tzinfo-data" # we need this for windows only
@@ -34,6 +34,7 @@ Gem::Specification.new do |spec|
34
34
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
35
35
  spec.add_development_dependency "guard", "~> 2.14"
36
36
  spec.add_development_dependency "guard-rspec", "~> 4.7"
37
+ spec.add_development_dependency "openssl"
37
38
  spec.add_development_dependency "rake", "~> 13.0"
38
39
  spec.add_development_dependency "rspec", "~> 3.6"
39
40
  spec.add_development_dependency "rubocop", "~> 1"
@@ -42,5 +43,5 @@ spec.add_development_dependency "rubocop-performance"
42
43
  spec.add_development_dependency "simplecov", "~> 0.15"
43
44
  spec.add_development_dependency "timecop", "~> 0.9"
44
45
  spec.add_development_dependency "webmock"
45
- spec.add_development_dependency "canon"
46
+ spec.add_development_dependency "canon", "= 0.1.3"
46
47
  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: 2.7.6
4
+ version: 2.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-09-29 00:00:00.000000000 Z
11
+ date: 2025-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-standoc
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 3.1.0
19
+ version: 3.2.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 3.1.0
26
+ version: 3.2.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: pubid
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '4.7'
125
+ - !ruby/object:Gem::Dependency
126
+ name: openssl
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: rake
127
141
  requirement: !ruby/object:Gem::Requirement
@@ -238,16 +252,16 @@ dependencies:
238
252
  name: canon
239
253
  requirement: !ruby/object:Gem::Requirement
240
254
  requirements:
241
- - - ">="
255
+ - - '='
242
256
  - !ruby/object:Gem::Version
243
- version: '0'
257
+ version: 0.1.3
244
258
  type: :development
245
259
  prerelease: false
246
260
  version_requirements: !ruby/object:Gem::Requirement
247
261
  requirements:
248
- - - ">="
262
+ - - '='
249
263
  - !ruby/object:Gem::Version
250
- version: '0'
264
+ version: 0.1.3
251
265
  description: 'Metanorma for the ITU.
252
266
 
253
267
  '
@@ -336,6 +350,7 @@ files:
336
350
  - lib/metanorma/itu/front_id.rb
337
351
  - lib/metanorma/itu/isodoc.rng
338
352
  - lib/metanorma/itu/itu.rng
353
+ - lib/metanorma/itu/log.rb
339
354
  - lib/metanorma/itu/processor.rb
340
355
  - lib/metanorma/itu/relaton-itu.rng
341
356
  - lib/metanorma/itu/reqt.rng