metanorma-bipm 1.0.2 → 1.0.7

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.
@@ -59,6 +59,8 @@ module IsoDoc
59
59
  dn = isoxml.at(ns("//bibdata/ext/structuredidentifier/part"))
60
60
  dn and set(:partid, @i18n.l10n("#{label1} #{dn&.text}"))
61
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")
62
64
  end
63
65
 
64
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
@@ -33,27 +33,41 @@ module IsoDoc
33
33
  doccontrol docxml
34
34
  end
35
35
 
36
- def doccontrol docxml
36
+ def doccontrol(docxml)
37
37
  return unless docxml.at(ns("//bibdata/relation[@type = 'supersedes']"))
38
38
  clause = <<~END
39
39
  <doccontrol>
40
40
  <title>Document Control</title>
41
41
  <table unnumbered="true"><tbody>
42
- <tr><td>Authors:</td><td/><td>#{list_authors(docxml)}</td></tr>
43
- <tr>#{list_draft(docxml, 1)&.map { |x| "<td>#{x}</td>" }&.join }
44
- <td>#{list_cochairs(docxml)}</td></tr>
45
- <tr>#{list_draft(docxml, 2)&.map { |x| "<td>#{x}</td>" }&.join }
46
- <td>#{list_chairs(docxml)}</td></tr>
42
+ <tr><th>Authors:</th><td/><td>#{list_authors(docxml)}</td></tr>
43
+ #{doccontrol_row1(docxml)}
44
+ #{doccontrol_row2(docxml)}
47
45
  #{list_drafts(docxml)}
48
46
  </tbody></table></doccontrol>
49
47
  END
50
48
  docxml.root << clause
51
49
  end
52
50
 
51
+ def doccontrol_row1(docxml)
52
+ return "" if list_draft(docxml, 1) == ["", ""] && list_cochairs(docxml).empty?
53
+ <<~ROW
54
+ <tr>#{list_draft(docxml, 1)&.map { |x| "<td>#{x}</td>" }&.join }
55
+ <td>#{list_cochairs(docxml)}</td></tr>
56
+ ROW
57
+ end
58
+
59
+ def doccontrol_row2(docxml)
60
+ return "" if list_draft(docxml, 2) == ["", ""] && list_chairs(docxml).empty?
61
+ <<~ROW
62
+ <tr>#{list_draft(docxml, 2)&.map { |x| "<td>#{x}</td>" }&.join }
63
+ <td>#{list_chairs(docxml)}</td></tr>
64
+ ROW
65
+ end
66
+
53
67
  def list_drafts(xml)
54
68
  ret = ""
55
69
  i = 3
56
- while a = list_draft(xml, i)
70
+ while a = list_draft(xml, i) != ["", ""]
57
71
  ret += "<tr>#{list_draft(xml, i).map { |x| "<td>#{x}</td>" }.join }"\
58
72
  "<td/></tr>"
59
73
  i += 1
@@ -62,14 +76,14 @@ module IsoDoc
62
76
  end
63
77
 
64
78
  def list_draft(xml, i)
65
- return unless d =
79
+ return ["", ""] unless d =
66
80
  xml.at(ns("//bibdata/relation[@type = 'supersedes'][#{i}]/bibitem"))
67
81
  date = d&.at(ns("./date"))&.text
68
82
  draft = d&.at(ns("./version/draft"))&.text and
69
83
  draft = "Draft #{draft}"
70
84
  edn = d&.at(ns("./edition"))&.text and
71
- edn = "Edition #{edn}"
72
- [date, [draft, edn].join(" ")]
85
+ edn = "Version #{edn}"
86
+ [[draft, edn].join(" "), date]
73
87
  end
74
88
 
75
89
  def list_authors(xml)
@@ -84,6 +98,7 @@ module IsoDoc
84
98
 
85
99
  def list_cochairs(xml)
86
100
  ret = list_people(xml, "//bibdata/contributor[#{COCHAIR}]/person")
101
+ ret.empty? and return ""
87
102
  role = xml&.at(ns("//bibdata/contributor[#{COCHAIR}]/role"))&.text
88
103
  label = ret.size > 1 && role ? "#{role}s" : role
89
104
  "#{label}: #{@i18n.multiple_and(ret, @i18n.get["and"])}"
@@ -91,6 +106,7 @@ module IsoDoc
91
106
 
92
107
  def list_chairs(xml)
93
108
  ret = list_people(xml, "//bibdata/contributor#{CHAIR}/person")
109
+ ret.empty? and return ""
94
110
  role = xml&.at(ns("//bibdata/contributor#{CHAIR}/role"))&.text
95
111
  label = ret.size > 1 && role ? "#{role}s" : role
