metanorma-csd 1.0.10 → 1.0.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 91fc0a9da08260a793f3b925205be38d57708084a0ce67d173df0bba2ec10e0b
4
- data.tar.gz: 1606fa2d8f2b3832f9946ccb4d7848e2cf333cf8df82db1e3a554bcf827230ab
3
+ metadata.gz: cfa77e6bb51c1c9b88c27780e2c2469d07a8a677dce69b429c90bf5a9e8935ad
4
+ data.tar.gz: ac9a4b4d45310c4dc67d5c9f4cf8f5ab16c400557bcc87181d8d373e07faca7b
5
5
  SHA512:
6
- metadata.gz: 623ed2ae7a6a907824b5bb3c30ab9ca579a62a3230e0ffb79269754ae145f2fcec879e376895a26538cd96e1ed131fd6b53356d9e8aa647274cf187088f53882
7
- data.tar.gz: a922a098a6a216b2b9ba0a6718dea2557c529cc4ef379b264938e88890a163f1d9cac6e0892c07d20c119a28b43e1f98d60ebc8c5cac8e7ed1a6857cd375fc88
6
+ metadata.gz: 0b53a3f7c310eac3fd0eb622e04f828b54f6be4f92513eb5614eac743007c94479bdfae7fa3d63d62466f56498f3b3c28b2756ab6aebd06542133029d4423635
7
+ data.tar.gz: 4c0e567f10f0f0e76a75cd4724908d62be56ae7daf9e8ae4c7f681afa475faed3eb09b668db7e260d49c4e8365c2572c5d77678f4e54079a866af44b1bcaf63f
@@ -120,8 +120,11 @@ tables etc, and automatically generating references and citations.
120
120
 
121
121
  == Document Attributes
122
122
 
123
+ === Common attributes
124
+
123
125
  The gem relies on Asciidoctor document attributes to provide necessary
124
- metadata about the document. These include:
126
+ metadata about the document. The https://github.com/riboseinc/metanorma-standoc[metanorma-standoc]
127
+ gem documents the Asciidoctor document attributes common to all metanorma gems. These include:
125
128
 
126
129
  `:edition:`:: The document edition
127
130
 
@@ -168,7 +171,22 @@ other committees are added as `_3`, `_4`...
168
171
  The attribute `:draft:`, if present, includes review notes in the XML output;
169
172
  these are otherwise suppressed.
170
173
 
171
- == AsciiCSD features not also present in AsciiISO
174
+ === Attributs specific to CSD
175
+
176
+ `:fullname{_i}:`:: The full name of a person who is a contributor to the document.
177
+ A second person is indicated by using a numeric suffix: `:fullname:`, `:fullname_2:`, `fullname_3:`, &c.
178
+
179
+ `:surname{_i}:`:: The surname of a person who is a contributor to the document.
180
+ `:givenname{_i}:`:: The given name(s) of a person who is a contributor to the document.
181
+ `:role{_i}:`:: The role of a a person who is a contributor to the document. By default,
182
+ they are coded as an `editor`; they can also be represented as an `author`.
183
+
184
+
185
+ == Asciidoctor features specific to CSAND
186
+
187
+ The https://github.com/riboseinc/metanorma-standoc[metanorma-standoc]
188
+ gem documents the customisations of Asciidoctor markup common to all metanorma gems.
189
+ The following markup is specific to this gem:
172
190
 
