metanorma-plugin-plantuml 1.0.2 → 1.0.4

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.
data/README.adoc CHANGED
@@ -4,7 +4,7 @@ image:https://github.com/metanorma/metanorma-plugin-plantuml/workflows/rake/badg
4
4
 
5
5
  == Purpose
6
6
 
7
- This is a Metanorma plugin to enable usage of PlantUML diagrams in Metanorma
7
+ This Metanorma plugin enables the usage of PlantUML diagrams in Metanorma
8
8
  documents.
9
9
 
10
10
  It provides a Ruby API that wraps a bundled PlantUML JAR file.
@@ -59,47 +59,152 @@ $ gem install metanorma-plugin-plantuml
59
59
 
60
60
  == Usage
61
61
 
62
+ === General
63
+
62
64
  This plugin enables PlantUML diagram generation in Metanorma documents through
63
- the `plantuml` block directive.
65
+ multiple methods, including:
66
+
67
+ * Block syntax using `[plantuml]` blocks
68
+ * Command syntax using `plantuml_image::{path}[{options}]`
69
+
70
+ Both syntaxes support various diagram types, output formats, and image
71
+ attributes, as well as PlantUML's `include!` and `includesub!` directives for
72
+ modular diagrams.
73
+
74
+ The effect of both syntaxes is the same: they generate and embed PlantUML diagrams
75
+ as images in the output document.
76
+
77
+ However, there are important differences in using them with external files, as
78
+ it is described in the various options.
79
+
80
+ The difference lies in how the PlantUML source is provided:
81
+
82
+ * In the block syntax, the PlantUML source is defined directly within the
83
+ document, and hence generated by PlantUML without a specific file context.
84
+
85
+ * In the command syntax, the PlantUML source is read from an external file,
86
+ which provides a file context for the PlantUML source.
87
+
88
+ Generally, the command syntax is more suitable for referencing external PlantUML
89
+ files.
90
+
64
91
 
92
+ === Command syntax for external diagrams
65
93
 
66
- === Basic syntax
94
+ PlantUML diagrams can be directly referenced from external files using the
95
+ `plantuml_image::{path}[{options}]` command.
67
96
 
68
- ==== Block style
97
+ Syntax:
69
98
 
70
99
  [source,asciidoc]
71
100
  ----
72
- [plantuml]
73
- ....
101
+ plantuml_image::{plantuml-source.puml}[{options}]
102
+ ----
103
+
104
+ Where,
105
+
106
+ `{plantuml-source.puml}`:: Path to the PlantUML source file, relative to the
107
+ path of the current file.
108
+
109
+ `{options}`:: (Optional) Comma-separated list of options to customize diagram
110
+ generation.
111
+
112
+ .Specifying an external PlantUML diagram using the `plantuml_image` command without options
113
+ [example]
114
+ ====
115
+ [source,asciidoc]
116
+ ----
117
+ plantuml_image::foo/bar.puml[]
118
+ ----
119
+
120
+ The file `foo/bar.puml` looks like:
121
+
122
+ [source,plantuml]
123
+ ----
74
124
  @startuml
75
125
  Alice -> Bob: Hello
76
126
  Bob -> Alice: Hi there
77
127
  @enduml
128
+ ----
129
+ ====
130
+
131
+ .Specifying an external PlantUML diagram using the `plantuml_image` command with options
132
+ [example]
133
+ ====
134
+ [source,asciidoc]
135
+ ----
136
+ plantuml_image::foo/bar.puml[format=svg]
137
+ ----
138
+
139
+ The file `foo/bar.puml` is the same as above.
140
+ The `format=svg` option specifies the output format as SVG.
141
+ ====
142
+
143
+
144
+
145
+ === Block syntax for inline diagrams
146
+
147
+ PlantUML diagrams can be defined directly within your Metanorma document using
148
+ `[plantuml]` blocks.
149
+
150
+ Syntax:
151
+
152
+ [source,asciidoc]
153
+ ----
154
+ [plantuml]
155
+ ....
156
+ {PlantUML diagram source here}
78
157
  ....
79
158
  ----
80
159
 
