metanorma-rsd 1.3.11 → 1.4.4

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: 42a45132215438e659d5a94aeca1b994e2866dc25e4430fc1b4a2b234223c035
4
- data.tar.gz: c30c2134bef3717dbe33c25b71622478ff897f9f2d5a1b8fe5e40e03fbd6d1a2
3
+ metadata.gz: 101eb1fc5a1a726cefc8e12dcd570733d0cb2b800c586c4628ba4674647e671f
4
+ data.tar.gz: 78064e1735d8fac74138360ae08438a82447b2974d6a38f3587ce8e9b2d5c47f
5
5
  SHA512:
6
- metadata.gz: db9637f124dcba7b544c9caeabade267c831b8335e3e5bf058e26be2840b314eca861398321641286809bda22acf4ccd6fc73ef60db74e2f90b4ba1bd662a400
7
- data.tar.gz: 9e5837db5f2ff899ca643eb3a8b63f220b3e5836431babfd8f360fbfffa55d190a18369655d61735905c6f6ec5c6c3157c42f0ce1341415e6c496988f7c12a50
6
+ metadata.gz: 1311e29995441ad9c98b18cf3a280a131e3870736706369610328fc34bf673a29461777048f48fd155b9c2dfb428c72a0bd8b22bd4664847f43ed5ee74bad15a
7
+ data.tar.gz: 5dd2bd74300087c571aaaa77377192e4f55943df03cbc87080903812d20894a4f49359d6ab79f77f7cce3a7267ca735c83a781d06572a702cf4570df132dccd4
@@ -1,12 +1,11 @@
1
- # Auto-generated !!! Do not edit it manually
2
- # use ci-master https://github.com/metanorma/metanorma-build-scripts
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
3
  name: macos
4
4
 
5
5
  on:
6
6
  push:
7
7
  branches: [ master ]
8
8
  pull_request:
9
- branches: [ '**' ]
10
9
 
11
10
  jobs:
12
11
  test-macos:
@@ -1,12 +1,11 @@
1
- # Auto-generated !!! Do not edit it manually
2
- # use ci-master https://github.com/metanorma/metanorma-build-scripts
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
3
  name: ubuntu
4
4
 
5
5
  on:
6
6
  push:
7
7
  branches: [ master ]
8
8
  pull_request:
9
- branches: [ '**' ]
10
9
 
11
10
  jobs:
12
11
  test-linux:
@@ -25,7 +24,7 @@ jobs:
25
24
  architecture: 'x64'
26
25
  - name: Update gems
27
26
  run: |
28
- gem install bundler
27
+ gem install bundler
29
28
  bundle install --jobs 4 --retry 3
30
29
  - name: Use Node
31
30
  uses: actions/setup-node@v1
@@ -1,12 +1,11 @@
1
- # Auto-generated !!! Do not edit it manually
2
- # use ci-master https://github.com/metanorma/metanorma-build-scripts
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
3
  name: windows
4
4
 
5
5
  on:
6
6
  push:
7
7
  branches: [ master ]
8
8
  pull_request:
9
- branches: [ '**' ]
10
9
 
11
10
  jobs:
12
11
  test-windows:
@@ -26,7 +25,7 @@ jobs:
26
25
  - name: Update gems
27
26
  shell: pwsh
28
27
  run: |
29
- gem install bundler
28
+ gem install bundler
30
29
  bundle config --local path vendor/bundle
31
30
  bundle update
32
31
  bundle install --jobs 4 --retry 3
@@ -1,8 +1,9 @@
1
1
  = AsciiRSD: Asciidoctor processor for Ribose Standard Documents (RSD)
2
2
 
3
3
  image:https://img.shields.io/gem/v/metanorma-rsd.svg["Gem Version", link="https://rubygems.org/gems/metanorma-rsd"]
