metanorma-nist 1.1.3 → 1.2.0

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: 79b2cd1ac9a7ff463c23371e7bfa9e29ec244601341ed33e603f7e0354f4d9e6
4
- data.tar.gz: 5aca2aca01a5ff7066b71df1f73c1e3e2c83c3ee786170e7a50fa107f3e6a9f2
3
+ metadata.gz: 0def1e8573338383bf4e456fc4fc092a232c08ef46b676facc570908ad9fd9aa
4
+ data.tar.gz: 820cf042c13235a0519ee6818573d9fb445bb6e0d368265a7e72753ea7e40c94
5
5
  SHA512:
6
- metadata.gz: d0dd3462d1f337597610e80f572727ce6a49097fa9501cbd1eaa47d3b22fc67d1cea85c7012d23b51dac3718e3f8caf28c25ac0a4bb2bef439cbb638555c46d1
7
- data.tar.gz: f8cdb2613aee57ba726feedd3b4c48dab082f1ab69363056dd3d80432db3a2398a95e96a378aeefd724914f975a80884d095c464e129828d7a9a10509f3432bb
6
+ metadata.gz: 0c5a2abc6a91c220a19917f5b314a18fa06067263c391fbe4d97897d16461b11af49c61feaf8a737264c355627aa42a202981a1b8c40ed7fb37bb8c39791b2e0
7
+ data.tar.gz: 0fc41aabba065a26cef8e432bf32b2c5c2927e9a3826cf89c578905e9154b51085ca447463e8feddff9ed7f21ae32ed5f79b65981dee54921f86d976c0b4b40d
@@ -94,8 +94,8 @@ module Asciidoctor
94
94
 
95
95
  def boilerplate_isodoc(xmldoc)
96
96
  conv = super
97
- conv.labels = conv.labels.merge({nist_division: @nistdivision,
98
- nist_division_address: @nistdivisionaddress})
97
+ conv.i18n.set(:nist_division, @nistdivision)
98
+ conv.i18n.set(:nist_division_address, @nistdivisionaddress)
99
99
  conv
100
100
  end
101
101
 
@@ -3,9 +3,15 @@ module Asciidoctor
3
3
  class Converter < Standoc::Converter
4
4
  def cleanup(xmldoc)
5
5
  sourcecode_cleanup(xmldoc)
6
+ annex_rename(xmldoc)
6
7
  super
7
8
  end
8
9
 
10
+ def annex_rename(xmldoc)
11
+ return unless xmldoc.xpath("//references").size == 1
12
+ replace_title(xmldoc, "//annex[references]", @i18n&.normref, true)
13
+ end
14
+
9
15
  def sourcecode_cleanup(xmldoc)
10
16
  xmldoc.xpath("//sourcecode").each do |x|
11
17
  x.traverse do |n|
@@ -37,7 +43,7 @@ module Asciidoctor
37
43
  move_execsummary_into_preface(x, preface)
38
44
  end
39
45
 
40
- def move_clauses_into_preface1(x, preface)
46
+ def move_clauses_into_preface1(x, preface)
41
47
  x.xpath("//clause[@preface]").each do |c|
42
48
  c.delete("preface")
43
49
  title = c&.at("./title")&.text.downcase
@@ -45,9 +51,9 @@ module Asciidoctor
45
51
  c.name = "executivesummary" if title == "executive summary"
46
52
  preface.add_child c.remove
47
53
  end
48
- end
54
+ end
49
55
 
50
- def move_execsummary_into_preface(x, preface)
56
+ def move_execsummary_into_preface(x, preface)
51
57
  x.xpath("//clause[@executivesummary]").each do |c|
52
58
  c.delete("executivesummary")
53
59
  title = c&.at("./title")&.text.downcase
@@ -150,7 +156,7 @@ module Asciidoctor
150
156
  elsif metaid = bib&.at("./docidentifier[@type = 'NIST']")&.text
151
157
  key = metaid.sub(/-(\d+)/) {|m| sprintf "-%09d", ($1.to_i) }