81
- ==== Block macro style
160
+ Where,
161
+
162
+ `[plantuml]`:: Specifies that the block contains PlantUML source code.
163
+
164
+ `....`:: Delimiters that indicate the start and end of the PlantUML source code.
165
+
166
+ `{PlantUML diagram source here}`:: The actual PlantUML diagram definition using
167
+ PlantUML syntax.
168
+
169
+
170
+ The block can be used with or without options.
171
+
172
+ Syntax with options:
82
173
 
83
174
  [source,asciidoc]
84
175
  ----
85
- plantuml_image::path/to/my-plantuml.puml[]
176
+ [plantuml,{options}]
177
+ ....
178
+ {PlantUML diagram source here}
179
+ ....
86
180
  ----
87
181
 
88
- The file `path/to/my-plantuml.puml` looks like:
89
- [source,plantuml]
182
+ Where,
183
+
184
+ `{options}`:: Comma-separated list of options to customize diagram generation.
185
+
186
+
187
+ .Specifying a simple PlantUML diagram in the `[plantuml]` block
188
+ [example]
189
+ ====
190
+ [source,asciidoc]
90
191
  ----
192
+ [plantuml]
193
+ ....
91
194
  @startuml
92
195
  Alice -> Bob: Hello
93
196
  Bob -> Alice: Hi there
94
197
  @enduml
198
+ ....
95
199
  ----
200
+ ====
201
+
96
202
 
97
- `plantuml_image` block macro performs the same function as the `plantuml` block,
98
- but the PlantUML diagram is defined in a separate file instead of a block.
99
203
 
100
204
  === Supported diagram types
101
205
 
102
- PlantUML supports various diagram types, each with its own `@start` and `@end` directives:
206
+ PlantUML, and therefore this plugin, supports various diagram types, each with
207
+ its own `@start` and `@end` directives:
103
208
 
104
209
  `@startuml` / `@enduml`:: UML diagrams (sequence, class, activity, etc.)
105
210
  `@startmindmap` / `@endmindmap`:: Mind map diagrams
@@ -150,12 +255,40 @@ Bob --> Alice: Authentication Response
150
255
  ----
151
256
  ====
152
257
 
258
+
153
259
  === Format options
154
260
 
155
261
  ==== Single format specification
156
262
 
157
- Specify the output format using the `format` attribute:
263
+ The output format is specified using the `format` option, which can be applied
264
+ in both block and command syntaxes.
265
+
266
+ Block syntax:
158
267
 
268
+ [source,adoc]
269
+ ----
270
+ [plantuml,format={format}]
271
+ ----
272
+
273
+ Command syntax:
274
+
275
+ [source,adoc]
276
+ ----
277
+ plantuml_image::{path}[format={format}]
278
+ ----
279
+
280
+ Where `{format}` can be one of the following:
281
+
282
+ `png`:: (default) Portable Network Graphics
283
+ `svg`:: Scalable Vector Graphics
284
+ `pdf`:: Portable Document Format
285
+ `txt`:: ASCII art text output
286
+ `eps`:: Encapsulated PostScript
287
+
288
+
289
+ .Block syntax with format option
290
+ [example]
291
+ ====
159
292
  [source,asciidoc]
160
293
  ----
161
294
  [plantuml,format=svg]
@@ -165,19 +298,47 @@ Alice -> Bob: Hello
165
298
  @enduml
166
299
  ....
167
300
  ----
301
+ ====
168
302
 
169
- Supported formats:
303
+ .Command syntax with format option
304
+ [example]
305
+ ====
306
+ [source,asciidoc]
307
+ ----
308
+ plantuml_image::path/to/my-plantuml.puml[format=svg]
309
+ ----
310
+ ====
170
311
 
171
- `png`:: (default) Portable Network Graphics
172
- `svg`:: Scalable Vector Graphics
173
- `pdf`:: Portable Document Format
174
- `txt`:: ASCII art text output
175
- `eps`:: Encapsulated PostScript
176
312
 
177
313
  ==== Multiple format generation
178
314
 
