commenter 0.2.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 117378c9e464895bd51cb22c7b17e8793c256923b5985a88e0f1f6baa3d317b9
4
+ data.tar.gz: 97ccf63eb89b9f2e91c1620801ed9c297af6ccf62c78bcd60400916389491f85
5
+ SHA512:
6
+ metadata.gz: 9ee87e7b5aa0e5d4129d3466fd4d322820fbcd5436a63d498ce39f9fa1a58dea3cd0c3967a74117c3e30573a0f3c778d5b80fd39351f4bbb851fc2fb43f76519
7
+ data.tar.gz: 7beffdc600b9305eb1ced613ed81e62d4feecd15e44a118727ab50c89a8089f7477e3b30e5a8db9f70c106a5b10484bbcfacdf4a66c009b7b7d2e68ebef01e0d
@@ -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,25 @@
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 }}
25
+
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,8 @@
1
+ AllCops:
2
+ TargetRubyVersion: 3.0
3
+
4
+ Style/StringLiterals:
5
+ EnforcedStyle: double_quotes
6
+
7
+ Style/StringLiteralsInInterpolation:
8
+ EnforcedStyle: double_quotes
@@ -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
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in commenter.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "rubocop", "~> 1.21"
data/README.adoc ADDED
@@ -0,0 +1,284 @@
1
+ = Commenter: ISO Comment Sheet Processor
2
+
3
+ image:https://img.shields.io/gem/v/commenter.svg["Gem Version", link="https://rubygems.org/gems/commenter"]
4
+ image:https://github.com/metanorma/commenter/actions/workflows/rake.yml/badge.svg["Build Status", link="https://github.com/metanorma/commenter/actions/workflows/rake.yml"]
5
+ image:https://img.shields.io/github/issues-pr-raw/metanorma/commenter.svg["Pull Requests", link="https://github.com/metanorma/commenter/pulls"]
6
+ image:https://img.shields.io/github/commits-since/metanorma/commenter/latest.svg["Commits since latest",link="https://github.com/metanorma/commenter/releases"]
7
+
8
+ == Purpose
9
+
10
+ Commenter is a Ruby gem for working with ISO comment sheets in DOCX format.
11
+
12
+ It provides utilities for parsing, manipulating, and serializing ISO comment
13
+ data, converting between DOCX and structured YAML with schema validation.
14
+
15
+ The format is taken from:
16
+
17
+ * "ISO/IEC/CEN/CENELEC electronic balloting commenting template/version 2012-03"
18
+
19
+ This gem only supports plain text comment extraction and filling. Only use this
20
+ to handle plain text comments and resolutions.
21
+
22
+ NOTE: Mathematical formulas, images, and complex formatting are not supported
23
+ due to limitations in the underlying docx gem. Comments containing such elements
24
+ will have their text content extracted, but formatting and embedded objects will
25
+ be lost.
26
+
27
+ == Installation
28
+
29
+ Add this line to your application's Gemfile:
30
+
31
+ [source,ruby]
32
+ ----
33
+ gem 'commenter'
34
+ ----
35
+
36
+ And then execute:
37
+
38
+ [source,shell]
39
+ ----
40
+ $ bundle install
41
+ ----
42
+
43
+ Or install it yourself as:
44
+
45
+ [source,shell]
46
+ ----
47
+ $ gem install commenter
48
+ ----
49
+
50
+ == Usage
51
+
52
+ === Importing comments from DOCX
53
+
54
+ Convert an ISO comment sheet DOCX file to structured YAML:
55
+
56
+ [source,shell]
57
+ ----
58
+ $ commenter import "ISO 80000-2 review comments.docx" -o comments.yaml
59
+ ----
60
+
61
+ This will create two files:
62
+
63
+ `comments.yaml`:: The structured comment data
64
+ `schema/iso_comment_2012-03.yaml`:: The YAML schema for validation
65
+
66
+ ==== Import options
67
+
68
+ [source,shell]
69
+ ----
70
+ $ commenter import input.docx -o comments.yaml --exclude-observations --schema-dir schemas/
71
+ ----
72
+
73
+ Options:
74
+
75
+ `-o, --output FILE`:: Output YAML file (default: comments.yaml)
76
+ `-e, --exclude-observations`:: Skip the observations column
77
+ `--schema-dir DIR`:: Directory for schema file (default: schema)
78
+
79
+ ==== Metadata (extraction limitation)
80
+
81
+ WARNING: Due to a limitation in the underlying `docx` gem, metadata fields
82
+ (Date, Document, Project) from the DOCX header cannot be automatically
83
+ extracted. This is because the required functionality is not yet merged (see
84
+ https://github.com/ruby-docx/docx/pull/73[docx gem PR #73]).
85
+
86
+ The generated YAML will have empty metadata fields that you can manually
87
+ populate:
88
+
89
+ [source,yaml]
90
+ ----
91
+ # yaml-language-server: $schema=schema/iso_comment_2012-03.yaml
92
+
93
+ version: "2012-03"
94
+ date: "" # Manually add: e.g., "2023-04-25"
95
+ document: "" # Manually add: e.g., "ISO 80000-2:2019"
96
+ project: "" # Manually add: e.g., "Project name"
97
+ comments:
98
+ ----
99
+
100
+ Alternatively, you can provide metadata during import using CLI options (planned
101
+ for future release).
102
+
103
+
104
+ ==== Example YAML output
105
+
106
+ [source,yaml]
107
+ ----
108
+ # yaml-language-server: $schema=schema/iso_comment_2012-03.yaml
109
+
110
+ version: "2012-03"
111
+ date: "2023-04-25"
112
+ document: "ISO 80000-2:2019"
113
+ project: "Mathematics review"
114
+ comments:
115
+ - id: DE-001
116
+ body: DE
117
+ locality:
118
+ line_number:
119
+ clause: "_whole document"
120
+ element:
121
+ type: ge
122
+ comments: |
123
+ The document should include more examples
124
+ to clarify the implementation requirements.
125
+ proposed_change: |
126
+ Add section 4.5 with practical examples
127
+ showing typical use cases.
128
+ observations: |
129
+ Accepted. Examples will be added in the
130
+ next revision.
131
+ - id: US-002
132
+ body: US
133
+ locality:
134
+ line_number: "45"
135
+ clause: "5.2.1"
136
+ element: "Table 3"
137
+ type: te
138
+ comments: |
139
+ The values in Table 3 appear to be
140
+ inconsistent with the formula in 5.1.
141
+ proposed_change: |
142
+ Correct the values in column 2 of Table 3
143
+ to match the calculation method.
144
+ observations:
145
+ ----
146
+
147
+ === Filling DOCX templates from YAML
148
+
149
+ This gem contains a command-line utility to fill a DOCX template with comments
150
+ from a YAML file. It generates a filled comment sheet that can be used for
151
+ review and resolution tracking.
152
+
153
+ The base template is the ISO comment sheet template located at
154
+ `data/iso_comment_template_2012-03.docx`. You can also provide a custom
155
+ template file using the `--template` option.
156
+
157
+ Syntax:
158
+
159
+ [source,shell]
160
+ ----
161
+ $ commenter fill comments.yaml -o filled_comments.docx
162
+ ----
163
+
164
+ ==== Fill Options
165
+
166
+ Options:
167
+
168
+ `-o, --output FILE`:: Output DOCX file (default: filled_comments.docx)
169
+ `-t, --template FILE`:: Custom template file
170
+ `-s, --shading`:: Apply status-based cell shading (FIXME: not yet supported)
171
+
172
+ === Comment ID format
173
+
174
+ Typical comment IDs follow the pattern: `{MB/NC}-{number}` or `{MB/NC}-{org_id}-{seq_id}`
175
+
176
+ [example]
177
+ ====
178
+ * `US-001` - First comment from ANSI (US)
179
+ * `DE-01-002` - Second comment from organization 01 within DIN (DE)
180
+ * `**-001` - First comment from ISO secretariat
181
+
182
+ Where:
183
+
184
+ * `US` = ANSI (American National Standards Institute)
185
+ * `DE` = DIN (Deutsches Institut für Normung)
186
+ * `**` = ISO Secretariat
187
+ * `CC` = CalConnect
188
+ ====
189
+
190
+ === Comment Types
191
+
192
+ The comment types are defined as follows:
193
+
194
+ `ge`:: General comment
195
+ `te`:: Technical comment
196
+ `ed`:: Editorial comment
197
+
198
+ === Workflow integration
199
+
200
+ [source,mermaid]
201
+ ----
202
+ flowchart LR
203
+ A[ISO Comment Sheet DOCX] --> B[commenter import]
204
+ B --> C[YAML + Schema]
205
+ C --> D[Version Control, e.g. post to GitHub issues]
206
+ D --> E[Review Process]
207
+ E --> F[commenter fill, e.g. pull from resolved GitHub issues]
208
+ F --> G[Updated DOCX]
209
+ G --> H[ISO Secretariat]
210
+ ----
211
+
212
+ === Shading Rules
213
+
214
+ WARNING: Cell shading is not currently implemented.
215
+
216
+ The `--shading` option is accepted but will only print status information to the
217
+ console.
218
+
219
+ When the `--shading` option is used, the following status patterns would be
220
+ recognized:
221
+
222
+ |===
223
+ | Status Pattern | Intended Color | Hex Code | Example
224
+
225
+ | `accept(ed)?` | Green | #92D050 | "Accepted"
226
+ | `awm\|accept with modifications` | Olive Green | #C4D79B | "Accept with modifications"
227
+ | `noted` | Blue | #8DB4E2 | "Noted"
228
+ | `reject(ed)?` | Pink | #FF99CC | "Rejected"
229
+ | `todo` | Diagonal stripes | #D9D9D9 | "TODO: Review"
230
+
231
+ |===
232
+
233
+
234
+ == Data model
235
+
236
+ The comment structure follows this schema:
237
+
238
+ [source,yaml]
239
+ ----
240
+ version: "2012-03" # Template version
241
+ date: string | null # Comment sheet date (manually populated)
242
+ document: string | null # Document being reviewed (manually populated)
243
+ project: string | null # Project name (manually populated)
244
+ comments: # Array of comment objects
245
+ - id: string # Comment identifier
246
+ body: string # Member body abbreviation
247
+ locality: # Location information
248
+ line_number: string | null
249
+ clause: string
250
+ element: string | null
251
+ type: "ge" | "te" | "ed" # Comment type
252
+ comments: string # Comment text
253
+ proposed_change: string # Proposed solution
254
+ observations: string | null # Secretariat observations (optional)
255
+ ----
256
+
257
+
258
+ == Schema validation
259
+
260
+ Each exported YAML file includes a schema reference for IDE support:
261
+
262
+ [source,yaml]
263
+ ----
264
+ # yaml-language-server: $schema=schema/iso_comment_2012-03.yaml
265
+ ----
266
+
267
+ This enables:
268
+
269
+ * Auto-completion in VS Code and other editors
270
+ * Real-time validation
271
+ * Inline documentation
272
+
273
+
274
+ == Copyright
275
+
276
+ This gem is developed, maintained and funded by
277
+ https://www.ribose.com[Ribose Inc.]
278
+
279
+
280
+ == License
281
+
282
+ The gem is available as open source under the terms of the
283
+ https://opensource.org/licenses/BSD-2-Clause[2-Clause BSD License].
284
+
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/commenter.gemspec ADDED
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/commenter/version"
4
+
5
+ all_files_in_git = Dir.chdir(File.expand_path(__dir__)) do
6
+ `git ls-files -z`.split("\x0")
7
+ end
8
+
9
+ Gem::Specification.new do |spec|
10
+ spec.name = "commenter"
11
+ spec.version = Commenter::VERSION
12
+ spec.authors = ["Ribose"]
13
+ spec.email = ["open.source@ribose.com"]
14
+
15
+ spec.summary = "Library to work with ISO comment sheets in DOCX format."
16
+ spec.description = "Convert between ISO comment sheet DOCX and structured YAML with schema validation."
17
+ spec.homepage = "https://github.com/metanorma/commenter"
18
+ spec.license = "BSD-2-Clause"
19
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
20
+
21
+ spec.metadata["homepage_uri"] = spec.homepage
22
+ spec.metadata["source_code_uri"] = spec.homepage
23
+ spec.metadata["bug_tracker_uri"] = "#{spec.homepage}/issues"
24
+
25
+ # Specify which files should be added to the gem when it is released.
26
+ spec.files = all_files_in_git
27
+ .reject { |f| f.match(%r{\A(?:test|features|bin|\.)/}) }
28
+
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_dependency "docx", "~> 0.8"
34
+ spec.add_dependency "thor", "~> 1.0"
35
+ end