Skip to content

Commit a6c59af

Browse files
committed
validate editorial groups within gem: closes relaton/relaton-iho#2
1 parent c9413ac commit a6c59af

File tree

4 files changed

+39
-5
lines changed

4 files changed

+39
-5
lines changed

lib/asciidoctor/iho/biblio.rng

+10-2
Original file line numberDiff line numberDiff line change
@@ -661,9 +661,9 @@
661661
<optional>
662662
<ref name="status"/>
663663
</optional>
664-
<optional>
664+
<zeroOrMore>
665665
<ref name="copyright"/>
666-
</optional>
666+
</zeroOrMore>
667667
<zeroOrMore>
668668
<ref name="docrelation"/>
669669
</zeroOrMore>
@@ -1024,6 +1024,14 @@
10241024
<oneOrMore>
10251025
<ref name="owner"/>
10261026
</oneOrMore>
1027+
<optional>
1028+
<ref name="copyright_scope"/>
1029+
</optional>
1030+
</element>
1031+
</define>
1032+
<define name="copyright_scope">
1033+
<element name="scope">
1034+
<text/>
10271035
</element>
10281036
</define>
10291037
<define name="from">

lib/asciidoctor/iho/converter.rb

+8-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,14 @@ def metadata_commentperiod(node, xml)
5858
end
5959

6060
def metadata_committee(node, xml)
61-
return unless node.attr("workgroup")
61+
unless node.attr("workgroup")
62+
@log.add("AsciiDoc Input", nil, "Missing workgroup attribute for document")
63+
return
64+
end
65+
metadata_committee1(node, xml)
66+
end
67+
68+
def metadata_committee1(node, xml)
6269
xml.editorialgroup do |a|
6370
a.committee node.attr("committee")
6471
a.workgroup node.attr("workgroup")

lib/asciidoctor/iho/iho.rng

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
<optional>
3232
<ref name="doctype"/>
3333
</optional>
34-
<oneOrMore>
34+
<zeroOrMore>
3535
<ref name="editorialgroup"/>
36-
</oneOrMore>
36+
</zeroOrMore>
3737
<zeroOrMore>
3838
<ref name="ics"/>
3939
</zeroOrMore>

spec/asciidoctor/validate_spec.rb

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
require "spec_helper"
2+
3+
RSpec.describe Asciidoctor::IHO do
4+
5+
it "warns about missing workgroup" do
6+
FileUtils.rm_f "test.err"
7+
Asciidoctor.convert(<<~"INPUT", backend: :iho, header_footer: true)
8+
#{VALIDATING_BLANK_HDR}
9+
10+
== Clause 1
11+
12+
Subclause
13+
INPUT
14+
expect(File.read("test.err")).to include "Missing workgroup attribute for document"
15+
end
16+
17+
18+
end
19+

0 commit comments

Comments
 (0)