179
- Generate multiple formats simultaneously using the `formats` attribute:
315
+ It is possible to generate multiple output formats simultaneously by specifying
316
+ the `formats` option, which accepts a comma-separated list of formats.
317
+
318
+ While Metanorma does not currently support embedding multiple images for a single
319
+ diagram, generating multiple formats can be useful for documentation or other
320
+ purposes.
321
+
322
+ Block syntax:
323
+
324
+ [source,adoc]
325
+ ----
326
+ [plantuml,formats="{format1},{format2},..."]
327
+ ----
328
+
329
+ Command syntax:
330
+
331
+ [source,adoc]
332
+ ----
333
+ plantuml_image::{path}[formats="{format1},{format2},..."]
334
+ ----
335
+
336
+ Where `{format1}`, `{format2}`, etc. can be any of the supported formats listed
337
+ above.
180
338
 
339
+ .Block syntax with multiple formats
340
+ [example]
341
+ ====
181
342
  [source,asciidoc]
182
343
  ----
183
344
  [plantuml,formats="png,svg,pdf"]
@@ -187,11 +348,26 @@ Alice -> Bob: Hello
187
348
  @enduml
188
349
  ....
189
350
  ----
351
+ ====
352
+
190
353
 
191
354
  ==== Document-level format configuration
192
355
 
193
- Set the default format for all PlantUML diagrams in your document:
356
+ The default format for all PlantUML diagrams in a document can be set using the
357
+ `plantuml-image-format` document attribute.
358
+
359
+ Syntax:
194
360
 
361
+ [source,asciidoc]
362
+ ----
363
+ :plantuml-image-format: {format}
364
+ ----
365
+
366
+ Where `{format}` can be any of the supported formats listed above.
367
+
368
+ .Document with document-level format configuration
369
+ [example]
370
+ ====
195
371
  [source,asciidoc]
196
372
  ----
197
373
  :plantuml-image-format: svg
@@ -203,14 +379,82 @@ Alice -> Bob: Hello
203
379
  @enduml
204
380
  ....
205
381
  ----
382
+ ====
383
+
384
+ === Using `!include` and `!includesub`
385
+
386
+ ==== General
387
+
388
+ PlantUML supports modular diagram definitions using the `!include` and
389
+ `!includesub` directives to include external PlantUML files or specific parts of
390
+ them.
391
+
392
+ PlantUML is able to resolve relative paths in these directives based on the context
393
+ of the PlantUML source.
394
+
395
+ This is where the behavior differs between the block syntax and the command
396
+ syntax:
397
+
398
+ * In the block syntax, as the PlantUML source is defined inline within the
399
+ document, there is no associated file path for the PlantUML source. The
400
+ consequence is that PlantUML cannot resolve relative paths in `!include` or
401
+ `!includesub` directives, as there is no associated file path. In order to
402
+ resolve includes, you must specify the `includedirs` option to provide
403
+ directories to search for included files.
404
+
405
+ * In the command syntax, the PlantUML source is read from an external file. This
406
+ means that relative paths in `!include` or `!includesub` directives are resolved
407
+ relative to the location of the PlantUML source file. The `includedirs` option
408
+ is not needed for resolving includes, but can still be used to add additional
409
+ directories to search.
410
+
411
+
412
+ ==== Setting `includedirs`
206
413
 
207
- ==== Document-level includedirs configuration
414
+ PlantUML allows you to specify include directories using the `includedirs`
415
+ option. This option can be set at both the document level and the block level,
416
+ through the option of the same name.
208
417
 
209
- When using `!include` or `!includesub` in your PlantUML diagrams, you can set
210
- the default include directories (separated by semicolons) by
211
- `plantuml-includedirs` to search for files for all PlantUML diagrams in your
212
- document:
418
+ There are two ways to set `includedirs`:
419
+
420
+ * Document-level configuration using the `plantuml-includedirs` document attribute
421
+
422
+ * The `includedirs` option in the `[plantuml]` block or `plantuml_image` command
423
+
424
+ Note that when using the `plantuml_image` command, the directory that contains
425
+ the specified PlantUML file will be automatically added as one of the
426
+ `includedirs` directories. This means that any relative includes in the PlantUML
427
+ file will be resolved relative to the file's location, even if `includedirs` is
428
+ not explicitly set.
429
+
430
+
431
+ ==== Document-level `plantuml-includedirs` attribute
432
+
433
+ It is possible to set default include directories (separated by semicolons) for
434
+ all PlantUML diagrams in a document using the `plantuml-includedirs` document
435
+ attribute.
436
+
437
+ This is useful when a document contains multiple PlantUML diagrams that share
438
+ common include files stored in specific directories, e.g. style definitions.
439
+
440
+ The directories specified in this attribute will be used as the default include
441
+ paths for all PlantUML diagrams in the document, including for both `[plantuml]`
442
+ blocks and `plantuml_image` commands.
443
+
444
+ NOTE: When using the `plantuml_image` command, the directory that contains the
445
+ specified PlantUML file will always be automatically added as one of the
446
+ `includedirs` directories.
447
+
448
+ Syntax:
213
449
 
