metanorma-ieee 0.0.2 → 0.0.5

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.
@@ -1,5 +1,5 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <grammar ns="https://www.metanorma.org/ns/ieee" xmlns="http://relaxng.org/ns/structure/1.0">
2
+ <grammar ns="https://www.metanorma.org/ns/ieee" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
3
3
  <!--
4
4
  Currently we inherit from a namespaced grammar, isostandard. Until we inherit from isodoc,
5
5
  we cannot have a new default namespace: we will end up with a grammar with two different
@@ -14,20 +14,43 @@
14
14
  <value>guide</value>
15
15
  <value>recommended-practice</value>
16
16
  <value>standard</value>
17
+ <value>whitepaper</value>
18
+ <value>redline</value>
19
+ <value>other</value>
17
20
  </choice>
18
21
  </define>
22
+ <define name="stage">
23
+ <element name="stage">
24
+ <choice>
25
+ <value>draft</value>
26
+ <value>approved</value>
27
+ <value>superseded</value>
28
+ <value>withdrawn</value>
29
+ </choice>
30
+ </element>
31
+ </define>
19
32
  <define name="editorialgroup">
20
33
  <element name="editorialgroup">
21
- <ref name="society"/>
22
- <ref name="balloting-group"/>
23
- <ref name="working-group"/>
34
+ <optional>
35
+ <ref name="society"/>
36
+ </optional>
37
+ <optional>
38
+ <ref name="balloting-group"/>
39
+ </optional>
40
+ <optional>
41
+ <ref name="working-group"/>
42
+ </optional>
24
43
  <oneOrMore>
25
44
  <ref name="committee"/>
26
45
  </oneOrMore>
27
46
  </element>
28
47
  </define>
29
48
  <define name="DocumentSubtype">
30
- <value>trial-use</value>
49
+ <choice>
50
+ <value>amendment</value>
51
+ <value>corrigendum</value>
52
+ <value>erratum</value>
53
+ </choice>
31
54
  </define>
32
55
  <define name="BibDataExtensionType">
33
56
  <optional>
@@ -36,14 +59,82 @@
36
59
  <optional>
37
60
  <ref name="docsubtype"/>
38
61
  </optional>
39
- <ref name="editorialgroup"/>
62
+ <optional>
63
+ <ref name="trialuse"/>
64
+ </optional>
65
+ <optional>
66
+ <ref name="editorialgroup"/>
67
+ </optional>
40
68
  <zeroOrMore>
41
69
  <ref name="ics"/>
42
70
  </zeroOrMore>
71
+ <optional>
72
+ <ref name="standard_status"/>
73
+ </optional>
74
+ <optional>
75
+ <ref name="standard_modified"/>
76
+ </optional>
77
+ <optional>
78
+ <ref name="pubstatus"/>
79
+ </optional>
80
+ <optional>
81
+ <ref name="holdstatus"/>
82
+ </optional>
43
83
  </define>
44
84
  </include>
85
+ <define name="standard_status">
86
+ <element name="standard_status">
87
+ <choice>
88
+ <value>Inactive</value>
89
+ <value>Active</value>
90
+ <value>Superseded</value>
91
+ </choice>
92
+ </element>
93
+ </define>
94
+ <define name="standard_modified">
95
+ <element name="standard_modified">
96
+ <choice>
97
+ <value>Draft</value>
98
+ <value>Withdrawn</value>
99
+ <value>Superseded</value>
100
+ <value>Approved</value>
101
+ <value>Reserved</value>
102
+ <value>Redline</value>
103
+ </choice>
104
+ </element>
105
+ </define>
106
+ <define name="pubstatus">
107
+ <element name="pubstatus">
108
+ <choice>
109
+ <value>Active</value>
110
+ <value>Inactive</value>
111
+ </choice>
112
+ </element>
113
+ </define>
114
+ <define name="holdstatus">
115
+ <element name="holdstatus">
116
+ <choice>
117
+ <value>Hold</value>
118
+ <value>Publish</value>
119
+ </choice>
120
+ </element>
121
+ </define>
122
+ <define name="BibliographicDateType" combine="choice">
123
+ <value>feedback-ended</value>
124
+ </define>
125
+ <define name="trialuse">
126
+ <element name="trial-use">
127
+ <data type="boolean"/>
128
+ </element>
129
+ </define>
45
130
  <define name="balloting-group">
46
131
  <element name="balloting-group">
