metanorma 1.1.3 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb71b62025d938d52251d5bfb6d1911b3de32299500e12b8fa414a63520a86c3
4
- data.tar.gz: df9deea25ea6e374426ad40b3146c63610251873ec652142acffc9274af5856c
3
+ metadata.gz: 189106fda9c97a62268cdf23a26f7b10f9784cff4d9cdf590563c0f9e71aaea5
4
+ data.tar.gz: feec6fdbfbcdb931b3ca3ce782d9ba35248481902e66ca515b94f60346217dfe
5
5
  SHA512:
6
- metadata.gz: 6404a68d6371fb24f27e36cc69dc0479da638ec79ef3bb48edf1939d6ec3beffb36c5b86f1402bc238a01ed05481dac255a30ac043cf8a806b24d464e5a16592
7
- data.tar.gz: 1881fb5c6c4e3c1d6239b1a4c34dca109f4bc489d33942d42c8e09c9177aef29ce557219aeff7656458bd6e2de918859155728b908ba64c7d6c68c8f1bbdb942
6
+ metadata.gz: e6843c3813d6d378a320ccdec21e85174889a0634396a0e1e15eeaf82192bf80414a8e698a7818cfebc575a3925e46007c6a006964179979682e51ea49a173b5
7
+ data.tar.gz: 972d7e156885833eab9f91e142dd427dea72093d0a7eee665b5229e6e1dbd41bed117c8e72a09d6be9b6f2360c11eec3fa70eb0eb84807f5656bc08b496f56fc
@@ -0,0 +1,47 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ name: notify
4
+
5
+ on:
6
+ push:
7
+ branches: [ master ]
8
+ tags:
9
+ - '*'
10
+
11
+ jobs:
12
+ notify:
13
+ name: Notify dependent repos
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - name: Trigger repositories
17
+ env:
18
+ GH_USERNAME: metanorma-ci
19
+ GH_ACCESS_TOKEN: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
20
+ run: |
21
+ curl -LO --retry 3 https://raw.githubusercontent.com/metanorma/metanorma-build-scripts/master/trigger-gh-actions.sh
22
+ [[ -f ".github/workflows/dependent_repos.env" ]] && source .github/workflows/dependent_repos.env
23
+ CLIENT_PAYLOAD=$(cat <<EOF
24
+ "{ "ref": "${GITHUB_REF}", "repo": "${GITHUB_REPOSITORY}" }"
25
+ EOF
26
+ )
27
+ for repo in $TEMPLATE_REPOS" $SAMPLES_REPOS"
28
+ do
29
+ sh trigger-gh-actions.sh $ORGANISATION $repo $GH_USERNAME $GH_ACCESS_TOKEN $GITHUB_REPOSITORY "$CLIENT_PAYLOAD"
30
+ done
31
+
32
+ - name: Trigger release repositories
33
+ if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')
34
+ env:
35
+ GH_USERNAME: metanorma-ci
36
+ GH_ACCESS_TOKEN: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
37
+ run: |
38
+ curl -LO --retry 3 https://raw.githubusercontent.com/metanorma/metanorma-build-scripts/master/trigger-gh-actions.sh
39
+ [[ -f ".github/workflows/dependent_repos.env" ]] && source .github/workflows/dependent_repos.env
40
+ CLIENT_PAYLOAD=$(cat <<EOF
41
+ "{ "ref": "${GITHUB_REF}", "repo": "${GITHUB_REPOSITORY}" }"
42
+ EOF
43
+ )
44
+ for repo in $DEPENDENT_REPOS
45
+ do
46
+ sh trigger-gh-actions.sh $ORGANISATION $repo $GH_USERNAME $GH_ACCESS_TOKEN $GITHUB_REPOSITORY "$CLIENT_PAYLOAD"
47
+ done
@@ -0,0 +1,44 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ name: rake
4
+
5
+ on:
6
+ push:
7
+ branches: [ master ]
8
+ pull_request:
9
+
10
+ jobs:
11
+ rake:
12
+ name: Test on Ruby ${{ matrix.ruby }} ${{ matrix.os }}
13
+ runs-on: ${{ matrix.os }}
14
+ continue-on-error: ${{ matrix.experimental }}
15
+ strategy:
16
+ fail-fast: false
17
+ matrix:
18
+ ruby: [ '2.6', '2.5', '2.4' ]
19
+ os: [ ubuntu-latest, windows-latest, macos-latest ]
20
+ experimental: [ false ]
21
+ include:
22
+ - ruby: '2.7'
23
+ os: 'ubuntu-latest'
24
+ experimental: true
25
+ - ruby: '2.7'
26
+ os: 'windows-latest'
27
+ experimental: true
28
+ - ruby: '2.7'
29
+ os: 'macos-latest'
30
+ experimental: true
31
+ steps:
32
+ - uses: actions/checkout@master
33
+
34
+ - name: Use Ruby
35
+ uses: ruby/setup-ruby@v1
36
+ with:
37
+ ruby-version: ${{ matrix.ruby }}
38
+ bundler-cache: true
39
+
40
+ - name: Update gems
41
+ run: bundle install --jobs 4 --retry 3
42
+
43
+ - name: Run specs
44
+ run: bundle exec rake
@@ -12,10 +12,10 @@ module Metanorma
12
12
 
