metanorma-standoc 1.1.4 → 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,157 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
3
+ <!--
4
+ Presupposes isodoc.rnc, is included in it
5
+ include "isodoc.rnc" { }
6
+ -->
7
+ <define name="requirement">
8
+ <element name="requirement">
9
+ <ref name="RequirementType"/>
10
+ </element>
11
+ </define>
12
+ <define name="recommendation">
13
+ <element name="recommendation">
14
+ <ref name="RequirementType"/>
15
+ </element>
16
+ </define>
17
+ <define name="permission">
18
+ <element name="permission">
19
+ <ref name="RequirementType"/>
20
+ </element>
21
+ </define>
22
+ <define name="RequirementType">
23
+ <optional>
24
+ <attribute name="obligation">
25
+ <ref name="ObligationType"/>
26
+ </attribute>
27
+ </optional>
28
+ <attribute name="id">
29
+ <data type="ID"/>
30
+ </attribute>
31
+ <optional>
32
+ <attribute name="filename"/>
33
+ </optional>
34
+ <optional>
35
+ <ref name="reqtitle"/>
36
+ </optional>
37
+ <optional>
38
+ <ref name="label"/>
39
+ </optional>
40
+ <optional>
41
+ <ref name="subject"/>
42
+ </optional>
43
+ <optional>
44
+ <ref name="reqinherit"/>
45
+ </optional>
46
+ <zeroOrMore>
47
+ <ref name="classification"/>
48
+ </zeroOrMore>
49
+ <zeroOrMore>
50
+ <choice>
51
+ <ref name="measurementtarget"/>
52
+ <ref name="specification"/>
53
+ <ref name="verification"/>
54
+ <ref name="import"/>
55
+ <ref name="description"/>
56
+ </choice>
57
+ </zeroOrMore>
58
+ <optional>
59
+ <ref name="reqt_references"/>
60
+ </optional>
61
+ <zeroOrMore>
62
+ <choice>
63
+ <ref name="requirement"/>
64
+ <ref name="recommendation"/>
65
+ <ref name="permission"/>
66
+ </choice>
67
+ </zeroOrMore>
68
+ </define>
69
+ <define name="reqtitle">
70
+ <element name="title">
71
+ <ref name="FormattedString"/>
72
+ </element>
73
+ </define>
74
+ <define name="label">
75
+ <element name="label">
76
+ <text/>
77
+ </element>
78
+ </define>
79
+ <define name="subject">
80
+ <element name="subject">
81
+ <text/>
82
+ </element>
83
+ </define>
84
+ <define name="reqinherit">
85
+ <element name="subject">
86
+ <text/>
87
+ </element>
88
+ </define>
89
+ <define name="measurementtarget">
90
+ <element name="measurement-target">
91
+ <ref name="RequirementSubpart"/>
92
+ </element>
93
+ </define>
94
+ <define name="specification">
95
+ <element name="specification">
96
+ <ref name="RequirementSubpart"/>
97
+ </element>
98
+ </define>
99
+ <define name="verification">
100
+ <element name="verification">
101
+ <ref name="RequirementSubpart"/>
102
+ </element>
103
+ </define>
104
+ <define name="import">
105
+ <element name="import">
106
+ <ref name="RequirementSubpart"/>
107
+ </element>
108
+ </define>
109
+ <define name="description">
110
+ <element name="description">
111
+ <ref name="RequirementSubpart"/>
112
+ </element>
113
+ </define>
114
+ <define name="reqt_references">
115
+ <element name="references">
116
+ <oneOrMore>
117
+ <ref name="bibitem"/>
118
+ </oneOrMore>
119
+ </element>
120
+ </define>
121
+ <define name="RequirementSubpart">
122
+ <optional>
123
+ <attribute name="type"/>
124
+ </optional>
125
+ <optional>
126
+ <attribute name="exclude">
127
+ <data type="boolean"/>
128
+ </attribute>
129
+ </optional>
130
+ <oneOrMore>
131
+ <ref name="BasicBlock"/>
132
+ </oneOrMore>
133
+ </define>
134
+ <define name="ObligationType">
135
+ <choice>
136
+ <value>requirement</value>
137
+ <value>recommendation</value>
138
+ <value>permission</value>
139
+ </choice>
140
+ </define>
141
+ <define name="classification">
142
+ <element name="classification">
143
+ <ref name="classification_tag"/>
144
+ <ref name="classification_value"/>
145
+ </element>
146
+ </define>
147
+ <define name="classification_tag">
148
+ <element name="tag">
149
+ <text/>
150
+ </element>
151
+ </define>
152
+ <define name="classification_value">
153
+ <element name="value">
154
+ <text/>
155
+ </element>
156
+ </define>
157
+ </grammar>
@@ -116,7 +116,8 @@ module Asciidoctor
116
116
  ::Nokogiri::XML::Builder.with fragment, &block
