metanorma-tools 0.1.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 +7 -0
- data/.github/workflows/rake.yml +15 -0
- data/.github/workflows/release.yml +24 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.rubocop.yml +14 -0
- data/CODE_OF_CONDUCT.md +132 -0
- data/Gemfile +11 -0
- data/README.adoc +94 -0
- data/Rakefile +8 -0
- data/docs/figure-extraction.adoc +111 -0
- data/docs/iso-drg-filename-guidance.adoc +584 -0
- data/docs/workflows-iso.adoc +70 -0
- data/exe/metanorma-tools +6 -0
- data/lib/metanorma/tools/cli.rb +79 -0
- data/lib/metanorma/tools/commands/extract_images.rb +25 -0
- data/lib/metanorma/tools/commands.rb +8 -0
- data/lib/metanorma/tools/document_metadata.rb +40 -0
- data/lib/metanorma/tools/figure.rb +124 -0
- data/lib/metanorma/tools/figure_extractor.rb +384 -0
- data/lib/metanorma/tools/iso_graphic_filename.rb +149 -0
- data/lib/metanorma/tools/version.rb +7 -0
- data/lib/metanorma/tools.rb +18 -0
- data/metanorma-tools.gemspec +37 -0
- data/sig/metanorma/tools.rbs +6 -0
- data/spec/fixtures/document-en.dis.presentation.xml +3417 -0
- data/spec/metanorma/tools/cli_spec.rb +102 -0
- data/spec/metanorma/tools/document_metadata_spec.rb +308 -0
- data/spec/metanorma/tools/figure_extractor_spec.rb +265 -0
- data/spec/metanorma/tools/iso_graphic_filename_spec.rb +316 -0
- data/spec/metanorma/tools_spec.rb +15 -0
- data/spec/spec_helper.rb +16 -0
- metadata +148 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 76e3a5e6d7264d8ef41b974de472562d470df5ae00c3d5c02c7e1ba4cbc13da9
|
4
|
+
data.tar.gz: 34cdac2a1177adc3a5abec9c8032df6fd7ce61564c8a222e5c9e0119ae769457
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 737e212afb0c25293f4f1d3886c39d882cc88f5bd25ecb83dec13b0884664667c6fb05952fc339aab487bc22bd05650be1777de2a28d2f718c483af119510a21
|
7
|
+
data.tar.gz: a0aa96f957e218d682a2e5827f7608359618243e7218fbe82bb2359eec1066d70a7102333254ff28de32fc9f469b0569728f1ab2b72c6379a6409eee77740de8
|
@@ -0,0 +1,15 @@
|
|
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, main ]
|
8
|
+
tags: [ v* ]
|
9
|
+
pull_request:
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
rake:
|
13
|
+
uses: metanorma/ci/.github/workflows/generic-rake.yml@main
|
14
|
+
secrets:
|
15
|
+
pat_token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# Auto-generated by Cimas: Do not edit it manually!
|
2
|
+
# See https://github.com/metanorma/cimas
|
3
|
+
name: release
|
4
|
+
|
5
|
+
on:
|
6
|
+
workflow_dispatch:
|
7
|
+
inputs:
|
8
|
+
next_version:
|
9
|
+
description: |
|
10
|
+
Next release version. Possible values: x.y.z, major, minor, patch (or pre|rc|etc).
|
11
|
+
Also, you can pass 'skip' to skip 'git tag' and do 'gem push' for the current version
|
12
|
+
required: true
|
13
|
+
default: 'skip'
|
14
|
+
repository_dispatch:
|
15
|
+
types: [ do-release ]
|
16
|
+
|
17
|
+
jobs:
|
18
|
+
release:
|
19
|
+
uses: metanorma/ci/.github/workflows/rubygems-release.yml@main
|
20
|
+
with:
|
21
|
+
next_version: ${{ github.event.inputs.next_version }}
|
22
|
+
secrets:
|
23
|
+
rubygems-api-key: ${{ secrets.METANORMA_CI_RUBYGEMS_API_KEY }}
|
24
|
+
pat_token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
inherit_from:
|
2
|
+
- https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
|
3
|
+
- .rubocop_todo.yml
|
4
|
+
|
5
|
+
plugins:
|
6
|
+
- rubocop-performance
|
7
|
+
- rubocop-rake
|
8
|
+
- rubocop-rspec
|
9
|
+
|
10
|
+
AllCops:
|
11
|
+
TargetRubyVersion: 3.0
|
12
|
+
NewCops: enable
|
13
|
+
Exclude:
|
14
|
+
- 'vendor/**/*'
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our
|
6
|
+
community a harassment-free experience for everyone, regardless of age, body
|
7
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
8
|
+
identity and expression, level of experience, education, socio-economic status,
|
9
|
+
nationality, personal appearance, race, caste, color, religion, or sexual
|
10
|
+
identity and orientation.
|
11
|
+
|
12
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
13
|
+
diverse, inclusive, and healthy community.
|
14
|
+
|
15
|
+
## Our Standards
|
16
|
+
|
17
|
+
Examples of behavior that contributes to a positive environment for our
|
18
|
+
community include:
|
19
|
+
|
20
|
+
* Demonstrating empathy and kindness toward other people
|
21
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
22
|
+
* Giving and gracefully accepting constructive feedback
|
23
|
+
* Accepting responsibility and apologizing to those affected by our mistakes,
|
24
|
+
and learning from the experience
|
25
|
+
* Focusing on what is best not just for us as individuals, but for the overall
|
26
|
+
community
|
27
|
+
|
28
|
+
Examples of unacceptable behavior include:
|
29
|
+
|
30
|
+
* The use of sexualized language or imagery, and sexual attention or advances of
|
31
|
+
any kind
|
32
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
33
|
+
* Public or private harassment
|
34
|
+
* Publishing others' private information, such as a physical or email address,
|
35
|
+
without their explicit permission
|
36
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
37
|
+
professional setting
|
38
|
+
|
39
|
+
## Enforcement Responsibilities
|
40
|
+
|
41
|
+
Community leaders are responsible for clarifying and enforcing our standards of
|
42
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
43
|
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
44
|
+
or harmful.
|
45
|
+
|
46
|
+
Community leaders have the right and responsibility to remove, edit, or reject
|
47
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
48
|
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
49
|
+
decisions when appropriate.
|
50
|
+
|
51
|
+
## Scope
|
52
|
+
|
53
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
54
|
+
an individual is officially representing the community in public spaces.
|
55
|
+
Examples of representing our community include using an official email address,
|
56
|
+
posting via an official social media account, or acting as an appointed
|
57
|
+
representative at an online or offline event.
|
58
|
+
|
59
|
+
## Enforcement
|
60
|
+
|
61
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
62
|
+
reported to the community leaders responsible for enforcement at
|
63
|
+
[INSERT CONTACT METHOD].
|
64
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
65
|
+
|
66
|
+
All community leaders are obligated to respect the privacy and security of the
|
67
|
+
reporter of any incident.
|
68
|
+
|
69
|
+
## Enforcement Guidelines
|
70
|
+
|
71
|
+
Community leaders will follow these Community Impact Guidelines in determining
|
72
|
+
the consequences for any action they deem in violation of this Code of Conduct:
|
73
|
+
|
74
|
+
### 1. Correction
|
75
|
+
|
76
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
77
|
+
unprofessional or unwelcome in the community.
|
78
|
+
|
79
|
+
**Consequence**: A private, written warning from community leaders, providing
|
80
|
+
clarity around the nature of the violation and an explanation of why the
|
81
|
+
behavior was inappropriate. A public apology may be requested.
|
82
|
+
|
83
|
+
### 2. Warning
|
84
|
+
|
85
|
+
**Community Impact**: A violation through a single incident or series of
|
86
|
+
actions.
|
87
|
+
|
88
|
+
**Consequence**: A warning with consequences for continued behavior. No
|
89
|
+
interaction with the people involved, including unsolicited interaction with
|
90
|
+
those enforcing the Code of Conduct, for a specified period of time. This
|
91
|
+
includes avoiding interactions in community spaces as well as external channels
|
92
|
+
like social media. Violating these terms may lead to a temporary or permanent
|
93
|
+
ban.
|
94
|
+
|
95
|
+
### 3. Temporary Ban
|
96
|
+
|
97
|
+
**Community Impact**: A serious violation of community standards, including
|
98
|
+
sustained inappropriate behavior.
|
99
|
+
|
100
|
+
**Consequence**: A temporary ban from any sort of interaction or public
|
101
|
+
communication with the community for a specified period of time. No public or
|
102
|
+
private interaction with the people involved, including unsolicited interaction
|
103
|
+
with those enforcing the Code of Conduct, is allowed during this period.
|
104
|
+
Violating these terms may lead to a permanent ban.
|
105
|
+
|
106
|
+
### 4. Permanent Ban
|
107
|
+
|
108
|
+
**Community Impact**: Demonstrating a pattern of violation of community
|
109
|
+
standards, including sustained inappropriate behavior, harassment of an
|
110
|
+
individual, or aggression toward or disparagement of classes of individuals.
|
111
|
+
|
112
|
+
**Consequence**: A permanent ban from any sort of public interaction within the
|
113
|
+
community.
|
114
|
+
|
115
|
+
## Attribution
|
116
|
+
|
117
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
118
|
+
version 2.1, available at
|
119
|
+
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
120
|
+
|
121
|
+
Community Impact Guidelines were inspired by
|
122
|
+
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
123
|
+
|
124
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
125
|
+
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
|
126
|
+
[https://www.contributor-covenant.org/translations][translations].
|
127
|
+
|
128
|
+
[homepage]: https://www.contributor-covenant.org
|
129
|
+
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
130
|
+
[Mozilla CoC]: https://github.com/mozilla/diversity
|
131
|
+
[FAQ]: https://www.contributor-covenant.org/faq
|
132
|
+
[translations]: https://www.contributor-covenant.org/translations
|
data/Gemfile
ADDED
data/README.adoc
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
= Metanorma Tools
|
2
|
+
|
3
|
+
image:https://img.shields.io/gem/v/metanorma-tools.svg["Gem Version", link="https://rubygems.org/gems/metanorma-tools"]
|
4
|
+
image:https://github.com/metanorma/metanorma-tools/actions/workflows/rake.yml/badge.svg["Windows Build Status", link="https://github.com/metanorma/metanorma-tools/actions/workflows/rake.yml"]
|
5
|
+
image:https://img.shields.io/github/issues-pr-raw/metanorma/metanorma-tools.svg["Pull Requests", link="https://github.com/metanorma/metanorma-tools/pulls"]
|
6
|
+
image:https://img.shields.io/github/commits-since/metanorma/metanorma-tools/latest.svg["Commits since latest",link="https://github.com/metanorma/metanorma-tools/releases"]
|
7
|
+
|
8
|
+
== Purpose
|
9
|
+
|
10
|
+
Metanorma Tools is a command-line interface that supports the standards
|
11
|
+
development lifecycle for various SDOs (Standards Development Organizations) to
|
12
|
+
facilitate the production, packaging and delivery of Metanorma documents.
|
13
|
+
|
14
|
+
The post-compilation steps work on Metanorma Presentation XML output
|
15
|
+
(`*.presentation.xml`).
|
16
|
+
|
17
|
+
|
18
|
+
== Features
|
19
|
+
|
20
|
+
The gem provides workflow tools for:
|
21
|
+
|
22
|
+
ISO (International Organization for Standardization)::
|
23
|
+
|
24
|
+
** link:docs/figure-extraction.adoc[ISO figure package]: export images with ISO
|
25
|
+
DRG compliant filenames into a package from Metanorma PXML
|
26
|
+
|
27
|
+
** Comment management for ISO comment sheets (planned - integrating `commenter` gem functionality)
|
28
|
+
|
29
|
+
** GitHub comment management integration for collaborative review processes (planned)
|
30
|
+
** Pre-production fetch of ISO documents from the OBP into Metanorma documents (planned)
|
31
|
+
|
32
|
+
* [other SDOs when needed...]
|
33
|
+
|
34
|
+
|
35
|
+
== Installation
|
36
|
+
|
37
|
+
Add this line to your application's Gemfile:
|
38
|
+
|
39
|
+
[source,ruby]
|
40
|
+
----
|
41
|
+
gem 'metanorma-tools'
|
42
|
+
----
|
43
|
+
|
44
|
+
And then execute:
|
45
|
+
|
46
|
+
[source,shell]
|
47
|
+
----
|
48
|
+
$ bundle install
|
49
|
+
----
|
50
|
+
|
51
|
+
Or install it yourself as:
|
52
|
+
|
53
|
+
[source,shell]
|
54
|
+
----
|
55
|
+
$ gem install metanorma-tools
|
56
|
+
----
|
57
|
+
|
58
|
+
|
59
|
+
== Usage
|
60
|
+
|
61
|
+
See the documentation for individual tools:
|
62
|
+
|
63
|
+
* link:docs/figure-extraction.adoc[Figure extraction] - Extract embedded
|
64
|
+
figures from Metanorma presentation XML files
|
65
|
+
|
66
|
+
ISO workflows:
|
67
|
+
|
68
|
+
* link:docs/workflows-iso.adoc[ISO workflows and best practices]
|
69
|
+
* link:docs/iso-drg-filename-guidance.adoc[ISO DRG filename guidance]
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
== Development notes
|
74
|
+
|
75
|
+
The `spec/fixtures/document-en.dis.presentation.xml` file contains sample
|
76
|
+
Metanorma XML for testing purposes from the
|
77
|
+
https://github.com/metanorma/mn-samples-iso[mn-samples-iso repository].
|
78
|
+
|
79
|
+
== Dependencies
|
80
|
+
|
81
|
+
* `lutaml-model`: For structured data modeling
|
82
|
+
* `nokogiri`: For XML parsing
|
83
|
+
* `rubyzip`: For ZIP archive creation
|
84
|
+
* `thor`: For command-line interface
|
85
|
+
|
86
|
+
== Copyright
|
87
|
+
|
88
|
+
This gem is developed, maintained and funded by
|
89
|
+
https://www.ribose.com[Ribose Inc.]
|
90
|
+
|
91
|
+
== License
|
92
|
+
|
93
|
+
The gem is available as open source under the terms of the
|
94
|
+
https://opensource.org/licenses/BSD-2-Clause[2-Clause BSD License].
|
data/Rakefile
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
= Figure extraction
|
2
|
+
|
3
|
+
== Overview
|
4
|
+
|
5
|
+
The figure extraction tool extracts embedded figures from Metanorma presentation
|
6
|
+
XML files.
|
7
|
+
|
8
|
+
The filenames are generated according to the extended
|
9
|
+
link:docs/iso-drg-filename-guidance.adoc[ISO DRG guidelines].
|
10
|
+
|
11
|
+
|
12
|
+
== How it works
|
13
|
+
|
14
|
+
* The input Metanorma presentation XML file is parsed to identify embedded
|
15
|
+
figures and obtain metadata needed for the naming.
|
16
|
+
|
17
|
+
* Each figure is extracted and saved according to the specified output format
|
18
|
+
and naming conventions.
|
19
|
+
|
20
|
+
|
21
|
+
== Usage
|
22
|
+
|
23
|
+
=== Command
|
24
|
+
|
25
|
+
Extract figures from a Metanorma presentation XML file:
|
26
|
+
|
27
|
+
[source,bash]
|
28
|
+
----
|
29
|
+
metanorma-tools extract-images document.presentation.xml
|
30
|
+
----
|
31
|
+
|
32
|
+
When no options are provided, the files will be named according to ISO DRG guidelines.
|
33
|
+
|
34
|
+
This generates filenames like:
|
35
|
+
|
36
|
+
* `19135-1_ed1fig1.svg`
|
37
|
+
|
38
|
+
`-o, --output-dir DIR`::
|
39
|
+
Output directory for extracted figures (default: under current directory). By
|
40
|
+
default named using the "document portion" of the DRG filename pattern as the
|
41
|
+
output directory name.
|
42
|
+
+
|
43
|
+
[example]
|
44
|
+
====
|
45
|
+
`19135-1_ed1/{image_filenames}`
|
46
|
+
====
|
47
|
+
|
48
|
+
`--prefix PREFIX`::
|
49
|
+
Filename prefix for extracted figures
|
50
|
+
+
|
51
|
+
[example]
|
52
|
+
====
|
53
|
+
`{prefix}_fig1.svg`
|
54
|
+
====
|
55
|
+
|
56
|
+
`--zip`::
|
57
|
+
Create ZIP archive of extracted figures. By default named using the "document
|
58
|
+
portion" of the DRG filename pattern.
|
59
|
+
+
|
60
|
+
[example]
|
61
|
+
====
|
62
|
+
`19135-1_ed1.zip`
|
63
|
+
====
|
64
|
+
|
65
|
+
`--retain-original-filenames`::
|
66
|
+
Keep original filenames from source document. The Metanorma XML
|
67
|
+
presentation format allows for embedded figures to retain their original
|
68
|
+
filenames, which can be useful for versioning and tracking changes.
|
69
|
+
+
|
70
|
+
[example]
|
71
|
+
====
|
72
|
+
`80000-2_ed2fig2_originalname.png`
|
73
|
+
====
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
A custom prefix can be specified to follow a specific naming convention (that is
|
78
|
+
different from the ISO DRG style).
|
79
|
+
|
80
|
+
[source,bash]
|
81
|
+
----
|
82
|
+
metanorma-tools extract-images document.presentation.xml \
|
83
|
+
--prefix "my_prefix" \
|
84
|
+
--output-dir figures
|
85
|
+
----
|
86
|
+
|
87
|
+
[example]
|
88
|
+
====
|
89
|
+
`figures/my_prefixfig2_originalname.png`
|
90
|
+
====
|
91
|
+
|
92
|
+
|
93
|
+
To create a figure submission package, use the following command:
|
94
|
+
|
95
|
+
[source,bash]
|
96
|
+
----
|
97
|
+
metanorma-tools extract-images document.presentation.xml \
|
98
|
+
--zip \
|
99
|
+
--output-dir submission-figures
|
100
|
+
----
|
101
|
+
|
102
|
+
[example]
|
103
|
+
====
|
104
|
+
`submission-figures.zip`
|
105
|
+
====
|
106
|
+
|
107
|
+
|
108
|
+
== See also
|
109
|
+
|
110
|
+
* link:iso-drg-filename-guidance.adoc[ISO DRG filename guidance]
|
111
|
+
* link:workflows-iso.adoc[ISO workflows and best practices]
|