metanorma-iso 1.7.4 → 1.8.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +3 -13
  3. data/.hound.yml +3 -1
  4. data/.rubocop.yml +3 -7
  5. data/lib/asciidoctor/iso/base.rb +14 -11
  6. data/lib/asciidoctor/iso/biblio.rng +1 -0
  7. data/lib/asciidoctor/iso/cleanup.rb +40 -24
  8. data/lib/asciidoctor/iso/front.rb +28 -16
  9. data/lib/asciidoctor/iso/front_id.rb +66 -50
  10. data/lib/asciidoctor/iso/isodoc.rng +321 -4
  11. data/lib/asciidoctor/iso/isostandard-amd.rng +3 -0
  12. data/lib/asciidoctor/iso/isostandard.rng +12 -0
  13. data/lib/asciidoctor/iso/section.rb +2 -1
  14. data/lib/asciidoctor/iso/validate.rb +22 -110
  15. data/lib/asciidoctor/iso/validate_image.rb +97 -0
  16. data/lib/asciidoctor/iso/validate_requirements.rb +26 -20
  17. data/lib/asciidoctor/iso/validate_section.rb +55 -29
  18. data/lib/asciidoctor/iso/validate_style.rb +36 -24
  19. data/lib/asciidoctor/iso/validate_title.rb +2 -4
  20. data/lib/isodoc/iso/base_convert.rb +8 -2
  21. data/lib/isodoc/iso/html/style-human.css +7 -0
  22. data/lib/isodoc/iso/html/style-iso.css +7 -0
  23. data/lib/isodoc/iso/html_convert.rb +0 -1
  24. data/lib/isodoc/iso/iso.amendment.xsl +680 -198
  25. data/lib/isodoc/iso/iso.international-standard.xsl +680 -198
  26. data/lib/isodoc/iso/metadata.rb +1 -0
  27. data/lib/isodoc/iso/presentation_xml_convert.rb +44 -33
  28. data/lib/isodoc/iso/sts_convert.rb +10 -13
  29. data/lib/isodoc/iso/word_convert.rb +0 -1
  30. data/lib/isodoc/iso/xref.rb +52 -34
  31. data/lib/metanorma/iso/processor.rb +1 -0
  32. data/lib/metanorma/iso/version.rb +1 -1
  33. data/metanorma-iso.gemspec +7 -7
  34. data/spec/asciidoctor/base_spec.rb +426 -305
  35. data/spec/asciidoctor/blocks_spec.rb +96 -34
  36. data/spec/asciidoctor/cleanup_spec.rb +383 -25
  37. data/spec/asciidoctor/section_spec.rb +0 -14
  38. data/spec/asciidoctor/validate_spec.rb +218 -83
  39. data/spec/isodoc/postproc_spec.rb +481 -438
  40. data/spec/spec_helper.rb +16 -15
  41. metadata +46 -46
  42. data/lib/isodoc/iso/html/scripts.html +0 -178
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e78f6a52feda554f9e3578e30ffd3af32afe6c771d16414f584ceadd38589b13
4
- data.tar.gz: 2da68557d15c9436c6dc310203895e5611c64331b0f038e66590ad4611bdb5db
3
+ metadata.gz: 40c9fc0bf08ed5cca2885426c54c0b1970511fbdd14a7e982197bb57f95fc55b
4
+ data.tar.gz: 4695506d2644d2b01090cd4bfa7cd123672dd99de111a6c09f50fea1c84ed3c3
5
5
  SHA512:
6
- metadata.gz: f1d80f1af14c5abfd4cc74a0e91dbcc0e4414fd46105ebbd80507871bba8ea788c1e8b09525b8672d85bd4f453d07b5a2b2621a96ebc63270999a2b9989ecbaa
7
- data.tar.gz: '09b997180fa6f3c0a1ac2298efda92fc634f5ea1404115c1d65104da739ca278f6a134ee9114ba2b1d53fc4c9415ba6655a7612982479964b5b1bb2c5790a85a'
6
+ metadata.gz: 5b8317d64f94cee315afeb98045ff026c0b5df38ea7c141c4fa1d839d758dce919382ff5ae72c76893d296b74d69bae965a50096b7fdfb159b0085c122783a19
7
+ data.tar.gz: 2f6a2bdb6e5b33adbe3970838f4d4c2ca0f97fe8b40cbe66b828e5fec18fc5cd7932cc42a2880c0765d5b6621a26502d3ae0fa38533488e0cfebb2a1e96917ea
@@ -4,7 +4,7 @@ name: rake
4
4
 
5
5
  on:
6
6
  push:
7
- branches: [ master, main ]
7
+ branches: [ master, main ]
8
8
  tags: [ v* ]
9
9
  pull_request:
10
10
 
@@ -16,19 +16,9 @@ jobs:
16
16
  strategy:
17
17
  fail-fast: false
18
18
  matrix:
19
- ruby: [ '2.7', '2.6', '2.5', '2.4' ]
19
+ ruby: [ '3.0', '2.7', '2.6', '2.5', '2.4' ]
20
20
  os: [ ubuntu-latest, windows-latest, macos-latest ]
21
21
  experimental: [ false ]
22
- include:
23
- - ruby: '3.0'
24
- os: 'ubuntu-latest'
25
- experimental: true
26
- - ruby: '3.0'
27
- os: 'windows-latest'
28
- experimental: true
29
- - ruby: '3.0'
30
- os: 'macos-latest'
31
- experimental: true
32
22
  steps:
33
23
  - uses: actions/checkout@master
34
24
 
@@ -49,5 +39,5 @@ jobs:
49
39
  with:
50
40
  token: ${{ secrets.METANORMA_CI_PAT_TOKEN || secrets.GITHUB_TOKEN }}
51
41
  repository: ${{ github.repository }}
52
- event-type: notify
42
+ event-type: tests-passed
53
43
  client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'
data/.hound.yml CHANGED
@@ -1,3 +1,5 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
1
3
  ruby:
2
- Enabled: true
4
+ enabled: true
3
5
  config_file: .rubocop.yml
data/.rubocop.yml CHANGED
@@ -1,14 +1,10 @@
1
- # This project follows the Ribose OSS style guide.
2
- # https://github.com/riboseinc/oss-guides
3
- # All project-specific additions and overrides should be specified in this file.
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
4
3
  inherit_from:
5
4
  - https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
6
5
 
7
6
  # local repo-specific modifications
7
+ # ...
8
8
 
9
9
  AllCops:
10
- DisplayCopNames: false
11
- StyleGuideCopsOnly: false
12
10
  TargetRubyVersion: 2.4
13
- Rails:
14
- Enabled: true
@@ -17,8 +17,8 @@ module Asciidoctor
17
17
  end
18
18
 
19
19
  def html_converter_alt(node)
20
- IsoDoc::Iso::HtmlConvert.new(html_extract_attributes(node).
21
- merge(alt: true))
20
+ IsoDoc::Iso::HtmlConvert.new(html_extract_attributes(node)
21
+ .merge(alt: true))
22
22
  end
23
23
 
24
24
  def doc_converter(node)
@@ -27,11 +27,13 @@ module Asciidoctor
27
27
 
28
28
  def pdf_converter(node)
29
29
  return nil if node.attr("no-pdf")
30
+
30
31
  IsoDoc::Iso::PdfConvert.new(doc_extract_attributes(node))
31
32
  end
32
33
 
33
34
  def sts_converter(node)
34
35
  return nil if node.attr("no-pdf")
36
+
35
37
  IsoDoc::Iso::StsConvert.new(html_extract_attributes(node))
36
38
  end
37
39
 
@@ -42,25 +44,26 @@ module Asciidoctor
42
44
  def init(node)
43
45
  super
44
46
  @amd = %w(amendment technical-corrigendum).include? doctype(node)