450
+ [source,asciidoc]
451
+ ----
452
+ :plantuml-includedirs: {path1};{path2};...
453
+ ----
454
+
455
+ .Resolving PlantUML includes with document-level `includedirs` attribute
456
+ [example]
457
+ ====
214
458
  [source,asciidoc]
215
459
  ----
216
460
  :plantuml-includedirs: path/to/plantuml/include-1;path/to/plantuml/include-2
@@ -243,14 +487,19 @@ title this contains only B and D
243
487
  ....
244
488
  ----
245
489
 
246
- This plugin will search the include directories specified by
247
- `includedirs` options (i.e. `path/to/plantuml/include-1` and
248
- `path/to/plantuml/include-2`) for the files referenced in `!include` or
249
- `!includesub` directives (i.e. `sequences.puml`, `components.puml` and
250
- `subpart.puml`).
490
+ These `[plantuml]` blocks use `!include` and `!includesub` directives to include
491
+ external PlantUML files. PlantUML will search the include directories specified
492
+ by `includedirs` options to find `sequences.puml`, `components.puml` and
493
+ `subpart.puml`, at:
494
+
495
+ * `path/to/plantuml/include-1`
496
+ * `path/to/plantuml/include-2`
497
+ ====
251
498
 
252
- You can also use `plantuml_image` to include external PlantUML files as images:
253
499
 
500
+ .Resolving PlantUML includes in `plantuml_image` command with document-level `includedirs` attribute
501
+ [example]
502
+ ====
254
503
  [source,asciidoc]
255
504
  ----
256
505
  :plantuml-includedirs: path/to/plantuml/include-1;path/to/plantuml/include-2
@@ -260,7 +509,8 @@ plantuml_image::path/to/my-plantuml-1.puml[]
260
509
  plantuml_image::path/to/my-plantuml-2.puml[]
261
510
  ----
262
511
 
263
- The file `path/to/my-plantuml-1.puml` looks like:
512
+ With `path/to/my-plantuml-1.puml` as:
513
+
264
514
  [source,plantuml]
265
515
  ----
266
516
  @startuml
@@ -268,7 +518,8 @@ The file `path/to/my-plantuml-1.puml` looks like:
268
518
  @enduml
269
519
  ----
270
520
 
271
- The file `path/to/my-plantuml-2.puml` looks like:
521
+ With `path/to/my-plantuml-2.puml` as:
522
+
272
523
  [source,plantuml]
273
524
  ----
274
525
  @startuml
@@ -281,16 +532,48 @@ APIGateway --> DB
281
532
  @enduml
282
533
  ----
283
534
 
284
- When using `plantuml_image`, the path of the directory of the PlantUML file will
285
- also be added into the `includedirs`. (i.e. `path/to` will be added to
286
- `includedirs`)
535
+ In using the `plantuml_image` command, the directory containing each PlantUML file
536
+ (`path/to` in this case) is automatically added to the `includedirs`.
537
+
538
+ Thus in rendering `path/to/my-plantuml-1.puml`, PlantUML will search for
539
+ `sequences.puml` in both `path/to` and the directories specified by the
540
+ `plantuml-includedirs` attribute.
287
541
 
288
- ==== Block-level includedirs configuration
542
+ Similarly, in rendering `path/to/my-plantuml-2.puml`, PlantUML will search for
543
+ `components.puml` in both `path/to` and the directories specified by the
544
+ `plantuml-includedirs` attribute.
545
+ ====
546
+
547
+
548
+ ==== Diagram-level `includedirs` option
289
549
 
