metanorma-ogc 1.5.4 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +4 -32
  3. data/.gitignore +11 -0
  4. data/Gemfile +0 -1
  5. data/lib/isodoc/ogc/biblio.rb +7 -6
  6. data/lib/isodoc/ogc/html/htmlstyle.css +48 -28
  7. data/lib/isodoc/ogc/html/htmlstyle.scss +18 -11
  8. data/lib/isodoc/ogc/html/wordstyle.css +30 -18
  9. data/lib/isodoc/ogc/html/wordstyle.scss +30 -18
  10. data/lib/isodoc/ogc/html/wordstyle_wp.css +22 -12
  11. data/lib/isodoc/ogc/html/wordstyle_wp.scss +22 -12
  12. data/lib/isodoc/ogc/metadata.rb +1 -0
  13. data/lib/isodoc/ogc/ogc.abstract-specification-topic.xsl +1520 -1369
  14. data/lib/isodoc/ogc/ogc.best-practice.xsl +1520 -1369
  15. data/lib/isodoc/ogc/ogc.change-request-supporting-document.xsl +1520 -1369
  16. data/lib/isodoc/ogc/ogc.community-practice.xsl +1520 -1369
  17. data/lib/isodoc/ogc/ogc.community-standard.xsl +1520 -1369
  18. data/lib/isodoc/ogc/ogc.discussion-paper.xsl +1520 -1369
  19. data/lib/isodoc/ogc/ogc.engineering-report.xsl +1520 -1369
  20. data/lib/isodoc/ogc/ogc.other.xsl +1520 -1369
  21. data/lib/isodoc/ogc/ogc.policy.xsl +1520 -1369
  22. data/lib/isodoc/ogc/ogc.reference-model.xsl +1520 -1369
  23. data/lib/isodoc/ogc/ogc.release-notes.xsl +1520 -1369
  24. data/lib/isodoc/ogc/ogc.standard.xsl +1520 -1369
  25. data/lib/isodoc/ogc/ogc.test-suite.xsl +1520 -1369
  26. data/lib/isodoc/ogc/ogc.user-guide.xsl +1520 -1369
  27. data/lib/isodoc/ogc/ogc.white-paper.xsl +1496 -1349
  28. data/lib/isodoc/ogc/presentation_xml_convert.rb +24 -8
  29. data/lib/isodoc/ogc/reqt.rb +17 -3
  30. data/lib/{asciidoctor → metanorma}/ogc/basicdoc.rng +0 -0
  31. data/lib/{asciidoctor → metanorma}/ogc/biblio.rng +0 -0
  32. data/lib/{asciidoctor → metanorma}/ogc/boilerplate.xml +0 -0
  33. data/lib/{asciidoctor → metanorma}/ogc/cleanup.rb +54 -10
  34. data/lib/{asciidoctor → metanorma}/ogc/converter.rb +13 -3
  35. data/lib/{asciidoctor → metanorma}/ogc/front.rb +2 -2
  36. data/lib/{asciidoctor → metanorma}/ogc/isodoc.rng +35 -2
  37. data/lib/{asciidoctor → metanorma}/ogc/ogc.rng +0 -0
  38. data/lib/{asciidoctor → metanorma}/ogc/reqt.rng +0 -0
  39. data/lib/{asciidoctor → metanorma}/ogc/validate.rb +39 -1
  40. data/lib/metanorma/ogc/version.rb +1 -1
  41. data/lib/metanorma/ogc.rb +1 -0
  42. data/lib/metanorma-ogc.rb +0 -1
  43. data/metanorma-ogc.gemspec +1 -1
  44. metadata +14 -15
  45. data/lib/asciidoctor/ogc.rb +0 -6
@@ -189,22 +189,33 @@ module IsoDoc
189
189
  end
190
190
 
191
191
  def bibdata_i18n(bib)
192
- stage = bib&.at(ns("./status/stage"))
193
192
  doctype = bib&.at(ns("./ext/doctype"))
193
+ rename_stage(bib&.at(ns("./status/stage")), doctype, bib)
194
+ rename_doctype(doctype, bib&.at(ns("./date[@type = 'published']")) ||
195
+ bib&.at(ns("./date[@type = 'issued']")))
196
+ super
197
+ end
198
+
199
+ def rename_stage(stage, doctype, _bib)
194
200
  if stage&.text == "approved" &&
195
201
  !%w(standard abstract-specification-topic
196
202
  community-standard).include?(doctype&.text)
197
203
  stage.children = "published"
198
204
  end
199
- super
200
205
  end
201
206
 