117
117
  fragment.to_xml(encoding: "US-ASCII").lines.map do |l|
118
118
  #l.gsub(/(?<!\s)\n/, " ")
119
- l.sub(/\n$/, " ")
119
+ #l.sub(/\n$/, " ")
120
+ l.sub(/\s*\n$/, " ")
120
121
  end
121
122
  end
122
123
 
@@ -11,11 +11,19 @@ module Asciidoctor
11
11
 
12
12
  SOURCELOCALITY = "./termsource/origin/locality[@type = 'clause']/referenceFrom".freeze
13
13
 
14
+ def init_iev
15
+ return nil if @no_isobib
16
+ return @iev if @iev
17
+ @iev = Iev::Db.new(@iev_globalname, @iev_localname) unless @no_isobib
18
+ @iev
19
+ end
20
+
14
21
  def iev_validate(xmldoc)
15
22
  xmldoc.xpath("//term").each do |t|
16
23
  /^IEC 60050-/.match(t&.at("./termsource/origin/@citeas")&.text) or next
17
24
  pref = t.xpath("./preferred").inject([]) { |m, x| m << x&.text&.downcase }
18
25
  locality = t.xpath(SOURCELOCALITY)&.text or next
26
+ @iev = init_iev or return
19
27
  iev = @iev.fetch(locality, xmldoc&.at("//language")&.text || "en") or next
20
28
  pref.include?(iev.downcase) or