132
+ <attribute name="type">
133
+ <choice>
134
+ <value>individual</value>
135
+ <value>entity</value>
136
+ </choice>
137
+ </attribute>
47
138
  <text/>
48
139
  </element>
49
140
  </define>
@@ -1285,7 +1285,12 @@
1285
1285
  </define>
1286
1286
  <define name="span">
1287
1287
  <element name="span">
1288
- <attribute name="class"/>
1288
+ <optional>
1289
+ <attribute name="class"/>
1290
+ </optional>
1291
+ <optional>
1292
+ <attribute name="style"/>
1293
+ </optional>
1289
1294
  <oneOrMore>
1290
1295
  <ref name="TextElement"/>
1291
1296
  </oneOrMore>
@@ -2504,6 +2509,16 @@
2504
2509
  <text/>
2505
2510
  </element>
2506
2511
  </optional>
2512
+ <optional>
2513
+ <element name="amendment">
2514
+ <text/>
2515
+ </element>
2516
+ </optional>
2517
+ <optional>
2518
+ <element name="corrigendum">
2519
+ <text/>
2520
+ </element>
2521
+ </optional>
2507
2522
  <optional>
2508
2523
  <element name="language">
2509
2524
  <text/>
@@ -108,7 +108,7 @@
108
108
  </element>
109
109
  </define>
110
110
  <define name="label">
111
- <element name="label">
111
+ <element name="identifier">
112
112
  <oneOrMore>
113
113
  <ref name="TextElement"/>
114
114
  </oneOrMore>
@@ -0,0 +1,11 @@
1
+ module Metanorma
2
+ module IEEE
3
+ class TermLookupCleanup < Metanorma::Standoc::TermLookupCleanup
4
+ def remove_missing_ref_term(node, _target)
5
+ node.at("../xrefrender")&.remove
6
+ node.replace("<preferred><expression><name>#{node.children.to_xml}"\
7
+ "</name></expression></preferred>")
8
+ end
9
+ end
10
+ end
11
+ end
@@ -19,71 +19,31 @@ module Metanorma
19
19
  list_validate(doc)
20
20
  table_style(doc)
21
21
  figure_validate(doc)
22
+ amend_validate(doc)
22
23
  end
23
24
 
24
25
  def bibdata_validate(doc)
25
26
  doctype_validate(doc)
26
- # stage_validate(doc)
27
- # substage_validate(doc)
27
+ stage_validate(doc)
28
28
  end
29
29
 
30
30
  def doctype_validate(xmldoc)
31
31
  doctype = xmldoc&.at("//bibdata/ext/doctype")&.text
32
- %w(standard recommended-practice guide
33
- amendment technical-corrigendum).include? doctype or
32
+ %w(standard recommended-practice guide whitepaper redline other)
33
+ .include? doctype or
34
34
  @log.add("Document Attributes", nil,
35
35
  "#{doctype} is not a recognised document type")
36
+ docsubtype = xmldoc&.at("//bibdata/ext/subdoctype")&.text or return
37
+ %w(amendment corrigendum erratum document).include? docsubtype or
38
+ @log.add("Document Attributes", nil,
39
+ "#{docsubtype} is not a recognised document subtype")
36
40
  end
37
41
 
38
- def title_validate(xml)
39
- title_validate_type(xml)
40
- title_validate_capitalisation(xml)
41
- end
42
-
43
- # Style Manual 11.3
44
- def title_validate_type(xml)
45
- title = xml.at("//bibdata/title") or return
46
- draft = xml.at("//bibdata//draft")
47
- type = xml.at("//bibdata/ext/doctype")
48
- subtype = xml.at("//bibdata/ext/subdoctype")
49
- target = draft ? "Draft " : ""
50
- target += subtype ? "#{strict_capitalize_phrase(subtype.text)} " : ""
51
- target += type ? "#{strict_capitalize_phrase(type.text)} " : ""
52
- /^#{target}/.match?(title.text) or
53
- @log.add("Style", title,
54
- "Expected title to start as: #{target}")
55
- end
56
-
57
- def strict_capitalize_phrase(str)
58
- ret = str.split(/[ -]/).map do |w|
59
- letters = w.chars
60
- letters.first.upcase! unless /^[ -]/.match?(w)
61
- letters.join
62
- end.join(" ")
63
- ret = "Trial-Use" if ret == "Trial Use"
64
- ret
65
- end
66
-
67
- # Style Manual 11.3
68
- def title_validate_capitalisation(xml)
69
- title = xml.at("//bibdata/title") or return
70
- found = false
71
- title.text.split(/[ -]/).each do |w|
72
- /^[[:upper:]]/.match?(w) or preposition?(w) or
73
- found = true
74
- end
75
- found and @log.add("Style", title,
76
- "Title contains uncapitalised word other than preposition")
77
- end
78
-
79
- def preposition?(word)
80
- %w(aboard about above across after against along amid among anti around
81
- as at before behind below beneath beside besides between beyond but
82
- by concerning considering despite down during except excepting
83
- excluding following for from in inside into like minus near of off
84
- on onto opposite outside over past per plus regarding round save
85
- since than through to toward towards under underneath unlike until
86
- up upon versus via with within without a an the).include?(word)
42
+ def stage_validate(xmldoc)
43
+ stage = xmldoc&.at("//bibdata/status/stage")&.text
44
+ %w(draft approved superseded withdrawn).include? stage or
45
+ @log.add("Document Attributes", nil,
46
+ "#{stage} is not a recognised stage")
87
47
  end
