metanorma-bipm 2.0.6 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,6 +3,7 @@ require "metanorma-generic"
3
3
  require "metanorma-iso"
4
4
  require_relative "init"
5
5
  require_relative "index"
6
+ require_relative "doccontrol"
6
7
 
7
8
  module IsoDoc
8
9
  module BIPM
@@ -85,99 +86,6 @@ module IsoDoc
85
86
  doccontrol docxml
86
87
  end
87
88
 
88
- def doccontrol(doc)
89
- return unless doc.at(ns("//bibdata/relation[@type = 'supersedes']"))
90
-
91
- clause = <<~DOCCONTROL
92
- <doccontrol>
93
- <title>Document Control</title>
94
- <table unnumbered="true"><tbody>
95
- <tr><th>Authors:</th><td/><td>#{list_authors(doc)}</td></tr>
96
- #{doccontrol_row1(doc)} #{doccontrol_row2(doc)} #{list_drafts(doc)}
97
- </tbody></table></doccontrol>
98
- DOCCONTROL
99
- doc.root << clause
100
- end
101
-
102
- def doccontrol_row1(doc)
103
- return "" if list_draft(doc, 1) == ["", ""] && list_cochairs(doc).empty?
104
-
105
- <<~ROW
106
- <tr>#{list_draft(doc, 1)&.map { |x| "<td>#{x}</td>" }&.join}
107
- <td>#{list_cochairs(doc)}</td></tr>
108
- ROW
109
- end
110
-
111
- def doccontrol_row2(docxml)
112
- list_draft(docxml, 2) == ["", ""] && list_chairs(docxml).empty? and
113
- return ""
114
-
115
- <<~ROW
116
- <tr>#{list_draft(docxml, 2)&.map { |x| "<td>#{x}</td>" }&.join}
117
- <td>#{list_chairs(docxml)}</td></tr>
118
- ROW
119
- end
120
-
121
- def list_drafts(xml)
122
- ret = ""
123
- i = 3
124
- while list_draft(xml, i) != ["", ""]
125
- ret += "<tr>#{list_draft(xml, i).map { |x| "<td>#{x}</td>" }.join} "\
126
- "<td/></tr>"
127
- i += 1
128
- end
129
- ret
130
- end
131
-
132
- def list_draft(xml, idx)
133
- d = xml.at(ns("//bibdata/relation[@type = 'supersedes'][#{idx}]"\
134
- "/bibitem")) or return ["", ""]
135
-
136
- draft = d&.at(ns("./version/draft"))&.text and draft = "Draft #{draft}"
137
- edn = d&.at(ns("./edition"))&.text and edn = "Version #{edn}"
138
- [[draft, edn].join(" "), d&.at(ns("./date"))&.text]
139
- end
140
-
141
- def list_authors(xml)
142
- ret = list_people(
143
- xml, "//bibdata/contributor[xmlns:role/@type = 'author']/person"
144
- )
145
- @i18n.boolean_conj(ret, "and")
146
- end
147
-
148
- COCHAIR = "xmlns:role[contains(text(),'co-chair')]".freeze
149
- CHAIR = "[xmlns:role[contains(text(),'chair')]"\
150
- "[not(contains(text(),'co-chair'))]]".freeze
151
-
152
- def list_cochairs(xml)
153
- ret = list_people(xml, "//bibdata/contributor[#{COCHAIR}]/person")
154
- ret.empty? and return ""
155
- role = xml&.at(ns("//bibdata/contributor[#{COCHAIR}]/role"))&.text
156
- label = ret.size > 1 && role ? "#{role}s" : role
157
- "#{label}: #{@i18n.boolean_conj(ret, 'and')}"
158
- end
159
-
160
- def list_chairs(xml)
161
- ret = list_people(xml, "//bibdata/contributor#{CHAIR}/person")
162
- ret.empty? and return ""
163
- role = xml&.at(ns("//bibdata/contributor#{CHAIR}/role"))&.text
164
- label = ret.size > 1 && role ? "#{role}s" : role
165
- "#{label}: #{@i18n.boolean_conj(ret, 'and')}"
166
- end
167
-
168
- def list_people(xml, xpath)
169
- ret = []
170
- xml.xpath(ns(xpath)).each do |p|
171
- name = p&.at(ns("./name/completename"))&.text
172
- aff = p&.at(ns("./affiliation/organization/abbreviation"))&.text ||
173
- p&.at(ns("./affiliation/organization/name"))&.text
174
- c = name || ""
175
- aff and c += " (#{aff})"
176
- ret << c
177
- end
178
- ret
179
- end
180
-
181
89
  def twitter_cldr_localiser_symbols
182
90
  { group: "&#xA0;", fraction_group: "&#xA0;", fraction_group_digits: 3 }
183
91
  end
@@ -153,8 +153,9 @@ module IsoDoc
153
153
 