21
29
  warn %(Term "#{pref[0]}" does not match IEV #{locality} "#{iev}")
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Standoc
3
- VERSION = "1.1.4".freeze
3
+ VERSION = "1.1.5".freeze
4
4
  end
5
5
  end
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
  This gem is in active development.
18
18
  DESCRIPTION
19
19
 
20
- spec.homepage = "https://github.com/riboseinc/metanorma-standoc"
20
+ spec.homepage = "https://github.com/metanorma/metanorma-standoc"
21
21
  spec.license = "BSD-2-Clause"
22
22
 
23
23
  spec.bindir = "bin"
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.add_dependency "asciidoctor", "~> 1.5.7"
30
30
  spec.add_dependency "ruby-jing"
31
31
  spec.add_dependency "isodoc", "~> 0.9.0"
32
- spec.add_dependency "iev", "~> 0.2.0"
32
+ spec.add_dependency "iev", "~> 0.2.1"
33
33
  spec.add_dependency "relaton", "~> 0.3.1"
34
34
  spec.add_dependency "sterile", "~> 1.0.14"
35
35
  spec.add_dependency "concurrent-ruby"
@@ -1,4 +1,5 @@
1
1
  require "spec_helper"
2
+ require "open3"
2
3
 
3
4
  RSpec.describe Asciidoctor::Standoc do
4
5
  it "processes pass blocks" do
@@ -598,6 +599,27 @@ RSpec.describe Asciidoctor::Standoc do
598
599
  OUTPUT
599
600
  end
600
601
 
602
+ it "processes preambles with titles" do
603
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
604
+ #{ASCIIDOC_BLANK_HDR}
605
+ .Preamble
606
+ This is a preamble
607
+
608
+ == Section 1
609
+ INPUT
610
+ #{BLANK_HDR}
611
+ <preface><foreword obligation="informative">
612
+ <title>Preamble</title>
613
+ <p id="_">This is a preamble</p>
614
+ </foreword></preface><sections>
615
+ <clause id="_" inline-header="false" obligation="normative">
616
+ <title>Section 1</title>
617
+ </clause></sections>
618
+ </standard-document>
619
+ OUTPUT
620
+ end
621
+
622
+
601
623
  it "processes images" do
602
624
  expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
603
625
  #{ASCIIDOC_BLANK_HDR}
@@ -616,17 +638,17 @@ RSpec.describe Asciidoctor::Standoc do
616
638
  OUTPUT
617
639
  end
618
640
 
619
- it "accepts width and height attributes on images" do
641
+ it "accepts attributes on images" do
620
642
  expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
621
643
  #{ASCIIDOC_BLANK_HDR}
622
- [height=4,width=3]
644
+ [height=4,width=3,alt="IMAGE",filename="riceimg1.png"]
623
645
  image::spec/examples/rice_images/rice_image1.png[]
624
646
 
625
647
  INPUT
626
648
  #{BLANK_HDR}
627
649
  <sections>
628
650
  <figure id="_">
629
- <image src="spec/examples/rice_images/rice_image1.png" id="_" imagetype="PNG" height="4" width="3"/>
651
+ <image src="spec/examples/rice_images/rice_image1.png" id="_" imagetype="PNG" height="4" width="3" alt="IMAGE" filename="riceimg1.png"/>
630
652
  </figure>
631
653
  </sections>
632
654
  </standard-document>
@@ -718,7 +740,7 @@ RSpec.describe Asciidoctor::Standoc do
718
740
  expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
719
741
  #{ASCIIDOC_BLANK_HDR}
720
742
  .Caption
721
- [source,ruby]
743
+ [source,ruby,filename=sourcecode1.rb]
722
744
  --
723
745
  puts "Hello, world."
724
746
  %w{a b c}.each do |x|
@@ -728,7 +750,7 @@ RSpec.describe Asciidoctor::Standoc do
728
750
  INPUT
729
751
  #{BLANK_HDR}
730
752
  <sections>
731
- <sourcecode id="_" lang="ruby"><name>Caption</name>puts "Hello, world."
753
+ <sourcecode id="_" lang="ruby" filename="sourcecode1.rb"><name>Caption</name>puts "Hello, world."
732
754
  %w{a b c}.each do |x|
733
755
  puts x
734
756
  end</sourcecode>
@@ -924,7 +946,7 @@ RSpec.describe Asciidoctor::Standoc do
924
946
  it "processes recommendation with internal markup of structure" do
925
947
  input = <<~"INPUT"
926
948
  #{ASCIIDOC_BLANK_HDR}
927
- [recommendation,label="/ogc/recommendation/wfs/2",subject="user",classification="control-class:Technical;priority:P0;family:System and Communications Protection,System and Communications Protocols",obligation="permission,recommendation"]
949
+ [recommendation,label="/ogc/recommendation/wfs/2",subject="user",classification="control-class:Technical;priority:P0;family:System and Communications Protection,System and Communications Protocols",obligation="permission,recommendation",filename="reqt1.rq"]
928
950
  ====
929
951
  I recommend _this_.
930
952
 
@@ -973,7 +995,7 @@ RSpec.describe Asciidoctor::Standoc do
973
995
  output = <<~"OUTPUT"
974
996
  #{BLANK_HDR}
975
997
  <sections>
976
- <recommendation id="_" obligation="permission,recommendation"><label>/ogc/recommendation/wfs/2</label><subject>user</subject>
998
+ <recommendation id="_" obligation="permission,recommendation" filename="reqt1.rq"><label>/ogc/recommendation/wfs/2</label><subject>user</subject>
977
999
  <classification><tag>control-class</tag><value>Technical</value></classification><classification><tag>priority</tag><value>P0</value></classification><classification><tag>family</tag><value>System and Communications Protection</value></classification><classification><tag>family</tag><value>System and Communications Protocols</value></classification>
978
1000
  <description><p id="_">I recommend <em>this</em>.</p>
979
1001
  </description><specification exclude="false" type="tabular"><p id="_">This is the object of the recommendation:</p><table id="_"> <tbody> <tr> <td align="left">Object</td> <td align="left">Value</td> </tr> <tr> <td align="left">Mission</td> <td align="left">Accomplished</td> </tr> </tbody></table></specification><description>
@@ -119,7 +119,7 @@ EOS
119
119
  it "flushes biblio caches" do
120
120
  relaton_bib_file = File.expand_path("~/.relaton/cache")
121
121
  relaton_bib_file1 = File.expand_path("~/.relaton-bib.pstore1")
122
- iev_file = File.expand_path("~/.iev.pstore")
122
+ iev_file = File.expand_path("~/.iev/cache")
123
123
  iev_file1 = File.expand_path("~/.iev.pstore1")
124
124
  FileUtils.rm_rf relaton_bib_file1 if File.exist? relaton_bib_file1
125
125
  FileUtils.mv relaton_bib_file, relaton_bib_file1 if File.exist? relaton_bib_file
@@ -127,7 +127,7 @@ EOS
127
127
  FileUtils.mv iev_file, iev_file1 if File.exist? iev_file
128
128
 
129
129
  File.open("#{Dir.home}/.relaton/cache", "w") { |f| f.write "XXX" }
130
- FileUtils.rm_rf File.expand_path("~/.iev.pstore")
130
+ FileUtils.rm_rf File.expand_path("~/.iev/cache")
131
131
 
132
132
  # mock_isobib_get_123
133
133
  VCR.use_cassette "isobib_get_123" do
@@ -140,7 +140,22 @@ EOS
140
140
  INPUT
141
141
  end
142
142
  expect(File.exist?("#{Dir.home}/.relaton/cache")).to be true
143
- expect(File.exist?("#{Dir.home}/.iev.pstore")).to be true
143
+ expect(File.exist?("#{Dir.home}/.iev/cache")).to be false
144
+
145
+ mock_open_uri('103-01-02')
146
+ Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
147
+ [bibliography]
148
+ == Normative References
149
+ * [[[iev,IEV]]], _iev_
150
+
151
+ == Terms and definitions
152
+ === Automation
153
+
154
+ [.source]
155
+ <<iev,clause="103-01-02">>
156
+ INPUT
157
+ expect(File.exist?("#{Dir.home}/.iev/cache")).to be true
158
+
144
159
 
145
160
  db = Relaton::Db.new "#{Dir.home}/.relaton/cache", nil
146
161
  entry = db.load_entry("ISO(ISO 123:2001)")
@@ -148,9 +163,9 @@ EOS
148
163
  expect(entry).to be_equivalent_to(ISO_123_DATED)
149
164
 
150
165
  FileUtils.rm_rf File.expand_path("~/.relaton/cache")
151
- FileUtils.rm_rf File.expand_path("~/.iev.pstore")
166
+ FileUtils.rm_rf File.expand_path("~/.iev/cache")
152
167
  FileUtils.mv File.expand_path("~/.relaton-bib.pstore1"), File.expand_path("~/.relaton/cache"), force: true
153
- FileUtils.mv File.expand_path("~/.iev.pstore1"), File.expand_path("~/.iev.pstore"), force: true
168
+ FileUtils.mv File.expand_path("~/.iev.pstore1"), File.expand_path("~/.iev/cache"), force: true
154
169
  end
155
170
 
156
171
  it "does not fetch references for ISO references in preparation" do
@@ -73,8 +73,8 @@ it "validates document against ISO XML schema" do
73
73
  end
74
74
 
75
75
  it "Warning if terms mismatches IEV" do
76
- FileUtils.mv File.expand_path("~/.iev.pstore"), File.expand_path("~/.iev.pstore1"), force: true
77
- FileUtils.rm_f "test.iev.pstore"
76
+ FileUtils.mv File.expand_path("~/.iev/cache"), File.expand_path("~/.iev.pstore1"), force: true
77
+ FileUtils.rm_f "test_iev/pstore"
78
78
  mock_open_uri('103-01-02')
79
79
  expect { Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true) }.to output(%r{Term "automation" does not match IEV 103-01-02 "functional"}).to_stderr