96
112
  "#{label}: #{@i18n.multiple_and(ret, @i18n.get["and"])}"
@@ -9,19 +9,31 @@ module IsoDoc
9
9
  end
10
10
 
11
11
  def clause_names(docxml, sect_num)
12
+ if docxml&.at(ns("//bibdata/ext/editorialgroup/committee/@acronym"))&.
13
+ value == "JCGM"
14
+ clause_names_jcgm(docxml, sect_num)
15
+ else
16
+ clause_names_bipm(docxml, sect_num)
17
+ end
18
+ end
19
+
20
+ def clause_names_jcgm(docxml, sect_num)
21
+ docxml.xpath(ns("//clause[parent::sections][not(@type = 'scope')]"\
22
+ "[not(descendant::terms)]")).each_with_index do |c, i|
23
+ section_names(c, sect_num, 1)
24
+ end
25
+ end
26
+
27
+ def clause_names_bipm(docxml, sect_num)
12
28
  n = Counter.new
13
29
  docxml.xpath(ns("//sections/clause[not(@unnumbered = 'true')] | "\
14
30
  "//sections/terms[not(@unnumbered = 'true')] | "\
15
31
  "//sections/definitions[not(@unnumbered = 'true')]")).
16
- each do |c|
17
- section_names(c, n, 1)
18
- end
32
+ each { |c| section_names(c, n, 1) }
19
33
  docxml.xpath(ns("//sections/clause[@unnumbered = 'true'] | "\
20
34
  "//sections/terms[@unnumbered = 'true'] | "\
21
35
  "//sections/definitions[@unnumbered = 'true']")).
22
- each do |c|
23
- unnumbered_section_names(c, 1)
24
- end
36
+ each { |c| unnumbered_section_names(c, 1) }
25
37
  end
26
38
 
27
39
  NUMBERED_SUBCLAUSES = "./clause[not(@unnumbered = 'true')] | "\
@@ -56,8 +68,8 @@ module IsoDoc
56
68
  def unnumbered_section_names(clause, lvl)
57
69
  return if clause.nil?
58
70
  lbl = clause&.at(ns("./title"))&.text || "[#{clause["id"]}]"
59
- @anchors[clause["id"]] =
60
- { label: lbl, xref: l10n(%{"#{lbl}"}), level: lvl, type: "clause" }
71
+ @anchors[clause["id"]] = { label: lbl, xref: l10n(%{"#{lbl}"}),
72
+ level: lvl, type: "clause" }
61
73
  clause.xpath(ns(SUBCLAUSES)).each_with_index do |c, i|
62
74
  unnumbered_section_names1(c, lvl + 1)
63
75
  end
@@ -65,7 +77,8 @@ module IsoDoc
65
77
 
66
78
  def section_names1(clause, num, level)
67
79
  @anchors[clause["id"]] =