152
158
  elsif metaid = bib&.at("./docidentifier[not(@type = 'DOI' or "\
153
- "@type = 'metanorma' or @type = 'ISSN' or @type = 'ISBN')]")&.text
159
+ "@type = 'metanorma' or @type = 'ISSN' or @type = 'ISBN')]")&.text
154
160
  key = metaid.sub(/-(\d+)/) {|m| sprintf "-%09d", ($1.to_i) }
155
161
  else # no usable docid
156
162
  key = "000000000" + bib["id"]
@@ -171,6 +177,30 @@ module Asciidoctor
171
177
  end
172
178
  acc
173
179
  end
180
+
181
+ def section_names_refs_cleanup(x)
182
+ replace_title(x, "//bibliography//references[@normative = 'true']",
183
+ @i18n&.normref, true)
184
+ replace_title(x, "//bibliography//references[@normative = 'false']",
185
+ @i18n&.bibliography, true)
186
+ end
187
+
188
+ def section_names_terms_cleanup(x)
189
+ replace_title(x, "//definitions[@type = 'symbols']", @i18n&.symbols)
190
+ replace_title(x, "//definitions[@type = 'abbreviated_terms']", @i18n&.abbrev)
191
+ replace_title(x, "//definitions[not(@type)]", @i18n&.symbolsabbrev)
192
+ replace_title(x, "//sections//terms#{SYMnoABBR} | //sections//clause[.//terms]#{SYMnoABBR}",
193
+ @i18n&.termsdefsymbols, true)
194
+ replace_title(x, "//sections//terms#{ABBRnoSYM} | //sections//clause[.//terms]#{ABBRnoSYM}",
195
+ @i18n&.termsdefabbrev, true)
196
+ replace_title(x, "//sections//terms#{SYMABBR} | //sections//clause[.//terms]#{SYMABBR}",
197
+ @i18n&.termsdefsymbolsabbrev, true)
198
+ replace_title(x, "//sections//terms#{NO_SYMABBR} | //sections//clause[.//terms]#{NO_SYMABBR}",
199
+ @i18n&.termsdefsymbolsabbrev, true)
200
+ replace_title(
201
+ x, "//sections//terms[not(.//definitions)] | //sections//clause[.//terms][not(.//definitions)]",
202
+ @i18n&.termsdef, true)
203
+ end
174
204
  end
175
205
  end
176
206
  end
@@ -100,9 +100,12 @@ module Asciidoctor
100
100
  def outputs(node, ret)
101
101
  File.open(@filename + ".xml", "w:UTF-8") { |f| f.write(ret) }
102
102
  presentation_xml_converter(node).convert(@filename + ".xml")
103
- html_converter(node).convert(@filename + ".presentation.xml", nil, false, "#{@filename}.html")
104
- doc_converter(node).convert(@filename + ".presentation.xml", nil, false, "#{@filename}.doc")
105
- pdf_converter(node)&.convert(@filename + ".presentation.xml", nil, false, "#{@filename}.pdf")
103
+ html_converter(node).convert(@filename + ".presentation.xml",
104
+ nil, false, "#{@filename}.html")
105
+ doc_converter(node).convert(@filename + ".presentation.xml",
106
+ nil, false, "#{@filename}.doc")
107
+ pdf_converter(node)&.convert(@filename + ".presentation.xml",
108
+ nil, false, "#{@filename}.pdf")
106
109
  end
107
110
 
108
111
  def clause_parse(attrs, xml, node)
@@ -159,7 +162,7 @@ module Asciidoctor
159
162
  def bibliography_annex_parse(attrs, xml, node)
160
163
  attrs1 = attrs.merge(id: "_" + UUIDTools::UUID.random_create)
161
164
  xml.annex **attr_code(attrs1) do |xml_section|
162
- xml_section.title { |t| t << "Bibliography" }
165
+ xml_section.title { |t| t << node.title }
163
166
  @biblio = true
164
167
  xml.references **attr_code(attrs.merge(normative: true)) do |r|
165
168
  r << node.content
@@ -27,31 +27,35 @@ module Asciidoctor
27
27
  end
28
28
  end
29
29
 
