commenter 0.2.1 → 0.2.3
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 +4 -4
- data/.github/workflows/release.yml +0 -1
- data/.rubocop.yml +2 -0
- data/.rubocop_todo.yml +79 -0
- data/README.adoc +507 -18
- data/commenter.gemspec +4 -0
- data/data/github_config_sample.yaml +86 -0
- data/data/github_issue_body_template.liquid +35 -0
- data/data/github_issue_title_template.liquid +1 -0
- data/exe/commenter +1 -1
- data/lib/commenter/cli.rb +138 -2
- data/lib/commenter/comment.rb +72 -4
- data/lib/commenter/comment_sheet.rb +10 -8
- data/lib/commenter/filler.rb +74 -20
- data/lib/commenter/github_integration.rb +498 -0
- data/lib/commenter/parser.rb +10 -6
- data/lib/commenter/version.rb +1 -1
- data/lib/commenter.rb +1 -0
- data/schema/iso_comment_2012-03.yaml +38 -0
- data/spec/commenter/comment_sheet_spec.rb +193 -0
- data/spec/commenter/comment_spec.rb +220 -0
- data/spec/commenter/github_integration_spec.rb +183 -0
- data/spec/commenter_spec.rb +0 -1
- metadata +66 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 31fa0d4ee056c833d9f2b329d994e5d6151e3430426e6d4f02dfca4c670d0c18
|
|
4
|
+
data.tar.gz: b459baef384850cfa84cfb22c48212771ee57fa0e11cbd803c1db33dfb44aae2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 989ff9a26a63210438385658edaee8a0d94a35c9d80916dfefe89575ce739f9efc75bdcc372d737a955de236fdefdeaaca0be65146363dea5833ac280cc97cdb
|
|
7
|
+
data.tar.gz: 5cdcb2b0ca204b6e419d009f45eeb6dfd4867c7eb51196a04ad2499c7c64e5cb5288b85522f031a7a823e9242c3e8edec771d7c2d1bb8f5f9b079df7e86cc54b
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# This configuration was generated by
|
|
2
|
+
# `rubocop --auto-gen-config`
|
|
3
|
+
# on 2026-03-16 10:59:51 UTC using RuboCop version 1.85.1.
|
|
4
|
+
# The point is for the user to remove these configuration records
|
|
5
|
+
# one by one as the offenses are removed from the code base.
|
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
|
8
|
+
|
|
9
|
+
# Offense count: 1
|
|
10
|
+
Gemspec/RequiredRubyVersion:
|
|
11
|
+
Exclude:
|
|
12
|
+
- 'commenter.gemspec'
|
|
13
|
+
|
|
14
|
+
# Offense count: 1
|
|
15
|
+
Lint/NonLocalExitFromIterator:
|
|
16
|
+
Exclude:
|
|
17
|
+
- 'lib/commenter/filler.rb'
|
|
18
|
+
|
|
19
|
+
# Offense count: 15
|
|
20
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
|
|
21
|
+
Metrics/AbcSize:
|
|
22
|
+
Max: 78
|
|
23
|
+
|
|
24
|
+
# Offense count: 10
|
|
25
|
+
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
|
26
|
+
# AllowedMethods: refine
|
|
27
|
+
Metrics/BlockLength:
|
|
28
|
+
Max: 171
|
|
29
|
+
|
|
30
|
+
# Offense count: 5
|
|
31
|
+
# Configuration parameters: CountComments, CountAsOne.
|
|
32
|
+
Metrics/ClassLength:
|
|
33
|
+
Max: 231
|
|
34
|
+
|
|
35
|
+
# Offense count: 8
|
|
36
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns.
|
|
37
|
+
Metrics/CyclomaticComplexity:
|
|
38
|
+
Max: 22
|
|
39
|
+
|
|
40
|
+
# Offense count: 22
|
|
41
|
+
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
|
42
|
+
Metrics/MethodLength:
|
|
43
|
+
Max: 53
|
|
44
|
+
|
|
45
|
+
# Offense count: 8
|
|
46
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns.
|
|
47
|
+
Metrics/PerceivedComplexity:
|
|
48
|
+
Max: 22
|
|
49
|
+
|
|
50
|
+
# Offense count: 1
|
|
51
|
+
# Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros, UseSorbetSigs.
|
|
52
|
+
# NamePrefix: is_, has_, have_, does_
|
|
53
|
+
# ForbiddenPrefixes: is_, has_, have_, does_
|
|
54
|
+
# AllowedMethods: is_a?
|
|
55
|
+
# MethodDefinitionMacros: define_method, define_singleton_method
|
|
56
|
+
Naming/PredicatePrefix:
|
|
57
|
+
Exclude:
|
|
58
|
+
- 'spec/**/*'
|
|
59
|
+
- 'lib/commenter/comment.rb'
|
|
60
|
+
|
|
61
|
+
# Offense count: 7
|
|
62
|
+
# Configuration parameters: AllowedConstants.
|
|
63
|
+
Style/Documentation:
|
|
64
|
+
Exclude:
|
|
65
|
+
- 'spec/**/*'
|
|
66
|
+
- 'test/**/*'
|
|
67
|
+
- 'lib/commenter/cli.rb'
|
|
68
|
+
- 'lib/commenter/comment.rb'
|
|
69
|
+
- 'lib/commenter/comment_sheet.rb'
|
|
70
|
+
- 'lib/commenter/filler.rb'
|
|
71
|
+
- 'lib/commenter/github_integration.rb'
|
|
72
|
+
- 'lib/commenter/parser.rb'
|
|
73
|
+
|
|
74
|
+
# Offense count: 3
|
|
75
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
76
|
+
# Configuration parameters: AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
|
|
77
|
+
# URISchemes: http, https
|
|
78
|
+
Layout/LineLength:
|
|
79
|
+
Max: 138
|
data/README.adoc
CHANGED
|
@@ -161,13 +161,348 @@ Syntax:
|
|
|
161
161
|
$ commenter fill comments.yaml -o filled_comments.docx
|
|
162
162
|
----
|
|
163
163
|
|
|
164
|
-
==== Fill
|
|
164
|
+
==== Fill options
|
|
165
165
|
|
|
166
166
|
Options:
|
|
167
167
|
|
|
168
168
|
`-o, --output FILE`:: Output DOCX file (default: filled_comments.docx)
|
|
169
169
|
`-t, --template FILE`:: Custom template file
|
|
170
|
-
`-s, --shading`:: Apply status-based cell shading
|
|
170
|
+
`-s, --shading`:: Apply status-based cell shading
|
|
171
|
+
|
|
172
|
+
=== GitHub Integration
|
|
173
|
+
|
|
174
|
+
==== Overview
|
|
175
|
+
|
|
176
|
+
The commenter gem provides comprehensive GitHub integration for collaborative comment review and tracking. The workflow consists of two main commands:
|
|
177
|
+
|
|
178
|
+
* `github-create` - Creates GitHub issues from comments and tracks them in YAML
|
|
179
|
+
* `github-retrieve` - Retrieves final observations from closed GitHub issues
|
|
180
|
+
|
|
181
|
+
==== Creating GitHub issues from comments
|
|
182
|
+
|
|
183
|
+
===== Basic usage
|
|
184
|
+
|
|
185
|
+
[source,shell]
|
|
186
|
+
----
|
|
187
|
+
$ commenter github-create --config github_config.yaml comments.yaml
|
|
188
|
+
----
|
|
189
|
+
|
|
190
|
+
This command creates GitHub issues for each comment and automatically updates the YAML file with GitHub issue information (issue numbers, URLs, status, timestamps).
|
|
191
|
+
|
|
192
|
+
==== Configuration file
|
|
193
|
+
|
|
194
|
+
Create a GitHub configuration file to specify repository, authentication, and
|
|
195
|
+
issue settings:
|
|
196
|
+
|
|
197
|
+
[source,yaml]
|
|
198
|
+
----
|
|
199
|
+
github:
|
|
200
|
+
repository: "owner/repo-name"
|
|
201
|
+
token: "ghp_xxxxxxxxxxxx"
|
|
202
|
+
milestone:
|
|
203
|
+
name: "ISO 80000-2 DIS Review"
|
|
204
|
+
default_labels: ["comment-review", "iso-standard"]
|
|
205
|
+
stage_labels:
|
|
206
|
+
WD: ["working-draft"]
|
|
207
|
+
DIS: ["draft-international-standard"]
|
|
208
|
+
----
|
|
209
|
+
|
|
210
|
+
A sample configuration file is provided at `data/github_config_sample.yaml`.
|
|
211
|
+
|
|
212
|
+
==== Issue templates
|
|
213
|
+
|
|
214
|
+
===== General
|
|
215
|
+
|
|
216
|
+
The gem uses Liquid templates to format GitHub issue titles and bodies. Default
|
|
217
|
+
templates are provided, but you can customize them.
|
|
218
|
+
|
|
219
|
+
===== Title template variables
|
|
220
|
+
|
|
221
|
+
The title template (`data/github_issue_title_template.liquid`) supports these variables:
|
|
222
|
+
|
|
223
|
+
* `stage` - Approval stage (WD/CD/DIS/FDIS/PRF/PUB)
|
|
224
|
+
* `document` - Document identifier
|
|
225
|
+
* `comment_id` - Comment identifier
|
|
226
|
+
* `brief_summary` - Generated summary combining locality and description
|
|
227
|
+
* `body` - Member body abbreviation
|
|
228
|
+
* `type` - Comment type code
|
|
229
|
+
* `clause`, `element`, `line_number` - Location information
|
|
230
|
+
* `unique_id` - Rendered unique identifier (see <<_duplicate_detection>>)
|
|
231
|
+
|
|
232
|
+
===== Body template variables
|
|
233
|
+
|
|
234
|
+
The body template (`data/github_issue_body_template.liquid`) supports all title
|
|
235
|
+
variables plus:
|
|
236
|
+
|
|
237
|
+
* `comments` - Full comment text
|
|
238
|
+
* `proposed_change` - Proposed change text
|
|
239
|
+
* `observations` - Secretariat observations
|
|
240
|
+
* `has_observations` - Boolean for conditional rendering
|
|
241
|
+
* `has_proposed_change` - Boolean for conditional rendering
|
|
242
|
+
* `project` - Project name
|
|
243
|
+
* `date` - Comment sheet date
|
|
244
|
+
* `version` - Template version
|
|
245
|
+
* `type_full_name` - Full comment type name (General/Technical/Editorial)
|
|
246
|
+
* `locality_summary` - Formatted locality string
|
|
247
|
+
|
|
248
|
+
===== Custom templates
|
|
249
|
+
|
|
250
|
+
[example]
|
|
251
|
+
====
|
|
252
|
+
Create custom templates and reference them in your configuration:
|
|
253
|
+
|
|
254
|
+
[source,yaml]
|
|
255
|
+
----
|
|
256
|
+
github:
|
|
257
|
+
templates:
|
|
258
|
+
title: "custom_title.liquid"
|
|
259
|
+
body: "custom_body.liquid"
|
|
260
|
+
unique_id: "[{{ stage | upcase }}] {{ comment_id }}" # Optional: customize unique ID
|
|
261
|
+
----
|
|
262
|
+
====
|
|
263
|
+
|
|
264
|
+
==== Command options
|
|
265
|
+
|
|
266
|
+
* `-c, --config FILE` - GitHub configuration YAML file (required)
|
|
267
|
+
* `--stage STAGE` - Override approval stage
|
|
268
|
+
* `--milestone NAME` - Override milestone name
|
|
269
|
+
* `--assignee HANDLE` - Override assignee GitHub handle
|
|
270
|
+
* `--title-template FILE` - Custom title template
|
|
271
|
+
* `--body-template FILE` - Custom body template
|
|
272
|
+
* `--dry-run` - Preview issues without creating them
|
|
273
|
+
|
|
274
|
+
==== Examples
|
|
275
|
+
|
|
276
|
+
[example]
|
|
277
|
+
====
|
|
278
|
+
Create issues with custom stage:
|
|
279
|
+
|
|
280
|
+
[source,shell]
|
|
281
|
+
----
|
|
282
|
+
$ commenter github-create --config github_config.yaml --stage DIS comments.yaml
|
|
283
|
+
----
|
|
284
|
+
|
|
285
|
+
Preview issues before creation:
|
|
286
|
+
|
|
287
|
+
[source,shell]
|
|
288
|
+
----
|
|
289
|
+
$ commenter github-create --config github_config.yaml --dry-run comments.yaml
|
|
290
|
+
----
|
|
291
|
+
====
|
|
292
|
+
|
|
293
|
+
==== Security considerations
|
|
294
|
+
|
|
295
|
+
For security reasons, it is recommended to use the `GITHUB_TOKEN` environment
|
|
296
|
+
variable instead of storing the token in the configuration file.
|
|
297
|
+
|
|
298
|
+
[source,shell]
|
|
299
|
+
----
|
|
300
|
+
$ export GITHUB_TOKEN=ghp_xxxxxxxxxxxx
|
|
301
|
+
$ commenter github comments.yaml --config github_config.yaml
|
|
302
|
+
----
|
|
303
|
+
|
|
304
|
+
==== Duplicate detection
|
|
305
|
+
|
|
306
|
+
The gem automatically checks for existing issues to avoid duplicates. The duplicate
|
|
307
|
+
detection uses a **configurable unique identifier** that is:
|
|
308
|
+
|
|
309
|
+
. Rendered from a Liquid template
|
|
310
|
+
. Embedded in the issue title for human identification
|
|
311
|
+
. Used as the search pattern to find existing issues
|
|
312
|
+
|
|
313
|
+
This ensures that the search pattern always matches what appears in the title,
|
|
314
|
+
preventing synchronization issues.
|
|
315
|
+
|
|
316
|
+
===== Unique ID template
|
|
317
|
+
|
|
318
|
+
The unique identifier is defined by the `unique_id` template in your configuration:
|
|
319
|
+
|
|
320
|
+
[source,yaml]
|
|
321
|
+
----
|
|
322
|
+
github:
|
|
323
|
+
templates:
|
|
324
|
+
# Default: "[STAGE] COMMENT_ID"
|
|
325
|
+
unique_id: "[{{ stage | upcase }}] {{ comment_id }}"
|
|
326
|
+
----
|
|
327
|
+
|
|
328
|
+
The default renders to: `[DIS] GB-001`
|
|
329
|
+
|
|
330
|
+
===== Why stage-aware unique IDs?
|
|
331
|
+
|
|
332
|
+
ISO standards go through multiple ballot stages (WD, CD, DIS, FDIS). The same
|
|
333
|
+
comment ID (e.g., `GB-001`) appears at each stage, but represents **different
|
|
334
|
+
comments**:
|
|
335
|
+
|
|
336
|
+
| Stage | Comment ID | Unique ID | Same Issue? |
|
|
337
|
+
|-------|------------|-----------|-------------|
|
|
338
|
+
| CD | GB-001 | `[CD] GB-001` | No |
|
|
339
|
+
| DIS | GB-001 | `[DIS] GB-001` | No |
|
|
340
|
+
|
|
341
|
+
Without stage-aware unique IDs, CD `GB-001` and DIS `GB-001` would be treated as
|
|
342
|
+
duplicates, causing the DIS comment to be skipped.
|
|
343
|
+
|
|
344
|
+
===== Custom unique ID patterns
|
|
345
|
+
|
|
346
|
+
You can customize the unique ID pattern to match your title template format:
|
|
347
|
+
|
|
348
|
+
[source,yaml]
|
|
349
|
+
----
|
|
350
|
+
github:
|
|
351
|
+
templates:
|
|
352
|
+
# Different order
|
|
353
|
+
unique_id: "{{ comment_id }} [{{ stage | upcase }}]"
|
|
354
|
+
|
|
355
|
+
# With document prefix
|
|
356
|
+
unique_id: "{{ document }} - {{ comment_id }}"
|
|
357
|
+
|
|
358
|
+
# With body prefix (for multi-body projects)
|
|
359
|
+
unique_id: "{{ body }}/{{ comment_id }}"
|
|
360
|
+
|
|
361
|
+
# Single stage project (no stage needed)
|
|
362
|
+
unique_id: "{{ comment_id }}"
|
|
363
|
+
----
|
|
364
|
+
|
|
365
|
+
===== Using unique_id in templates
|
|
366
|
+
|
|
367
|
+
The `unique_id` is available as a variable in title and body templates:
|
|
368
|
+
|
|
369
|
+
[source,liquid]
|
|
370
|
+
----
|
|
371
|
+
{{ unique_id }}: {{ brief_summary }} {% if document %}({{ document }}){% endif %}
|
|
372
|
+
----
|
|
373
|
+
|
|
374
|
+
This renders to: `[DIS] GB-001: Clause 5.1 summary (ISO/DIS 2533)`
|
|
375
|
+
|
|
376
|
+
==== Retrieving observations from GitHub issues
|
|
377
|
+
|
|
378
|
+
===== Basic usage
|
|
379
|
+
|
|
380
|
+
After GitHub issues have been created and reviewed, use the `github-retrieve` command to extract final observations from closed issues:
|
|
381
|
+
|
|
382
|
+
[source,shell]
|
|
383
|
+
----
|
|
384
|
+
$ commenter github-retrieve --config github_config.yaml comments.yaml
|
|
385
|
+
----
|
|
386
|
+
|
|
387
|
+
This command:
|
|
388
|
+
|
|
389
|
+
* Reads GitHub issue information from the YAML file (no searching required)
|
|
390
|
+
* Fetches observations from closed GitHub issues only
|
|
391
|
+
* Updates the same YAML file with extracted observations
|
|
392
|
+
* Preserves all existing comment data
|
|
393
|
+
|
|
394
|
+
===== Magic comment syntax
|
|
395
|
+
|
|
396
|
+
To provide official observations in GitHub issues, use markdown blockquotes with special markers:
|
|
397
|
+
|
|
398
|
+
[source,markdown]
|
|
399
|
+
----
|
|
400
|
+
> **OBSERVATION:**
|
|
401
|
+
> Accepted. The proposed change will be included in clause 5.2.1 of the next revision.
|
|
402
|
+
> Technical details have been reviewed and approved by the working group.
|
|
403
|
+
----
|
|
404
|
+
|
|
405
|
+
Alternative shorter syntax:
|
|
406
|
+
|
|
407
|
+
[source,markdown]
|
|
408
|
+
----
|
|
409
|
+
> **COMMENTER OBSERVATION:**
|
|
410
|
+
> Noted. This will be considered for future revisions.
|
|
411
|
+
----
|
|
412
|
+
|
|
413
|
+
===== Retrieval options
|
|
414
|
+
|
|
415
|
+
* `-c, --config FILE` - GitHub configuration YAML file (required)
|
|
416
|
+
* `-o, --output FILE` - Output YAML file (default: update original)
|
|
417
|
+
* `--include-open` - Include observations from open issues (not recommended)
|
|
418
|
+
* `--dry-run` - Preview observations without updating YAML
|
|
419
|
+
|
|
420
|
+
===== Examples
|
|
421
|
+
|
|
422
|
+
[example]
|
|
423
|
+
====
|
|
424
|
+
Preview observations before updating:
|
|
425
|
+
|
|
426
|
+
[source,shell]
|
|
427
|
+
----
|
|
428
|
+
$ commenter github-retrieve --config github_config.yaml --dry-run comments.yaml
|
|
429
|
+
----
|
|
430
|
+
|
|
431
|
+
Save to new file instead of updating original:
|
|
432
|
+
|
|
433
|
+
[source,shell]
|
|
434
|
+
----
|
|
435
|
+
$ commenter github-retrieve --config github_config.yaml -o final_comments.yaml comments.yaml
|
|
436
|
+
----
|
|
437
|
+
|
|
438
|
+
Include observations from open issues:
|
|
439
|
+
|
|
440
|
+
[source,shell]
|
|
441
|
+
----
|
|
442
|
+
$ commenter github-retrieve --config github_config.yaml --include-open comments.yaml
|
|
443
|
+
----
|
|
444
|
+
====
|
|
445
|
+
|
|
446
|
+
===== Enhanced YAML structure
|
|
447
|
+
|
|
448
|
+
After using `github-create`, your YAML file will include GitHub integration information:
|
|
449
|
+
|
|
450
|
+
[source,yaml]
|
|
451
|
+
----
|
|
452
|
+
comments:
|
|
453
|
+
- id: US-001
|
|
454
|
+
body: US
|
|
455
|
+
locality:
|
|
456
|
+
clause: "5.2.1"
|
|
457
|
+
element: "Table 3"
|
|
458
|
+
type: te
|
|
459
|
+
comments: "The values in Table 3 appear inconsistent..."
|
|
460
|
+
proposed_change: "Correct the values in column 2..."
|
|
461
|
+
observations: ""
|
|
462
|
+
github:
|
|
463
|
+
issue_number: 123
|
|
464
|
+
issue_url: "https://github.com/owner/repo/issues/123"
|
|
465
|
+
status: "open"
|
|
466
|
+
created_at: "2024-01-15T10:30:00Z"
|
|
467
|
+
----
|
|
468
|
+
|
|
469
|
+
After using `github-retrieve` (when the issue is closed):
|
|
470
|
+
|
|
471
|
+
[source,yaml]
|
|
472
|
+
----
|
|
473
|
+
comments:
|
|
474
|
+
- id: US-001
|
|
475
|
+
# ... other fields unchanged ...
|
|
476
|
+
observations: "Accepted. The proposed change will be included in clause 5.2.1."
|
|
477
|
+
github:
|
|
478
|
+
issue_number: 123
|
|
479
|
+
issue_url: "https://github.com/owner/repo/issues/123"
|
|
480
|
+
status: "closed"
|
|
481
|
+
created_at: "2024-01-15T10:30:00Z"
|
|
482
|
+
updated_at: "2024-01-20T14:45:00Z"
|
|
483
|
+
----
|
|
484
|
+
|
|
485
|
+
===== Configuration for retrieval
|
|
486
|
+
|
|
487
|
+
The GitHub configuration file supports retrieval-specific settings:
|
|
488
|
+
|
|
489
|
+
[source,yaml]
|
|
490
|
+
----
|
|
491
|
+
github:
|
|
492
|
+
repository: "owner/repo-name"
|
|
493
|
+
retrieval:
|
|
494
|
+
# Magic comment markers to look for
|
|
495
|
+
observation_markers:
|
|
496
|
+
- "**OBSERVATION:**"
|
|
497
|
+
- "**COMMENTER OBSERVATION:**"
|
|
498
|
+
|
|
499
|
+
# Fallback to last comment if no magic comment found
|
|
500
|
+
fallback_to_last_comment: true
|
|
501
|
+
|
|
502
|
+
# Only retrieve from closed issues (recommended)
|
|
503
|
+
closed_issues_only: true
|
|
504
|
+
----
|
|
505
|
+
|
|
171
506
|
|
|
172
507
|
=== Comment ID format
|
|
173
508
|
|
|
@@ -187,7 +522,7 @@ Where:
|
|
|
187
522
|
* `CC` = CalConnect
|
|
188
523
|
====
|
|
189
524
|
|
|
190
|
-
=== Comment
|
|
525
|
+
=== Comment types
|
|
191
526
|
|
|
192
527
|
The comment types are defined as follows:
|
|
193
528
|
|
|
@@ -202,22 +537,20 @@ The comment types are defined as follows:
|
|
|
202
537
|
flowchart LR
|
|
203
538
|
A[ISO Comment Sheet DOCX] --> B[commenter import]
|
|
204
539
|
B --> C[YAML + Schema]
|
|
205
|
-
C --> D[
|
|
206
|
-
D --> E[
|
|
207
|
-
E --> F[
|
|
208
|
-
F --> G[
|
|
209
|
-
G --> H[
|
|
540
|
+
C --> D[commenter github-create]
|
|
541
|
+
D --> E[YAML + GitHub Info]
|
|
542
|
+
E --> F[GitHub Issues + Review Process]
|
|
543
|
+
F --> G[commenter github-retrieve]
|
|
544
|
+
G --> H[YAML + Observations]
|
|
545
|
+
H --> I[commenter fill]
|
|
546
|
+
I --> J[Final DOCX]
|
|
547
|
+
J --> K[ISO Secretariat]
|
|
210
548
|
----
|
|
211
549
|
|
|
212
|
-
=== Shading
|
|
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.
|
|
550
|
+
=== Shading rules
|
|
218
551
|
|
|
219
|
-
When the `--shading` option is used, the following status patterns
|
|
220
|
-
recognized:
|
|
552
|
+
When the `--shading` option is used, the following status patterns are
|
|
553
|
+
recognized and applied to the observations column:
|
|
221
554
|
|
|
222
555
|
|===
|
|
223
556
|
| Status Pattern | Intended Color | Hex Code | Example
|
|
@@ -252,6 +585,12 @@ comments: # Array of comment objects
|
|
|
252
585
|
comments: string # Comment text
|
|
253
586
|
proposed_change: string # Proposed solution
|
|
254
587
|
observations: string | null # Secretariat observations (optional)
|
|
588
|
+
github: # GitHub integration information (optional)
|
|
589
|
+
issue_number: integer # GitHub issue number
|
|
590
|
+
issue_url: string # GitHub issue URL
|
|
591
|
+
status: "open" | "closed" # GitHub issue status
|
|
592
|
+
created_at: string # ISO 8601 timestamp
|
|
593
|
+
updated_at: string # ISO 8601 timestamp (optional)
|
|
255
594
|
----
|
|
256
595
|
|
|
257
596
|
|
|
@@ -271,14 +610,164 @@ This enables:
|
|
|
271
610
|
* Inline documentation
|
|
272
611
|
|
|
273
612
|
|
|
613
|
+
== Development
|
|
614
|
+
|
|
615
|
+
=== Getting started
|
|
616
|
+
|
|
617
|
+
After checking out the repo, run `bin/setup` to install dependencies:
|
|
618
|
+
|
|
619
|
+
[source,shell]
|
|
620
|
+
----
|
|
621
|
+
$ git clone https://github.com/metanorma/commenter.git
|
|
622
|
+
$ cd commenter
|
|
623
|
+
$ bin/setup
|
|
624
|
+
----
|
|
625
|
+
|
|
626
|
+
Then, run `rake spec` to run the tests:
|
|
627
|
+
|
|
628
|
+
[source,shell]
|
|
629
|
+
----
|
|
630
|
+
$ bundle exec rake spec
|
|
631
|
+
----
|
|
632
|
+
|
|
633
|
+
You can also run `bin/console` for an interactive prompt that will allow you to experiment:
|
|
634
|
+
|
|
635
|
+
[source,shell]
|
|
636
|
+
----
|
|
637
|
+
$ bin/console
|
|
638
|
+
----
|
|
639
|
+
|
|
640
|
+
=== Running tests
|
|
641
|
+
|
|
642
|
+
The gem includes comprehensive test coverage for all major components:
|
|
643
|
+
|
|
644
|
+
[source,shell]
|
|
645
|
+
----
|
|
646
|
+
# Run all tests
|
|
647
|
+
$ bundle exec rspec
|
|
648
|
+
|
|
649
|
+
# Run specific test files
|
|
650
|
+
$ bundle exec rspec spec/commenter/comment_spec.rb
|
|
651
|
+
$ bundle exec rspec spec/commenter/comment_sheet_spec.rb
|
|
652
|
+
$ bundle exec rspec spec/commenter/github_integration_spec.rb
|
|
653
|
+
|
|
654
|
+
# Run tests with coverage
|
|
655
|
+
$ bundle exec rspec --format documentation
|
|
656
|
+
----
|
|
657
|
+
|
|
658
|
+
=== Testing GitHub integration
|
|
659
|
+
|
|
660
|
+
To test the GitHub integration features:
|
|
661
|
+
|
|
662
|
+
1. Create a test repository on GitHub
|
|
663
|
+
2. Generate a personal access token with appropriate permissions
|
|
664
|
+
3. Create a test configuration file:
|
|
665
|
+
|
|
666
|
+
[source,yaml]
|
|
667
|
+
----
|
|
668
|
+
github:
|
|
669
|
+
repository: "your-username/test-repo"
|
|
670
|
+
default_labels: ["test-comment"]
|
|
671
|
+
default_assignee: "your-username"
|
|
672
|
+
----
|
|
673
|
+
|
|
674
|
+
4. Test with dry-run mode first:
|
|
675
|
+
|
|
676
|
+
[source,shell]
|
|
677
|
+
----
|
|
678
|
+
$ GITHUB_TOKEN=your_token bundle exec exe/commenter github test_comments.yaml --config test_config.yaml --dry-run
|
|
679
|
+
----
|
|
680
|
+
|
|
681
|
+
NOTE: For testing template rendering and dry-run functionality without a real GitHub token, you can use a dummy token:
|
|
682
|
+
|
|
683
|
+
[source,shell]
|
|
684
|
+
----
|
|
685
|
+
$ GITHUB_TOKEN=dummy_token bundle exec exe/commenter github test_comments.yaml --config test_config.yaml --dry-run
|
|
686
|
+
----
|
|
687
|
+
|
|
688
|
+
This allows you to test the issue preview functionality, template rendering, and configuration parsing without making actual GitHub API calls.
|
|
689
|
+
|
|
690
|
+
=== Code structure
|
|
691
|
+
|
|
692
|
+
The gem is organized into several key components:
|
|
693
|
+
|
|
694
|
+
==== Core classes
|
|
695
|
+
|
|
696
|
+
`Commenter::Comment`:: Represents individual comments with locality, type, and content
|
|
697
|
+
`Commenter::CommentSheet`:: Container for multiple comments with metadata
|
|
698
|
+
`Commenter::Parser`:: Handles DOCX parsing and YAML generation
|
|
699
|
+
`Commenter::Filler`:: Fills DOCX templates with comment data
|
|
700
|
+
`Commenter::GitHubIssueCreator`:: Creates GitHub issues from comments
|
|
701
|
+
|
|
702
|
+
==== CLI interface
|
|
703
|
+
|
|
704
|
+
`Commenter::Cli`:: Thor-based command-line interface with subcommands:
|
|
705
|
+
|
|
706
|
+
** `import` - Convert DOCX to YAML
|
|
707
|
+
** `fill` - Fill DOCX template from YAML
|
|
708
|
+
** `github-create` - Create GitHub issues from comments
|
|
709
|
+
** `github-retrieve` - Retrieve observations from GitHub issues
|
|
710
|
+
|
|
711
|
+
==== Templates and configuration
|
|
712
|
+
|
|
713
|
+
* `data/iso_comment_template_2012-03.docx` - Base DOCX template
|
|
714
|
+
* `data/github_issue_title_template.liquid` - GitHub issue title template
|
|
715
|
+
* `data/github_issue_body_template.liquid` - GitHub issue body template
|
|
716
|
+
* `data/github_config_sample.yaml` - Sample GitHub configuration
|
|
717
|
+
* `schema/iso_comment_2012-03.yaml` - YAML schema for validation
|
|
718
|
+
|
|
719
|
+
=== Debugging
|
|
720
|
+
|
|
721
|
+
Enable debug output for troubleshooting:
|
|
722
|
+
|
|
723
|
+
[source,shell]
|
|
724
|
+
----
|
|
725
|
+
# Enable verbose output
|
|
726
|
+
$ bundle exec exe/commenter import input.docx --verbose
|
|
727
|
+
|
|
728
|
+
# Debug GitHub API calls
|
|
729
|
+
$ OCTOKIT_DEBUG=true bundle exec exe/commenter github comments.yaml --config config.yaml --dry-run
|
|
730
|
+
----
|
|
731
|
+
|
|
732
|
+
=== Troubleshooting
|
|
733
|
+
|
|
734
|
+
==== Common issues
|
|
735
|
+
|
|
736
|
+
**DOCX parsing errors**::
|
|
737
|
+
** Ensure the DOCX file follows the ISO comment template format
|
|
738
|
+
** Check for corrupted or password-protected files
|
|
739
|
+
** Verify table structure matches expected format
|
|
740
|
+
|
|
741
|
+
**GitHub API errors**::
|
|
742
|
+
** Verify your GitHub token has appropriate permissions
|
|
743
|
+
** Check rate limiting if making many requests
|
|
744
|
+
** Ensure repository exists and is accessible
|
|
745
|
+
|
|
746
|
+
**Template rendering errors**::
|
|
747
|
+
** Validate Liquid template syntax
|
|
748
|
+
** Check that all referenced variables are available
|
|
749
|
+
** Test templates with sample data first
|
|
750
|
+
|
|
751
|
+
**Schema validation errors**::
|
|
752
|
+
** Ensure YAML follows the required structure
|
|
753
|
+
** Check for missing required fields
|
|
754
|
+
** Validate comment ID format
|
|
755
|
+
|
|
756
|
+
==== Getting help
|
|
757
|
+
|
|
758
|
+
* Check the issue tracker on GitHub
|
|
759
|
+
* Review existing test cases for usage examples
|
|
760
|
+
* Run commands with `--help` for detailed options
|
|
761
|
+
* Use `--dry-run` mode to preview operations safely
|
|
762
|
+
|
|
763
|
+
|
|
274
764
|
== Copyright
|
|
275
765
|
|
|
276
766
|
This gem is developed, maintained and funded by
|
|
277
|
-
https://www.ribose.com[Ribose
|
|
767
|
+
https://www.ribose.com[Ribose]
|
|
278
768
|
|
|
279
769
|
|
|
280
770
|
== License
|
|
281
771
|
|
|
282
772
|
The gem is available as open source under the terms of the
|
|
283
773
|
https://opensource.org/licenses/BSD-2-Clause[2-Clause BSD License].
|
|
284
|
-
|
data/commenter.gemspec
CHANGED
|
@@ -30,6 +30,10 @@ Gem::Specification.new do |spec|
|
|
|
30
30
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
|
31
31
|
spec.require_paths = ["lib"]
|
|
32
32
|
|
|
33
|
+
spec.add_dependency "base64", "~> 0.1"
|
|
33
34
|
spec.add_dependency "docx", "~> 0.8"
|
|
35
|
+
spec.add_dependency "dotenv", "~> 2.8"
|
|
36
|
+
spec.add_dependency "liquid", "~> 5.0"
|
|
37
|
+
spec.add_dependency "octokit", "~> 6.0"
|
|
34
38
|
spec.add_dependency "thor", "~> 1.0"
|
|
35
39
|
end
|