290
- When using `!include` or `!includesub` in your PlantUML diagrams, you can set
291
- the default include directories (separated by semicolons) by `includedirs` in
292
- block-level to search for files for the PlantUML diagram defined in your block:
550
+ The `includedirs` option can be used to specify include directories (separated
551
+ by semicolons) for both `[plantuml]` blocks and the `plantuml_image` command.
552
+
553
+ This option applies only to a single diagram in the document without affecting
554
+ others.
555
+
556
+ The diagram-level `includedirs` configuration can be used together with the
557
+ document-level configuration to provide more granular control over include
558
+ paths, where it is considered to have higher precedence than the document-level
559
+ configuration.
560
+
561
+ Syntax:
293
562
 
563
+ [source,asciidoc]
564
+ ----
565
+ [plantuml,includedirs="{path1};{path2};..."]
566
+ ----
567
+
568
+ Where,
569
+
570
+ `{path1}`, `{path2}`, etc.:: paths to directories containing PlantUML files to
571
+ be included, delimited by semicolons.
572
+
573
+
574
+ .Resolving PlantUML includes using diagram-level `includedirs` in `[plantuml]` blocks
575
+ [example]
576
+ ====
294
577
  [source,asciidoc]
295
578
  ----
296
579
  [plantuml,includedirs="path/to/plantuml/include-1"]
@@ -315,25 +598,64 @@ APIGateway --> DB
315
598
 
316
599
  This plugin will search `sequences.puml` in `path/to/plantuml/include-1` and
317
600
  `components.puml` in `path/to/plantuml/include-2`.
601
+ ====
318
602
 
319
- The block-level `includedirs` configuration can be used together with the
320
- document-level configuration to provide more granular control over include
321
- paths. You can set multiple paths by separating them with semicolons.
322
-
323
- You can also use `plantuml_image` to set `includedirs` option to include
324
- external PlantUML files:
325
603
 
604
+ .Resolving PlantUML includes using diagram-level `includedirs` with `plantuml_image` command
605
+ [example]
606
+ ====
326
607
  [source,asciidoc]
327
608
  ----
328
609
  plantuml_image::path/to/my-plantuml-1.puml[includedirs=path/to/plantuml/include-1]
329
610
 
330
611
  plantuml_image::path/to/my-plantuml-2.puml[includedirs=path/to/plantuml/include-2]
331
612
  ----
613
+ ====
614
+
332
615
 
333
616
  === Image attributes
334
617
 
335
- Standard AsciiDoc image attributes are supported:
618
+ The block and command syntaxes both support standard AsciiDoc image attributes
619
+ to customize the appearance and behavior of the generated PlantUML diagrams.
620
+
621
+ Supported attributes are as follows:
622
+
623
+ `id`:: Element identifier
624
+ `title`:: Image title/caption
625
+ `alt`:: Alternative text
626
+ `width`:: Image width
627
+ `height`:: Image height
628
+ `align`:: Alignment (left, center, right)
629
+ `float`:: Float positioning
630
+ `role`:: CSS class/role
631
+
632
+
633
+ Block syntax:
634
+
635
+ [source,asciidoc]
636
+ ----
637
+ [plantuml,{image-attributes}]
638
+ ....
639
+ {PlantUML diagram source here}
640
+ ....
641
+ ----
642
+
643
+ Command syntax:
336
644
 
645
+ [source,asciidoc]
646
+ ----
647
+ plantuml_image::{path}[{image-attributes}]
648
+ ----
649
+
650
+ Where,
651
+
652
+ `{image-attributes}`:: Comma-separated list of AsciiDoc image attributes in
653
+ `key=value` format.
654
+
655
+
656
+ .Specifying image attributes in `[plantuml]` block
657
+ [example]
658
+ ====
337
659
  [source,asciidoc]
338
660
  ----
339
661
  [plantuml,id=my-diagram,title="My Sequence Diagram",width=600,height=400]
@@ -343,46 +665,88 @@ Alice -> Bob: Hello
343
665
  @enduml
344
666
  ....
345
667
  ----
668
+ ====
346
669
 
347
- Supported attributes:
348
-
349
- `id`:: Element identifier
350
- `title`:: Image title/caption
351
- `alt`:: Alternative text
352
- `width`:: Image width
353
- `height`:: Image height
354
- `align`:: Alignment (left, center, right)
355
- `float`:: Float positioning
356
- `role`:: CSS class/role
357
670
 