30
+ def asciidoc_sub(text)
31
+ Asciidoctor::Standoc::Utils::asciidoc_sub(text)
32
+ end
33
+
30
34
  def title_subtitle(node, t, at)
31
35
  return unless node.attr("title-sub")
32
36
  t.title(**attr_code(at.merge(type: "subtitle"))) do |t1|
33
- t1 << Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("title-sub"))
37
+ t1 << asciidoc_sub(node.attr("title-sub"))
34
38
  end
35
39
  node.attr("title-sub-short") and
36
40
  t.title(**attr_code(at.merge(type: "short-subtitle"))) do |t1|
37
- t1 << Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("title-sub-short"))
41
+ t1 << asciidoc_sub(node.attr("title-sub-short"))
38
42
  end
39
43
  end
40
44
 
41
45
  def title_document_class(node, t, at)
42
46
  return unless node.attr("title-document-class")
43
47
  t.title(**attr_code(at.merge(type: "document-class"))) do |t1|
44
- t1 << Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("title-document-class"))
48
+ t1 << asciidoc_sub(node.attr("title-document-class"))
45
49
  end
46
50
  end
47
51
 
48
52
  def title_main(node, t, at)
49
53
  t.title(**attr_code(at.merge(type: "main"))) do |t1|
50
- t1 << (Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("title-main")) || node.title)
54
+ t1 << (asciidoc_sub(node.attr("title-main")) || node.title)
51
55
  end
52
56
  node.attr("title-main-short") and
53
57
  t.title(**attr_code(at.merge(type: "short-title"))) do |t1|
54
- t1 << Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("title-main-short"))
58
+ t1 << asciidoc_sub(node.attr("title-main-short"))
55
59
  end
56
60
  end
57
61
 
@@ -72,7 +76,8 @@ module Asciidoctor
72
76
  xml.contributor do |c|
73
77
  c.role **{ type: "publisher" }
74
78
  c.organization do |a|
75
- a.name "NIST"
79
+ a.name "National Institute of Standards and Technology"
80
+ a.abbreviation "NIST"
76
81
  d = node.attr("nist-division") and a.subdivision d
77
82
  end
78
83
  end
@@ -86,9 +91,10 @@ module Asciidoctor
86
91
  node.attr("technical-committee") and
87
92
  a.committee(node.attr("technical-committee"))
88
93
  node.attr("subcommittee") and
89
- a.subcommittee(node.attr("subcommittee"),
90
- **attr_code(type: node.attr("subcommittee-type"),
91
- number: node.attr("subcommittee-number")))
94
+ a.subcommittee(
95
+ node.attr("subcommittee"),
96
+ **attr_code(type: node.attr("subcommittee-type"),
97
+ number: node.attr("subcommittee-number")))
92
98
  (node.attr("workgroup") || node.attr("workinggroup")) and