13
13
  # @return [Array<String>] documents-inline to inject the XML into
14
14
  # the collection manifest; documents-external to keeps them outside
15
- attr_reader :directives
15
+ attr_accessor :directives
16
16
 
17
17
  # @return [Hash<String, Metanorma::Document>]
18
- attr_reader :documents
18
+ attr_accessor :documents
19
19
 
20
20
  # @param file [String] path to source file
21
21
  # @param directives [Array<String>] documents-inline to inject the XML into
@@ -47,7 +47,7 @@ module Metanorma
47
47
  Nokogiri::XML::Builder.new do |xml|
48
48
  xml.send("metanorma-collection",
49
49
  "xmlns" => "http://metanorma.org") do |mc|
50
- @bibdata.to_xml mc, bibdata: true, date_format: :full
50
+ mc << @bibdata.to_xml(bibdata: true, date_format: :full)
51
51
  @manifest.to_xml mc
52
52
  content_to_xml "prefatory", mc
53
53
  doccontainer mc
@@ -49,9 +49,32 @@ module Metanorma
49
49
  folder = File.dirname col.file
50
50
  cr = new(col.to_xml, folder, options)
51
51
  cr.files
52
+ cr.concatenate(col, options)
52
53
  cr.coverpage if options[:format]&.include?(:html)
53
54
  end
54
55
 
56
+ def concatenate(col, options)
57
+ options[:format] << :presentation if options[:format].include?(:pdf)
58
+ options[:format].uniq.each do |e|
59
+ next unless %i(presentation xml).include?(e)
60
+ ext = e == :presentation ? "presentation.xml" : e.to_s
61
+ out = col.clone
62
+ out.directives << "documents-inline"
63
+ out.documents.keys.each do |id|
64
+ filename = @files[id][:outputs][e]
65
+ out.documents[id] = Metanorma::Document.raw_file(filename)
66
+ end
67
+ File.open(File.join(@outdir, "collection.#{ext}"), "w:UTF-8") { |f| f.write(out.to_xml) }
68
+ end
69
+ options[:format].include?(:pdf) and
70
+ pdfconv.convert(File.join(@outdir, "collection.presentation.xml"))
71
+ end
72
+
73
+ def pdfconv
74
+ x = Asciidoctor.load nil, backend: @doctype.to_sym
75
+ x.converter.pdf_converter(Dummy.new)
76
+ end
77
+
55
78
  # Dummy class
56
79
  class Dummy
57
80
  def attr(_xyz); end
@@ -220,7 +243,7 @@ module Metanorma
220
243
  docid = bib&.at(ns("./docidentifier"))&.text
221
244
  unless @files[docid]
222
245
  warn "Cannot find crossreference to document #{docid} in document "\
223
- "#{identifier}!"
246
+ "#{identifier}!"
224
247
  abort
225
248
  end
226
249
  id = bib["id"]
@@ -288,9 +311,12 @@ module Metanorma
288
311
  # warn "metanorma compile -x html #{f.path}"
289
312
  c = Compile.new
290
313
  c.compile f.path, format: :asciidoc, extension_keys: @format
291
- @format.each do |ext|
314
+ @files[identifier][:outputs] = {}
315
+ @format.each do |e|
316
+ ext = c.processor.output_formats[e]
292
317
  fn = File.basename(filename).sub(/(?<=\.)[^\.]+$/, ext.to_s)
293
318
  FileUtils.mv f.path.sub(/\.xml$/, ".#{ext}"), File.join(@outdir, fn)
319
+ @files[identifier][:outputs][e] = File.join(@outdir, fn)
294
320
  end
295
321
  end
296
322
  end
