metanorma-bipm 1.0.1 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -29,7 +29,7 @@ module IsoDoc
29
29
  ns("#{TITLE}[@type='main'][@language='#{lang1}']"))&.text || ""))
30
30
  set(:docsubtitle, @c.encode(isoxml&.at(
31
31
  ns("#{TITLE}[@type='main'][@language='#{lang2}']"))&.text || ""))
32
- %w(appendix part subtitle).each do |e|
32
+ %w(appendix annex part subtitle).each do |e|
33
33
  set("#{e}title".to_sym, @c.encode(isoxml&.at(
34
34
  ns("#{TITLE}[@type='#{e}'][@language='#{lang1}']"))&.text || ""))
35
35
  set("#{e}subtitle".to_sym, @c.encode(isoxml&.at(
@@ -51,10 +51,16 @@ module IsoDoc
51
51
  dn = isoxml.at(ns("//bibdata/ext/structuredidentifier/appendix"))
52
52
  dn and set(:appendixid, @i18n.l10n("#{label1} #{dn&.text}"))
53
53
  dn and set(:appendixid_alt, @i18n.l10n("#{label2} #{dn&.text}"))
54
+ label1, label2 = @lang == "fr" ? %w(Appendice Annex) : %w(Annex Appendice)
55
+ dn = isoxml.at(ns("//bibdata/ext/structuredidentifier/annexid"))
56
+ dn and set(:annexid, @i18n.l10n("#{label1} #{dn&.text}"))
57
+ dn and set(:annexid_alt, @i18n.l10n("#{label2} #{dn&.text}"))
54
58
  label1, label2 = @lang == "fr" ? %w(Partie Part) : %w(Part Partie)
55
59
  dn = isoxml.at(ns("//bibdata/ext/structuredidentifier/part"))
56
60
  dn and set(:partid, @i18n.l10n("#{label1} #{dn&.text}"))
57
61
  dn and set(:partid_alt, @i18n.l10n("#{label2} #{dn&.text}"))
62
+ set(:org_abbrev,
63
+ isoxml.at(ns("//bibdata/ext/editorialgroup/committee[@acronym = 'JCGM']")) ? "JCGM" : "BIPM")
58
64
  end
59
65
 
60
66
  def extract_person_names_affiliations(authors)
@@ -15,6 +15,7 @@ module IsoDoc
15
15
  end
16
16
 
17
17
  def pdf_stylesheet(docxml)
18
+ return "jcgm.standard.xsl" if docxml&.at(ns("//bibdata/ext/editorialgroup/committee/@acronym"))&.value == "JCGM"
18
19
  doctype = docxml&.at(ns("//bibdata/ext/doctype"))&.text
19
20
  doctype = "brochure" unless %w(guide mise-en-pratique rapport).
20
21
  include? doctype
@@ -8,7 +8,7 @@ module IsoDoc
8
8
  class PresentationXMLConvert < IsoDoc::Generic::PresentationXMLConvert
9
9
  def table1(f)
10
10
  return if labelled_ancestor(f)
11
- return if f["unnumbered"] && !f.at(ns("./name"))
11
+ return if f["unnumbered"]
12
12
  n = @xrefs.anchor(f['id'], :label, false)
13
13
  prefix_name(f, ".<tab/>", l10n("#{@i18n.table.capitalize} #{n}"), "name")
14
14
  end
@@ -1,24 +1,38 @@
1
1
  module IsoDoc
2
2
  module BIPM
3
+ class Counter < IsoDoc::XrefGen::Counter
4
+ end
5
+
3
6
  class Xref < IsoDoc::Xref
4
7
  def initialize(lang, script, klass, i18n, options = {})
5
8
  super
6
9
  end
7
10
 
8
11
  def clause_names(docxml, sect_num)
9
- sect_num = 0
12
+ if docxml&.at(ns("//bibdata/ext/editorialgroup/committee/@acronym"))&.value == "JCGM"
13
+ clause_names_jcgm(docxml, sect_num)
14
+ else
15
+ clause_names_bipm(docxml, sect_num)
16
+ end
17
+ end
18
+
19
+ def clause_names_jcgm(docxml, sect_num)
20
+ docxml.xpath(ns("//clause[parent::sections][not(@type = 'scope')][not(descendant::terms)]")).
21
+ each_with_index do |c, i|
22
+ section_names(c, sect_num, 1)
23
+ end
24
+ end
25
+
26
+ def clause_names_bipm(docxml, sect_num)
27
+ n = Counter.new
10
28
  docxml.xpath(ns("//sections/clause[not(@unnumbered = 'true')] | "\
11
29
  "//sections/terms[not(@unnumbered = 'true')] | "\
12
30
  "//sections/definitions[not(@unnumbered = 'true')]")).
13
- each_with_index do |c, i|
14
- section_names(c, (i + sect_num), 1)
15
- end
31
+ each { |c| section_names(c, n, 1) }
16
32
  docxml.xpath(ns("//sections/clause[@unnumbered = 'true'] | "\
17
33
  "//sections/terms[@unnumbered = 'true'] | "\
18
34
  "//sections/definitions[@unnumbered = 'true']")).
19
- each do |c|
20
- unnumbered_section_names(c, 1)
21
- end
35
+ each { |c| unnumbered_section_names(c, 1) }
22
36
  end
23
37
 
24
38
  NUMBERED_SUBCLAUSES = "./clause[not(@unnumbered = 'true')] | "\
@@ -35,12 +49,13 @@ module IsoDoc
35
49
 
36
50
  def section_names(clause, num, lvl)
37
51
  return num if clause.nil?
38
- num = num + 1
39
- @anchors[clause["id"]] =
40
- { label: num.to_s, xref: l10n("#{@labels["clause"]} #{num}"),
41
- level: lvl, type: "clause" }
42
- clause.xpath(ns(NUMBERED_SUBCLAUSES)).each_with_index do |c, i|
43
- section_names1(c, "#{num}.#{i + 1}", lvl + 1)
52
+ num.increment(clause)
53
+ @anchors[clause["id"]] = { label: num.print, xref: l10n("#{@labels["clause"]} #{num.print}"),
54
+ level: lvl, type: "clause" }
55
+ i = Counter.new
56
+ clause.xpath(ns(NUMBERED_SUBCLAUSES)).each do |c|
57
+ i.increment(c)
58
+ section_names1(c, "#{num.print}.#{i.print}", lvl + 1)
44
59
  end
45
60
  clause.xpath(ns(UNNUMBERED_SUBCLAUSES)).each_with_index do |c, i|
46
61
  unnumbered_section_names1(c, lvl + 1)
@@ -51,8 +66,7 @@ module IsoDoc
51
66
  def unnumbered_section_names(clause, lvl)
52
67
  return if clause.nil?
53
68
  lbl = clause&.at(ns("./title"))&.text || "[#{clause["id"]}]"
54
- @anchors[clause["id"]] =
55
- { label: lbl, xref: l10n(%{"#{lbl}"}), level: lvl, type: "clause" }
69
+ @anchors[clause["id"]] = { label: lbl, xref: l10n(%{"#{lbl}"}), level: lvl, type: "clause" }
56
70
  clause.xpath(ns(SUBCLAUSES)).each_with_index do |c, i|
57
71
  unnumbered_section_names1(c, lvl + 1)
58
72
  end
@@ -62,8 +76,10 @@ module IsoDoc
62
76
  @anchors[clause["id"]] =
63
77
  { label: num, level: level, xref: l10n("#{@labels["subclause"]} #{num}"),
64
78
  type: "clause" }
65
- clause.xpath(ns(NUMBERED_SUBCLAUSES)).each_with_index do |c, i|
66
- section_names1(c, "#{num}.#{i + 1}", level + 1)
79
+ i = Counter.new
80
+ clause.xpath(ns(NUMBERED_SUBCLAUSES)).each do |c|
81
+ i.increment(c)
82
+ section_names1(c, "#{num}.#{i.print}", level + 1)
67
83
  end
68
84
  clause.xpath(ns(UNNUMBERED_SUBCLAUSES)).each_with_index do |c, i|
69
85
  unnumbered_section_names1(c, lvl + 1)
@@ -83,64 +99,54 @@ module IsoDoc
83
99
  super
84
100
  @annexlbl = docxml.at(ns("//bibdata/ext/structuredidentifier/appendix")) ?
85
101
  @labels["appendix"] : @labels["annex"]
86
- docxml.xpath(ns("//annex[not(@unnumbered = 'true')]")).
87
- each_with_index { |c, i| annex_names(c, (i+1).to_s) }
88
- docxml.xpath(ns("//annex[@unnumbered = 'true']")).
89
- each { |c| unnumbered_annex_names(c) }
102
+ docxml.xpath(ns("//annex[not(@unnumbered = 'true')]")).each_with_index { |c, i| annex_names(c, (i+1).to_s) }
103
+ docxml.xpath(ns("//annex[@unnumbered = 'true']")).each { |c| unnumbered_annex_names(c) }
104
+ docxml.xpath(ns("//indexsect")).each { |b| preface_names(b) }
90
105
  end
91
106
 
92
107
  def annex_names(clause, num)
93
- @anchors[clause["id"]] =
94
- { label: annex_name_lbl(clause, num), type: "clause", value: num.to_s,
95
- xref: l10n("#{@annexlbl} #{num}"), level: 1 }
108
+ @anchors[clause["id"]] = { label: annex_name_lbl(clause, num), type: "clause", value: num.to_s,
109
+ xref: l10n("#{@annexlbl} #{num}"), level: 1 }
96
110
  if a = single_annex_special_section(clause)
97
111
  annex_names1(a, "#{num}", 1)
98
112
  else
99
- clause.xpath(ns(NUMBERED_SUBCLAUSES)).each_with_index do |c, i|
100
- annex_names1(c, "#{num}.#{i + 1}", 2)
101
- end
102
- clause.xpath(ns(UNNUMBERED_SUBCLAUSES)).each do |c|
103
- unnumbered_annex_names1(c, 2)
113
+ i = Counter.new
114
+ clause.xpath(ns(NUMBERED_SUBCLAUSES)).each do |c|
115
+ i.increment(c)
116
+ annex_names1(c, "#{num}.#{i.print}", 2)
104
117
  end
118
+ clause.xpath(ns(UNNUMBERED_SUBCLAUSES)).each { |c| unnumbered_annex_names1(c, 2) }
105
119
  end
106
120
  hierarchical_asset_names(clause, num)
107
121
  end
108
122
 
109
123
  def unnumbered_annex_names(clause)
110
124
  lbl = clause&.at(ns("./title"))&.text || "[#{clause["id"]}]"
111
- @anchors[clause["id"]] =
112
- { label: lbl, type: "clause", value: "",
113
- xref: l10n(%{"#{lbl}"}), level: 1 }
125
+ @anchors[clause["id"]] = { label: lbl, type: "clause", value: "", xref: l10n(%{"#{lbl}"}), level: 1 }
114
126
  if a = single_annex_special_section(clause)
115
127
  annex_names1(a, "#{num}", 1)
116
128
  else
117
- clause.xpath(ns(SUBCLAUSES)).each do |c|
118
- unnumbered_annex_names1(c, 2)
119
- end
129
+ clause.xpath(ns(SUBCLAUSES)).each { |c| unnumbered_annex_names1(c, 2) }
120
130
  end
121
131
  hierarchical_asset_names(clause, lbl)
122
132
  end
123
133
 
124
134
  def annex_names1(clause, num, level)
125
- @anchors[clause["id"]] =
126
- { label: num, xref: l10n("#{@annexlbl} #{num}"),
127
- level: level, type: "clause" }
128
- clause.xpath(ns(NUMBERED_SUBCLAUSES)).each_with_index do |c, i|
129
- annex_names1(c, "#{num}.#{i + 1}", level + 1)
130
- end
131
- clause.xpath(ns(UNNUMBERED_SUBCLAUSES)).each do |c|
132
- unnumbered_annex_names1(c, level + 1)
135
+ @anchors[clause["id"]] = { label: num, xref: l10n("#{@annexlbl} #{num}"),
136
+ level: level, type: "clause" }
137
+ i = Counter.new
138
+ clause.xpath(ns(NUMBERED_SUBCLAUSES)).each do |c|
139
+ i.increment(c)
140
+ annex_names1(c, "#{num}.#{i.print}", level + 1)
133
141
  end
142
+ clause.xpath(ns(UNNUMBERED_SUBCLAUSES)).each { |c| unnumbered_annex_names1(c, level + 1) }
134
143
  end
135
144
 
136
145
  def unnumbered_annex_names1(clause, level)
137
146
  lbl = clause&.at(ns("./title"))&.text || "[#{clause["id"]}]"
138
- @anchors[clause["id"]] =
139
- { label: lbl, xref: l10n(%{"#{lbl}"}),
140
- level: level, type: "clause" }
141
- clause.xpath(ns(SUBCLAUSES)).each do |c|
142
- unnumbered_annex_names1(c, level + 1)
143
- end
147
+ @anchors[clause["id"]] = { label: lbl, xref: l10n(%{"#{lbl}"}),
148
+ level: level, type: "clause" }
149
+ clause.xpath(ns(SUBCLAUSES)).each { |c| unnumbered_annex_names1(c, level + 1) }
144
150
  end
145
151
 
146
152
  def annex_name_lbl(clause, num)
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module BIPM
3
- VERSION = "1.0.1"
3
+ VERSION = "1.0.6"
4
4
  end
5
5
  end
@@ -26,14 +26,14 @@ Gem::Specification.new do |spec|
26
26
  spec.require_paths = ["lib"]
27
27
  spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
28
28
 
29
- spec.add_dependency "metanorma-generic", "~> 1.8.1"
29
+ spec.add_dependency "metanorma-generic", "~> 1.9.0"
30
30
 
31
31
  spec.add_development_dependency "byebug", "~> 9.1"
32
32
  spec.add_development_dependency "sassc", "2.4.0"
33
33
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
34
34
  spec.add_development_dependency "guard", "~> 2.14"
35
35
  spec.add_development_dependency "guard-rspec", "~> 4.7"
36
- spec.add_development_dependency "rake", "~> 12.0"
36
+ spec.add_development_dependency "rake", "~> 13.0"
37
37
  spec.add_development_dependency "rspec", "~> 3.6"
38
38
  spec.add_development_dependency "rubocop", "~> 0.50"
39
39
  spec.add_development_dependency "simplecov", "~> 0.15"
data/metanorma.yml CHANGED
@@ -5,6 +5,7 @@ organization_name_long:
5
5
  en: Bureau International des Poids et Mesures
6
6
  document_namespace: https://www.metanorma.org/ns/bipm
7
7
  xml_root_tag: 'bipm-standard'
8
+ docid_template: "{{ org_abbrev }} {{ docnumeric }}"
8
9
  html_bodyfont: Times New Roman
9
10
  html_headerfont: Times New Roman
10
11
  html_normalfontsize: "15px"
@@ -83,8 +84,8 @@ committees:
83
84
  - CCU
84
85
  - Consultative Committee for Units
85
86
  - Comité consultatif des unités
86
- - CCL-CCT
87
- - Frequency Standards Working Group
87
+ - CCL-CCTF-WGFS
88
+ - CCL-CCTF Frequency Standards Working Group
88
89
  - JCGM
89
90
  - Joint Committee for Guides in Metrology
90
91
  - Comité commun pour les guides en métrologie
@@ -110,6 +111,8 @@ metadata_extensions:
110
111
  _output: part
111
112
  appendix-id:
112
113
  _output: appendix
114
+ annex-id:
115
+ _output: annexid
113
116
  relations:
114
117
  - supersedes
115
118
  - superseded-by
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-bipm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.6
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-12-28 00:00:00.000000000 Z
11
+ date: 2021-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-generic
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.8.1
19
+ version: 1.9.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: 1.8.1
26
+ version: 1.9.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: byebug
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '12.0'
103
+ version: '13.0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '12.0'
110
+ version: '13.0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rspec
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -189,6 +189,7 @@ files:
189
189
  - lib/asciidoctor/bipm/bipm.rng
190
190
  - lib/asciidoctor/bipm/boilerplate-en.xml
191
191
  - lib/asciidoctor/bipm/boilerplate-fr.xml
192
+ - lib/asciidoctor/bipm/boilerplate-jcgm-en.xml
192
193
  - lib/asciidoctor/bipm/converter.rb
193
194
  - lib/asciidoctor/bipm/isodoc.rng
194
195
  - lib/asciidoctor/bipm/reqt.rng
@@ -223,6 +224,7 @@ files:
223
224
  - lib/isodoc/bipm/i18n.rb
224
225
  - lib/isodoc/bipm/index.rb
225
226
  - lib/isodoc/bipm/init.rb
227
+ - lib/isodoc/bipm/jcgm.standard.xsl
226
228
  - lib/isodoc/bipm/metadata.rb
227
229
  - lib/isodoc/bipm/pdf_convert.rb
228
230
  - lib/isodoc/bipm/presentation_xml_convert.rb
@@ -252,7 +254,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
252
254
  - !ruby/object:Gem::Version
253
255
  version: '0'
254
256
  requirements: []
255
- rubygems_version: 3.0.3
257
+ rubygems_version: 3.1.4
256
258
  signing_key:
257
259
  specification_version: 4
258
260
  summary: metanorma-bipm lets you write BIPM standards in Metanorma.