358
671
  === Filename specification
359
672
 
360
- Specify custom filenames within the PlantUML source:
673
+ PlantUML supports specifying custom filenames for generated diagrams using the
674
+ `@start{type} [filename]` directive, where `{type}` is the diagram type (e.g.,
675
+ `uml`, `mindmap`, etc.) and `filename` is the desired name for the output
676
+ file.
677
+
678
+ This feature is not well documented in official PlantUML documentation, but is
679
+ described at:
680
+
681
+ * PlantUML Language Reference Guide, 4.7, where `@startuml PERT` is used
682
+ * https://forum.plantuml.net/19896/name-conventions-for-%40startuml-filename[PlantUML Forum: Name conventions for @startuml filename]
683
+ * https://forum.plantuml.net/5483/please-specify-filename-%40startuml-extension-automatically[PlantUML Forum: Please specify filename @startuml extension automatically]
684
+
685
+ When a custom filename is specified, PlantUML generates the output file using
686
+ the specified filename and the appropriate file extension based on the diagram
687
+ type.
688
+
689
+ This custom filename feature is supported in both block and command syntaxes.
690
+
691
+ Syntax:
361
692
 
362
693
  [source,asciidoc]
363
694
  ----
364
695
  [plantuml]
365
696
  ....
366
- @startuml my-custom-name
697
+ @startuml {custom-filename}
698
+ {PlantUML diagram source here}
699
+ @enduml
700
+ ....
701
+ ----
702
+
703
+ Where,
704
+
705
+ `{custom-filename}`:: Desired name for the generated diagram file, without
706
+ file extension.
707
+
708
+ .Specifying a custom filename in `[plantuml]` block
709
+ [example]
710
+ ====
711
+ [source,asciidoc]
712
+ ----
713
+ [plantuml]
714
+ ....
715
+ @startuml AliceToBob
367
716
  Alice -> Bob: Hello
368
717
  @enduml
369
718
  ....
370
719
  ----
371
720
 
372
- This generates `my-custom-name.png` (or specified format) instead of an
373
- auto-generated filename.
721
+ This generates `AliceToBob.png` (which is the default format since none was
722
+ specified) instead of an auto-generated filename. This file is then embedded in
723
+ the output document using the specified filename.
724
+ ====
374
725
 
375
726
 
376
- === Configuration options
377
727
 
378
- ==== Disable PlantUML processing
728
+ === Disable PlantUML processing
379
729
 
380
- Disable PlantUML processing document-wide:
730
+ It is possible to disable PlantUML processing either document-wide or via an
731
+ environment variable.
732
+
733
+ When disabled, PlantUML blocks are rendered as code listings instead of
734
+ diagrams.
735
+
736
+ The `:plantuml-disabled:` document attribute can be used to disable PlantUML
737
+ processing for a specific document.
738
+
739
+ Syntax:
381
740
 
382
741
  [source,asciidoc]
383
742
  ----
384
743
  :plantuml-disabled:
744
+ ----
385
745
 
746
+ [example]
747
+ ====
748
+ [source,asciidoc]
749
+ ----
386
750
  [plantuml]
387
751
  ....
388
752
  @startuml
@@ -391,22 +755,36 @@ Alice -> Bob: Hello
391
755
  ....
392
756
  ----
393
757
 
394
- When disabled, PlantUML blocks are rendered as code listings instead of diagrams.
758
+ This renders the PlantUML block as a code listing instead of a diagram.
759
+ ====
395
760
 
396
- ==== Environment variable
761
+ The same effect can be achieved using by setting the `PLANTUML_DISABLED`
762
+ environment variable to `true`.
397
763
 
398
- Disable PlantUML processing via environment variable:
764
+ Syntax:
399
765
 
766
+ [source,console]
767
+ ----
768
+ $ PLANTUML_DISABLED=true metanorma ...
769
+ ----
770
+
771
+ [example]
772
+ ====
400
773
  [source,console]
401
774
  ----
402
775
  $ PLANTUML_DISABLED=true metanorma document.adoc
403
776
  ----
777
+ ====
778
+
404
779
 
