metanorma-plugin-plantuml 1.0.2 → 1.0.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7c85595e30e3155c473b4f44936209c3f95c8ab5cf29d55a2368bad6584c136
|
4
|
+
data.tar.gz: d7e58a9934d9995c9b36c3b86dc543a7c633d0c31fab5dd543707b7f347207c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '05039945787b1a1d65f8a37193db39346f2d42ac820dff54d70724fbb09bdbe2808a9ca20477a78e78b1357f65de337c289a075feabf27c9e3ae92264e671865'
|
7
|
+
data.tar.gz: 1cff1673fbed5b3e00a6e05d7642cccce29e6d5f5d2cd62500860fddf089a8fc7046a2c49df41b422804b03eb762bd0bb6ac21d67e8763e6d38583f29df4e0ed
|
data/.github/workflows/rake.yml
CHANGED
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
|
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
|
-
|
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.
|
64
87
|
|
88
|
+
Generally, the command syntax is more suitable for referencing external PlantUML
|
89
|
+
files.
|
65
90
|
|
66
|
-
=== Basic syntax
|
67
91
|
|
68
|
-
|
92
|
+
=== Command syntax for external diagrams
|
93
|
+
|
94
|
+
PlantUML diagrams can be directly referenced from external files using the
|
95
|
+
`plantuml_image::{path}[{options}]` command.
|
96
|
+
|
97
|
+
Syntax:
|
69
98
|
|
70
99
|
[source,asciidoc]
|
71
100
|
----
|
72
|
-
[
|
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
|
-
|
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
|
-
|
176
|
+
[plantuml,{options}]
|
177
|
+
....
|
178
|
+
{PlantUML diagram source here}
|
179
|
+
....
|
86
180
|
----
|
87
181
|
|
88
|
-
|
89
|
-
|
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
|
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
|
-
|
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:
|
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:
|
158
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
|
-
|
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
|
-
|
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
|
-
|
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:
|
206
397
|
|
207
|
-
|
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.
|
208
404
|
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
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.
|
213
410
|
|
411
|
+
|
412
|
+
==== Setting `includedirs`
|
413
|
+
|
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.
|
417
|
+
|
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:
|
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
|
-
|
247
|
-
|
248
|
-
`
|
249
|
-
|
250
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
285
|
-
|
286
|
-
|
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.
|
541
|
+
|
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
|
+
|
287
547
|
|
288
|
-
====
|
548
|
+
==== Diagram-level `includedirs` option
|
289
549
|
|
290
|
-
|
291
|
-
|
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.
|
293
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:
|
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
|
-
|
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:
|
336
634
|
|
635
|
+
[source,asciidoc]
|
636
|
+
----
|
637
|
+
[plantuml,{image-attributes}]
|
638
|
+
....
|
639
|
+
{PlantUML diagram source here}
|
640
|
+
....
|
641
|
+
----
|
642
|
+
|
643
|
+
Command syntax:
|
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
|
-
|
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:
|
692
|
+
|
693
|
+
[source,asciidoc]
|
694
|
+
----
|
695
|
+
[plantuml]
|
696
|
+
....
|
697
|
+
@startuml {custom-filename}
|
698
|
+
{PlantUML diagram source here}
|
699
|
+
@enduml
|
700
|
+
....
|
701
|
+
----
|
702
|
+
|
703
|
+
Where,
|
361
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
|
+
====
|
362
711
|
[source,asciidoc]
|
363
712
|
----
|
364
713
|
[plantuml]
|
365
714
|
....
|
366
|
-
@startuml
|
715
|
+
@startuml AliceToBob
|
367
716
|
Alice -> Bob: Hello
|
368
717
|
@enduml
|
369
718
|
....
|
370
719
|
----
|
371
720
|
|
372
|
-
This generates `
|
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
|
+
====
|
725
|
+
|
726
|
+
|
374
727
|
|
728
|
+
=== Disable PlantUML processing
|
375
729
|
|
376
|
-
|
730
|
+
It is possible to disable PlantUML processing either document-wide or via an
|
731
|
+
environment variable.
|
377
732
|
|
378
|
-
|
733
|
+
When disabled, PlantUML blocks are rendered as code listings instead of
|
734
|
+
diagrams.
|
379
735
|
|
380
|
-
|
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
|
-
|
758
|
+
This renders the PlantUML block as a code listing instead of a diagram.
|
759
|
+
====
|
395
760
|
|
396
|
-
|
761
|
+
The same effect can be achieved using by setting the `PLANTUML_DISABLED`
|
762
|
+
environment variable to `true`.
|
397
763
|
|
398
|
-
|
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
|
408
|
-
relative to
|
409
|
-
|
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)
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
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}]`
|
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
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Metanorma
|
4
4
|
module Plugin
|
5
5
|
module Plantuml
|
6
|
-
# PlantUML block processor
|
6
|
+
# PlantUML block processor
|
7
7
|
class BlockProcessor < ::Asciidoctor::Extensions::BlockProcessor
|
8
8
|
include ::Metanorma::Plugin::Plantuml::BlockProcessorBase
|
9
9
|
use_dsl
|
@@ -37,9 +37,8 @@ module Metanorma
|
|
37
37
|
options = {}
|
38
38
|
|
39
39
|
# Parse include directory
|
40
|
-
options[:includedirs] = parse_doc_includedirs(parent.document)
|
41
40
|
options[:includedirs] = add_attrs_to_includedirs(
|
42
|
-
parent.document, attrs,
|
41
|
+
parent.document, attrs, parse_doc_includedirs(parent.document)
|
43
42
|
)
|
44
43
|
|
45
44
|
options
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Metanorma
|
4
4
|
module Plugin
|
5
5
|
module Plantuml
|
6
|
-
# PlantUML block processor
|
6
|
+
# PlantUML block processor
|
7
7
|
class ImageBlockMacroProcessor < ::Asciidoctor::Extensions::BlockMacroProcessor
|
8
8
|
include ::Metanorma::Plugin::Plantuml::BlockProcessorBase
|
9
9
|
use_dsl
|