Skip to content

Commit

Permalink
committee-document doctype: #1093
Browse files Browse the repository at this point in the history
  • Loading branch information
opoudjis committed Feb 12, 2024
1 parent 1077f06 commit 200f799
Show file tree
Hide file tree
Showing 8 changed files with 199 additions and 120 deletions.
1 change: 1 addition & 0 deletions lib/isodoc/iso/i18n-de.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ doctype_dict:
amendment: Änderung
technical-corrigendum: Technische Berichtigung
directive: Richtlinie
committee-document: Ausschussdokument
stage_dict:
"00": Vorläufiges Arbeitselement
"10": Neuer Arbeitselementvorschlag
Expand Down
1 change: 1 addition & 0 deletions lib/isodoc/iso/i18n-en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ doctype_dict:
amendment: Amendment
technical-corrigendum: Technical Corrigendum
directive: Directive
committee document: Committee Document
stage_dict:
"00": Preliminary work item
"10": New work item proposal
Expand Down
1 change: 1 addition & 0 deletions lib/isodoc/iso/i18n-fr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ doctype_dict:
amendment: Amendement
technical-corrigendum: Rectificatif technique
directive: Directive
committee-document: Document du comité
stage_dict:
"00": Élément de travail préliminaire
"10": Nouvelle proposition d'élément de travail
Expand Down
1 change: 1 addition & 0 deletions lib/isodoc/iso/i18n-ru.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ doctype_dict:
amendment: Поправка
technical-corrigendum: Техническое Исправление
directive: Директива
committee-document: Документ комитета
stage_dict:
"00": Предварительный рабочий элемент
"10": Предложение нового рабочего элемента
Expand Down
1 change: 1 addition & 0 deletions lib/isodoc/iso/i18n-zh-Hans.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ doctype_dict:
amendment: 修正
technical-corrigendum: 技术勘误
directive: 指令
committee-document: 委员会文件
stage_dict:
"00": 初步工作项
"10": 新工作项提案
Expand Down
37 changes: 25 additions & 12 deletions lib/metanorma/iso/front_id.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
require "date"
require "nokogiri"
require "htmlentities"
require "json"
require "pathname"
require "open-uri"
require "twitter_cldr"
require "pubid-iso"
require "pubid-cen"
Expand All @@ -23,18 +19,18 @@ def metadata_id(node, xml)
xml.docnumber node.attr("docnumber")
end

DOCTYPE2HASHID =
{ directive: :dir, "technical-report": :tr, "guide": :guide,
"technical-specification": :ts,
"publicly-available-specification": :pas,
"committee-document": :tc }.freeze

# @param type [nil, :tr, :ts, :amd, :cor, :guide, :dir, :tc, Type]
# document's type, eg. :tr, :ts, :amd, :cor, Type.new(:tr)
def get_typeabbr(node, amd: false)
node.attr("amendment-number") and return :amd
node.attr("corrigendum-number") and return :cor
case doctype(node)
when "directive" then :dir
when "technical-report" then :tr
when "technical-specification" then :ts
when "publicly-available-specification" then :pas
when "guide" then :guide
end
DOCTYPE2HASHID[doctype(node).to_sym]
end

def iso_id(node, xml)
Expand Down Expand Up @@ -109,11 +105,28 @@ def iso_id_params_add(node)
node.attr("corrigendum-number"),
year: iso_id_year(node),
iteration: node.attr("iteration") }
iso_id_stage_populate(ret, node, stage)
tc_number(ret, node)
compact_blank(ret)
end

def tc_number(ret, node)
doctype(node) == "committee-document" or return ret
n = node.attr("subcommittee-number") and
ret.merge!({ sctype: node.attr("subcommittee-type") || "SC",
scnumber: n })
n = node.attr("technical-committee-number") and
ret.merge!({ tctype: node.attr("technical-committee-type") || "TC",
tcnumber: n })
ret
end

def iso_id_stage_populate(ret, node, stage)
if stage && !cen?(node.attr("publisher"))
ret[:stage] = stage
ret[:stage] == "60.00" and ret[:stage] = :PRF
end
compact_blank(ret)
ret
end

def iso_id_stage(node)
Expand Down
3 changes: 2 additions & 1 deletion lib/metanorma/iso/validate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ def termdef_style(xmldoc)
def doctype_validate(_xmldoc)
%w(international-standard technical-specification technical-report
publicly-available-specification international-workshop-agreement
guide amendment technical-corrigendum).include? @doctype or
guide amendment technical-corrigendum committee-document)
.include? @doctype or
@log.add("Document Attributes", nil,
"#{@doctype} is not a recognised document type")
end
Expand Down
Loading

0 comments on commit 200f799

Please sign in to comment.