@@ -5,7 +5,7 @@ require "htmlentities"
5
5
  module Metanorma
6
6
  class Compile
7
7
  # @return [Array<String>]
8
- attr_reader :errors
8
+ attr_reader :errors, :processor
9
9
 
10
10
  def initialize
11
11
  @registry = Metanorma::Registry.instance
@@ -4,9 +4,10 @@ module Metanorma
4
4
  attr_reader :file
5
5
 
6
6
  # @param bibitem [RelatonBib::BibliographicItem]
7
- def initialize(bibitem, file)
7
+ def initialize(bibitem, file, options = {})
8
8
  @bibitem = bibitem
9
9
  @file = file
10
+ @raw = options[:raw]
10
11
  end
11
12
 
12
13
  class << self
@@ -22,6 +23,12 @@ module Metanorma
22
23
  new from_xml(xml)
23
24
  end
24
25
 
26
+ # raw XML file, can be used to put in entire file instead of just bibitem
27
+ def raw_file(filename)
28
+ doc = Nokogiri::XML(File.read(filename, encoding: "UTF-8"))
29
+ new(doc, filename, raw: true)
30
+ end
31
+
25
32
  private
26
33
 
27
34
  # #param xml [Nokogiri::XML::Document, Nokogiri::XML::Element]
@@ -47,7 +54,7 @@ module Metanorma
47
54
  when :xml
48
55
  from_xml Nokogiri::XML(File.read(file, encoding: "UTF-8"))
49
56
  when :yaml
50
- yaml = File.read(file, ecoding: "UTF-8")
57
+ yaml = File.read(file, encoding: "UTF-8")
51
58
  Relaton::Cli::YAMLConvertor.convert_single_file(yaml)
52
59
  end
53
60
  end
@@ -68,15 +75,19 @@ module Metanorma
68
75
 
69
76
  # @return [String]
70
77
  def type
71
- @type ||= (@bibitem.docidentifier.first&.type ||
72
- @bibitem.docidentifier.first&.id&.match(/^[^\s]+/)&.to_s)&.downcase ||
73
- "standoc"
78
+ @type ||= (@bibitem.docidentifier.first&.type&.downcase ||
79
+ @bibitem.docidentifier.first&.id&.match(/^[^\s]+/)&.to_s)&.downcase ||
80
+ "standoc"
74
81
  end
75
82
 
76
83
  private
77
84
 
78
85
  def render_xml(builder)
79
- builder.send(type + "-standard") { |b| @bibitem.to_xml b, bibdata: true }
86
+ if @raw
87
+ builder << @bibitem.root.to_xml
88
+ else
89
+ builder.send(type + "-standard") { |b| b << @bibitem.to_xml(bibdata: true) }
90
+ end
80
91
  end
81
92
  end
82
93
  end
@@ -7,8 +7,7 @@ module Metanorma
7
7
 
8
8
  def process(file, filename, type, options = {})
9
9
  require "asciidoctor"