93
99
  a.workgroup(node.attr("workgroup") || node.attr("workinggroup"),
94
100
  **attr_code(type: node.attr("workgroup-type"),
@@ -112,7 +118,8 @@ module Asciidoctor
112
118
  c.from from
113
119
  c.owner do |owner|
114
120
  owner.organization do |o|
115
- o.name "NIST"
121
+ o.name "National Institute of Standards and Technology"
122
+ o.abbreviation "NIST"
116
123
  end
117
124
  end
118
125
  end
@@ -149,14 +156,13 @@ module Asciidoctor
149
156
  end
150
157
 
151
158
  def relaton_relation_descriptions
152
- super.merge({
153
- "supersedes" => "obsoletes",
154
- "superseded-by" => "obsoleted-by",
155
- })
159
+ super.merge({ "supersedes" => "obsoletes",
160
+ "superseded-by" => "obsoleted-by", })
156
161
  end
157
162
 
158
163
  def metadata_getrelation(node, xml, type, desc = nil)
159
- if type == "obsoleted-by" and desc.nil? and node.attr("superseding-status")
164
+ if type == "obsoleted-by" and desc.nil? and
165
+ node.attr("superseding-status")
160
166
  metadata_superseding_doc(node, xml)
161
167
  end
162
168
  super
@@ -166,10 +172,8 @@ module Asciidoctor
166
172
  xml.relation **{ type: "obsoletedBy" } do |r|
167
173
  r.bibitem **{ type: "standard" } do |b|
168
174
  metadata_superseding_titles(b, node)
169
- doi = node.attr("superseding-doi") and
170
- b.uri doi, **{ type: "doi" }
171
- url = node.attr("superseding-url") and
172
- b.uri url, **{ type: "uri" }
175
+ doi = node.attr("superseding-doi") and b.uri doi, **{ type: "doi" }
176
+ url = node.attr("superseding-url") and b.uri url, **{ type: "uri" }
173
177
  metadata_superseding_ids(b, xml)
174
178
  metadata_superseding_authors(b, node)
175
179
  metadata_superseding_dates(b, node)
@@ -205,19 +209,19 @@ module Asciidoctor
205
209
  def metadata_superseding_titles(b, node)
206
210
  if node.attr("superseding-title")
207
211
  b.title **{ type: "main" } do |t|
208
- t << Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("superseding-title"))
212
+ t << asciidoc_sub(node.attr("superseding-title"))
209
213
  end
210
214
  node.attr("superseding-subtitle") and
211
215
  b.title **{ type: "subtitle" } do |t|
212
- t << Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("superseding-subtitle"))
216
+ t << asciidoc_sub(node.attr("superseding-subtitle"))
213
217
  end
214
218
  else
215
219
  b.title **{ type: "main" } do |t|
216
- t << (Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("title-main")) || node.title)
220
+ t << (asciidoc_sub(node.attr("title-main")) || node.title)
217
221
  end
218
222
  node.attr("title-sub") and
219
223
  b.title **{ type: "subtitle" } do |t|
220
- t << Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("title-sub"))
224
+ t << asciidoc_sub(node.attr("title-sub"))
221
225
  end
222
226
  end
223
227
  end
@@ -64,7 +64,7 @@ module Asciidoctor
64
64
  end
65
65
 
66
66
  def status_abbr(stage, iter)
67
- IsoDoc::NIST::Metadata.new(nil, nil, {}).status_abbr(stage, iter)
67
+ IsoDoc::NIST::Metadata.new(nil, nil, @i18n).status_abbr(stage, iter)
68
68
  end
69
69
 
70
70
  def add_id_parts(args, long)
@@ -922,6 +922,9 @@
922
922
  <optional>
923
923
  <attribute name="script"/>
924
924
  </optional>
925
+ <optional>
926
+ <attribute name="type"/>
927
+ </optional>
925
928
  <optional>
926
929
  <attribute name="obligation">
927
930
  <choice>
@@ -961,9 +964,6 @@
961
964
  </define>
962
965
  <define name="content-subsection">
963
966
  <element name="clause">
964
- <optional>
965
- <attribute name="type"/>
966
- </optional>
967
967
  <ref name="Content-Section"/>
968
968
  </element>
969
969
  </define>
@@ -992,6 +992,9 @@
992
992
  </choice>
993
993
  </attribute>
994
994
  </optional>
995
+ <optional>
996
+ <attribute name="type"/>
997
+ </optional>
995
998
  <optional>
996
999
  <ref name="section-title"/>
997
1000
  </optional>
@@ -1011,9 +1014,6 @@
1011
1014
  </define>
1012
1015
  <define name="clause">
1013
1016
  <element name="clause">
1014
- <optional>
1015
- <attribute name="type"/>
1016
- </optional>
1017
1017
  <ref name="Clause-Section"/>
1018
1018
  </element>
1019
1019
  </define>
@@ -1042,6 +1042,9 @@
1042
1042
  </choice>
1043
1043
  </attribute>
1044
1044
  </optional>
1045
+ <optional>
1046
+ <attribute name="type"/>
1047
+ </optional>
1045
1048
  <optional>
1046
1049
  <ref name="section-title"/>
1047
1050
  </optional>
@@ -1180,6 +1183,9 @@
1180
1183
  <optional>
1181
1184
  <attribute name="script"/>
1182
1185
  </optional>