202
- def ol(docxml)
203
- docxml.xpath(ns("//ol")).each do |f|
204
- ol1(f)
207
+ def rename_doctype(doctype, date)
208
+ return unless doctype&.text == "white-paper" && date
209
+
210
+ if Date.iso8601(date.text) >= Date.iso8601("2021-12-16")
211
+ doctype.children = "technical-paper"
205
212
  end
206
213
  end
207
214
 
215
+ def ol(docxml)
216
+ docxml.xpath(ns("//ol")).each { |f| ol1(f) }
217
+ end
218
+
208
219
  def ol1(elem)
209
220
  return unless elem["class"] == "steps"
210
221
 
@@ -214,11 +225,16 @@ module IsoDoc
214
225
  end
215
226
 
216
227
  def termsource1(elem)
217
- mod = elem.at(ns("./modification")) and
218
- termsource_modification(mod)
228
+ while elem&.next_element&.name == "termsource"
229
+ elem << "; #{elem.next_element.remove.children.to_xml}"
230
+ end
219
231
  elem.children = l10n("[<strong>#{@i18n.source}:</strong> "\
220
232
  "#{elem.children.to_xml.strip}]")
221
- elem&.next_element&.name == "termsource" and elem.next = "; "
233
+ end
234
+
235
+ def bibliography_bibitem_number_skip(bibitem)
236
+ @xrefs.klass.implicit_reference(bibitem) ||
237
+ bibitem.at(ns(".//docidentifier[@type = 'metanorma-ordinal']"))
222
238
  end
223
239
 
224
240
  include Init
@@ -33,9 +33,8 @@ module IsoDoc
33
33
 
34
34
  def recommendation_name(node, out)
35
35
  b = out.add_child("<p class='#{recommendation_class(node)}'></p>").first
36
- if name = node&.at(ns("./name"))&.remove
36
+ name = node&.at(ns("./name"))&.remove and
37
37
  name.children.each { |n| b << n }
38
- end
39
38
  if title = node&.at(ns("./title"))&.remove
40
39
  b << l10n(": ") if name
41
40
  title.children.each { |n| b << n }
@@ -64,6 +63,9 @@ module IsoDoc
64
63
  oblig = node["obligation"] and out << ["Obligation", oblig]
65
64
  subj = node&.at(ns("./subject"))&.remove&.children and
66
65
  out << [rec_subj(node), subj]
66
+ %w(general class).include?(node["type_original"]) and
67
+ test = @reqt_links[node["id"]] and
68
+ out << ["Conformance test", "<xref target='#{test}'/>"]
67
69
  node.xpath(ns("./inherit")).each do |i|
68
70
  out << ["Dependency", i.remove.children]
69
71
  end
@@ -75,7 +77,8 @@ module IsoDoc
75
77
  return node unless node.at(ns("./component[@class = 'step']"))
76
78
 
77
79
  d = node.at(ns("./component[@class = 'step']"))
78
- d = d.replace("<ol class='steps'><li>#{d.children.to_xml}</li></ol>").first
80
+ d = d.replace("<ol class='steps'><li>#{d.children.to_xml}</li></ol>")
81
+ .first
79
82
  node.xpath(ns("./component[@class = 'step']")).each do |f|
80
83
  f = f.replace("<li>#{f.children.to_xml}</li>").first
81
84
  d << f
@@ -177,6 +180,7 @@ module IsoDoc
177
180
  end
178
181
 
179
182
  def recommendation_to_table(docxml)
183
+ @reqt_links = reqt_links(docxml)
180
184
  docxml.xpath(ns("//recommendation")).each do |r|
181
185
  recommendation_parse1(r, "recommendation")
182
186
  end
@@ -189,6 +193,16 @@ module IsoDoc
189
193
  requirement_table_cleanup(docxml)
190
194
  end
191
195
 
196
+ def reqt_links(docxml)
197
+ docxml.xpath(ns("//requirement | //recommendation | //permission"))
198
+ .each_with_object({}) do |r, m|
199
+ next unless %w(conformanceclass verification).include?(r["type"])
200
+ next unless subject = r&.at(ns("./subject/xref/@target"))&.text
201
+
202
+ m[subject] = r["id"]
203
+ end
204
+ end
205
+
192
206
  # table nested in table: merge label and caption into a single row
193
207
  def requirement_table_cleanup1(outer, inner)
194
208
  outer.delete("colspan")
File without changes
File without changes
File without changes
@@ -1,4 +1,4 @@
1
- module Asciidoctor
1
+ module Metanorma
2
2
  module Ogc
3
3
  class Converter < Standoc::Converter
4
4
  def sections_cleanup(xml)
@@ -58,6 +58,9 @@ module Asciidoctor
58
58
  super
