Skip to content

Commit

Permalink
Merge pull request #303 from metanorma/fix/doctype-attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
opoudjis authored Sep 11, 2023
2 parents 6fe6729 + 7b0a6d4 commit 2f8c0b5
Show file tree
Hide file tree
Showing 10 changed files with 154 additions and 63 deletions.
4 changes: 4 additions & 0 deletions Gemfile.devel
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
gem "metanorma-standoc", git: "https://github.com/metanorma/metanorma-standoc", branch: "fix/doctype-attribute"
gem "metanorma-iso", git: "https://github.com/metanorma/metanorma-iso", branch: "fix/doctype-attribute"
gem "isodoc", git: "https://github.com/metanorma/isodoc", branch: "main"

3 changes: 1 addition & 2 deletions lib/isodoc/ieee/word_convert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ def initialize(options)
end

def convert1(docxml, filename, dir)
doctype = docxml.at(ns("//bibdata/ext/doctype"))
if %w(amendment corrigendum).include?(doctype&.text)
if %w(amendment corrigendum).include?(@doctype)
@header = html_doc_path("header_amd.html")
end
super
Expand Down
7 changes: 3 additions & 4 deletions lib/metanorma/ieee/validate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ def bibdata_validate(doc)
end

def doctype_validate(xmldoc)
doctype = xmldoc&.at("//bibdata/ext/doctype")&.text
%w(standard recommended-practice guide whitepaper redline other)
.include? doctype or
.include?(@doctype) or
@log.add("Document Attributes", nil,
"#{doctype} is not a recognised document type")
docsubtype = xmldoc&.at("//bibdata/ext/subdoctype")&.text or return
"#{@doctype} is not a recognised document type")
docsubtype = xmldoc.at("//bibdata/ext/subdoctype")&.text or return
%w(amendment corrigendum erratum document).include? docsubtype or
@log.add("Document Attributes", nil,
"#{docsubtype} is not a recognised document subtype")
Expand Down
3 changes: 1 addition & 2 deletions lib/metanorma/ieee/validate_section.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ module Metanorma
module IEEE
class Converter < Standoc::Converter
def section_validate(doc)
doctype = doc&.at("//bibdata/ext/doctype")&.text
unless %w(amendment technical-corrigendum).include? doctype
unless %w(amendment technical-corrigendum).include? @doctype
sections_presence_validate(doc.root)
sections_sequence_validate(doc.root)
end
Expand Down
3 changes: 1 addition & 2 deletions lib/metanorma/ieee/validate_style.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,10 @@ def title_validate(xml)
def title_validate_type(xml)
title = xml.at("//bibdata/title") or return
draft = xml.at("//bibdata//draft")
type = xml.at("//bibdata/ext/doctype")
trial = xml.at("//bibdata/ext/trial-use[text() = 'true']")
target = draft ? "Draft " : ""
target += trial ? "Trial-Use " : ""
target += type ? "#{strict_capitalize_phrase(type.text)} " : ""
target += @doctype ? "#{strict_capitalize_phrase(@doctype)} " : ""
/^#{target}/.match?(title.text) or
@log.add("Style", title,
"Expected title to start as: #{target}")
Expand Down
2 changes: 1 addition & 1 deletion spec/isodoc/inline_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@
</m:msup>
</m:math>
<latexmath>( x + y )^{2}</latexmath>
<asciimath>( x + y )^(2)</asciimath>
<asciimath>(x + y)^(2)</asciimath>
</stem>
</p>
</foreword>
Expand Down
8 changes: 4 additions & 4 deletions spec/metanorma/refs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,13 @@
<docidentifier type="IETF" primary="true">RFC7991</docidentifier>
</bibitem>
</relation>
<series type="stream">
<title format="text/plain">IAB</title>
</series>
<series>
<title format="text/plain">RFC</title>
<number>7749</number>
</series>
<series type="stream">
<title format="text/plain">IAB</title>
</series>
<keyword>XML</keyword>
<keyword>IETF</keyword>
<keyword>RFC</keyword>
Expand Down Expand Up @@ -299,7 +299,7 @@
<docidentifier type="ISO" primary="true">ISO 639-5:2008</docidentifier>
</bibitem>
</relation>
<relation type="instance">
<relation type="instanceOf">
<bibitem type="standard">
<title type="title-main" format="text/plain" language="en" script="Latn">Code for individual languages and language groups</title>
<title type="main" format="text/plain" language="en" script="Latn">Code for individual languages and language groups</title>
Expand Down
53 changes: 28 additions & 25 deletions spec/relaton/render_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -318,31 +318,34 @@
end

it "renders software" do
input = <<~INPUT
<bibitem type="software">
<title>metanorma-standoc</title>
<uri>https://github.com/metanorma/metanorma-standoc</uri>
<date type="published"><on>2019-09-04</on></date>
<contributor>
<role type="author"/>
<organization>
<name>Ribose Inc.</name>
</organization>
</contributor>
<contributor>
<role type="distributor"/>
<organization>
<name>GitHub</name>
</organization>
</contributor>
<edition>1.3.1</edition>
</bibitem>
INPUT
output = <<~OUTPUT
<formattedref>Ribose Inc., “metanorma-standoc.” 2019, <link target='https://github.com/metanorma/metanorma-standoc'>https://github.com/metanorma/metanorma-standoc</link>.</formattedref>
OUTPUT
expect(renderer.render(input))
.to be_equivalent_to output
VCR.use_cassette "standoc" do
input = <<~INPUT
<bibitem type="software">
<title>metanorma-standoc</title>
<uri>https://github.com/metanorma/metanorma-standoc</uri>
<date type="published"><on>2019-09-04</on></date>
<date type="accessed"><on>2023-09-06</on></date>
<contributor>
<role type="author"/>
<organization>
<name>Ribose Inc.</name>
</organization>
</contributor>
<contributor>
<role type="distributor"/>
<organization>
<name>GitHub</name>
</organization>
</contributor>
<edition>1.3.1</edition>
</bibitem>
INPUT
output = <<~OUTPUT
<formattedref>Ribose Inc., “metanorma-standoc.” 2019, accessed September 6, 2023, <link target='https://github.com/metanorma/metanorma-standoc'>https://github.com/metanorma/metanorma-standoc</link>.</formattedref>
OUTPUT
expect(renderer.render(input))
.to be_equivalent_to output
end
end

it "renders home standard" do
Expand Down
46 changes: 23 additions & 23 deletions spec/vcr_cassettes/multistandard1.yml

Large diffs are not rendered by default.

88 changes: 88 additions & 0 deletions spec/vcr_cassettes/standoc.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2f8c0b5

Please sign in to comment.