1186
+ <optional>
1187
+ <attribute name="type"/>
1188
+ </optional>
1183
1189
  <optional>
1184
1190
  <attribute name="obligation">
1185
1191
  <choice>
@@ -21,26 +21,30 @@ module Asciidoctor
21
21
  def doctype_validate(xmldoc)
22
22
  doctype = xmldoc&.at("//bibdata/ext/doctype")&.text
23
23
  %w(standard).include? doctype or
24
- @log.add("Document Attributes", nil, "#{doctype} is not a recognised document type")
24
+ @log.add("Document Attributes", nil,
25
+ "#{doctype} is not a recognised document type")
25
26
  end
26
27
 
27
28
  def stage_validate(xmldoc)
28
29
  stage = xmldoc&.at("//bibdata/status/stage")&.text
29
30
  %w(draft-internal draft-wip draft-prelim draft-public draft-approval
30
31
  final final-review).include? stage or
31
- @log.add("Document Attributes", nil, "#{stage} is not a recognised stage")
32
+ @log.add("Document Attributes", nil,
33
+ "#{stage} is not a recognised stage")
32
34
  end
33
35
 
34
36
  def substage_validate(xmldoc)
35
37
  substage = xmldoc&.at("//bibdata/status/substage")&.text or return
36
38
  %w(active retired withdrawn).include? substage or
37
- @log.add("Document Attributes", nil, "#{substage} is not a recognised substage")
39
+ @log.add("Document Attributes", nil,
40
+ "#{substage} is not a recognised substage")
38
41
  end
39
42
 
40
43
  def iteration_validate(xmldoc)
41
44
  iteration = xmldoc&.at("//bibdata/status/iteration")&.text or return
42
45
  %w(final).include? iteration.downcase or /^\d+$/.match(iteration) or
43
- @log.add("Document Attributes", nil, "#{iteration} is not a recognised iteration")
46
+ @log.add("Document Attributes", nil,
47
+ "#{iteration} is not a recognised iteration")
44
48
  end
45
49
 
46
50
  def series_validate(xmldoc)
@@ -48,7 +52,8 @@ module Asciidoctor
48
52
  found = false
49
53
  SERIES.each { |_, v| found = true if v == series }
50
54
  found or
51
- @log.add("Document Attributes", nil, "#{series} is not a recognised series")
55
+ @log.add("Document Attributes", nil,
56
+ "#{series} is not a recognised series")
52
57
  end
53
58
 
54
59
  def validate(doc)
@@ -60,8 +65,9 @@ module Asciidoctor
60
65
  def introduction_validate(doc)
61
66
  intro = doc.at("//sections/clause/title")
62
67
  intro&.text == "Introduction" or
63
- @log.add("Style", intro, "First section of document body should be Introduction, "\
64
- "not #{intro&.text}")
68
+ @log.add("Style", intro,
69
+ "First section of document body should be Introduction, "\
70
+ "not #{intro&.text}")
65
71
  end
66
72
 
67
73
  REF_SECTIONS_TO_VALIDATE = "//references[not(parent::clause)]/title | "\
@@ -80,8 +86,9 @@ module Asciidoctor
80
86
  return if names == ["References"]
81
87
  return if names == ["Bibliography"]
82
88
  return if names == ["References", "Bibliography"]
83
- @log.add("Style", nil, "Reference clauses #{names.join(', ')} do not follow expected "\
84
- "pattern in NIST")
89
+ @log.add("Style", nil,
90
+ "Reference clauses #{names.join(', ')} do not follow "\
91
+ "expected pattern in NIST")
85
92
  end
86
93
  end
87
94
  end
@@ -1,6 +1,4 @@
1
1
  require "isodoc"
2
- require_relative "metadata"
3
- require_relative "xref"
4
2
  require_relative "refs"
5
3
  require_relative "section"
6
4
  require "fileutils"
@@ -8,26 +6,11 @@ require "fileutils"
8
6
  module IsoDoc
9
7
  module NIST
10
8
  module BaseConvert