59
59
  a = xmldoc.at("//bibdata/status/stage")
60
60
  a.text == "published" and a.children = "approved"
61
+ doctype = xmldoc.at("//bibdata/ext/doctype")
62
+ doctype.text == "technical-paper" and
63
+ doctype.children = "white-paper"
61
64
  end
62
65
 
63
66
  def section_names_terms_cleanup(xml)
@@ -171,17 +174,58 @@ module Asciidoctor
171
174
  xmldoc.xpath(REQRECPER).each do |r|
172
175
  next unless r["type"]
173
176
 
174
- r["type"] = case r["type"]
175
- when "requirement", "recommendation", "permission"
176
- "general"
177
- when "requirements_class" then "class"
178
- when "conformance_test" then "verification"
179
- when "conformance_class" then "conformanceclass"
180
- when "abstract_test" then "abstracttest"
181
- else r["type"]
182
- end
177
+ requirement_type1(r)
183
178
  end
184
179
  end
180
+
181
+ def requirement_type1(reqt)
182
+ reqt["type"] = case reqt["type"]
183
+ when "requirement", "recommendation", "permission"
184
+ "general"
185
+ when "requirements_class" then "class"
186
+ when "conformance_test" then "verification"
187
+ when "conformance_class" then "conformanceclass"
188
+ when "abstract_test" then "abstracttest"
189
+ else reqt["type"]
190
+ end
191
+ end
192
+
193
+ def normref_cleanup(xmldoc)
194
+ r1 = xmldoc.at("//references[title[translate(text(), 'R', 'r') = "\
195
+ "'Normative references']]")
196
+ r2 = xmldoc.at("//references[title[text() = 'References']]")
197
+ if r1 && r2
198
+ r2["normative"] = false
199
+ end
200
+ super
201
+ end
202
+
203
+ def obligations_cleanup_inherit(xml)
204
+ xml.xpath("//annex").each do |r|
205
+ r["obligation"] = "informative" unless r["obligation"]
206
+ end
207
+ xml.xpath("//clause[not(ancestor::boilerplate)]").each do |r|
208
+ r["obligation"] = "normative" unless r["obligation"]
209
+ end
210
+ xml.xpath(::Metanorma::Standoc::Utils::SUBCLAUSE_XPATH).each do |r|
211
+ o = r&.at("./ancestor::*/@obligation")&.text and r["obligation"] = o
212
+ end
213
+ end
214
+
215
+ def sections_order_cleanup(xml)
216
+ super
217
+ sort_annexes(xml)
218
+ end
219
+
220
+ def sort_annexes(xml)
221
+ last = xml.at("//annex[last()]") or return
222
+ last.next = "<sentinel/>" and last = last.next_element
223
+ gl = xml.at("//annex[.//term]") and last.previous = gl.remove
224
+ rev = xml.at("//annex[title[normalize-space(.) = 'Revision history']]") ||
225
+ xml.at("//annex[title[normalize-space(.) = 'Revision History']]") and
226
+ last.previous = rev.remove
227
+ last.remove
228
+ end
185
229
  end
186
230
  end
187
231
  end
@@ -1,11 +1,11 @@
1
1
  require "asciidoctor"
2
- require "asciidoctor/standoc/converter"
2
+ require "metanorma/standoc/converter"
3
3
  require "fileutils"
4
4
  require_relative "front"
5
5
  require_relative "validate"
6
6
  require_relative "cleanup"
7
7
 
8
- module Asciidoctor
8
+ module Metanorma
9
9
  module Ogc
10
10
  # A {Converter} implementation that generates RSD output, and a document
11
11
  # schema encapsulation of the document for validation
@@ -31,7 +31,7 @@ module Asciidoctor
31
31
  change-request-supporting-document community-practice
32
32
  community-standard discussion-paper engineering-report
33
33
  reference-model release-notes standard user-guide white-paper
34
- test-suite}.include? d
34
+ technical-paper test-suite}.include? d
35
35
  @warned_doctype or
36
36
  @log.add("Document Attributes", nil,
37
37
  "'#{d}' is not a legal document type: reverting to 'standard'")
@@ -134,6 +134,16 @@ module Asciidoctor
134
134
  super
135
135
  end
136
136
 
137
+ def set_obligation(attrs, node)
138
+ if node.attr("style") == "appendix" && node.level == 1
139
+ attrs[:obligation] = if node.attributes.has_key?("obligation")
140
+ node.attr("obligation")
141
+ else "informative"
142
+ end
143
+ else super
144
+ end
145
+ end
146
+
137
147
  def presentation_xml_converter(node)