80
80
  = Document title
@@ -91,12 +91,12 @@ it "Warning if terms mismatches IEV" do
91
91
  [.source]
92
92
  <<iev,clause="103-01-02">>
93
93
  INPUT
94
- FileUtils.mv File.expand_path("~/.iev.pstore1"), File.expand_path("~/.iev.pstore"), force: true
94
+ FileUtils.mv File.expand_path("~/.iev.pstore1"), File.expand_path("~/.iev/cache"), force: true
95
95
  end
96
96
 
97
97
  it "No warning if English term matches IEV" do
98
- FileUtils.mv File.expand_path("~/.iev.pstore"), File.expand_path("~/.iev.pstore1"), force: true
99
- FileUtils.rm_f "test.iev.pstore"
98
+ FileUtils.mv File.expand_path("~/.iev/cache"), File.expand_path("~/.iev.pstore1"), force: true
99
+ FileUtils.rm_f "test_iev/cache"
100
100
  mock_open_uri('103-01-02')
101
101
  expect { Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true) }.not_to output(%r{does not match IEV 103-01-02}).to_stderr
102
102
  = Document title
@@ -113,12 +113,12 @@ it "No warning if English term matches IEV" do
113
113
  [.source]
114
114
  <<iev,clause="103-01-02">>
115
115
  INPUT