88
48
 
89
49
  def locality_validate(root)
@@ -237,6 +197,51 @@ module Metanorma
237
197
  "More than one image in the table cell")
238
198
  end
239
199
  end
200
+
201
+ # Style manual 20.2.2
202
+ def amend_validate(xmldoc)
203
+ xmldoc.xpath("//amend").each do |a|
204
+ desc = a.at("./description")
205
+ if desc && !desc.text.strip.empty?
206
+ amend_validate1(a, desc.text.strip,
207
+ a.at("./newcontent//figure | "\
208
+ "./newcontent//formula"))
209
+ else @log.add("Style", a,
210
+ "Editorial instruction is missing from change")
211
+ end
212
+ end
213
+ end
214
+
215
+ def amend_validate1(amend, description, figure_or_formula)
216
+ case amend["change"]
217
+ when "add" then /^Insert /.match?(description) or
218
+ @log.add("Style", amend,
219
+ "'Add' change description should start with _Insert_")
220
+ when "delete" then /^Insert /.match?(description) or
221
+ @log.add("Style", amend,
222
+ "'Delete' change description should start with _Delete_")
223
+ when "modify"
224
+ amend_validate_modify(amend, description, figure_or_formula)
225
+ end
226
+ end
227
+
228
+ AMD_VALID_MOD = [
229
+ "'Modify' change description should start with _Change_ or _Replace_",
230
+ "'Modify' change description for change involving figure or equation "\
231
+ "should start with _Replace_",
232
+ "'Modify' change description for change not involving figure or "\
233
+ "equation should start with _Change_",
234
+ ].freeze
235
+
236
+ def amend_validate_modify(amend, description, figure_or_formula)
237
+ if !/^Change |^Replace/.match?(description)
238
+ @log.add("Style", amend, AMD_VALID_MOD[0])
239
+ elsif /^Change /.match?(description)
240
+ !figure_or_formula or @log.add("Style", amend, AMD_VALID_MOD[1])
241
+ else
242
+ figure_or_formula or @log.add("Style", amend, AMD_VALID_MOD[2])
243
+ end
244
+ end
240
245
  end
241
246
  end
242
247
  end
@@ -106,6 +106,59 @@ module Metanorma
106
106
  end
107
107
  end
108
108
  ret.map { |x| x.is_a?(Array) ? x : [] }