4
- image:https://travis-ci.com/metanorma/metanorma-rsd.svg["Build Status", link="https://travis-ci.com/metanorma/metanorma-rsd"]
5
- image:https://ci.appveyor.com/api/projects/status/col74y763yt5xaka?svg=true["Appveyor Build Status", link="https://ci.appveyor.com/project/metanorma/metanorma-rsd"]
4
+ image:https://github.com/metanorma/metanorma-rsd/workflows/macos/badge.svg["Build Status (macOS)", link="https://github.com/metanorma/metanorma-rsd/actions?workflow=macos"]
5
+ image:https://github.com/metanorma/metanorma-rsd/workflows/ubuntu/badge.svg["Build Status (ubuntu)", link="https://github.com/metanorma/metanorma-rsd/actions?workflow=ubuntu"]
6
+ image:https://github.com/metanorma/metanorma-rsd/workflows/windows/badge.svg["Build Status (Windows)", link="https://github.com/metanorma/metanorma-rsd/actions?workflow=windows"]
6
7
  image:https://codeclimate.com/github/metanorma/metanorma-rsd/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/metanorma-rsd"]
7
8
  image:https://img.shields.io/github/issues-pr-raw/metanorma/metanorma-rsd.svg["Pull Requests", link="https://github.com/metanorma/metanorma-rsd/pulls"]
8
9
  image:https://img.shields.io/github/commits-since/metanorma/metanorma-rsd/latest.svg["Commits since latest",link="https://github.com/metanorma/metanorma-rsd/releases"]
@@ -87,8 +88,7 @@ this general model can be found on its page. Details of the RSD modifications
87
88
  to this general model can be found on the https://github.com/metanorma/metanorma-model-rsd[RSD model]
88
89
  repository.
89
90
 
91
+ ////
90
92
  == Examples
93
+ ////
91
94
 
92
- * link:spec/examples/rfc6350.adoc[] is an AsciiRSD version of https://tools.ietf.org/html/rfc6350[RFC 6350].
93
- * link:spec/examples/rfc6350.html[] is an HTML file generated from the AsciiRSD.
94
- * link:spec/examples/rfc6350.doc[] is a Word document generated from the AsciiRSD.
@@ -1,7 +1,4 @@
1
1
  module Asciidoctor
2
2
  module Rsd
3
-
4
- RSD_NAMESPACE = "https://open.ribose.com/standards/rsd"
5
-
6
3
  end
7
4
  end
@@ -703,21 +703,11 @@
703
703
  </define>
704
704
  <define name="TypedTitleString">
705
705
  <optional>
706
- <attribute name="type">
707
- <ref name="TitleType"/>
708
- </attribute>
706
+ <attribute name="type"/>
709
707
  </optional>
710
708
  <ref name="FormattedString"/>
711
709
  </define>
712
- <define name="TitleType">
713
- <choice>
714
- <value>alternative</value>
715
- <value>original</value>
716
- <value>unofficial</value>
717
- <value>subtitle</value>
718
- <value>main</value>
719
- </choice>
720
- </define>
710
+ <!-- TitleType = ( "alternative" | "original" | "unofficial" | "subtitle" | "main" ) -->
721
711
  <define name="TypedUri">
722
712
  <optional>
723
713
  <attribute name="type"/>
@@ -1,81 +1,17 @@
1
- require "asciidoctor"
2
- require "asciidoctor/rsd"
3
1
  require "asciidoctor/standoc/converter"
4
- require "isodoc/rsd/html_convert"
5
- require "isodoc/rsd/word_convert"
6
- require "fileutils"
7
- require_relative "validate"
2
+ require 'asciidoctor/generic/converter'
8
3
 
9
4
  module Asciidoctor
10
5
  module Rsd
11
-
12
6
  # A {Converter} implementation that generates RSD output, and a document
13
7
  # schema encapsulation of the document for validation
14
8
  #
15
- class Converter < Standoc::Converter
16
-
9
+ class Converter < Asciidoctor::Generic::Converter
17
10
  register_for "rsd"
18
11
 