173
191
  * `+[keyword]#...#+`: encodes keywords, such as "MUST", "MUST NOT". (Encoded as
174
192
  `<span class="keyword">...</span>`.
@@ -4,6 +4,8 @@ require "isodoc/csd/word_convert"
4
4
  require "metanorma/csd"
5
5
  require "asciidoctor/standoc/converter"
6
6
  require "fileutils"
7
+ require_relative "validate_section"
8
+ require_relative "front"
7
9
 
8
10
  module Asciidoctor
9
11
  module Csd
@@ -19,89 +21,6 @@ module Asciidoctor
19
21
  super
20
22
  end
21
23
 
22
- def metadata_author(node, xml)
23
- xml.contributor do |c|
24
- c.role **{ type: "author" }
25
- c.organization do |a|
26
- a.name "CalConnect"
27
- end
28
- end
29
- end
30
-
31
- def metadata_publisher(node, xml)
32
- xml.contributor do |c|
33
- c.role **{ type: "publisher" }
34
- c.organization do |a|
35
- a.name "CalConnect"
36
- end
37
- end
38
- end
39
-
40
- def metadata_committee(node, xml)
41
- xml.editorialgroup do |a|
42
- a.technical_committee node.attr("technical-committee"),
43
- **attr_code(type: node.attr("technical-committee-type"))
44
- i = 2
45
- while node.attr("technical-committee_#{i}") do
46
- a.technical_committee node.attr("technical-committee_#{i}"),
47
- **attr_code(type: node.attr("technical-committee-type_#{i}"))
48
- i += 1
49
- end
50
- end
51
- end
52
-
53
- def metadata_status(node, xml)
54
- status = node.attr("status")
55
- unless status && ::Metanorma::Csd::DOCSTATUS.keys.include?(status)
56
- warn "#{status} is not a legal status"
57
- end
58
- xml.status(**{ format: "plain" }) { |s| s << status }
59
- end
60
-
61
- def prefix_id(node)
62
- prefix = "CC"
63
- typesuffix = ::Metanorma::Csd::DOCSUFFIX[node.attr("doctype")] || ""
64
- prefix += "/#{typesuffix}" unless typesuffix.empty?
65
- status = ::Metanorma::Csd::DOCSTATUS[node.attr("status")] || ""
66
- prefix += "/#{status}" unless status.empty?
67
- prefix
68
- end
69
-
70
- def metadata_id(node, xml)
71
- id = node.attr("docnumber") || "???"
72
- prefix = prefix_id(node)
73
- id = "#{prefix} #{id}"
74
- year = node.attr("copyright-year")
75
- id += ":#{year}" if year
76
- xml.docidentifier id, **{type: "csd"}
77
- xml.docnumber node.attr("docnumber")
78
- end
79
-
80
- def doctype(node)
81
- d = node.attr("doctype")
82
- unless ::Metanorma::Csd::DOCSUFFIX.keys.include?(d)
83
- warn "#{d} is not a legal document type: reverting to 'standard'"
84
- d = "standard"
85
- end
86
- d
87
- end
88
-
89
- def metadata_copyright(node, xml)
90
- from = node.attr("copyright-year") || Date.today.year
91
- xml.copyright do |c|
92
- c.from from
93
- c.owner do |owner|
94
- owner.organization do |o|
95
- o.name "CalConnect"
96
- end
97
- end
98
- end
99
- end
100
-
101
- def title_validate(root)
102
- nil
103
- end
104
-
105
24
  def makexml(node)
106
25
  result = ["<?xml version='1.0' encoding='UTF-8'?>\n<csd-standard>"]
107
26
  @draft = node.attributes.has_key?("draft")
@@ -0,0 +1,118 @@
1
+ require "asciidoctor"
2
+ require "asciidoctor/standoc/converter"
3
+ require "fileutils"
4
+
5
+ module Asciidoctor
6
+ module Csd
7
+
8
+ class Converter < Standoc::Converter
9
+
10
+ def metadata_author(node, xml)
11
+ xml.contributor do |c|
12
+ c.role **{ type: "author" }
13
+ c.organization do |a|
14
+ a.name "CalConnect"
15
+ end
16
+ end
17
+ personal_author(node, xml)
18
+ end
19
+
20
+ def personal_author(node, xml)
21
+ if node.attr("fullname") || node.attr("surname")
22
+ personal_author1(node, xml, "")
23
+ end
24
+ i = 2
25
+ while node.attr("fullname_#{i}") || node.attr("surname_#{i}")
26
+ personal_author1(node, xml, "_#{i}")
27
+ i += 1
28
+ end
29
+ end
30
+
31
+ def personal_author1(node, xml, suffix)
32
+ xml.contributor do |c|
33
+ c.role **{ type: node.attr("role#{suffix}")&.downcase || "author" }
34
+ c.person do |p|
35
+ p.name do |n|
36
+ if node.attr("fullname#{suffix}")
37
+ n.completename node.attr("fullname#{suffix}")
38
+ else
39
+ n.forename node.attr("givenname#{suffix}")
40
+ n.surname node.attr("surname#{suffix}")
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+
47
+ def metadata_publisher(node, xml)
48
+ xml.contributor do |c|
49
+ c.role **{ type: "publisher" }
50
+ c.organization do |a|
51
+ a.name "CalConnect"
52
+ end
53
+ end
54
+ end
55
+
56
+ def metadata_committee(node, xml)
57
+ xml.editorialgroup do |a|
58
+ a.technical_committee node.attr("technical-committee"),
59
+ **attr_code(type: node.attr("technical-committee-type"))
60
+ i = 2
61
+ while node.attr("technical-committee_#{i}") do
62
+ a.technical_committee node.attr("technical-committee_#{i}"),
63
+ **attr_code(type: node.attr("technical-committee-type_#{i}"))
64
+ i += 1
65
+ end
66
+ end
67
+ end
68
+
69
+ def metadata_status(node, xml)
70
+ status = node.attr("status")
71
+ unless status && ::Metanorma::Csd::DOCSTATUS.keys.include?(status)
72
+ warn "#{status} is not a legal status"
73
+ end
74
+ xml.status(**{ format: "plain" }) { |s| s << status }
75
+ end
76
+
77
+ def prefix_id(node)
78
+ prefix = "CC"
79
+ typesuffix = ::Metanorma::Csd::DOCSUFFIX[node.attr("doctype")] || ""
80
+ prefix += "/#{typesuffix}" unless typesuffix.empty?
81
+ status = ::Metanorma::Csd::DOCSTATUS[node.attr("status")] || ""
82
+ prefix += "/#{status}" unless status.empty?
83
+ prefix
84
+ end
85
+
86
+ def metadata_id(node, xml)
87
+ id = node.attr("docnumber") || "???"
88
+ prefix = prefix_id(node)
89
+ id = "#{prefix} #{id}"
90
+ year = node.attr("copyright-year")
91
+ id += ":#{year}" if year
92
+ xml.docidentifier id, **{type: "csd"}
93
+ xml.docnumber node.attr("docnumber")
94
+ end
95
+
96
+ def doctype(node)
97
+ d = node.attr("doctype")
98
+ unless ::Metanorma::Csd::DOCSUFFIX.keys.include?(d)
99
+ warn "#{d} is not a legal document type: reverting to 'standard'"
100
+ d = "standard"
101
+ end
102
+ d
103
+ end
104
+
105
+ def metadata_copyright(node, xml)
106
+ from = node.attr("copyright-year") || Date.today.year
107
+ xml.copyright do |c|
108
+ c.from from
109
+ c.owner do |owner|
110
+ owner.organization do |o|
111
+ o.name "CalConnect"
112
+ end
113
+ end
114
+ end
115
+ end
116
+ end
117
+ end
118
+ end
@@ -744,6 +744,9 @@
744
744
  </define>
745
745
  <define name="preface">
746
746
  <element name="preface">
747
+ <optional>
748
+ <ref name="preface_abstract"/>
749
+ </optional>
747
750
  <ref name="foreword"/>
748
751
  <optional>
749
752
  <ref name="introduction"/>
@@ -811,6 +814,11 @@
811
814
  </optional>
812
815
  </element>
813
816
  </define>
817
+ <define name="preface_abstract">
818
+ <element name="abstract">
819
+ <ref name="Basic-Section"/>
820
+ </element>
821
+ </define>
814
822
  <define name="foreword">
815
823
  <element name="foreword">
816
824
  <ref name="Basic-Section"/>
@@ -0,0 +1,138 @@
1
+ require "nokogiri"
2
+
3
+ module Asciidoctor
4
+ module Csd
5
+ class Converter < Standoc::Converter
6
+ def section_validate(doc)
7
+ advisory = doc.root.at("//bibdata[@type = 'advisory']")
8
+ symbols_validate(doc.root) unless advisory
9
+ sections_sequence_validate(doc.root) unless advisory
10
+ super
11
+ end
12
+
13
+ ONE_SYMBOLS_WARNING = "ISO style: only one Symbols and Abbreviated "\
14
+ "Terms section in the standard".freeze
15
+
16
+ NON_DL_SYMBOLS_WARNING = "ISO style: Symbols and Abbreviated Terms can "\
17
+ "only contain a definition list".freeze
18
+
19
+ def symbols_validate(root)
20
+ f = root.xpath("//definitions")
21
+ f.empty? && return
22
+ (f.size == 1) || warn(ONE_SYMBOLS_WARNING)
23
+ f.first.elements.each do |e|
24
+ unless e.name == "dl"
25
+ warn(NON_DL_SYMBOLS_WARNING)
26
+ return
27
+ end
28
+ end
29
+ end
30
+
31
+ def seqcheck(names, msg, accepted)
32
+ n = names.shift
33
+ unless accepted.include? n
34
+ warn "ISO style: #{msg}"
35
+ names = []
36
+ end
37
+ names
38
+ end
39
+
40
+ # spec of permissible section sequence
41
+ # we skip normative references, it goes to end of list
42
+ SEQ =
43
+ [
44
+ {
45
+ msg: "Initial section must be (content) Foreword",
46
+ val: [{ tag: "foreword", title: "Foreword" }],
47
+ },
48
+ {
49
+ msg: "Prefatory material must be followed by (clause) Scope",
50
+ val: [{ tag: "introduction", title: "Introduction" },
51
+ { tag: "clause", title: "Scope" }],
52
+ },
53
+ {
54
+ msg: "Prefatory material must be followed by (clause) Scope",
55
+ val: [{ tag: "clause", title: "Scope" }],
56
+ },
57
+ {
58
+ msg: "Normative References must be followed by "\
59
+ "Terms and Definitions",
60
+ val: [
61
+ { tag: "terms", title: "Terms and definitions" },
62
+ { tag: "clause", title: "Terms and definitions" },
63
+ {
64
+ tag: "terms",
65
+ title: "Terms, definitions, symbols and abbreviated terms",
66
+ },
67
+ {
68
+ tag: "clause",
69
+ title: "Terms, definitions, symbols and abbreviated terms",
70
+ },
71
+ ],
72
+ },
73
+ ].freeze
74
+
75
+ SECTIONS_XPATH =
76
+ "//foreword | //introduction | //sections/terms | .//annex | "\
77
+ "//sections/definitions | //sections/clause | //references[not(parent::clause)] | "\
78
+ "//clause[descendant::references][not(parent::clause)]".freeze
79
+
80
+ def sections_sequence_validate(root)
81
+ f = root.xpath(SECTIONS_XPATH)
82
+ names = f.map { |s| { tag: s.name, title: s&.at("./title")&.text } }
83
+ names = seqcheck(names, SEQ[0][:msg], SEQ[0][:val]) || return
84
+ n = names[0]
85
+ names = seqcheck(names, SEQ[1][:msg], SEQ[1][:val]) || return
86
+ if n == { tag: "introduction", title: "Introduction" }
87
+ names = seqcheck(names, SEQ[2][:msg], SEQ[2][:val]) || return
88
+ end
89
+ names = seqcheck(names, SEQ[3][:msg], SEQ[3][:val]) || return
90
+ n = names.shift
91
+ if n == { tag: "definitions", title: nil }
92
+ n = names.shift || return
93
+ end
94
+ unless n
95
+ warn "ISO style: Document must contain at least one clause"
96
+ return
97
+ end
98
+ n[:tag] == "clause" ||
99
+ warn("ISO style: Document must contain clause after "\
100
+ "Terms and Definitions")
101
+ n == { tag: "clause", title: "Scope" } &&
102
+ warn("ISO style: Scope must occur before Terms and Definitions")
103
+ n = names.shift || return
104
+ while n[:tag] == "clause"
105
+ n[:title] == "Scope" &&
106
+ warn("ISO style: Scope must occur before Terms and Definitions")
107
+ n = names.shift || return
108
+ end
109
+ unless n[:tag] == "annex" || n[:tag] == "references"
110
+ warn "ISO style: Only annexes and references can follow clauses"
111
+ end
112
+ while n[:tag] == "annex"
113
+ n = names.shift
114
+ if n.nil?
115
+ warn("ISO style: Document must include (references) "\
116
+ "Normative References")
117
+ return
118
+ end
119
+ end
120
+ n == { tag: "references", title: "Normative References" } ||
121
+ warn("ISO style: Document must include (references) "\
122
+ "Normative References")
123
+ n = names.shift
124
+ n == { tag: "references", title: "Bibliography" } ||
125
+ warn("ISO style: Final section must be (references) Bibliography")
126
+ names.empty? ||
127
+ warn("ISO style: There are sections after the final Bibliography")
128
+ end
129
+
130
+ def style_warning(node, msg, text)
131
+ return if @novalid
132
+ w = "ISO style: WARNING (#{Standoc::Utils::current_location(node)}): #{msg}"
133
+ w += ": #{text}" if text
134
+ warn w
135
+ end
136
+ end
137
+ end
138
+ end
@@ -36,6 +36,17 @@
36
36
  <div class="coverpage-tc-name">
37
37
  <span>TC {{ tc }}</span>
38
38
  </div>
39
+
40
+ {% if editors %}
41
+ <div class="coverpage-tc-name">
42
+ <span>Editors: {{ editors | join: ", " }}</span>
43
+ </div>
44
+ {% endif %}
45
+ {% if authors %}
46
+ <div class="coverpage-tc-name">
47
+ <span>Authors: {{ authors | join: ", " }}</span>
48
+ </div>
49
+ {% endif %}
39
50
  </div>
40
51
 
41
52
  <div class="title-section1">
@@ -44,10 +55,10 @@
44
55
  </div>
45
56
 
46
57
  <div class="coverpage-stage-block" >
47
- <span class="coverpage-maturity" id="{{ status | replace: ' ', '-' | downcase }}">{{ status }}</span>
58
+ <span class="coverpage-maturity" id="{{ status | replace: ' ', '-' | downcase }}">{% if unpublished %}{{ status }}{% endif %}</span>
48
59
  </div>
49
60
 
50
- {% if status != "Published" and status != "Withdrawn" %}
61
+ {% if unpublished %}
51
62
  <div class="coverpage-warning">
52
63
  <span class="title">Warning for Drafts</span>
53
64
 
@@ -10,6 +10,17 @@ style='mso-no-proof:yes'>{{ tc | join: "/" }}</span></p>
10
10
  style='mso-bidi-font-weight:normal'><span lang="EN-GB" style='font-size:24.0pt'>{{ doctitle }}</span>
11
11
  </b><br/><span lang="EN-GB" style='font-size:16.0pt'>{{ docsubtitle }}</span></p>
12
12
 
13
+ {% if editors %}
14
+ <p class="MsoNormal" align="center" style='text-align:center'>
15
+ <span>Editors: {{ editors | join: ", " }}</span>
16
+ </p>
17
+ {% endif %}
18
+ {% if authors %}
19
+ <p class="MsoNormal" align="center" style='text-align:center'>
20
+ <span>Authors: {{ authors | join: ", " }}</span>
21
+ </p>
22
+ {% endif %}
23
+
13
24
  <p class="MsoNormal" style='margin-top:100.0pt'><span lang="EN-GB"><o:p>&nbsp;</o:p></span></p>
14
25
 
15
26
  <div style='mso-element:para-border-div;border:solid windowtext 1.0pt;
@@ -18,7 +29,7 @@ margin-left:4.25pt;margin-right:4.25pt'>
18
29
 
19
30
  <p class="MsoNormal" align="center" style='text-align:center;border:none;
20
31
  mso-border-alt:solid windowtext .5pt;padding:0cm;mso-padding-alt:1.0pt 4.0pt 1.0pt 4.0pt'><span
21
- lang="EN-GB" style='font-size:16.0pt'>{{ status }} {{ doctype }}</span></p>
32
+ lang="EN-GB" style='font-size:16.0pt'>{% if unpublished %}{{ status }} {% endif %}{{ doctype }}</span></p>
22
33
 
23
34
  {% if doctype == "Policy And Procedures" or doctype == "Proposal" %}
24
35
  <p class="MsoNormal" align="center" style='text-align:center;border:none;
@@ -33,7 +44,7 @@ mso-border-alt:solid windowtext .5pt;padding:0cm;mso-padding-alt:1.0pt 4.0pt 1.0
33
44
  mso-border-alt:solid windowtext .5pt;padding:1.0pt 4.0pt 1.0pt 4.0pt;
34
45
  margin-left:4.25pt;margin-right:4.25pt'>
35
46
 
36
- {% if status != "Published" and status != "Withdrawn" %}
47
+ {% if unpublished %}
37
48
  <p class="MsoNormal" align="center" style='margin-bottom:6.0pt;text-align:center;
38
49
  border:none;mso-border-alt:solid windowtext .5pt;padding:0cm;mso-padding-alt:
39
50
  1.0pt 4.0pt 1.0pt 4.0pt'><b style='mso-bidi-font-weight:normal'><span
@@ -25,6 +25,26 @@ module IsoDoc
25
25
  set(:tc, "XXXX")
26
26
  tc = isoxml.at(ns("//bibdata/editorialgroup/technical-committee"))
27
27
  set(:tc, tc.text) if tc
28
+ authors = isoxml.xpath(ns("//bibdata/contributor[role/@type = 'author']/person/name"))
29
+ set(:authors, extract_person_names(authors))
30
+ editors = isoxml.xpath(ns("//bibdata/contributor[role/@type = 'editor']/person/name"))
31
+ set(:editors, extract_person_names(editors))
32
+ end
33
+
34
+ def extract_person_names(authors)
35
+ ret = []
36
+ authors.each do |a|
37
+ if a.at(ns("./completename"))
38
+ ret << a.at(ns("./completename")).text
39
+ else
40
+ fn = []
41
+ forenames = a.xpath(ns("./forename"))
42
+ forenames.each { |f| fn << f.text }
43
+ surname = a&.at(ns("./surname"))&.text
44
+ ret << fn.join(" ") + " " + surname
45
+ end
46
+ end
47
+ ret
28
48
  end
29
49
 
30
50
  def docid(isoxml, _out)
@@ -44,7 +64,10 @@ module IsoDoc
44
64
  def status_abbr(status)
45
65
  ::Metanorma::Csd::DOCSTATUS[status] || ""
46
66
  end
67
+
68
+ def unpublished(status)
69
+ %w(published withdrawn).include? status.downcase
70
+ end
47
71
  end
48
72
  end
49
73
  end
50
-
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Csd
3
- VERSION = "1.0.10"
3
+ VERSION = "1.0.11"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-csd
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.10
4
+ version: 1.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-11-12 00:00:00.000000000 Z
11
+ date: 2018-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-standoc
@@ -221,9 +221,11 @@ files:
221
221
  - lib/asciidoctor/csd/biblio.rng
222
222
  - lib/asciidoctor/csd/converter.rb
223
223
  - lib/asciidoctor/csd/csd.rng
224
+ - lib/asciidoctor/csd/front.rb
224
225
  - lib/asciidoctor/csd/isodoc.rng
225
226
  - lib/asciidoctor/csd/isostandard.rng
226
227
  - lib/asciidoctor/csd/pdf.js
228
+ - lib/asciidoctor/csd/validate_section.rb
227
229
  - lib/isodoc/csd/html/csd.scss
228
230
  - lib/isodoc/csd/html/dots-w@2x.png
229
231
  - lib/isodoc/csd/html/dots@2x.png