10
- ::Asciidoctor.convert(
11
- file,
10
+ out_opts = {
12
11
  to_file: false,
13
12
  safe: :safe,
14
13
  backend: type,
@@ -16,8 +15,28 @@ module Metanorma
16
15
  attributes: [
17
16
  "nodoc", "stem", "xrefstyle=short", "docfile=#{filename}",
18
17
  "output_dir=#{options[:"output-dir"]}"
19
- ],
20
- )
18
+ ]
19
+ }
20
+ unless asciidoctor_validate(file, filename, out_opts)
21
+ warn "Cannot continue compiling Asciidoctor document"
22
+ abort
23
+ end
24
+ ::Asciidoctor.convert(file, out_opts)
25
+ end
26
+
27
+ def asciidoctor_validate(file, filename, options)
28
+ err = nil
29
+ begin
30
+ previous_stderr, $stderr = $stderr, StringIO.new
31
+ ::Asciidoctor.load(file, options)
32
+ %r{(\n|^)asciidoctor: ERROR: ['"]?#{Regexp.escape(filename ||
33
+ "<empty>")}['"]?: line \d+: include file not found: }.match($stderr.string) and
34
+ err = $stderr.string
35
+ ensure
36
+ $stderr = previous_stderr
37
+ end
38
+ warn err unless err.nil?
39
+ err.nil?
21
40
  end
22
41
 
23
42
  def extract_metanorma_options(file)
@@ -4,10 +4,10 @@ require_relative "./utils.rb"
4
4
  module Metanorma
5
5
  module Output
6
6
  class XslfoPdf < Base
7
- def convert(url_path, output_path, xsl_stylesheet)
7
+ def convert(url_path, output_path, xsl_stylesheet, options = "")
8
8
  return if url_path.nil? || output_path.nil? || xsl_stylesheet.nil?
9
9
 
10
- Mn2pdf.convert(quote(url_path), quote(output_path), quote(xsl_stylesheet))
10
+ Mn2pdf.convert(quote(url_path), quote(output_path), quote(xsl_stylesheet), options)
11
11
  end
12
12
 
13
13
  def quote(x)
@@ -1,3 +1,3 @@
1
1
  module Metanorma
2
- VERSION = "1.1.3"
2
+ VERSION = "1.2.0"
3
3
  end
@@ -27,13 +27,16 @@ Gem::Specification.new do |spec|
27
27
  spec.add_runtime_dependency 'htmlentities'
28
28
  spec.add_runtime_dependency 'nokogiri'
29
29
  spec.add_runtime_dependency 'mn2pdf', "~> 1"
30
- spec.add_dependency "relaton-cli", "~> 1.2.0"
30
+ # get relaton-cli to avoic circular reference with metanorma-standoc
31
+ #spec.add_dependency "relaton-cli"
32
+ #spec.add_dependency "metanorma-standoc", "~> 1.5.3"
31
33
 
32
34
  spec.add_development_dependency "rake", "~> 12.0"
33
35
  spec.add_development_dependency "rspec", "~> 3.0"
34
36
  spec.add_development_dependency "byebug", "~> 10.0"
35
37
  spec.add_development_dependency "rspec-command", "~> 1.0"
36
38
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
37
- spec.add_development_dependency "metanorma-iso", "~> 1.5"
38
- spec.add_development_dependency "isodoc", "~> 1.2.1"
39
+ spec.add_development_dependency "metanorma-iso", "~> 1.5.8"
40
+ spec.add_development_dependency "sassc", "~> 2.4.0"
41
+ #spec.add_development_dependency "isodoc", "~> 1.2.1"
39
42
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-14 00:00:00.000000000 Z
11
+ date: 2020-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -66,20 +66,6 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1'
69
- - !ruby/object:Gem::Dependency
70
- name: relaton-cli
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: 1.2.0
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: 1.2.0
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: rake
85
71
  requirement: !ruby/object:Gem::Requirement
@@ -156,28 +142,28 @@ dependencies:
156
142
  requirements:
157
143
  - - "~>"
158
144
  - !ruby/object:Gem::Version
159
- version: '1.5'
145
+ version: 1.5.8
160
146
  type: :development
161
147
  prerelease: false
162
148
  version_requirements: !ruby/object:Gem::Requirement
163
149
  requirements:
164
150
  - - "~>"
165
151
  - !ruby/object:Gem::Version
166
- version: '1.5'
152
+ version: 1.5.8
167
153
  - !ruby/object:Gem::Dependency
168
- name: isodoc
154
+ name: sassc
169
155
  requirement: !ruby/object:Gem::Requirement
170
156
  requirements:
171
157
  - - "~>"
172
158
  - !ruby/object:Gem::Version
173
- version: 1.2.1
159
+ version: 2.4.0
174
160
  type: :development
175
161
  prerelease: false
176
162
  version_requirements: !ruby/object:Gem::Requirement
177
163
  requirements:
178
164
  - - "~>"
179
165
  - !ruby/object:Gem::Version
180
- version: 1.2.1
166
+ version: 2.4.0
181
167
  description: Library to process any Metanorma standard.
182
168
  email:
183
169
  - open.source@ribose.com
@@ -189,9 +175,8 @@ extra_rdoc_files:
189
175
  - LICENSE.txt
190
176
  files:
191
177
  - ".github/workflows/dependent_repos.env"
192
- - ".github/workflows/macos.yml"
193
- - ".github/workflows/ubuntu.yml"
194
- - ".github/workflows/windows.yml"
178
+ - ".github/workflows/notify.yml"
179
+ - ".github/workflows/rake.yml"
195
180
  - ".gitignore"
196
181
  - ".hound.yml"
197
182
  - ".rspec"
@@ -1,38 +0,0 @@
1
- # Auto-generated by Cimas: Do not edit it manually!
2
- # See https://github.com/metanorma/cimas
3
- name: macos
4
-
5
- on:
6
- push:
7
- branches: [ master ]
8
- pull_request:
9
- paths-ignore:
10
- - .github/workflows/ubuntu.yml
11
- - .github/workflows/windows.yml
12
-
13
- jobs:
14
- test-macos:
15
- name: Test on Ruby ${{ matrix.ruby }} macOS
16
- runs-on: macos-latest
17
- continue-on-error: ${{ matrix.experimental }}
18
- strategy:
19
- fail-fast: false
20
- matrix:
21
- ruby: [ '2.6', '2.5', '2.4' ]
22
- experimental: [false]
23
- include:
24
- - ruby: '2.7'
25
- experimental: true
26
- steps:
27
- - uses: actions/checkout@master
28
- - name: Use Ruby
29
- uses: actions/setup-ruby@v1
30
- with:
31
- ruby-version: ${{ matrix.ruby }}
32
- - name: Update gems
33
- run: |
34
- sudo gem install bundler --force
35
- bundle install --jobs 4 --retry 3
36
- - name: Run specs
37
- run: |
38
- bundle exec rake
@@ -1,56 +0,0 @@
1
- # Auto-generated by Cimas: Do not edit it manually!
2
- # See https://github.com/metanorma/cimas
3
- name: ubuntu
4
-
5
- on:
6
- push:
7
- branches: [ master ]
8
- tags:
9
- - '*'
10
- pull_request:
11
- paths-ignore:
12
- - .github/workflows/macos.yml
13
- - .github/workflows/windows.yml
14
-
15
- jobs:
16
- test-linux:
17
- name: Test on Ruby ${{ matrix.ruby }} Ubuntu
18
- runs-on: ubuntu-latest
19
- continue-on-error: ${{ matrix.experimental }}
20
- strategy:
21
- fail-fast: false
22
- matrix:
23
- ruby: [ '2.6', '2.5', '2.4' ]
24
- experimental: [false]
25
- include:
26
- - ruby: '2.7'
27
- experimental: true
28
- steps:
29
- - uses: actions/checkout@master
30
- - name: Use Ruby
31
- uses: actions/setup-ruby@v1
32
- with:
33
- ruby-version: ${{ matrix.ruby }}
34
- - name: Update gems
35
- run: |
36
- gem install bundler
37
- bundle install --jobs 4 --retry 3
38
- - name: Run specs
39
- run: |
40
- bundle exec rake
41
- - name: Trigger repositories
42
- if: matrix.ruby == '2.6'
43
- env:
44
- GH_USERNAME: metanorma-ci
45
- GH_ACCESS_TOKEN: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
46
- run: |
47
- curl -LO --retry 3 https://raw.githubusercontent.com/metanorma/metanorma-build-scripts/master/trigger-gh-actions.sh
48
- [[ -f ".github/workflows/dependent_repos.env" ]] && source .github/workflows/dependent_repos.env
49
- CLIENT_PAYLOAD=$(cat <<EOF
50
- "{ "ref": "${GITHUB_REF}", "repo": "${GITHUB_REPOSITORY}" }"
51
- EOF
52
- )
53
- for repo in $REPOS
54
- do
55
- sh trigger-gh-actions.sh $ORGANISATION $repo $GH_USERNAME $GH_ACCESS_TOKEN $GITHUB_REPOSITORY "$CLIENT_PAYLOAD"
56
- done
@@ -1,40 +0,0 @@
1
- # Auto-generated by Cimas: Do not edit it manually!
2
- # See https://github.com/metanorma/cimas
3
- name: windows
4
-
5
- on:
6
- push:
7
- branches: [ master ]
8
- pull_request:
9
- paths-ignore:
10
- - .github/workflows/macos.yml
11
- - .github/workflows/ubuntu.yml
12
-
13
- jobs:
14
- test-windows:
15
- name: Test on Ruby ${{ matrix.ruby }} Windows
16
- runs-on: windows-latest
17
- continue-on-error: ${{ matrix.experimental }}
18
- strategy:
19
- fail-fast: false
20
- matrix:
21
- ruby: [ '2.6', '2.5', '2.4' ]
22
- experimental: [false]
23
- include:
24
- - ruby: '2.7'
25
- experimental: true
26
- steps:
27
- - uses: actions/checkout@master
28
- - name: Use Ruby
29
- uses: actions/setup-ruby@v1
30
- with:
31
- ruby-version: ${{ matrix.ruby }}
32
- - name: Update gems
33
- shell: pwsh
34
- run: |
35
- gem install bundler
36
- bundle config --local path vendor/bundle
37
- bundle install --jobs 4 --retry 3
38
- - name: Run specs
39
- run: |
40
- bundle exec rake