138
148
  IsoDoc::Ogc::PresentationXMLConvert.new(html_extract_attributes(node))
139
149
  end
@@ -1,8 +1,8 @@
1
1
  require "asciidoctor"
2
- require "asciidoctor/standoc/converter"
2
+ require "metanorma/standoc/converter"
3
3
  require "fileutils"
4
4
 
5
- module Asciidoctor
5
+ module Metanorma
6
6
  module Ogc
7
7
  class Converter < Standoc::Converter
8
8
  def metadata_author(node, xml)
@@ -32,6 +32,19 @@
32
32
  <ref name="DocumentType"/>
33
33
  </element>
34
34
  </define>
35
+ <define name="bibitem">
36
+ <element name="bibitem">
37
+ <attribute name="id">
38
+ <data type="ID"/>
39
+ </attribute>
40
+ <optional>
41
+ <attribute name="hidden">
42
+ <data type="boolean"/>
43
+ </attribute>
44
+ </optional>
45
+ <ref name="BibliographicItem"/>
46
+ </element>
47
+ </define>
35
48
  <define name="section-title">
36
49
  <element name="title">
37
50
  <zeroOrMore>
@@ -690,6 +703,7 @@
690
703
  <ref name="terms"/>
691
704
  <ref name="term-clause"/>
692
705
  <ref name="definitions"/>
706
+ <ref name="floating-title"/>
693
707
  </choice>
694
708
  </oneOrMore>
695
709
  </element>
@@ -1680,6 +1694,7 @@
1680
1694
  <ref name="clause-subsection"/>
1681
1695
  <ref name="terms"/>
1682
1696
  <ref name="definitions"/>
1697
+ <ref name="floating-title"/>
1683
1698
  </choice>
1684
1699
  </oneOrMore>
1685
1700
  </choice>
@@ -1722,6 +1737,7 @@
1722
1737
  <ref name="terms"/>
1723
1738
  <ref name="definitions"/>
1724
1739
  <ref name="references"/>
1740
+ <ref name="floating-title"/>
1725
1741
  </choice>
1726
1742
  </zeroOrMore>
1727
1743
  </group>
@@ -1973,7 +1989,11 @@
1973
1989
  </optional>
1974
1990
  <element name="name">
1975
1991
  <zeroOrMore>
1976
- <ref name="PureTextElement"/>
1992
+ <choice>
1993
+ <ref name="PureTextElement"/>
1994
+ <ref name="stem"/>
1995
+ <ref name="index"/>
1996
+ </choice>
1977
1997
  </zeroOrMore>
1978
1998
  </element>
1979
1999
  <optional>
@@ -1987,7 +2007,7 @@
1987
2007
  </element>
1988
2008
  </optional>
1989
2009
  <optional>
1990
- <element name="grammar-info">
2010
+ <element name="grammar">
1991
2011
  <ref name="Grammar"/>
1992
2012
  </element>
1993
2013
  </optional>
@@ -2530,4 +2550,17 @@
2530
2550
  </oneOrMore>
2531
2551
  </element>
2532
2552
  </define>
2553
+ <define name="floating-title">
2554
+ <element name="floating-title">
2555
+ <attribute name="id">
2556
+ <data type="ID"/>
2557
+ </attribute>
2558
+ <attribute name="depth">
2559
+ <data type="int"/>
2560
+ </attribute>
2561
+ <zeroOrMore>
2562
+ <ref name="TextElement"/>
2563
+ </zeroOrMore>
2564
+ </element>
2565
+ </define>
2533
2566
  </grammar>
File without changes
File without changes
@@ -1,4 +1,4 @@
1
- module Asciidoctor
1
+ module Metanorma
2
2
  module Ogc
3
3
  class Converter < Standoc::Converter
4
4
  def validate(doc)
@@ -14,6 +14,44 @@ module Asciidoctor
14
14
  def content_validate(doc)
15
15
  super
16
16
  bibdata_validate(doc.root)