405
780
  === File organization
406
781
 
407
- Generated PlantUML images are stored in the `_plantuml_images/` directory
408
- relative to your document location. This directory is automatically created if
409
- it doesn't exist.
782
+ Generated PlantUML images are stored in a `_plantuml_images/` directory
783
+ relative to the document location (the document root, if it is made of multiple
784
+ files).
785
+
786
+ This directory is automatically created if it doesn't exist.
787
+
410
788
 
411
789
  == Development
412
790
 
@@ -417,21 +795,22 @@ Metanorma integration and PlantUML execution:
417
795
 
418
796
  [source]
419
797
  ----
420
- Metanorma Document
421
-
422
- BlockProcessor ← (processes [plantuml] blocks) or ImageBlockMacroProcessor ← (processes plantuml_image::{path}[{options}] macros)
423
-
424
- Backend ← (Metanorma integration, paths, validation)
425
-
426
- Wrapper ← (Java/JAR execution, file I/O)
427
-
428
- PlantUML JAR ← (diagram generation)
798
+ Metanorma Document
799
+
800
+ BlockProcessor ← (processes `[plantuml]` blocks)
801
+ and ImageBlockMacroProcessor ← (processes `plantuml_image::` commands)
802
+
803
+ Backend ← (Metanorma integration, paths, validation)
804
+
805
+ Wrapper ← (Java/JAR execution, file I/O)
806
+
807
+ PlantUML JAR ← (diagram generation)
429
808
  ----
430
809
 
431
810
  `BlockProcessor`:: Processes `[plantuml]` blocks in Metanorma documents and
432
811
  integrates with the Metanorma rendering pipeline.
433
812
 
434
- `ImageBlockMacroProcessor`:: Processes `plantuml_image::{path}[{options}]` macros
813
+ `ImageBlockMacroProcessor`:: Processes `plantuml_image::{path}[{options}]` commands
435
814
  in Metanorma documents and integrates with the Metanorma rendering pipeline.
436
815
 
437
816
  `Backend`:: Handles Metanorma-specific logic including document paths, PlantUML
@@ -453,6 +832,8 @@ PlantUML versions:
453
832
  | Gem version | PlantUML version | Notes
454
833
 
455
834
  | 1.0.0 | 1.2025.4 | Latest release with updated architecture
835
+ | 1.0.4 | 1.2025.7 | Latest release
836
+
456
837
  |===
457
838
 
458
839
  This approach allows the gem to follow standard semantic versioning practices
@@ -460,54 +841,133 @@ while clearly documenting which PlantUML version is bundled with each release.
460
841
 
461
842
  === Updating PlantUML version
462
843
 
463
- This gem bundles a specific version of PlantUML JAR file. To update to a newer
464
- version:
844
+ ==== General
845
+
846
+ This gem bundles a specific version of PlantUML JAR file.
847
+
848
+ There are two ways to update to a newer version.
849
+
850
+ ==== Automatic update (recommended)
851
+
852
+ The simplest way to update PlantUML is to use the automated update task:
853
+
854
+ [source,console]
855
+ ----
856
+ $ bundle exec rake update_plantuml
857
+ ----
858
+
859
+ This task will:
860
+
861
+ * Search GitHub for the latest valid PlantUML release (excluding pre-releases and native builds)
862
+ * Compare with the current version and skip if already up to date
863
+ * Update version files automatically (both PlantUML and gem versions)
864
+ * Download and verify the new JAR file
865
+ * Test the JAR functionality to ensure it works correctly
866
+
867
+ The task uses exit codes to indicate the result:
868
+
869
+ * Exit code 0: No update needed (already up to date)
870
+ * Exit code 1: Update completed successfully
871
+ * Exit code 2: Update failed due to an error
872
+
873
+ ==== Manual update
874
+
875
+ For manual updates or to specify a particular version:
465
876
 
466
877
  . Check the latest PlantUML release at
467
878
  https://github.com/plantuml/plantuml/releases
468
879
 
469
- . Update the version in `lib/metanorma/plugin/plantuml/version.rb`:
880
+ . Use the manual version update task:
470
881
  +
471
- [source,ruby]
882
+ [source,console]
472
883
  ----