19
- def initialize(backend, opts)
20
- super
21
- @libdir = File.dirname(__FILE__)
22
- end
23
-
24
- def metadata_author(node, xml)
25
- xml.contributor do |c|
26
- c.role **{ type: "author" }
27
- c.organization do |a|
28
- a.name "Ribose"
29
- end
30
- end
31
- end
32
-
33
- def metadata_publisher(node, xml)
34
- xml.contributor do |c|
35
- c.role **{ type: "publisher" }
36
- c.organization do |a|
37
- a.name "Ribose"
38
- end
39
- end
40
- end
41
-
42
- def metadata_committee(node, xml)
43
- return unless node.attr("committee")
44
- xml.editorialgroup do |a|
45
- a.committee node.attr("committee"),
46
- **attr_code(type: node.attr("committee-type"))
47
- i = 2
48
- while node.attr("committee_#{i}") do
49
- a.committee node.attr("committee_#{i}"),
50
- **attr_code(type: node.attr("committee-type_#{i}"))
51
- i += 1
52
- end
53
- end
54
- end
55
-
56
- def metadata_id(node, xml)
57
- docstatus = node.attr("status")
58
- dn = node.attr("docnumber")
59
- if docstatus
60
- abbr = IsoDoc::Rsd::Metadata.new("en", "Latn", {}).
61
- status_abbr(docstatus)
62
- dn = "#{dn}(#{abbr})" unless abbr.empty?
63
- end
64
- node.attr("copyright-year") and dn += ":#{node.attr("copyright-year")}"
65
- xml.docidentifier dn, **{type: "rsd"}
66
- xml.docnumber { |i| i << node.attr("docnumber") }
67
- end
68
-
69
- def metadata_copyright(node, xml)
70
- from = node.attr("copyright-year") || Date.today.year
71
- xml.copyright do |c|
72
- c.from from
73
- c.owner do |owner|
74
- owner.organization do |o|
75
- o.name "Ribose"
76
- end
77
- end
78
- end
12
+ def metadata_recipient(node, xml)
13
+ recipient = node.attr("recipient") || return
14
+ xml.recipient recipient
79
15
  end
80
16
 
81
17
  def metadata_security(node, xml)
@@ -86,70 +22,50 @@ module Asciidoctor
86
22
  def metadata_ext(node, xml)
87
23
  super
88
24
  metadata_security(node, xml)
89
- end
90
-
91
- def title_validate(root)
92
- nil
93
- end
94
-
95
- def makexml(node)
96
- result = ["<?xml version='1.0' encoding='UTF-8'?>\n<rsd-standard>"]
97
- @draft = node.attributes.has_key?("draft")
98
- result << noko { |ixml| front node, ixml }
99
- result << noko { |ixml| middle node, ixml }
100
- result << "</rsd-standard>"
101
- result = textcleanup(result)
102
- ret1 = cleanup(Nokogiri::XML(result))
103
- validate(ret1) unless @novalid
104
- ret1.root.add_namespace(nil, RSD_NAMESPACE)
25
+ metadata_recipient(node, xml)
26
+ end
27
+
28
+ def sectiontype(node, level = true)
29
+ ret = node&.attr("heading")&.downcase ||
30
+ node.title.gsub(/<[^>]+>/, "").downcase
31
+ ret1 = sectiontype_streamline(ret)
32
+ return ret1 if "symbols and abbreviated terms" == ret1
33
+ return ret1 if "executive summary" == ret1
34
+ return nil unless !level || node.level == 1
35
+ return nil if @seen_headers.include? ret
36
+ @seen_headers << ret
105
37
  ret1
106
38
  end
107
39
 