109
+ end
110
+
111
+ def title_validate(xml)
112
+ title_validate_type(xml)
113
+ title_validate_capitalisation(xml)
114
+ end
115
+
116
+ # Style Manual 11.3
117
+ def title_validate_type(xml)
118
+ title = xml.at("//bibdata/title") or return
119
+ draft = xml.at("//bibdata//draft")
120
+ type = xml.at("//bibdata/ext/doctype")
121
+ subtype = xml.at("//bibdata/ext/subdoctype")
122
+ subtype = "" if subtype == "document"
123
+ trial = xml.at("//bibdata/ext/trial-use[text() = 'true']")
124
+ target = draft ? "Draft " : ""
125
+ target += trial ? "Trial-Use " : ""
126
+ target += type ? "#{strict_capitalize_phrase(type.text)} " : ""
127
+ /^#{target}/.match?(title.text) or
128
+ @log.add("Style", title,
129
+ "Expected title to start as: #{target}")
130
+ end
131
+
132
+ def strict_capitalize_phrase(str)
133
+ ret = str.split(/[ -]/).map do |w|
134
+ letters = w.chars
135
+ letters.first.upcase! unless /^[ -]/.match?(w)
136
+ letters.join
137
+ end.join(" ")
138
+ ret = "Trial-Use" if ret == "Trial Use"
139
+ ret
140
+ end
141
+
142
+ # Style Manual 11.3
143
+ def title_validate_capitalisation(xml)
144
+ title = xml.at("//bibdata/title") or return
145
+ found = false
146
+ title.text.split(/[ -]/).each do |w|
147
+ /^[[:upper:]]/.match?(w) or preposition?(w) or
148
+ found = true
149
+ end
150
+ found and @log.add("Style", title,
151
+ "Title contains uncapitalised word other than preposition")
152
+ end
153
+
154
+ def preposition?(word)
155
+ %w(aboard about above across after against along amid among anti around
156
+ as at before behind below beneath beside besides between beyond but
157
+ by concerning considering despite down during except excepting
158
+ excluding following for from in inside into like minus near of off
159
+ on onto opposite outside over past per plus regarding round save
160
+ since than through to toward towards under underneath unlike until
161
+ up upon versus via with within without a an the).include?(word)
109
162
  end
110
163
  end
111
164
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module IEEE
3
- VERSION = "0.0.2".freeze
3
+ VERSION = "0.0.5".freeze
4
4
  end
5
5
  end
@@ -1,5 +1,5 @@
1
1
  nametemplate:
2
- one: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0] }} ,_{{initials[0] | join: '. '}}.{% endif %}"
2
+ one: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0] }} ,_{{initials[0] | join: '. '}} {% endif %}"
3
3
  two: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0] }} ,_{{initials[0] | join: '. '}}.{% endif %} , {{ labels['and'] }} {% if nonpersonal[1] %}{{ nonpersonal[1] }}{% else %}{{initials[1] | join: '. '}}. {{surname[1] }}{% endif %}"
4
4
  more: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0] }} ,_{{initials[0] | join: '. '}}.{% endif %} , {% if nonpersonal[1] %}{{ nonpersonal[1] }}{% else %}{{initials[1] | join: '. '}}. {{surname[1] }}{% endif %} , {{ labels['and'] }} {% if nonpersonal[2] %}{{ nonpersonal[2] }}{% else %}{{initials[2] | join: '. '}}. {{surname[2] }}{% endif %}"
5
5
  extenttemplate:
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.require_paths = ["lib"]
25
25
  spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
26
26
 
27
- spec.add_dependency "metanorma-standoc", "~> 2.1.0"
27
+ spec.add_dependency "metanorma-standoc", "~> 2.2.0"
28
28
 
29
29
  spec.add_development_dependency "debug"
30
30
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-ieee
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.5
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-07-04 00:00:00.000000000 Z
11
+ date: 2022-08-23 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: 2.1.0
19
+ version: 2.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: 2.1.0
26
+ version: 2.2.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: debug
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -217,6 +217,7 @@ files:
217
217
  - lib/isodoc/ieee.rb
218
218
  - lib/isodoc/ieee/base_convert.rb
219
219
  - lib/isodoc/ieee/html/header.html
220
+ - lib/isodoc/ieee/html/header_amd.html
220
221
  - lib/isodoc/ieee/html/html_ieee_intro.html
221
222
  - lib/isodoc/ieee/html/html_ieee_titlepage.html
222
223
  - lib/isodoc/ieee/html/htmlstyle.css
@@ -237,6 +238,7 @@ files:
237
238
  - lib/isodoc/ieee/init.rb
238
239
  - lib/isodoc/ieee/metadata.rb
239
240
  - lib/isodoc/ieee/pdf_convert.rb
241
+ - lib/isodoc/ieee/presentation_ref.rb
240
242
  - lib/isodoc/ieee/presentation_terms.rb
241
243
  - lib/isodoc/ieee/presentation_xml_convert.rb
242
244
  - lib/isodoc/ieee/word_authority.rb
@@ -257,6 +259,7 @@ files:
257
259
  - lib/metanorma/ieee/isodoc.rng
258
260
  - lib/metanorma/ieee/processor.rb
259
261
  - lib/metanorma/ieee/reqt.rng
262
+ - lib/metanorma/ieee/term_lookup_cleanup.rb
260
263
  - lib/metanorma/ieee/validate.rb
261
264
  - lib/metanorma/ieee/validate_section.rb
262
265
  - lib/metanorma/ieee/validate_style.rb