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.
@@ -0,0 +1,584 @@
1
+ = ISO DRG compliance
2
+
3
+ == Overview
4
+
5
+ === General
6
+
7
+ The ISO DRG (Document Review Group) requirements for document processing are
8
+ specified in the "DRG working instructions and directives" (August 2020), 3.1
9
+ "Revisable files".
10
+
11
+ 3.1 provides a quote on their guidelines for submission:
12
+
13
+ [quote]
14
+ ____
15
+ Guidelines for the submission of text and graphics to ISO/CS (2020)
16
+
17
+ As a general rule, submitted graphic files (e.g. diagrams, technical drawings)
18
+ need to be revisable and language neutral (with the exception of flowcharts and
19
+ organigrams). All drawing elements within the graphics (lines, symbols, etc.)
20
+ must be modifiable, allowing ISO/CS to adjust or change them when necessary
21
+ during the editing process. All text elements must be editable, and not
22
+ pixelized or outlined text. In addition, the revisable graphic files are made
23
+ available to the ISO members for their publishing activities.
24
+
25
+ To this end, please submit revisable (vector-drawn) files. ISO/CS is not
26
+ responsible for redrafting graphics that are not revisable.
27
+
28
+ ISO/CS recommends the formats listed below:
29
+
30
+ * AutoCAD (.dwg or .dxf)
31
+ * Illustrator (.ai)
32
+ * Vector file type (.eps or .svg)
33
+ * Word (.doc .docx), Excel (.xls .xlsx), Powerpoint (.ppt .pptx), Visio (.vsd .vsdx)
34
+ * CorelDraw (.cdr)
35
+
36
+ The following formats may be used only for images, pictures, etc. where there
37
+ are no text elements:
38
+
39
+ * .png, .tif, .jpeg
40
+ ____
41
+
42
+ The actual naming convention is as follows.
43
+
44
+ == File naming convention
45
+
46
+ === General
47
+
48
+ The file naming requirements differ by document type.
49
+
50
+ In 3.2 "File names" two file name patterns are given but they are not
51
+ complete as these components are missing:
52
+
53
+ * subfigure (described in the block image and examples);
54
+ * key (described in the block image and examples);
55
+ * language (described in the block image and examples);
56
+ * development stages (not described).
57
+
58
+ Here we provide a complete pattern for the ease of understanding
59
+ and example listing.
60
+
61
+ There are four parts of the full filename pattern:
62
+
63
+ * document portion
64
+ * in-document portion
65
+ * language portion
66
+ * file extension portion
67
+
68
+ == Document portion
69
+
70
+ === For Standard, TS, TR, PAS, IWA
71
+
72
+ [source]
73
+ ----
74
+ {StandardNumber}[-{partNumber}][_{stageCode}]_ed{editionNumber}
75
+ ----
76
+
77
+ Where:
78
+
79
+ `StandardNumber`::
80
+ The standard number, e.g. `12345`
81
+
82
+ `partNumber`::
83
+ The part number, e.g. `1`
84
+
85
+ `stageCode`::
86
+ The stage code, one of: `pwi`, `np`, `awi`, `wd`, `cd`, `dis`, `fdis`, `prf`
87
+ (final stage uses empty code)
88
+
89
+ `editionNumber`::
90
+ The edition number, e.g. `1`
91
+
92
+ [example]
93
+ ====
94
+ For the first edition of ISO 12345-1, the document portion is
95
+ `12345-1_ed1`.
96
+ ====
97
+
98
+ NOTE: TR/TS do not use the codes "FDIS" etc. TODO ask ISO/CS what the proper
99
+ codes are.
100
+
101
+ NOTE: The development stage is also provided.
102
+
103
+ === For Amendments / Corrigenda
104
+
105
+ [source]
106
+ ----
107
+ {StandardNumber}-{partNumber}[_{stageCode}]_ed{editionNumber}{supplementCode}{supplementNumber}
108
+ ----
109
+
110
+ Where:
111
+
112
+ `StandardNumber`::
113
+ The standard number, e.g. `12345`
114
+
115
+ `partNumber`::
116
+ The part number, e.g. `1`
117
+
118
+ `stageCode`::
119
+ The stage code, one of: `pwi`, `np`, `awi`, `wd`, `cd`, `dis`, `fdis`, `prf`
120
+ (final stage uses empty code)
121
+
122
+ `editionNumber`::
123
+ The edition number, e.g. `1`
124
+
125
+ `supplementCode`::
126
+ The supplement code. One of `amd`, `cor`
127
+
128
+ `supplementNumber`::
129
+ The supplement number, e.g. `1`
130
+
131
+ [example]
132
+ ====
133
+ For the second amendment to the first edition of ISO 12345-2, the portion is
134
+ `12345-2_ed1amd2`.
135
+
136
+ For the second amendment at FDAM to the first edition of ISO 12345-2, the
137
+ portion is `12345-2_ed1amd2_fdis`.
138
+ ====
139
+
140
+ NOTE: Amendments do not use the codes "FDIS" etc. TODO ask ISO/CS what the
141
+ proper codes are.
142
+
143
+ NOTE: The development stage is also provided.
144
+
145
+ == In-document portion
146
+
147
+ === General
148
+
149
+ There are 3 types of in-document types:
150
+
151
+ === Figure and subfigure
152
+
153
+ Where `subfigureAlphabet` is in lower alphabetic characters:
154
+
155
+ [source]
156
+ ----
157
+ fig{figureNumber}[subfigureAlphabet][_{languageCode}]
158
+ ----
159
+
160
+ [example]
161
+ ====
162
+ * "Figure 3" is represented as `fig3`.
163
+ * Figure 3 in French is represented as `fig3_f`.
164
+ * "Figure 3 a)" is represented as `fig3a`.
165
+ * "Figure 3 a)" in French is represented as `fig3a_f`.
166
+ * "Figure A.2" is represented as `figA2`.
167
+ ====
168
+
169
+ === Table
170
+
171
+ Where `tableNumber` is in lower alphabetic characters:
172
+
173
+ [source]
174
+ ----
175
+ {figurePortion}Tab{tableNumber}
176
+ ----
177
+
178
+ [example]
179
+ ====
180
+ * "Table 3" is `figTab3`.
181
+ * Second figure in "Table 1": `figTab1b`. (TODO Is this unnumbered?)
182
+ ====
183
+
184
+ === Figure key
185
+
186
+ Representing an individual key as legend to the figure:
187
+
188
+ [source]
189
+ ----
190
+ {figurePortion}_key{keyNumber}
191
+ ----
192
+
193
+ [example]
194
+ ====
195
+ Second key in "Figure 1": `fig1_key2`
196
+ ====
197
+
198
+ === Inline image in text
199
+
200
+ Where `textNumber` is in lower alphabetic characters:
201
+
202
+ [source]
203
+ ----
204
+ figText{textNumber}
205
+ ----
206
+
207
+ [example]
208
+ ====
209
+ * First graphical element inline with text: `figText1`
210
+ * Third graphical element inline with text: `figText3`
211
+ ====
212
+
213
+ NOTE: There is also description of the "Special Layout" with such a pattern:
214
+ "File for table 1 which does not have a figure number" is assigned the file
215
+ name `SL12345-1_ed1figTab1.dwg`. Since I have no idea what the special layout
216
+ is and is likely rare to encounter, it is omitted from this.
217
+
218
+ == Language portion
219
+
220
+ === General
221
+
222
+ Valid entries are:
223
+
224
+ `_e`::
225
+ English, but it is no longer needed
226
+
227
+ `_f`::
228
+ French
229
+
230
+ `_r`::
231
+ Russian
232
+
233
+ `_s`::
234
+ Spanish
235
+
236
+ `_a`::
237
+ Arabic
238
+
239
+ `_d`::
240
+ German
241
+
242
+ == Original filename preservation
243
+
244
+ === General
245
+
246
+ When extracting figures from Metanorma documents, if the original image has a
247
+ `filename` attribute, the ISO DRG pattern is extended to preserve the original
248
+ filename:
249
+
250
+ [source]
251
+ ----
252
+ {isoDRGpattern}_{originalFilename}.{extension}
253
+ ----
254
+
255
+ Where:
256
+
257
+ `isoDRGpattern`::
258
+ The standard ISO DRG filename pattern as described above
259
+
260
+ `originalFilename`::
261
+ The original filename (without extension) from the `filename` attribute
262
+
263
+ `extension`::
264
+ The file extension
265
+
266
+ [example]
267
+ ====
268
+ For Figure 1 with original filename "diagram-overview.png":
269
+ `12345-1_ed1fig1_diagram-overview.png`
270
+
271
+ For Figure A.2 subfigure a with original filename "flowchart.svg":
272
+ `12345-1_ed1figA2a_flowchart.svg`
273
+ ====
274
+
275
+ This extended pattern ensures that:
276
+
277
+ . Files follow ISO DRG naming conventions for proper document management
278
+ . Original filenames are preserved for reference and traceability
279
+ . The relationship between extracted figures and source documents is maintained
280
+
281
+ == File extension portion
282
+
283
+ === General
284
+
285
+ ISO/CS (pretty much) only accepts these files.
286
+
287
+ === Vector formats
288
+
289
+ * AutoCAD (`.dwg` or `.dxf`)
290
+ * Illustrator (`.ai`)
291
+ * Vector file type (`.eps` or `.svg`)
292
+ * Word (`.doc`, `.docx`), Excel (`.xls`, `.xlsx`), Powerpoint (`.ppt`, `.pptx`),
293
+ Visio (`.vsd`, `.vsdx`)
294
+ * CorelDraw (`.cdr`)
295
+
296
+ === Raster formats
297
+
298
+ Only useable when no text:
299
+
300
+ * Portable Network Graphics (`.png`)
301
+ * Tagged Image File Format (`.tif`)
302
+ * Joint Photographic Experts Group (`.jpeg`)
303
+
304
+ == Examples
305
+
306
+ === General
307
+
308
+ The following examples are given by the source document.
309
+
310
+ .File naming examples from ISO DRG Section 3.2
311
+ [cols="1,2,3",options="header"]
312
+ |===
313
+ | Where used | Filename | Description
314
+
315
+ | Normal figure
316
+ | `12345-1_ed1fig1.dwg`
317
+ | File for figure 1
318
+
319
+ | Normal figure
320
+ | `12345-1_ed1fig2.dwg`
321
+ | File for figure 2
322
+
323
+ | Normal figure, subfigure
324
+ | `12345-1_ed1fig1a.dwg`
325
+ | File for figure 1, subfigure a
326
+
327
+ | Normal figure, subfigure
328
+ | `12345-1_ed1fig1b.dwg`
329
+ | File for figure 1, subfigure b
330
+
331
+ | Normal figure, key file
332
+ | `12345-1_ed1fig1_key1.dwg`
333
+ | File for figure 1, first key file
334
+
335
+ | Normal figure, key file
336
+ | `12345-1_ed1fig1_key2.dwg`
337
+ | File for figure 1, second key file
338
+
339
+ | Table
340
+ | `12345-1_ed1figTab1.dwg`
341
+ | File for the single figure in Table 1
342
+
343
+ | Table
344
+ | `12345-1_ed1figTab1a.dwg`
345
+ | File for the first figure in Table 1
346
+
347
+ | Table
348
+ | `12345-1_ed1figTab1b.dwg`
349
+ | File for the second figure in Table 1
350
+
351
+ | Annex
352
+ | `12345-1_ed1figA1.dwg`
353
+ | File for the first figure in appendix A
354
+
355
+ | Annex
356
+ | `12345-1_ed1figA2.dwg`
357
+ | File for the second figure in appendix A
358
+
359
+ | Annex
360
+ | `12345-1_ed1figA1a.dwg`
361
+ | File for first figure in appendix A, subfigure a
362
+
363
+ | Annex
364
+ | `12345-1_ed1figA1b.dwg`
365
+ | File for first figure in appendix A, subfigure b
366
+
367
+ | Language
368
+ | `12345-1_ed1fig1_f.dwg`
369
+ | File for figure 1, French translation
370
+
371
+ | Amendment
372
+ | `12345-1_ed1amd1fig1.dwg`
373
+ | File for figure 1 of amendment 1
374
+
375
+ | Inline
376
+ | `12345-1_ed1figText1.dwg`
377
+ | File for graphical element inline with text
378
+
379
+ | Special Layout
380
+ | `SL12345-1_ed1figTab1.dwg`
381
+ | File for table 1 which does not have a figure
382
+ |===
383
+
384
+ == Data structure
385
+
386
+ === General
387
+
388
+ The data structure is designed to be MECE (Mutually Exclusive, Collectively
389
+ Exhaustive) and covers all ISO DRG filename patterns.
390
+
391
+ === Core schema
392
+
393
+ [source,yaml]
394
+ ----
395
+ # Document identification (required)
396
+ standard_number: 12345 # ISO standard number
397
+ part_number: 1 # optional, part number
398
+ edition_number: 2 # edition number
399
+
400
+ # Development stage (optional)
401
+ stage_code: "fdis" # pwi|np|awi|wd|cd|dis|fdis|prf or empty for final
402
+
403
+ # Supplement information (for amendments/corrigenda only)
404
+ supplement_type: "amd" # amd|cor (optional)
405
+ supplement_number: 1 # required if supplement_type present
406
+
407
+ # Content type (required - mutually exclusive)
408
+ content_type: "figure" # figure|table|key|text|special_layout
409
+
410
+ # Content-specific fields (conditional based on content_type)
411
+ figure_number: "3" # required for figure|table|key types
412
+ subfigure: "a" # optional, single lowercase letter (figure only)
413
+ table_number: "1" # used for table content_type
414
+ key_number: 2 # required for key content_type
415
+ text_number: 1 # required for text content_type
416
+
417
+ # Localization (optional)
418
+ language_code: "f" # e|f|r|s|a|d (empty for English)
419
+
420
+ # Output format (required)
421
+ file_extension: "svg" # svg|dwg|ai|eps|png|tif|jpeg|etc.
422
+ ----
423
+
424
+ === Field validation rules
425
+
426
+ * `standard_number`: Required integer
427
+ * `part_number`: Optional integer
428
+ * `edition_number`: Required integer
429
+ * `stage_code`: Optional string, one of: `pwi`, `np`, `awi`, `wd`, `cd`, `dis`,
430
+ `fdis`, `prf`, or empty for final stage
431
+ * `supplement_type`: Optional string, one of: `amd`, `cor`
432
+ * `supplement_number`: Required integer if `supplement_type` is present
433
+ * `content_type`: Required string, one of: `figure`, `table`, `key`, `text`,
434
+ `special_layout`
435
+ * `figure_number`: Required for `figure`, `table`, `key` content types. Format:
436
+ number or letter+number (e.g., "3", "A.2")
437
+ * `subfigure`: Optional single lowercase letter (a-z), only valid for `figure`
438
+ content type
439
+ * `table_number`: Used for `table` content type, typically same as
440
+ `figure_number`
441
+ * `key_number`: Required integer for `key` content type
442
+ * `text_number`: Required integer for `text` content type
443
+ * `language_code`: Optional string, one of: `e`, `f`, `r`, `s`, `a`, `d`
444
+ * `file_extension`: Required string
445
+
446
+ === Content type examples
447
+
448
+ ==== Standard figure
449
+
450
+ [source,yaml]
451
+ ----
452
+ standard_number: 12345
453
+ part_number: 1
454
+ edition_number: 2
455
+ content_type: "figure"
456
+ figure_number: "3"
457
+ file_extension: "svg"
458
+ # Generates: 12345-1_ed2fig3.svg
459
+ ----
460
+
461
+ ==== Figure with subfigure
462
+
463
+ [source,yaml]
464
+ ----
465
+ standard_number: 12345
466
+ part_number: 1
467
+ edition_number: 2
468
+ content_type: "figure"
469
+ figure_number: "3"
470
+ subfigure: "a"
471
+ file_extension: "svg"
472
+ # Generates: 12345-1_ed2fig3a.svg
473
+ ----
474
+
475
+ ==== Table figure
476
+
477
+ [source,yaml]
478
+ ----
479
+ standard_number: 12345
480
+ part_number: 1
481
+ edition_number: 2
482
+ content_type: "table"
483
+ figure_number: "1"
484
+ table_number: "1"
485
+ file_extension: "svg"
486
+ # Generates: 12345-1_ed2figTab1.svg
487
+ ----
488
+
489
+ ==== Figure key
490
+
491
+ [source,yaml]
492
+ ----
493
+ standard_number: 12345
494
+ part_number: 1
495
+ edition_number: 2
496
+ content_type: "key"
497
+ figure_number: "1"
498
+ key_number: 2
499
+ file_extension: "svg"
500
+ # Generates: 12345-1_ed2fig1_key2.svg
501
+ ----
502
+
503
+ ==== Inline text graphic
504
+
505
+ [source,yaml]
506
+ ----
507
+ standard_number: 12345
508
+ part_number: 1
509
+ edition_number: 2
510
+ content_type: "text"
511
+ text_number: 1
512
+ file_extension: "svg"
513
+ # Generates: 12345-1_ed2figText1.svg
514
+ ----
515
+
516
+ ==== Amendment figure
517
+
518
+ [source,yaml]
519
+ ----
520
+ standard_number: 12345
521
+ part_number: 1
522
+ edition_number: 2
523
+ supplement_type: "amd"
524
+ supplement_number: 1
525
+ content_type: "figure"
526
+ figure_number: "3"
527
+ file_extension: "svg"
528
+ # Generates: 12345-1_ed2amd1fig3.svg
529
+ ----
530
+
531
+ ==== Figure with language
532
+
533
+ [source,yaml]
534
+ ----
535
+ standard_number: 12345
536
+ part_number: 1
537
+ edition_number: 2
538
+ content_type: "figure"
539
+ figure_number: "3"
540
+ language_code: "f"
541
+ file_extension: "svg"
542
+ # Generates: 12345-1_ed2fig3_f.svg
543
+ ----
544
+
545
+ ==== Annex figure
546
+
547
+ [source,yaml]
548
+ ----
549
+ standard_number: 12345
550
+ part_number: 1
551
+ edition_number: 2
552
+ content_type: "figure"
553
+ figure_number: "A.2"
554
+ file_extension: "svg"
555
+ # Generates: 12345-1_ed2figA2.svg
556
+ ----
557
+
558
+ ==== Development stage figure
559
+
560
+ [source,yaml]
561
+ ----
562
+ standard_number: 12345
563
+ part_number: 1
564
+ edition_number: 2
565
+ stage_code: "fdis"
566
+ content_type: "figure"
567
+ figure_number: "3"
568
+ file_extension: "svg"
569
+ # Generates: 12345-1_fdis_ed2fig3.svg
570
+ ----
571
+
572
+ ==== Special layout
573
+
574
+ [source,yaml]
575
+ ----
576
+ standard_number: 12345
577
+ part_number: 1
578
+ edition_number: 2
579
+ content_type: "special_layout"
580
+ figure_number: "1"
581
+ table_number: "1"
582
+ file_extension: "dwg"
583
+ # Generates: SL12345-1_ed2figTab1.dwg
584
+ ----
@@ -0,0 +1,70 @@
1
+ = ISO workflows with Metanorma Tools
2
+
3
+ == Purpose
4
+
5
+ This document provides guidance on using Metanorma Tools for ISO-specific
6
+ standards editing workflows.
7
+
8
+ Metanorma Tools supports the complete ISO standards editing lifecycle, from
9
+ document preparation through comment resolution and final publication. The
10
+ tools are designed to work with ISO's specific requirements and processes.
11
+
12
+ == Workflow
13
+
14
+ A project leader is required to perform these actions in the development of
15
+ an ISO document:
16
+
17
+ Step 1: Import the ISO source document into Metanorma from:
18
+
19
+ * from a Word file from ISO/CS;
20
+ * from a Word file from the Committee Secretariat;
21
+ * from an ISO STS / NISO STS XML file from ISO/CS;
22
+ * ... if all else fails we import at least the terms from the ISO OBP.
23
+
24
+
25
+ Step 2: Iterate the Metanorma ISO document stage by stage and balloting between stages
26
+
27
+ * progressing through stages PWI/NP/AWI/WD/WDS/CD/CDS/D[IS|TR|TS|AM|COR]/FD[IS|TR|TS|AM|COR]/PRF;
28
+ * iterate the document, update attributes of `stage`, `substage`, `revdate`, `vote-date-*`;
29
+ * create study review / ballot packages
30
+ ** provide a Word file
31
+ ** provide a PDF file
32
+ ** at DIS / FDIS / PRF / IS, provide the DIS Word templated document to ISO/CS
33
+ ** (this gem does this now!) provide a figure package
34
+ * at each stage, manage comments on the ISO commenting template synchronizing with the chosen issue system (e.g. GitHub Issues)
35
+ * at each stage, port commented changes back to the Metanorma source
36
+ * after comments are resolved, link the commits/PRs to the comment IDs
37
+ * upload package to the chosen CI/CD release platform (e.g. GitHub Releases) and mark milestone
38
+
39
+ Step 3: Enjoy the publication!
40
+
41
+ == Figure package and extraction
42
+
43
+ Extract a figure package with compliant ISO DRG filenames:
44
+
45
+ [source,shell]
46
+ ----
47
+ $ metanorma-tools extract-images iso-document.presentation.xml --zip
48
+ # From ISO 690 edition 3
49
+ # => 690_ed3.zip (with figures 690_ed3figX.svg)
50
+ # From ISO/FDIS 19135 edition 2
51
+ # => 19135_fdis_ed2.zip (with figures 19135_fdis_ed2figX.svg)
52
+ ----
53
+
54
+ Details at: link:figure-extraction.adoc[Figure extraction]
55
+
56
+ // Planned: Import ISO comment sheets:
57
+
58
+ // [source,shell]
59
+ // ----
60
+ // $ metanorma-tools comment import "ISO DIS comments.docx" --output comments.yaml
61
+ // ----
62
+
63
+ // Planned: Fetch ISO documents from OBP:
64
+
65
+ // [source,shell]
66
+ // ----
67
+ // $ metanorma-tools obp-import urn:iso:80000:2:2019:en
68
+ // ----
69
+ // ====
70
+
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "../lib/metanorma/tools"
5
+
6
+ Metanorma::Tools::Cli.start(ARGV)