68
- { label: num, level: level, xref: l10n("#{@labels["subclause"]} #{num}"),
80
+ { label: num, level: level,
81
+ xref: l10n("#{@labels["subclause"]} #{num}"),
69
82
  type: "clause" }
70
83
  i = Counter.new
71
84
  clause.xpath(ns(NUMBERED_SUBCLAUSES)).each do |c|
@@ -94,6 +107,7 @@ module IsoDoc
94
107
  each_with_index { |c, i| annex_names(c, (i+1).to_s) }
95
108
  docxml.xpath(ns("//annex[@unnumbered = 'true']")).
96
109
  each { |c| unnumbered_annex_names(c) }
110
+ docxml.xpath(ns("//indexsect")).each { |b| preface_names(b) }
97
111
  end
98
112
 
99
113
  def annex_names(clause, num)
@@ -108,9 +122,8 @@ module IsoDoc
108
122
  i.increment(c)
109
123
  annex_names1(c, "#{num}.#{i.print}", 2)
110
124
  end
111
- clause.xpath(ns(UNNUMBERED_SUBCLAUSES)).each do |c|
112
- unnumbered_annex_names1(c, 2)
113
- end
125
+ clause.xpath(ns(UNNUMBERED_SUBCLAUSES)).
126
+ each { |c| unnumbered_annex_names1(c, 2) }
114
127
  end
115
128
  hierarchical_asset_names(clause, num)
116
129
  end
@@ -123,9 +136,8 @@ module IsoDoc
123
136
  if a = single_annex_special_section(clause)
124
137
  annex_names1(a, "#{num}", 1)
125
138
  else
126
- clause.xpath(ns(SUBCLAUSES)).each do |c|
127
- unnumbered_annex_names1(c, 2)
128
- end
139
+ clause.xpath(ns(SUBCLAUSES)).
140
+ each { |c| unnumbered_annex_names1(c, 2) }
129
141
  end
130
142
  hierarchical_asset_names(clause, lbl)
131
143
  end
@@ -139,24 +151,33 @@ module IsoDoc
139
151
  i.increment(c)
140
152
  annex_names1(c, "#{num}.#{i.print}", level + 1)
141
153
  end
142
- clause.xpath(ns(UNNUMBERED_SUBCLAUSES)).each do |c|
143
- unnumbered_annex_names1(c, level + 1)
144
- end
154
+ clause.xpath(ns(UNNUMBERED_SUBCLAUSES)).
155
+ each { |c| unnumbered_annex_names1(c, level + 1) }
145
156
  end
146
157
 
147
158
  def unnumbered_annex_names1(clause, level)
148
159
  lbl = clause&.at(ns("./title"))&.text || "[#{clause["id"]}]"
149
- @anchors[clause["id"]] =
150
- { label: lbl, xref: l10n(%{"#{lbl}"}),
151
- level: level, type: "clause" }
152
- clause.xpath(ns(SUBCLAUSES)).each do |c|
153
- unnumbered_annex_names1(c, level + 1)
154
- end
160
+ @anchors[clause["id"]] = { label: lbl, xref: l10n(%{"#{lbl}"}),
161
+ level: level, type: "clause" }
162
+ clause.xpath(ns(SUBCLAUSES)).
163
+ each { |c| unnumbered_annex_names1(c, level + 1) }
155
164
  end
156
165
 
157
166
  def annex_name_lbl(clause, num)
158
167
  l10n("<strong>#{@annexlbl} #{num}</strong>")
159
168
  end
169
+
170
+ def sequential_formula_names(clause)
171
+ c = Counter.new
172
+ clause.xpath(ns(".//formula")).each do |t|
173
+ next if t["id"].nil? || t["id"].empty?
174
+ @anchors[t["id"]] =
175
+ anchor_struct(c.increment(t).print, nil,
176
+ t["inequality"] ? @labels["inequality"] : @labels["formula"],
177
+ "formula", t["unnumbered"])
178
+ end
179
+ end
180
+
160
181
  end
161
182
  end
162
183
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module BIPM
3
- VERSION = "1.0.2"
3
+ VERSION = "1.0.7"
4
4
  end
5
5
  end
@@ -26,16 +26,16 @@ 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.2"
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
- spec.add_development_dependency "rubocop", "~> 0.50"
38
+ spec.add_development_dependency "rubocop", "~> 1.5.2"
39
39
  spec.add_development_dependency "simplecov", "~> 0.15"
40
40
  spec.add_development_dependency "timecop", "~> 0.9"
41
41
  end
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"
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.2
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-11 00:00:00.000000000 Z
11
+ date: 2021-03-29 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.2
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.2
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
@@ -128,14 +128,14 @@ dependencies:
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: '0.50'
131
+ version: 1.5.2
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: '0.50'
138
+ version: 1.5.2
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: simplecov
141
141
  requirement: !ruby/object:Gem::Requirement
@@ -175,6 +175,8 @@ extensions: []
175
175
  extra_rdoc_files: []
176
176
  files:
177
177
  - ".github/workflows/rake.yml"
178
+ - ".gitignore"
179
+ - ".rubocop.yml"
178
180
  - CODE_OF_CONDUCT.md
179
181
  - Gemfile
180
182
  - LICENSE
@@ -189,6 +191,7 @@ files:
189
191
  - lib/asciidoctor/bipm/bipm.rng
190
192
  - lib/asciidoctor/bipm/boilerplate-en.xml
191
193
  - lib/asciidoctor/bipm/boilerplate-fr.xml
194
+ - lib/asciidoctor/bipm/boilerplate-jcgm-en.xml
192
195
  - lib/asciidoctor/bipm/converter.rb
193
196
  - lib/asciidoctor/bipm/isodoc.rng
194
197
  - lib/asciidoctor/bipm/reqt.rng
@@ -223,6 +226,7 @@ files:
223
226
  - lib/isodoc/bipm/i18n.rb
224
227
  - lib/isodoc/bipm/index.rb
225
228
  - lib/isodoc/bipm/init.rb
229
+ - lib/isodoc/bipm/jcgm.standard.xsl
226
230
  - lib/isodoc/bipm/metadata.rb
227
231
  - lib/isodoc/bipm/pdf_convert.rb
228
232
  - lib/isodoc/bipm/presentation_xml_convert.rb
@@ -252,7 +256,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
252
256
  - !ruby/object:Gem::Version
253
257
  version: '0'
254
258
  requirements: []
255
- rubygems_version: 3.0.3
259
+ rubygems_version: 3.1.4
256
260
  signing_key:
257
261
  specification_version: 4
258
262
  summary: metanorma-bipm lets you write BIPM standards in Metanorma.