473
- PLANTUML_JAR_VERSION = "1.2025.4" # Update to latest version
474
- VERSION = "1.0.1" # Increment patch version
884
+ $ bundle exec rake update_plantuml_version[1.2025.7]
475
885
  ----
476
886
 
477
- . Clean the old JAR file:
887
+ . Download the new JAR file:
478
888
  +
479
889
  [source,console]
480
890
  ----
481
- $ bundle exec rake clean_jar
891
+ $ bundle exec rake clean_jar download_jar
482
892
  ----
483
893
 
484
- . Download the new JAR file:
894
+ . Test the functionality:
485
895
  +
486
896
  [source,console]
487
897
  ----
488
- $ bundle exec rake download_jar
898
+ $ bundle exec rake test_plantuml
489
899
  ----
490
900
 
491
- . Run tests to ensure everything works:
492
- +
901
+ ==== Version checking
902
+
903
+ You can check the current PlantUML and gem versions:
904
+
493
905
  [source,console]
494
906
  ----
495
- $ bundle exec rake spec
907
+ $ bundle exec rake check_plantuml_version
496
908
  ----
497
909
 
498
- . Update the gem version by incrementing the patch version (e.g., `1.0.0` →
499
- `1.0.1`) for PlantUML updates, or increment minor/major versions for gem feature
500
- updates.
910
+ You can find the latest available PlantUML version:
911
+
912
+ [source,console]
913
+ ----
914
+ $ bundle exec rake find_latest_plantuml
915
+ ----
501
916
 
502
917
  === Available rake tasks
503
918
 
919
+ ==== PlantUML management tasks
920
+
504
921
  [source,console]
505
922
  ----
506
- $ bundle exec rake download_jar # Download PlantUML JAR file
507
- $ bundle exec rake clean_jar # Remove downloaded JAR file
508
- $ bundle exec rake spec # Run tests
923
+ $ bundle exec rake update_plantuml # Update PlantUML to latest version (automatic)
924
+ $ bundle exec rake update_plantuml_version[VERSION] # Update PlantUML to specific version (manual)
925
+ $ bundle exec rake check_plantuml_version # Check current PlantUML and gem versions
926
+ $ bundle exec rake find_latest_plantuml # Find latest valid PlantUML release
927
+ $ bundle exec rake test_plantuml # Test PlantUML JAR functionality
509
928
  ----
510
929
 
930
+ ==== JAR file management tasks
931
+
932
+ [source,console]
933
+ ----
934
+ $ bundle exec rake download_jar # Download PlantUML JAR file
935
+ $ bundle exec rake clean_jar # Remove downloaded JAR file
936
+ ----
937
+
938
+ ==== Development tasks
939
+
940
+ [source,console]
941
+ ----
942
+ $ bundle exec rake spec # Run tests
943
+ $ bundle exec rake # Default task: download JAR + run tests
944
+ ----
945
+
946
+ ==== Task descriptions
947
+
948
+ `update_plantuml`:: Automatically finds the latest valid PlantUML release,
949
+ updates version files, downloads the new JAR, and tests functionality. This is
950
+ the recommended way to update PlantUML.
951
+
952
+ `update_plantuml_version[VERSION]`:: Manually updates the PlantUML version in
953
+ `version.rb` to the specified version and increments the gem version. Use this
954
+ when you need to specify a particular PlantUML version.
955
+
956
+ `check_plantuml_version`:: Displays the current PlantUML JAR version and gem
957
+ version from `version.rb`.
958
+
959
+ `find_latest_plantuml`:: Searches GitHub for the latest valid PlantUML release,
960
+ filtering out pre-releases, native builds, and invalid versions. Shows the
961
+ version and release information.
962
+
963
+ `test_plantuml`:: Tests the downloaded PlantUML JAR by running version checks
964
+ and generating a test diagram to ensure functionality.
965
+
966
+ `download_jar`:: Downloads the PlantUML JAR file based on the version specified
967
+ in `version.rb`. Creates the `data/` directory if it doesn't exist.
968
+
969
+ `clean_jar`:: Removes the downloaded PlantUML JAR file from `data/plantuml.jar`.
970
+
511
971
  == Documentation
512
972
 
513
973
  Please refer to https://www.metanorma.org.