154
154
  def annex_names(clause, num)
155
155
  @anchors[clause["id"]] = annex_name_anchors(clause, num)
156
- if a = single_annex_special_section(clause)
157
- annex_names1(a, num.to_s, 1)
156
+ if @klass.single_term_clause?(clause)
157
+ annex_names1(clause.at(ns("./references | ./terms | ./definitions")),
158
+ num.to_s, 1)
158
159
  else
159
160
  i = Counter.new
160
161
  prefix = @jcgm ? "" : "A"
@@ -176,8 +177,9 @@ module IsoDoc
176
177
  def unnumbered_annex_names(clause)
177
178
  lbl = clause&.at(ns("./title"))&.text || "[#{clause['id']}]"
178
179
  @anchors[clause["id"]] = unnumbered_annex_anchors(lbl)
179
- if a = single_annex_special_section(clause)
180
- annex_names1(a, num.to_s, 1)
180
+ if @klass.single_term_clause?(clause)
181
+ annex_names1(clause.at(ns("./references | ./terms | ./definitions")),
182
+ num.to_s, 1)
181
183
  else
182
184
  clause.xpath(ns(SUBCLAUSES))
183
185
  .each { |c| unnumbered_annex_names1(c, 2) }
@@ -229,10 +231,12 @@ module IsoDoc
229
231
 
230
232
  def initial_anchor_names(doc)
231
233
  super
234
+ if @parse_settings.empty? || @parse_settings[:clauses]
232
235
  if @jcgm
233
236
  @iso.introduction_names(doc.at(ns("//introduction")))
234
237
  @anchors.merge!(@iso.get)
235
238
  end
239
+ end
236
240
  end
237
241
 
238
242
  def sequential_figure_names(clause)
@@ -527,7 +527,7 @@
527
527
  </define>
528
528
  <define name="LocalityType">
529
529
  <data type="string">
530
- <param name="pattern">section|clause|part|paragraph|chapter|page|whole|table|annex|figure|note|list|example|volume|issue|time|anchor|locality:[a-zA-Z0-9_]+</param>
530
+ <param name="pattern">section|clause|part|paragraph|chapter|page|title|line|whole|table|annex|figure|note|list|example|volume|issue|time|anchor|locality:[a-zA-Z0-9_]+</param>
531
531
  </data>
532
532
  </define>
533
533
  <define name="referenceFrom">
@@ -677,6 +677,9 @@
677
677
  <zeroOrMore>
678
678
  <ref name="extent"/>
679
679
  </zeroOrMore>
680
+ <optional>
681
+ <ref name="bibliographic_size"/>
682
+ </optional>
680
683
  <zeroOrMore>
681
684
  <ref name="accesslocation"/>
682
685
  </zeroOrMore>
@@ -848,17 +851,46 @@
848
851
  </define>
849
852
  <define name="bplace">
850
853
  <element name="place">
851
- <optional>
852
- <attribute name="uri">
853
- <data type="anyURI"/>
854
- </attribute>
855
- </optional>
856
- <optional>
857
- <attribute name="region"/>
858
- </optional>
854
+ <choice>
855
+ <text/>
856
+ <group>
857
+ <ref name="bibliocity"/>
858
+ <zeroOrMore>
859
+ <ref name="biblioregion"/>
860
+ </zeroOrMore>
861
+ <zeroOrMore>
862
+ <ref name="bibliocountry"/>
863
+ </zeroOrMore>
864
+ </group>
865
+ </choice>
866
+ </element>
867
+ </define>
868
+ <define name="bibliocity">
869
+ <element name="city">
859
870
  <text/>
860
871
  </element>
861
872
  </define>
873
+ <define name="biblioregion">
874
+ <element name="region">
875
+ <ref name="RegionType"/>
876
+ </element>
877
+ </define>
878
+ <define name="bibliocountry">
879
+ <element name="country">
880
+ <ref name="RegionType"/>
881
+ </element>
882
+ </define>
883
+ <define name="RegionType">
884
+ <optional>
885
+ <attribute name="iso"/>
886
+ </optional>
887
+ <optional>
888
+ <attribute name="recommended">
889
+ <data type="boolean"/>
890
+ </attribute>
891
+ </optional>
892
+ <text/>
893
+ </define>
862
894
  <define name="bprice">
863
895
  <element name="price">
864
896
  <attribute name="currency"/>
@@ -922,9 +954,29 @@
922
954
  <text/>
923
955
  </element>
924
956
  </define>
957
+ <define name="sizevalue">
958
+ <element name="value">
959
+ <attribute name="type"/>
960
+ <text/>
961
+ </element>
962
+ </define>
963
+ <define name="bibliographic_size">
964
+ <element name="size">
965
+ <oneOrMore>
966
+ <ref name="sizevalue"/>
967
+ </oneOrMore>
968
+ </element>
969
+ </define>
925
970
  <define name="extent">