108
- def doctype(node)
109
- d = node.attr("doctype")
110
- unless %w{policy-and-procedures best-practices supporting-document
111
- report legal directives proposal standard}.include? d
112
- warn "#{d} is not a legal document type: reverting to 'standard'"
113
- d = "standard"
40
+ def make_preface(x, s)
41
+ if x.at("//foreword | //introduction | //acknowledgements | "\
42
+ "//clause[@preface] | //executivesummary")
43
+ preface = s.add_previous_sibling("<preface/>").first
44
+ f = x.at("//foreword") and preface.add_child f.remove
45
+ f = x.at("//executivesummary") and preface.add_child f.remove
46
+ f = x.at("//introduction") and preface.add_child f.remove
47
+ move_clauses_into_preface(x, preface)
48
+ f = x.at("//acknowledgements") and preface.add_child f.remove
114
49
  end
115
- d
50
+ make_abstract(x, s)
116
51
  end
117
52
 
118
- def document(node)
119
- init(node)
120
- ret1 = makexml(node)
121
- ret = ret1.to_xml(indent: 2)
122
- unless node.attr("nodoc") || !node.attr("docfile")
123
- filename = node.attr("docfile").gsub(/\.adoc/, ".xml").
124
- gsub(%r{^.*/}, "")
125
- File.open(filename, "w") { |f| f.write(ret) }
126
- html_converter(node).convert filename unless node.attr("nodoc")
127
- pdf_converter(node).convert filename unless node.attr("nodoc")
128
- word_converter(node).convert filename unless node.attr("nodoc")
129
- end
130
- @files_to_delete.each { |f| FileUtils.rm f }
131
- ret
132
- end
133
-
134
- def validate(doc)
135
- content_validate(doc)
136
- schema_validate(formattedstr_strip(doc.dup),
137
- File.join(File.dirname(__FILE__), "rsd.rng"))
138
- end
139
-
140
- def rsd_html_path(file)
141
- File.join(File.dirname(__FILE__), File.join("html", file))
53
+ def clause_parse(attrs, xml, node)
54
+ sectiontype(node) == "executive summary" and
55
+ return executivesummary_parse(attrs, xml, node)
56
+ super
142
57
  end
143
58
 
144
- def sections_cleanup(x)
145
- super
146
- x.xpath("//*[@inline-header]").each do |h|
147
- h.delete("inline-header")
59
+ def executivesummary_parse(attrs, xml, node)
60
+ xml.executivesummary **attr_code(attrs) do |xml_section|
61
+ xml_section.title { |t| t << node.title || "Executive Summary" }
62
+ content = node.content
63
+ xml_section << content
148
64
  end
149
65
  end
150
66
 
151
- def style(n, t)
152
- return
67
+ def configuration
68
+ Metanorma::Rsd.configuration
153
69
  end
154
70
 
155
71
  def html_converter(node)
@@ -101,9 +101,7 @@
101
101
  <ref name="structuredidentifier"/>
102
102
  </zeroOrMore>
103
103
  </define>
104
- <define name="TitleType">
105
- <text/>
106
- </define>
104
+ <!-- TitleType = text -->
107
105
  <define name="sections">
108
106
  <element name="sections">
109
107
  <oneOrMore>
@@ -645,6 +643,11 @@
645
643
  <optional>
646
644
  <attribute name="script"/>
647
645
  </optional>
646
+ <optional>
647
+ <attribute name="inline-header">
648
+ <data type="boolean"/>
649
+ </attribute>
650
+ </optional>
648
651
  <optional>
649
652
  <attribute name="obligation">
650
653
  <choice>
@@ -1,5 +1,5 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <grammar xmlns="http://relaxng.org/ns/structure/1.0">
2
+ <grammar ns="https://www.metanorma.org/ns/rsd" xmlns="http://relaxng.org/ns/structure/1.0">
3
3
  <!--
4
4
  Currently we inherit from a namespaced grammar, isostandard. Until we inherit from isodoc,
5
5
  we cannot have a new default namespace: we will end up with a grammar with two different
@@ -14,7 +14,7 @@ module Asciidoctor
14
14
  stage = xmldoc&.at("//bibdata/status/stage")&.text
15
15
  %w(proposal working-draft committee-draft draft-standard final-draft
16
16
  published withdrawn).include? stage or