47
+ @vocab = node.attr("docsubtype") == "vocabulary"
45
48
  end
46
49
 
47
50
  def ol_attrs(node)
48
- attr_code(keep_attrs(node).
49
- merge(id: ::Metanorma::Utils::anchor_or_uuid(node)))
51
+ attr_code(keep_attrs(node)
52
+ .merge(id: ::Metanorma::Utils::anchor_or_uuid(node)))
50
53
  end
51
54
 
52
55
  def outputs(node, ret)
53
- File.open(@filename + ".xml", "w:UTF-8") { |f| f.write(ret) }
54
- presentation_xml_converter(node).convert(@filename + ".xml")
55
- html_converter_alt(node).convert(@filename + ".presentation.xml",
56
+ File.open("#{@filename}.xml", "w:UTF-8") { |f| f.write(ret) }
57
+ presentation_xml_converter(node).convert("#{@filename}.xml")
58
+ html_converter_alt(node).convert("#{@filename}.presentation.xml",
56
59
  nil, false, "#{@filename}_alt.html")
57
- html_converter(node).convert(@filename + ".presentation.xml",
60
+ html_converter(node).convert("#{@filename}.presentation.xml",
58
61
  nil, false, "#{@filename}.html")
59
- doc_converter(node).convert(@filename + ".presentation.xml",
62
+ doc_converter(node).convert("#{@filename}.presentation.xml",
60
63
  nil, false, "#{@filename}.doc")
61
- pdf_converter(node)&.convert(@filename + ".presentation.xml",
64
+ pdf_converter(node)&.convert("#{@filename}.presentation.xml",
62
65
  nil, false, "#{@filename}.pdf")
63
- #sts_converter(node)&.convert(@filename + ".xml")
66
+ # sts_converter(node)&.convert(@filename + ".xml")
64
67
  end
65
68
  end
66
69
  end
@@ -787,6 +787,7 @@
787
787
  <value>adapted</value>
788
788
  <value>vote-started</value>
789
789
  <value>vote-ended</value>
790
+ <value>announced</value>
790
791
  </choice>
791
792
  </define>
792
793
  <define name="bdate">
@@ -22,20 +22,19 @@ module Asciidoctor
22
22
  def other_footnote_renumber(xmldoc)
23
23
  seen = {}
24
24
  i = 0
25
- xmldoc.xpath(PRE_NORMREF_FOOTNOTES).each do |fn|
26
- i, seen = other_footnote_renumber1(fn, i, seen)
27
- end
28
- xmldoc.xpath(NORMREF_FOOTNOTES).each do |fn|
29
- i, seen = other_footnote_renumber1(fn, i, seen)
30
- end
31
- xmldoc.xpath(POST_NORMREF_FOOTNOTES).each do |fn|
32
- i, seen = other_footnote_renumber1(fn, i, seen)
25
+ [PRE_NORMREF_FOOTNOTES, NORMREF_FOOTNOTES,
26
+ POST_NORMREF_FOOTNOTES].each do |xpath|
27
+ xmldoc.xpath(xpath).each do |fn|
28
+ i, seen = other_footnote_renumber1(fn, i, seen)
29
+ end
33
30
  end
34
31
  end
35
32
 
36
33
  def id_prefix(prefix, id)
37
- return id.text if @amd # we're just inheriting the prefixes from parent doc
38
- prefix.join("/") + ( id.text.match(%{^/}) ? "" : " " ) + id.text
34
+ # we're just inheriting the prefixes from parent doc
35
+ return id.text if @amd
36
+
37
+ prefix.join("/") + (id.text.match?(%{^/}) ? "" : " ") + id.text
39
38
  end
40
39
 
41
40
  def get_id_prefix(xmldoc)
@@ -66,8 +65,12 @@ module Asciidoctor
66
65
  super
67
66
  end
68
67
 
69
- TERM_CLAUSE = "//sections//terms".freeze
68
+ TERM_CLAUSE = "//sections//terms | "\
69
+ "//sections//clause[descendant::terms][not(descendant::definitions)]"
70
+ .freeze
71
+
70
72
  PUBLISHER = "./contributor[role/@type = 'publisher']/organization".freeze
73
+
71
74
  OTHERIDS = "@type = 'DOI' or @type = 'metanorma' or @type = 'ISSN' or "\
72
75
  "@type = 'ISBN'".freeze
73
76
 
@@ -79,6 +82,7 @@ module Asciidoctor
79
82
  return 2 if bib.at("#{PUBLISHER}[name = 'International "\
80
83
  "Electrotechnical Commission']")
81
84
  return 3 if bib.at("./docidentifier[@type][not(#{OTHERIDS})]")
85
+
82
86
  4
83
87
  end
84
88
 
@@ -101,25 +105,26 @@ module Asciidoctor
101
105
  num = bib&.at("./docnumber")&.text
102
106
  id = bib&.at("./docidentifier[not(#{OTHERIDS})]")
103
107
  metaid = bib&.at("./docidentifier[@type = 'metanorma']")&.text
104
- abbrid = metaid unless /^\[\d+\]$/.match(metaid)
108
+ abbrid = metaid unless /^\[\d+\]$/.match?(metaid)
105
109
  /\d-(?<partid>\d+)/ =~ id&.text
106
- type = id['type'] if id
110
+ type = id["type"] if id
107
111
  title = bib&.at("./title[@type = 'main']")&.text ||
108
112
  bib&.at("./title")&.text || bib&.at("./formattedref")&.text
109
113
  "#{pubclass} :: #{type} :: "\
110
- "#{num.nil? ? abbrid : sprintf("%09d", num.to_i)} :: "\
114
+ "#{num.nil? ? abbrid : sprintf('%09d', num.to_i)} :: "\
111
115
  "#{partid} :: #{id&.text} :: #{title}"
112
116
  end
113
117
 
114
- def sections_cleanup(x)
118
+ def sections_cleanup(xml)
115
119
  super
116
120
  return unless @amd
117
- x.xpath("//*[@inline-header]").each do |h|
118
- h.delete('inline-header')
121
+
122
+ xml.xpath("//*[@inline-header]").each do |h|
123
+ h.delete("inline-header")
119
124
  end
120
125
  end
121
126
 
122
- def boilerplate_file(xmldoc)
127
+ def boilerplate_file(_xmldoc)
123
128
  file = @lang == "fr" ? "boilerplate-fr.xml" : "boilerplate.xml"
124
129
  File.join(@libdir, file)
125
130
  end
@@ -146,16 +151,27 @@ module Asciidoctor
146
151
  end
147
152
 
148
153
  def unpublished_note(xmldoc)
149
- xmldoc.xpath("//bibitem[not(note[@type = 'Unpublished-Status'])]").each do |b|
154
+ xmldoc.xpath("//bibitem[not(note[@type = 'Unpublished-Status'])]")
155
+ .each do |b|
150
156
  next if pub_class(b) > 2
151
- next unless s = b.at("./status/stage") and s.text.to_i < 60
157
+ next unless (s = b.at("./status/stage")) && (s.text.to_i < 60)
158
+
152
159
  id = b.at("docidentifier").text
153
- b.at("./language | ./script | ./abstract | ./status").previous = <<~NOTE
154
- <note type="Unpublished-Status">
155
- <p>#{@i18n.under_preparation.sub(/%/, id)}</p></note>
156
- NOTE
160
+ b.at("./language | ./script | ./abstract | ./status")
161
+ .previous = %(<note type="Unpublished-Status">
162
+ <p>#{@i18n.under_preparation.sub(/%/, id)}</p></note>)
157
163
  end
158
164
  end
165
+
166
+ def termdef_boilerplate_insert(xmldoc, isodoc, once = false)
167
+ once = true
168
+ super
169
+ end
170
+
171
+ def term_defs_boilerplate_cont(src, term, isodoc)
172
+ @vocab and src.empty? and return
173
+ super
174
+ end
159
175
  end
160
176
  end
161
177
  end
@@ -33,7 +33,9 @@ module Asciidoctor
33
33
  csv_split(publishers).each do |p|
34
34
  xml.contributor do |c|
35
35
  c.role **{ type: "author" }
36
- c.organization { |a| organization(a, p, node, !node.attr("publisher")) }
36
+ c.organization do |a|
37
+ organization(a, p, false, node, !node.attr("publisher"))
38
+ end
37
39
  end
38
40
  end
39
41
  end
@@ -43,20 +45,25 @@ module Asciidoctor
43
45
  csv_split(publishers).each do |p|
44
46
  xml.contributor do |c|
45
47
  c.role **{ type: "publisher" }
46
- c.organization { |a| organization(a, p, node, !node.attr("publisher")) }
48
+ c.organization do |a|
49
+ organization(a, p, true, node, !node.attr("publisher"))
50
+ end
47
51
  end
48
52
  end
49
53
  end
50
54
 
51
55
  def metadata_copyright(node, xml)
52
- publishers = node.attr("copyright-holder") || node.attr("publisher") || "ISO"
56
+ publishers = node.attr("copyright-holder") || node.attr("publisher") ||
57
+ "ISO"
53
58
  csv_split(publishers).each do |p|
54
59
  xml.copyright do |c|
55
60
  c.from (node.attr("copyright-year") || Date.today.year)
56
61
  c.owner do |owner|
57
62
  owner.organization do |o|
58
- organization(o, p, node,
59
- !(node.attr("copyright-holder") || node.attr("publisher")))
63
+ organization(
64
+ o, p, true, node,
65
+ !(node.attr("copyright-holder") || node.attr("publisher"))
66
+ )
60
67
  end
61
68
  end
62
69
  end
@@ -82,34 +89,39 @@ module Asciidoctor
82
89
  end
83
90
  end
84
91
 
85
- def title_intro(node, t, lang, at)
92
+ def title_intro(node, xml, lang, at)
86
93
  return unless node.attr("title-intro-#{lang}")
87
- t.title(**attr_code(at.merge(type: "title-intro"))) do |t1|
94
+
95
+ xml.title(**attr_code(at.merge(type: "title-intro"))) do |t1|
88
96
  t1 << Metanorma::Utils::asciidoc_sub(node.attr("title-intro-#{lang}"))
89
97
  end
90
98
  end
91
99
 
92
- def title_main(node, t, lang, at)
93
- t.title **attr_code(at.merge(type: "title-main")) do |t1|
100
+ def title_main(node, xml, lang, at)
101
+ xml.title **attr_code(at.merge(type: "title-main")) do |t1|
94
102
  t1 << Metanorma::Utils::asciidoc_sub(node.attr("title-main-#{lang}"))
95
103
  end
96
104
  end
97
105
 
98
- def title_part(node, t, lang, at)
106
+ def title_part(node, xml, lang, at)
99
107
  return unless node.attr("title-part-#{lang}")
100
- t.title(**attr_code(at.merge(type: "title-part"))) do |t1|
108
+
109
+ xml.title(**attr_code(at.merge(type: "title-part"))) do |t1|
101
110
  t1 << Metanorma::Utils::asciidoc_sub(node.attr("title-part-#{lang}"))
102
111
  end
103
112
  end
104
113
 
105
- def title_amd(node, t, lang, at)
114
+ def title_amd(node, xml, lang, at)
106
115
  return unless node.attr("title-amendment-#{lang}")
107
- t.title(**attr_code(at.merge(type: "title-amd"))) do |t1|
108
- t1 << Metanorma::Utils::asciidoc_sub(node.attr("title-amendment-#{lang}"))
116
+
117
+ xml.title(**attr_code(at.merge(type: "title-amd"))) do |t1|
118
+ t1 << Metanorma::Utils::asciidoc_sub(
119
+ node.attr("title-amendment-#{lang}")
120
+ )
109
121
  end
110
122
  end
111
123
 
112
- def title_full(node, t, lang, at)
124
+ def title_full(node, xml, lang, at)
113
125
  title = node.attr("title-main-#{lang}")
114
126
  intro = node.attr("title-intro-#{lang}")
115
127
  part = node.attr("title-part-#{lang}")
@@ -117,7 +129,7 @@ module Asciidoctor
117
129
  title = "#{intro} -- #{title}" if intro
118
130
  title = "#{title} -- #{part}" if part
119
131
  title = "#{title} -- #{amd}" if amd && @amd
120
- t.title **attr_code(at.merge(type: "main")) do |t1|
132
+ xml.title **attr_code(at.merge(type: "main")) do |t1|
121
133
  t1 << Metanorma::Utils::asciidoc_sub(title)
122
134
  end
123
135
  end
@@ -35,22 +35,26 @@ module Asciidoctor
35
35
 
36
36
  def stage_abbr(stage, substage, doctype)
37
37
  return nil if stage.to_i > 60
38
+
38
39
  ret = STAGE_ABBRS[stage.to_sym]
39
40
  ret = "PRF" if stage == "60" && substage == "00"
40
41
  ret = "AWI" if stage == "10" && substage == "99"
41
- if %w(amendment technical-corrigendum technical-report
42
- technical-specification).include?(doctype)
42
+ if %w(amendment technical-corrigendum technical-report
43
+ technical-specification).include?(doctype)
43
44
  ret = "D" if stage == "40" && doctype == "amendment"
44
- ret = "FD" if stage == "50" && %w(amendment technical-corrigendum).include?(doctype)
45
+ ret = "FD" if stage == "50" && %w(amendment technical-corrigendum)
46
+ .include?(doctype)
45
47
  end
46
48
  ret
47
49
  end
48
50
 
49
51
  def stage_name(stage, substage, doctype, iteration = nil)
50
52
  return "Proof" if stage == "60" && substage == "00"
53
+
51
54
  ret = STAGE_NAMES[stage.to_sym]
52
55
  if iteration && %w(20 30).include?(stage)
53
- prefix = iteration.to_i.localize(@lang.to_sym).to_rbnf_s("SpelloutRules", "spellout-ordinal")
56
+ prefix = iteration.to_i.localize(@lang.to_sym)
57
+ .to_rbnf_s("SpelloutRules", "spellout-ordinal")
54
58
  ret = "#{prefix.capitalize} #{ret.downcase}"
55
59
  end
56
60
  ret
@@ -65,37 +69,39 @@ module Asciidoctor
65
69
  end
66
70
 
67
71
  def iso_id(node, xml)
68
- return unless !@amd && node.attr("docnumber") || @amd && node.attr("updates")
72
+ !@amd && node.attr("docnumber") || @amd && node.attr("updates") or
73
+ return
74
+
69
75
  dn = iso_id1(node)
70
76
  dn1 = id_stage_prefix(dn, node, false)
71
77
  dn2 = id_stage_prefix(dn, node, true)
72
78
  xml.docidentifier dn1, **attr_code(type: "ISO")
73
- xml.docidentifier id_langsuffix(dn1, node), **attr_code(type: "iso-with-lang")
74
- xml.docidentifier id_langsuffix(dn2, node), **attr_code(type: "iso-reference")
79
+ xml.docidentifier(id_langsuffix(dn1, node),
80
+ **attr_code(type: "iso-with-lang"))
81
+ xml.docidentifier(id_langsuffix(dn2, node),
82
+ **attr_code(type: "iso-reference"))
75
83
  end
76
84
 
77
85
  def iso_id1(node)
78
86
  if @amd
79
87
  dn = node.attr("updates")
80
- return add_amd_parts(dn, node)
88
+ add_amd_parts(dn, node)
81
89
  else
82
90
  part, subpart = node&.attr("partnumber")&.split(/-/)
83
- return add_id_parts(node.attr("docnumber"), part, subpart)
91
+ add_id_parts(node.attr("docnumber"), part, subpart)
84
92
  end
85
93
  end
86
94
 
87
- def add_amd_parts(dn, node)
88
- a = node.attr("amendment-number")
89
- c = node.attr("corrigendum-number")
95
+ def add_amd_parts(docnum, node)
90
96
  case doctype(node)
91
97
  when "amendment"
92
- "#{dn}/Amd #{node.attr('amendment-number')}"
98
+ "#{docnum}/Amd #{node.attr('amendment-number')}"
93
99
  when "technical-corrigendum"
94
- "#{dn}/Cor.#{node.attr('corrigendum-number')}"
100
+ "#{docnum}/Cor.#{node.attr('corrigendum-number')}"
95
101
  end
96
102
  end
97
103
 
98
- def id_langsuffix(dn, node)
104
+ def id_langsuffix(docnum, node)
99
105
  lang = node.attr("language") || "en"
100
106
  suffix = case lang
101
107
  when "en" then "(E)"
@@ -103,38 +109,43 @@ module Asciidoctor
103
109
  else
104
110
  "(X)"
105
111
  end
106
- "#{dn}#{suffix}"
112
+ "#{docnum}#{suffix}"
107
113
  end
108
114
 
109
115
  def structured_id(node, xml)
110
116
  return unless node.attr("docnumber")
117
+
111
118
  part, subpart = node&.attr("partnumber")&.split(/-/)
112
119
  xml.structuredidentifier do |i|
113
- i.project_number node.attr("docnumber"),
114
- **attr_code(part: part, subpart: subpart,
115
- amendment: node.attr("amendment-number"),
116
- corrigendum: node.attr("corrigendum-number"),
117
- origyr: node.attr("created-date"))
120
+ i.project_number(node.attr("docnumber"), **attr_code(
121
+ part: part, subpart: subpart,
122
+ amendment: node.attr("amendment-number"),
123
+ corrigendum: node.attr("corrigendum-number"),
124
+ origyr: node.attr("created-date")
125
+ ))
118
126
  end
119
127
  end
120
128
 
121
- def add_id_parts(dn, part, subpart)
122
- dn += "-#{part}" if part
123
- dn += "-#{subpart}" if subpart
124
- dn
129
+ def add_id_parts(docnum, part, subpart)
130
+ docnum += "-#{part}" if part
131
+ docnum += "-#{subpart}" if subpart
132
+ docnum
125
133
  end
126
134
 
127
135
  def id_stage_abbr(stage, substage, node, bare = false)
128
- ret = bare ?
129
- IsoDoc::Iso::Metadata.new("en", "Latn", @i18n)
130
- .status_abbrev(stage_abbr(stage, substage, doctype(node)),
131
- substage, nil, nil, doctype(node)) :
132
- IsoDoc::Iso::Metadata.new("en", "Latn", @i18n)
133
- .status_abbrev(stage_abbr(stage, substage, doctype(node)),
134
- substage, node.attr("iteration"),
135
- node.attr("draft"), doctype(node))
136
- if %w(amendment technical-corrigendum technical-report technical-specification).include?(doctype(node))
137
- ret = ret + " " unless %w(D FD).include?(ret)
136
+ ret = if bare
137
+ IsoDoc::Iso::Metadata.new("en", "Latn", @i18n)
138
+ .status_abbrev(stage_abbr(stage, substage, doctype(node)),
139
+ substage, nil, nil, doctype(node))
140
+ else
141
+ IsoDoc::Iso::Metadata.new("en", "Latn", @i18n)
142
+ .status_abbrev(stage_abbr(stage, substage, doctype(node)),
143
+ substage, node.attr("iteration"),
144
+ node.attr("draft"), doctype(node))
145
+ end
146
+ if %w(amendment technical-corrigendum technical-report
147
+ technical-specification).include?(doctype(node))
148
+ ret = "#{ret} " unless %w(D FD).include?(ret)
138
149
  end
139
150
  ret
140
151
  end
@@ -143,51 +154,56 @@ module Asciidoctor
143
154
  stage = get_stage(node)
144
155
  abbr = id_stage_abbr(get_stage(node), get_substage(node), node, true)
145
156
  typeabbr = get_typeabbr(node, true)
146
- typeabbr = "" if stage.to_i > 50 || stage.to_i == 60 && get_substage(node).to_i < 60
157
+ if stage.to_i > 50 || stage.to_i == 60 && get_substage(node).to_i < 60
158
+ typeabbr = ""
159
+ end
147
160
  "#{abbr}#{typeabbr}".strip
148
161
  end
149
162
 
150
- def id_stage_prefix(dn, node, force_year)
163
+ def id_stage_prefix(docnum, node, force_year)
151
164
  stage = get_stage(node)
152
165
  typeabbr = get_typeabbr(node)
153
166
  if stage && (stage.to_i < 60)
154
- dn = unpub_stage_prefix(dn, stage, typeabbr, node)
155
- elsif typeabbr && !@amd then dn = "/#{typeabbr}#{dn}"
167
+ docnum = unpub_stage_prefix(docnum, stage, typeabbr, node)
168
+ elsif typeabbr == "DIR " then docnum = "#{typeabbr}#{docnum}"
169
+ elsif typeabbr && !@amd then docnum = "/#{typeabbr}#{docnum}"
156
170
  end
157
171
  (force_year || !(stage && (stage.to_i < 60))) and
158
- dn = id_add_year(dn, node)
159
- dn
172
+ docnum = id_add_year(docnum, node)
173
+ docnum
160
174
  end
161
175
 
162
- def unpub_stage_prefix(dn, stage, typeabbr, node)
176
+ def unpub_stage_prefix(docnum, stage, typeabbr, node)
163
177
  abbr = id_stage_abbr(stage, get_substage(node), node)
164
178
  %w(40 50).include?(stage) && i = node.attr("iteration") and
165
179
  itersuffix = ".#{i}"
166
- return dn if abbr.nil? || abbr.empty? # prefixes added in cleanup
167
- return "/#{abbr}#{typeabbr} #{dn}#{itersuffix}" unless @amd
168
- a = dn.split(%r{/})
180
+ return docnum if abbr.nil? || abbr.empty? # prefixes added in cleanup
181
+ return "/#{abbr}#{typeabbr} #{docnum}#{itersuffix}" unless @amd
182
+
183
+ a = docnum.split(%r{/})
169
184
  a[-1] = "#{abbr}#{a[-1]}#{itersuffix}"
170
185
  a.join("/")
171
186
  end
172
187
 
173
- def id_add_year(dn, node)
188
+ def id_add_year(docnum, node)
174
189
  year = node.attr("copyright-year")
175
190
  @amd and year ||= node.attr("updated-date")&.sub(/-.*$/, "")
176
- dn += ":#{year}" if year
177
- dn
191
+ docnum += ":#{year}" if year
192
+ docnum
178
193
  end
179
194
 
180
195
  def get_stage(node)
181
- stage = node.attr("status") || node.attr("docstage") || "60"
196
+ node.attr("status") || node.attr("docstage") || "60"
182
197
  end
183
198
 
184
199
  def get_substage(node)
185
200
  stage = get_stage(node)
186
- node.attr("docsubstage") || ( stage == "60" ? "60" : "00" )
201
+ node.attr("docsubstage") || (stage == "60" ? "60" : "00")
187
202
  end
188
203
 
189
204
  def get_typeabbr(node, amd = false)
190
205
  case doctype(node)
206
+ when "directive" then "DIR "
191
207
  when "technical-report" then "TR "
192
208
  when "technical-specification" then "TS "
193
209
  when "amendment" then (amd ? "Amd " : "")