926
971
  <element name="extent">
927
- <ref name="BibItemLocality"/>
972
+ <choice>
973
+ <zeroOrMore>
974
+ <ref name="locality"/>
975
+ </zeroOrMore>
976
+ <zeroOrMore>
977
+ <ref name="localityStack"/>
978
+ </zeroOrMore>
979
+ </choice>
928
980
  </element>
929
981
  </define>
930
982
  <define name="series">
@@ -32,6 +32,43 @@
32
32
  <ref name="DocumentType"/>
33
33
  </element>
34
34
  </define>
35
+ <define name="admonition">
36
+ <element name="admonition">
37
+ <attribute name="type">
38
+ <ref name="AdmonitionType"/>
39
+ </attribute>
40
+ <optional>
41
+ <attribute name="class"/>
42
+ </optional>
43
+ <attribute name="id">
44
+ <data type="ID"/>
45
+ </attribute>
46
+ <optional>
47
+ <attribute name="uri">
48
+ <data type="anyURI"/>
49
+ </attribute>
50
+ </optional>
51
+ <optional>
52
+ <attribute name="coverpage">
53
+ <data type="boolean"/>
54
+ </attribute>
55
+ </optional>
56
+ <optional>
57
+ <attribute name="notag">
58
+ <data type="boolean"/>
59
+ </attribute>
60
+ </optional>
61
+ <optional>
62
+ <ref name="tname"/>
63
+ </optional>
64
+ <zeroOrMore>
65
+ <ref name="paragraph-with-footnote"/>
66
+ </zeroOrMore>
67
+ <zeroOrMore>
68
+ <ref name="note"/>
69
+ </zeroOrMore>
70
+ </element>
71
+ </define>
35
72
  <define name="index">
36
73
  <element name="index">
37
74
  <optional>
@@ -851,6 +888,16 @@
851
888
  <ref name="MultilingualRenderingType"/>
852
889
  </attribute>
853
890
  </optional>
891
+ <optional>
892
+ <attribute name="coverpage">
893
+ <data type="boolean"/>
894
+ </attribute>
895
+ </optional>
896
+ <optional>
897
+ <attribute name="notag">
898
+ <data type="boolean"/>
899
+ </attribute>
900
+ </optional>
854
901
  <oneOrMore>
855
902
  <choice>
856
903
  <ref name="paragraph"/>
@@ -1178,6 +1225,7 @@
1178
1225
  <ref name="concept"/>
1179
1226
  <ref name="add"/>
1180
1227
  <ref name="del"/>
1228
+ <ref name="span"/>
1181
1229
  </choice>
1182
1230
  </define>
1183
1231
  <define name="add">
@@ -1204,6 +1252,14 @@
1204
1252
  </choice>
1205
1253
  </element>
1206
1254
  </define>
1255
+ <define name="span">
1256
+ <element name="span">
1257
+ <attribute name="class"/>
1258
+ <oneOrMore>
1259
+ <ref name="TextElement"/>
1260
+ </oneOrMore>
1261
+ </element>
1262
+ </define>
1207
1263
  <define name="concept">
1208
1264
  <element name="concept">
1209
1265
  <optional>
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module BIPM
3
- VERSION = "2.0.6".freeze
3
+ VERSION = "2.1.0".freeze
4
4
  end
5
5
  end
@@ -26,8 +26,8 @@ Gem::Specification.new do |spec|
26
26
  spec.require_paths = ["lib"]
27
27
  spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
28
28
 
29
- spec.add_dependency "metanorma-generic", "~> 2.0.0"
30
- spec.add_dependency "metanorma-iso", "~> 2.0.0"
29
+ spec.add_dependency "metanorma-generic", "~> 2.1.0"
30
+ spec.add_dependency "metanorma-iso", "~> 2.1.0"
31
31
 
32
32
  spec.add_development_dependency "debug"
33
33
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
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: 2.0.6
4
+ version: 2.1.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: 2022-03-23 00:00:00.000000000 Z
11
+ date: 2022-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-generic
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.0.0
19
+ version: 2.1.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: 2.0.0
26
+ version: 2.1.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: metanorma-iso
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 2.0.0
33
+ version: 2.1.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 2.0.0
40
+ version: 2.1.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: debug
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -234,6 +234,7 @@ files:
234
234
  - lib/isodoc/bipm/bipm.guide.xsl
235
235
  - lib/isodoc/bipm/bipm.mise-en-pratique.xsl
236
236
  - lib/isodoc/bipm/bipm.rapport.xsl
237
+ - lib/isodoc/bipm/doccontrol.rb
237
238
  - lib/isodoc/bipm/html/html_bipm_intro.html
238
239
  - lib/isodoc/bipm/html/html_bipm_titlepage.html
239
240
  - lib/isodoc/bipm/html/htmlstyle.css