17
- warn "Document Attributes: #{stage} is not a recognised status"
17
+ @log.add("Document Attributes", nil, "#{stage} is not a recognised status")
18
18
  end
19
19
  end
20
20
  end
@@ -1,56 +1,62 @@
1
- require_relative "metadata"
2
- require "fileutils"
3
-
4
1
  module IsoDoc
5
2
  module Rsd
6
- module BaseConvert
7
- #def convert1(docxml, filename, dir)
8
- #FileUtils.cp html_doc_path('logo.svg'), File.join(@localdir, "logo.svg")
9
- #@files_to_delete << File.join(@localdir, "logo.svg")
10
- #super
11
- #end
12
-
3
+ module BaseConvert
13
4
  def metadata_init(lang, script, labels)
14
5
  @meta = Metadata.new(lang, script, labels)
15
6
  end
16
7
 
8
+ def info(isoxml, out)
9
+ @meta.security isoxml, out
10
+ @meta.recipient isoxml, out
11
+ super
12
+ end
13
+
17
14
  def annex_name(annex, name, div)
18
15
  div.h1 **{ class: "Annex" } do |t|
19
- t << "#{anchor(annex['id'], :label)} "
20
- t.br
21
- t.b do |b|
22
- name&.children&.each { |c2| parse(c2, b) }
23
- end
16
+ t << "#{anchor(annex['id'], :label)}<br/><br/>"
17
+ name&.children&.each { |c2| parse(c2, t) }
24
18
  end
25
19
  end
26
20
 
27
- def i18n_init(lang, script)
28
- super
29
- @annex_lbl = "Appendix"
21
+ def annex_name_lbl(clause, num)
22
+ obl = l10n("(#{@inform_annex_lbl})")
23
+ obl = l10n("(#{@norm_annex_lbl})") if clause["obligation"] == "normative"
24
+ l10n("#{@annex_lbl} #{num}<br/>#{obl}")
30
25
  end
31
26
 
32
- def fileloc(loc)
33
- File.join(File.dirname(__FILE__), loc)
27
+ def executivesummary docxml, out
28
+ f = docxml.at(ns("//executivesummary")) || return
29
+ title_attr = { class: "IntroTitle" }
30
+ page_break(out)
31
+ out.div **{ class: "Section3", id: f["id"] } do |div|
32
+ clause_name(nil, f&.at(ns("./title")), div, title_attr)
33
+ f.elements.each do |e|
34
+ parse(e, div) unless e.name == "title"
35
+ end
36
+ end
34
37
  end
35
38
 
36
- def cleanup(docxml)
39
+ def initial_anchor_names(d)
40
+ preface_names(d.at(ns("//executivesummary")))
37
41
  super
38
- term_cleanup(docxml)
42
+ sequential_asset_names(
43
+ d.xpath(ns("//preface/abstract | //foreword | //introduction | "\
44
+ "//preface/clause | //acknowledgements | //executivesummary")))
39
45
  end
40
46
 
41
- def term_cleanup(docxml)
42
- docxml.xpath("//p[@class = 'Terms']").each do |d|
43
- h2 = d.at("./preceding-sibling::*[@class = 'TermNum'][1]")
44
- h2.add_child("&nbsp;")
45
- h2.add_child(d.remove)
46
- end
47
- docxml
47
+ def clausedelim
48
+ ""
48
49
  end
49
50
 
50
- def info(isoxml, out)
51
- @meta.security isoxml, out
52
- super
51
+ def section_names1(clause, num, level)
52
+ @anchors[clause["id"]] =
53
+ { label: num, level: level, xref: num }
54
+ # subclauses are not prefixed with "Clause"
55
+ clause.xpath(ns("./clause | ./terms | ./term | ./definitions | ./references")).
56
+ each_with_index do |c, i|
57
+ section_names1(c, "#{num}.#{i + 1}", level + 1)
58
+ end
53
59
  end
54
- end
60
+ end
55
61
  end
56
62
  end