116
- FileUtils.mv File.expand_path("~/.iev.pstore1"), File.expand_path("~/.iev.pstore"), force: true
116
+ FileUtils.mv File.expand_path("~/.iev.pstore1"), File.expand_path("~/.iev/cache"), force: true
117
117
  end
118
118
 
119
119
  it "No warning if French term matches IEV" do
120
- FileUtils.mv File.expand_path("~/.iev.pstore"), File.expand_path("~/.iev.pstore1"), force: true
121
- FileUtils.rm_f "test.iev.pstore"
120
+ FileUtils.mv File.expand_path("~/.iev/cache"), File.expand_path("~/.iev.pstore1"), force: true
121
+ FileUtils.rm_f "test_iev/cache"
122
122
  mock_open_uri('103-01-02')
123
123
  expect { Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true) }.not_to output(%r{does not match IEV 103-01-02}).to_stderr
124
124
  = Document title
@@ -137,7 +137,7 @@ it "No warning if French term matches IEV" do
137
137
  [.source]
138
138
  <<iev,clause="103-01-02">>
139
139
  INPUT
140
- FileUtils.mv File.expand_path("~/.iev.pstore1"), File.expand_path("~/.iev.pstore"), force: true
140
+ FileUtils.mv File.expand_path("~/.iev.pstore1"), File.expand_path("~/.iev/cache"), force: true
141
141
  end
142
142
 
143
143
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-standoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-06 00:00:00.000000000 Z
11
+ date: 2019-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.2.0
61
+ version: 0.2.1
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.2.0
68
+ version: 0.2.1
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: relaton
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -362,6 +362,7 @@ files:
362
362
  - lib/asciidoctor/standoc/lists.rb
363
363
  - lib/asciidoctor/standoc/macros.rb
364
364
  - lib/asciidoctor/standoc/ref.rb
365
+ - lib/asciidoctor/standoc/reqt.rng
365
366
  - lib/asciidoctor/standoc/section.rb
366
367
  - lib/asciidoctor/standoc/table.rb
367
368
  - lib/asciidoctor/standoc/utils.rb
@@ -419,7 +420,7 @@ files:
419
420
  - spec/vcr_cassettes/isobib_get_124.yml
420
421
  - spec/vcr_cassettes/rfcbib_get_rfc8341.yml
421
422
  - spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml
422
- homepage: https://github.com/riboseinc/metanorma-standoc
423
+ homepage: https://github.com/metanorma/metanorma-standoc
423
424
  licenses:
424
425
  - BSD-2-Clause
425
426
  metadata: {}