17
+ reqt_link_validate(doc.root)
18
+ end
19
+
20
+ def reqt_link_validate(docxml)
21
+ ids = reqt_links(docxml)
22
+ reqt_to_conformance(ids, "general", "verification", "Requirement",
23
+ "Conformance test")
24
+ reqt_to_conformance(ids, "class", "conformanceclass",
25
+ "Requirement class", "Conformance class test")
26
+ conformance_to_reqt(ids, "general", "verification", "Requirement",
27
+ "Conformance test")
28
+ conformance_to_reqt(ids, "class", "conformanceclass",
29
+ "Requirement class", "Conformance class test")
30
+ end
31
+
32
+ def reqt_to_conformance(ids, reqtclass, confclass, reqtlabel, conflabel)
33
+ ids[reqtclass]&.each do |r|
34
+ ids[confclass]&.any? { |x| x[:subject] == r[:id] } or
35
+ @log.add("Requirements", r[:elem],
36
+ "#{reqtlabel} #{r[:id]} has no corresponding #{conflabel}")
37
+ end
38
+ end
39
+
40
+ def conformance_to_reqt(ids, reqtclass, confclass, reqtlabel, conflabel)
41
+ ids[confclass]&.each do |x|
42
+ ids[reqtclass]&.any? { |r| x[:subject] == r[:id] } or
43
+ @log.add("Requirements", x[:elem],
44
+ "#{conflabel} #{x[:id]} has no corresponding #{reqtlabel}")
45
+ end
46
+ end
47
+
48
+ def reqt_links(docxml)
49
+ docxml.xpath("//requirement | //recommendation | //permission")
50
+ .each_with_object({}) do |r, m|
51
+ m[r["type"]] ||= []
52
+ m[r["type"]] << { id: r["id"], elem: r,
53
+ subject: r&.at("./subject/xref/@target")&.text }
54
+ end
17
55
  end
18
56
 
19
57
  def bibdata_validate(doc)
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Ogc
3
- VERSION = "1.5.4".freeze
3
+ VERSION = "2.0.1".freeze
4
4
  end
5
5
  end
data/lib/metanorma/ogc.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "metanorma/ogc/version"
2
2
  require "metanorma/ogc/processor"
3
+ require "metanorma/ogc/converter"
3
4
 
4
5
  module Metanorma
5
6
  module Ogc
data/lib/metanorma-ogc.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  require "metanorma/ogc"
2
2
  require "asciidoctor"
3
- require "asciidoctor/ogc"
4
3
  require "isodoc/ogc"
5
4
 
6
5
  if defined? Metanorma
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
26
26
 
27
27
  spec.add_dependency "iso-639"
28
- spec.add_dependency "metanorma-standoc", "~> 1.11.0"
28
+ spec.add_dependency "metanorma-standoc", "~> 2.0.0"
29
29
 
30
30
  spec.add_development_dependency "debug"
31
31
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-ogc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.4
4
+ version: 2.0.1
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-12-13 00:00:00.000000000 Z
11
+ date: 2022-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: iso-639
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.11.0
33
+ version: 2.0.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: 1.11.0
40
+ version: 2.0.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: debug
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -199,17 +199,6 @@ files:
199
199
  - bin/console
200
200
  - bin/rspec
201
201
  - bin/setup
202
- - lib/asciidoctor/ogc.rb
203
- - lib/asciidoctor/ogc/basicdoc.rng
204
- - lib/asciidoctor/ogc/biblio.rng
205
- - lib/asciidoctor/ogc/boilerplate.xml
206
- - lib/asciidoctor/ogc/cleanup.rb
207
- - lib/asciidoctor/ogc/converter.rb
208
- - lib/asciidoctor/ogc/front.rb
209
- - lib/asciidoctor/ogc/isodoc.rng
210
- - lib/asciidoctor/ogc/ogc.rng
211
- - lib/asciidoctor/ogc/reqt.rng
212
- - lib/asciidoctor/ogc/validate.rb
213
202
  - lib/isodoc/ogc.rb
214
203
  - lib/isodoc/ogc/base_convert.rb
215
204
  - lib/isodoc/ogc/biblio.rb
@@ -264,7 +253,17 @@ files:
264
253
  - lib/isodoc/ogc/xref.rb
265
254
  - lib/metanorma-ogc.rb
266
255
  - lib/metanorma/ogc.rb
256
+ - lib/metanorma/ogc/basicdoc.rng
257
+ - lib/metanorma/ogc/biblio.rng
258
+ - lib/metanorma/ogc/boilerplate.xml
259
+ - lib/metanorma/ogc/cleanup.rb
260
+ - lib/metanorma/ogc/converter.rb
261
+ - lib/metanorma/ogc/front.rb
262
+ - lib/metanorma/ogc/isodoc.rng
263
+ - lib/metanorma/ogc/ogc.rng
267
264
  - lib/metanorma/ogc/processor.rb
265
+ - lib/metanorma/ogc/reqt.rng
266
+ - lib/metanorma/ogc/validate.rb
268
267
  - lib/metanorma/ogc/version.rb
269
268
  - metanorma-ogc.gemspec
270
269
  homepage: https://github.com/metanorma/metanorma-ogc
@@ -1,6 +0,0 @@
1
- require "asciidoctor/ogc/converter"
2
-
3
- module Asciidoctor
4
- module Ogc
5
- end
6
- end