11
- def metadata_init(lang, script, labels)
12
- @meta = Metadata.new(lang, script, labels)
9
+ def keywords(docxml, out)
10
+ f = docxml.at(ns("//preface/clause[@type = 'keywords']")) || return
11
+ intro_clause(f, out)
13
12
  end
14
13
 
15
- def xref_init(lang, script, klass, labels, options)
16
- @xrefs = Xref.new(lang, script, klass, labels, options)
17
- end
18
-
19
- def keywords(_docxml, out)
20
- kw = @meta.get[:keywords]
21
- kw.empty? and return
22
- out.div **{ class: "Section3" } do |div|
23
- clause_name(nil, "Keywords", div, class: "IntroTitle")
24
- div.p kw.sort.join("; ")
25
- end
26
- end
27
-
28
- FRONT_CLAUSE = "//*[parent::preface][not(local-name() = 'abstract' or "\
29
- "local-name() = 'foreword')]".freeze
30
-
31
14
  def skip_render(c, isoxml)
32
15
  return false unless c.name == "reviewernote"
33
16
  status = isoxml&.at(ns("//bibdata/status/stage"))&.text
@@ -35,10 +18,6 @@ module IsoDoc
35
18
  /^final/.match status
36
19
  end
37
20
 
38
- def fileloc(loc)
39
- File.join(File.dirname(__FILE__), loc)
40
- end
41
-
42
21
  def requirement_cleanup(docxml)
43
22
  docxml.xpath("//div[@class = 'recommend' or @class = 'require' "\
44
23
  "or @class = 'permission']").each do |d|
@@ -152,33 +131,6 @@ module IsoDoc
152
131
  super
153
132
  end
154
133
 
155
- def wrap_brackets(txt)
156
- return txt if /^\[.*\]$/.match txt
157
- "[#{txt}]"
158
- end
159
-
160
- def get_linkend(node)
161
- link = anchor_linkend(node, docid_l10n(node["target"] ||
162
- wrap_brackets(node['citeas'])))
163
- link += eref_localities(node.xpath(ns("./locality | ./localityStack")),
164
- link)
165
- contents = node.children.select do |c|
166
- !%w{locality localityStack}.include? c.name
167
- end
168
- return link if contents.nil? || contents.empty?
169
- Nokogiri::XML::NodeSet.new(node.document, contents).to_xml
170
- end
171
-
172
- def load_yaml(lang, script)
173
- y = if @i18nyaml then YAML.load_file(@i18nyaml)
174
- elsif lang == "en"
175
- YAML.load_file(File.join(File.dirname(__FILE__), "i18n-en.yaml"))
176
- else
177
- YAML.load_file(File.join(File.dirname(__FILE__), "i18n-en.yaml"))
178
- end
179
- super.merge(y)
180
- end
181
-
182
134
  def terms_parse(node, out)
183
135
  out.div **attr_code(id: node["id"]) do |div|
184
136
  node.at(ns("./title")) and
@@ -218,29 +170,16 @@ module IsoDoc
218
170
  def term_rest_parse(node, dd)
219
171
  set_termdomain("")
220
172
  node.children.each do |n|
221
- parse(n, dd) unless %w(preferred termsource).include?(n.name)
173
+ parse(n, dd) unless %w(preferred termsource name).include?(n.name)
222
174
  end
223
175
  end
224
176
 
225
177
  def modification_parse(node, out)
226
- out << @modified_lbl
178
+ out << @i18n.modified
227
179
  node.at(ns("./p[text()[normalize-space() != '']]")) and
228
180
  out << " &mdash; "
229
181
  node.at(ns("./p")).children.each { |n| parse(n, out) }
230
182
  end
231
-
232
- def annex_name(annex, name, div)
233
- div.h1 **{ class: "Annex" } do |t|
234
- t << "#{@xrefs.anchor(annex['id'], :label)} &mdash; "
235
- t.b do |b|
236
- if @bibliographycount == 1 && annex.at(ns("./references"))
237
- b << "References"
238
- else
239
- name&.children&.each { |c2| parse(c2, b) }
240
- end
241
- end
242
- end
243
- end
244
183
  end
245
184
  end
246
185
  end