metanorma-cc 1.5.5 → 1.6.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,67 +0,0 @@
1
- require "asciidoctor"
2
- require "asciidoctor/standoc/converter"
3
- require "fileutils"
4
-
5
- module Asciidoctor
6
- module CC
7
- class Converter < Standoc::Converter
8
- def default_publisher
9
- "CalConnect"
10
- end
11
-
12
- def metadata_committee(node, xml)
13
- return unless node.attr("technical-committee")
14
- xml.editorialgroup do |a|
15
- a.technical_committee node.attr("technical-committee"),
16
- **attr_code(type: node.attr("technical-committee-type"))
17
- i = 2
18
- while node.attr("technical-committee_#{i}") do
19
- a.technical_committee node.attr("technical-committee_#{i}"),
20
- **attr_code(type: node.attr("technical-committee-type_#{i}"))
21
- i += 1
22
- end
23
- end
24
- end
25
-
26
- def metadata_status(node, xml)
27
- status = node.attr("status")
28
- unless status && ::Metanorma::CC::DOCSTATUS.keys.include?(status)
29
- @log.add("Document Attributes", nil, "#{status} is not a legal status")
30
- end
31
- super
32
- end
33
-
34
- def prefix_id(node)
35
- prefix = "CC"
36
- typesuffix = ::Metanorma::CC::DOCSUFFIX[doctype(node)] || ""
37
- prefix += "/#{typesuffix}" unless typesuffix.empty?
38
- status = ::Metanorma::CC::DOCSTATUS[node.attr("status")] || ""
39
- prefix += "/#{status}" unless status.empty?
40
- prefix
41
- end
42
-
43
- def metadata_id(node, xml)
44
- id = node.attr("docnumber") || "???"
45
- prefix = prefix_id(node)
46
- id = "#{prefix} #{id}"
47
- year = node.attr("copyright-year")
48
- id += ":#{year}" if year
49
- xml.docidentifier id, **{type: "CalConnect"}
50
- xml.docnumber node.attr("docnumber")
51
- end
52
-
53
- @log_doctype = false
54
-
55
- def doctype(node)
56
- d = super
57
- unless ::Metanorma::CC::DOCSUFFIX.keys.include?(d) && !@log_doctype
58
- @log.add("Document Attributes", nil,
59
- "#{d} is not a legal document type: reverting to 'standard'")
60
- @log_doctype = true
61
- d = "standard"
62
- end
63
- d
64
- end
65
- end
66
- end
67
- end
@@ -1,29 +0,0 @@
1
- module Asciidoctor
2
- module CC
3
- class Converter < Standoc::Converter
4
- def content_validate(doc)
5
- super
6
- bibdata_validate(doc.root)
7
- end
8
-
9
- def bibdata_validate(doc)
10
- doctype_validate(doc)
11
- stage_validate(doc)
12
- end
13
-
14
- def doctype_validate(xmldoc)
15
- doctype = xmldoc&.at("//bibdata/ext/doctype")&.text
16
- %w(directive guide specification standard report administrative amendment
17
- technical-corrigendum advisory).include?(doctype) or
18
- @log.add("Document Attributes", nil, "#{doctype} is not a recognised document type")
19
- end
20
-
21
- def stage_validate(xmldoc)
22
- stage = xmldoc&.at("//bibdata/status/stage")&.text
23
- %w(proposal working-draft committee-draft draft-standard final-draft
24
- published withdrawn).include?(stage) or
25
- @log.add("Document Attributes", nil, "#{stage} is not a recognised status")
26
- end
27
- end
28
- end
29
- end