metanorma-mpfa 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/macos.yml +39 -0
- data/.github/workflows/ubuntu.yml +53 -0
- data/.github/workflows/windows.yml +41 -0
- data/.gitignore +1 -0
- data/.hound.yml +3 -0
- data/.rubocop.yml +10 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +11 -0
- data/LICENSE +25 -0
- data/README.adoc +79 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/manifest +146 -0
- data/bin/rspec +18 -0
- data/bin/setup +8 -0
- data/lib/asciidoctor/mpfa.rb +6 -0
- data/lib/asciidoctor/mpfa/basicdoc.rng +1059 -0
- data/lib/asciidoctor/mpfa/biblio.rng +1237 -0
- data/lib/asciidoctor/mpfa/converter.rb +113 -0
- data/lib/asciidoctor/mpfa/isodoc.rng +1504 -0
- data/lib/asciidoctor/mpfa/mpfd.rng +79 -0
- data/lib/asciidoctor/mpfa/reqt.rng +194 -0
- data/lib/asciidoctor/mpfa/section.rb +61 -0
- data/lib/asciidoctor/mpfa/validate.rb +30 -0
- data/lib/isodoc/mpfa/base_convert.rb +128 -0
- data/lib/isodoc/mpfa/html/header.html +242 -0
- data/lib/isodoc/mpfa/html/html_rsd_intro.html +8 -0
- data/lib/isodoc/mpfa/html/html_rsd_titlepage.html +58 -0
- data/lib/isodoc/mpfa/html/htmlstyle.scss +932 -0
- data/lib/isodoc/mpfa/html/logo.jpg +0 -0
- data/lib/isodoc/mpfa/html/logo.svg +1 -0
- data/lib/isodoc/mpfa/html/mpfa-logo-no-text@4x.png +0 -0
- data/lib/isodoc/mpfa/html/mpfa-logo@4x.png +0 -0
- data/lib/isodoc/mpfa/html/rsd.scss +763 -0
- data/lib/isodoc/mpfa/html/scripts.html +80 -0
- data/lib/isodoc/mpfa/html/word_rsd_intro.html +3 -0
- data/lib/isodoc/mpfa/html/word_rsd_titlepage.html +42 -0
- data/lib/isodoc/mpfa/html/wordstyle.scss +1157 -0
- data/lib/isodoc/mpfa/html_convert.rb +63 -0
- data/lib/isodoc/mpfa/i18n-en.yaml +2 -0
- data/lib/isodoc/mpfa/i18n-zh-Hans.yaml +2 -0
- data/lib/isodoc/mpfa/metadata.rb +74 -0
- data/lib/isodoc/mpfa/presentation_xml_convert.rb +10 -0
- data/lib/isodoc/mpfa/word_convert.rb +62 -0
- data/lib/isodoc/mpfa/xref.rb +102 -0
- data/lib/metanorma-mpfa.rb +11 -0
- data/lib/metanorma/mpfa.rb +7 -0
- data/lib/metanorma/mpfa/processor.rb +49 -0
- data/lib/metanorma/mpfa/version.rb +5 -0
- data/metanorma-mpfd.gemspec +46 -0
- metadata +280 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0fb2546742168abc4af81c4a1c6921b0c01c2e27fb8d52eed46cf40a20f92353
|
4
|
+
data.tar.gz: 26473b6efacf914469da737a54fab479e00e171438a3838df6f19b003082b9fc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 57b0d79d12c1ce861cb7c52c14b2257e5d1ca30a9c52f01c241ce413ce62767b63c0e4b70d7d192d6b1ed4cf81319664ce8b6c9ec6b4b28a4d64d6ecf69f44ad
|
7
|
+
data.tar.gz: 0e70bf148a47b66edc05bc372da8b77d50d6693e31b8cd2c613cb6d6615ae510327e2d5c4ca31cae3f1d3c0f44beb0f39dce64602a268b594928db29ec09f541
|
@@ -0,0 +1,39 @@
|
|
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
|
+
architecture: 'x64'
|
33
|
+
- name: Update gems
|
34
|
+
run: |
|
35
|
+
sudo gem install bundler --force
|
36
|
+
bundle install --jobs 4 --retry 3
|
37
|
+
- name: Run specs
|
38
|
+
run: |
|
39
|
+
bundle exec rake
|
@@ -0,0 +1,53 @@
|
|
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
|
+
architecture: 'x64'
|
35
|
+
- name: Update gems
|
36
|
+
run: |
|
37
|
+
gem install bundler
|
38
|
+
bundle install --jobs 4 --retry 3
|
39
|
+
- name: Run specs
|
40
|
+
run: |
|
41
|
+
bundle exec rake
|
42
|
+
- name: Trigger dependent repositories
|
43
|
+
if: github.ref == 'refs/heads/master' && matrix.ruby == '2.6'
|
44
|
+
env:
|
45
|
+
GH_USERNAME: ${{ secrets.PAT_USERNAME }}
|
46
|
+
GH_ACCESS_TOKEN: ${{ secrets.PAT_TOKEN }}
|
47
|
+
run: |
|
48
|
+
curl -LO --retry 3 https://raw.githubusercontent.com/metanorma/metanorma-build-scripts/master/trigger-gh-actions.sh
|
49
|
+
[[ -f ".github/workflows/dependent_repos.env" ]] && source .github/workflows/dependent_repos.env
|
50
|
+
for repo in $DEPENDENT_REPOS
|
51
|
+
do
|
52
|
+
sh trigger-gh-actions.sh $ORGANISATION $repo $GH_USERNAME $GH_ACCESS_TOKEN $GITHUB_REPOSITORY "{ \"ref\": \"${GITHUB_REF}\" }"
|
53
|
+
done
|
@@ -0,0 +1,41 @@
|
|
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
|
+
architecture: 'x64'
|
33
|
+
- name: Update gems
|
34
|
+
shell: pwsh
|
35
|
+
run: |
|
36
|
+
gem install bundler
|
37
|
+
bundle config --local path vendor/bundle
|
38
|
+
bundle install --jobs 4 --retry 3
|
39
|
+
- name: Run specs
|
40
|
+
run: |
|
41
|
+
bundle exec rake
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
.DS_Store
|
data/.hound.yml
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
# This project follows the Ribose OSS style guide.
|
2
|
+
# https://github.com/riboseinc/oss-guides
|
3
|
+
# All project-specific additions and overrides should be specified in this file.
|
4
|
+
|
5
|
+
inherit_from:
|
6
|
+
- https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
|
7
|
+
AllCops:
|
8
|
+
TargetRubyVersion: 2.3
|
9
|
+
Rails:
|
10
|
+
Enabled: true
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at ronald.tse@ribose.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
Encoding.default_external = Encoding::UTF_8
|
2
|
+
Encoding.default_internal = Encoding::UTF_8
|
3
|
+
|
4
|
+
source "https://rubygems.org"
|
5
|
+
git_source(:github) { |repo| "https://github.com/#{repo}" }
|
6
|
+
|
7
|
+
gemspec
|
8
|
+
|
9
|
+
if File.exist? 'Gemfile.devel'
|
10
|
+
eval File.read('Gemfile.devel'), nil, 'Gemfile.devel' # rubocop:disable Security/Eval
|
11
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
BSD 2-Clause License
|
2
|
+
|
3
|
+
Copyright (c) 2018, Ribose
|
4
|
+
All rights reserved.
|
5
|
+
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
8
|
+
|
9
|
+
* Redistributions of source code must retain the above copyright notice, this
|
10
|
+
list of conditions and the following disclaimer.
|
11
|
+
|
12
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
14
|
+
and/or other materials provided with the distribution.
|
15
|
+
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
17
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
18
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
19
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
20
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
21
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
22
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
23
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
24
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
25
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.adoc
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
= Metanorma-MPFA: Metanorma processor for MPFA documents
|
2
|
+
|
3
|
+
image:https://img.shields.io/gem/v/metanorma-mpfa.svg["Gem Version", link="https://rubygems.org/gems/metanorma-mpfa"]
|
4
|
+
image:https://github.com/metanorma/metanorma-mpfa/workflows/macos/badge.svg["Build Status (macOS)", link="https://github.com/metanorma/metanorma-mpfa/actions?workflow=macos"]
|
5
|
+
image:https://github.com/metanorma/metanorma-mpfa/workflows/ubuntu/badge.svg["Build Status (ubuntu)", link="https://github.com/metanorma/metanorma-mpfa/actions?workflow=ubuntu"]
|
6
|
+
image:https://github.com/metanorma/metanorma-mpfa/workflows/windows/badge.svg["Build Status (Windows)", link="https://github.com/metanorma/metanorma-mpfa/actions?workflow=windows"]
|
7
|
+
image:https://codeclimate.com/github/metanorma/metanorma-mpfa/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/metanorma-mpfa"]
|
8
|
+
image:https://img.shields.io/github/issues-pr-raw/metanorma/metanorma-mpfa.svg["Pull Requests", link="https://github.com/metanorma/metanorma-mpfa/pulls"]
|
9
|
+
image:https://img.shields.io/github/commits-since/metanorma/metanorma-mpfa/latest.svg["Commits since latest",link="https://github.com/metanorma/metanorma-mpfa/releases"]
|
10
|
+
|
11
|
+
_Formerly known as_ `metanorma-mpfd`.
|
12
|
+
|
13
|
+
WARNING: This gem is still under development. Moreover, unlike other Metanorma gems,
|
14
|
+
there is no formal MPFA specification, and this work is still currently exploratory.
|
15
|
+
|
16
|
+
== Functionality
|
17
|
+
|
18
|
+
This gem processes http://asciidoctor.org/[Asciidoctor] documents following
|
19
|
+
a template for generating documents for the http://www.mpfa.org.hk[Mandatory Provident Fund Schemes Authority of Hong Kong].
|
20
|
+
|
21
|
+
The gem currently inherits from the https://github.com/metanorma/metanorma-standoc
|
22
|
+
gem, and aligns closely to it. Refer to https://metanorma.com[] for guidance.
|
23
|
+
|
24
|
+
== Usage
|
25
|
+
|
26
|
+
The preferred way to invoke this gem is via the `metanorma` script:
|
27
|
+
|
28
|
+
[source,console]
|
29
|
+
----
|
30
|
+
$ metanorma --type mpfa a.adoc # output HTML and DOC
|
31
|
+
$ metanorma --type mpfa --extensions html a.adoc # output just HTML
|
32
|
+
$ metanorma --type mpfa --extensions doc a.adoc # output just DOC
|
33
|
+
$ metanorma --type mpfa --extensions xml a.adoc # output MPFA XML
|
34
|
+
----
|
35
|
+
|
36
|
+
The gem translates the document into Metanorma XML format, and then
|
37
|
+
validates its output against the MPFA Metanorma XML document model; errors are
|
38
|
+
reported to console against the XML, and are intended for users to
|
39
|
+
check that they have provided all necessary components of the
|
40
|
+
document.
|
41
|
+
|
42
|
+
The gem then converts the XML into output formats such as HTML and DOC.
|
43
|
+
|
44
|
+
Sample documents are available at https://github.com/metanorma/mn-samples-mpfa
|
45
|
+
|
46
|
+
=== Installation
|
47
|
+
|
48
|
+
If you are using a Mac, the https://github.com/metanorma/metanorma-macos-setup
|
49
|
+
repository has instructions on setting up your machine to run Metanorma
|
50
|
+
scripts such as this one. You need only run the following in a Terminal console:
|
51
|
+
|
52
|
+
[source,console]
|
53
|
+
----
|
54
|
+
$ bash <(curl -s https://raw.githubusercontent.com/metanorma/metanorma-macos-setup/master/metanorma-setup)
|
55
|
+
$ gem install metanorma-mpfa
|
56
|
+
$ gem install metanorma-cli
|
57
|
+
----
|
58
|
+
|
59
|
+
The metanorma-cli gem is the command-line interface for the Metanorma tool suite
|
60
|
+
(incorporating the `metanorma` executable seen above).
|
61
|
+
|
62
|
+
== Documentation
|
63
|
+
|
64
|
+
See https://www.metanorma.com/author/mpfa/[The MPFA flavor of Metanorma]
|
65
|
+
|
66
|
+
|
67
|
+
== Data Models
|
68
|
+
|
69
|
+
The MPFA Document format is an instance of the
|
70
|
+
https://github.com/metanorma/metanorma-model-standoc[StandardDocument model]. Details of
|
71
|
+
this general model can be found on its page.
|
72
|
+
|
73
|
+
== Examples
|
74
|
+
|
75
|
+
* Example documents are avalable at the https://github.com/metanorma/mn-samples-mpfa[MPFA Samples] repository.
|
76
|
+
|
77
|
+
////
|
78
|
+
* Document templates are available at the https://github.com/metanorma/mn-templates-mpf[mn-templates-mpf] repository.
|
79
|
+
/////
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "asciidoctor/rsd"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/manifest
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "yaml"
|
4
|
+
require "optparse"
|
5
|
+
require "metanorma"
|
6
|
+
require "uuidtools"
|
7
|
+
|
8
|
+
registry = Metanorma::Registry.instance
|
9
|
+
supported_gem_paths = [
|
10
|
+
"asciidoctor-rfc",
|
11
|
+
"metanorma-iso",
|
12
|
+
"metanorma-gb",
|
13
|
+
"metanorma-csd",
|
14
|
+
"metanorma-csand",
|
15
|
+
"metanorma-m3d",
|
16
|
+
"metanorma-rsd",
|
17
|
+
"metanorma-acme",
|
18
|
+
"metanorma-standoc",
|
19
|
+
]
|
20
|
+
|
21
|
+
puts "[metanorma] detecting backends:"
|
22
|
+
supported_gem_paths.each do |backend|
|
23
|
+
begin
|
24
|
+
puts backend
|
25
|
+
require backend
|
26
|
+
rescue LoadError
|
27
|
+
puts "[metanorma] backend #{backend} not present"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
puts
|
31
|
+
|
32
|
+
def uuid()
|
33
|
+
UUIDTools::UUID.random_create
|
34
|
+
end
|
35
|
+
|
36
|
+
def extract_documents(m)
|
37
|
+
return [] unless m and m["sections"]
|
38
|
+
ret = []
|
39
|
+
m["sections"].each do |s|
|
40
|
+
ret << s if s["file"]
|
41
|
+
ret << extract_documents(s) if s["sections"]
|
42
|
+
end
|
43
|
+
ret.flatten
|
44
|
+
end
|
45
|
+
|
46
|
+
def hyperlink(link)
|
47
|
+
return unless link
|
48
|
+
link.sub(/\.adoc(?=$|#)/, ".html")
|
49
|
+
end
|
50
|
+
|
51
|
+
def iterate(sections)
|
52
|
+
return "" unless sections
|
53
|
+
ret = ""
|
54
|
+
Array(sections).each do |m|
|
55
|
+
ret+= "<clause id='#{uuid}'>\n"
|
56
|
+
title = m["title"] && m["number"] ? "#{m['number']}. #{m['title']}" : ( m["number"] || m["title"] || "—" )
|
57
|
+
file = hyperlink(m["file"])
|
58
|
+
title = "<link target='#{file}'>#{title}</link>" if file
|
59
|
+
ret+= "<title>#{title}</title>\n"
|
60
|
+
ret+= "<p>#{m['description']}</p>\n" if m["description"]
|
61
|
+
ret+= "<p align='right'>#{m['revdate']}</p>\n" if m["revdate"]
|
62
|
+
ret += iterate(m["sections"])
|
63
|
+
ret+= "</clause>\n"
|
64
|
+
end
|
65
|
+
ret
|
66
|
+
end
|
67
|
+
|
68
|
+
options = {}
|
69
|
+
opt_parser = OptionParser.new do |opts|
|
70
|
+
opts.banner += " <file>"
|
71
|
+
opts.on(
|
72
|
+
'-t',
|
73
|
+
'--type TYPE',
|
74
|
+
"Type of standard to generate"
|
75
|
+
) { |v| options[:type] = v.to_sym }
|
76
|
+
|
77
|
+
opts.on(
|
78
|
+
'-r',
|
79
|
+
'--require LIBRARY',
|
80
|
+
'Require LIBRARY prior to execution'
|
81
|
+
) { |v|
|
82
|
+
options[:require] ||= []
|
83
|
+
options[:require] << v
|
84
|
+
}
|
85
|
+
|
86
|
+
|
87
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
88
|
+
puts opts
|
89
|
+
exit
|
90
|
+
end
|
91
|
+
end
|
92
|
+
opt_parser.parse!(ARGV)
|
93
|
+
options[:filename] = ARGV.pop
|
94
|
+
|
95
|
+
if options[:require]
|
96
|
+
options[:require].each do |r|
|
97
|
+
require r
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
|
102
|
+
manifest = YAML.load_file(ARGV.pop)
|
103
|
+
|
104
|
+
documents = extract_documents(manifest)
|
105
|
+
|
106
|
+
# TODO real lookup of namespaces and root elements
|
107
|
+
|
108
|
+
out = <<~END
|
109
|
+
<#{options[:type]}-standard xmlns="http://riboseinc.com/isoxml">
|
110
|
+
<bibdata type="standard">
|
111
|
+
<title>#{manifest["title"]}</title>
|
112
|
+
END
|
113
|
+
|
114
|
+
# TODO leave in anchor references?
|
115
|
+
#
|
116
|
+
documents.each do |d|
|
117
|
+
out += <<~END
|
118
|
+
<relation type="partOf">
|
119
|
+
<bibdata type="standard">
|
120
|
+
<title>#{d['title']}</title>
|
121
|
+
<docidentifier>#{d['number']}</docidentifier>
|
122
|
+
<abstract>#{d['description']}</abstract>
|
123
|
+
</bibdata>
|
124
|
+
</relation>
|
125
|
+
END
|
126
|
+
end
|
127
|
+
|
128
|
+
out += <<~END
|
129
|
+
</bibdata>
|
130
|
+
<sections>
|
131
|
+
END
|
132
|
+
|
133
|
+
out+=iterate(manifest["sections"])
|
134
|
+
|
135
|
+
out+= <<~END
|
136
|
+
</sections>
|
137
|
+
<#{options[:type]}-standard>
|
138
|
+
END
|
139
|
+
outfilename = options[:filename].sub(/\.[^.]+$/, ".xml")
|
140
|
+
File.open(outfilename, "w") { |f| f.write out }
|
141
|
+
|
142
|
+
processor = registry.find_processor(options[:type].to_sym)
|
143
|
+
ext = :html
|
144
|
+
file_extension = "html" || processor.output_formats[ext]
|
145
|
+
outfilename = options[:filename].sub(/\.[^.]+$/, ".#{file_extension}")
|
146
|
+
processor.output(out, outfilename, ext, {suppressheadingnumbers: true})
|