metanorma-plugin-plantuml 1.0.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.
- checksums.yaml +7 -0
- data/.github/workflows/plantuml-version-sync.yml +113 -0
- data/.github/workflows/rake.yml +15 -0
- data/.github/workflows/release.yml +25 -0
- data/Gemfile +28 -0
- data/LICENSE +25 -0
- data/README.adoc +374 -0
- data/Rakefile +38 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/data/plantuml.jar +0 -0
- data/lib/metanorma/plugin/plantuml/backend.rb +160 -0
- data/lib/metanorma/plugin/plantuml/block_processor.rb +82 -0
- data/lib/metanorma/plugin/plantuml/config.rb +48 -0
- data/lib/metanorma/plugin/plantuml/errors.rb +42 -0
- data/lib/metanorma/plugin/plantuml/utils.rb +28 -0
- data/lib/metanorma/plugin/plantuml/version.rb +8 -0
- data/lib/metanorma/plugin/plantuml/wrapper.rb +256 -0
- data/lib/metanorma-plugin-plantuml.rb +15 -0
- data/metanorma-plugin-plantuml.gemspec +35 -0
- metadata +91 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 82db5cce760911ac43ad666a3d25e800341ff7b4f591d0905562f2e8bccb99e2
|
4
|
+
data.tar.gz: 170923ac6b7ace25020922e57904417ced9a3ef6d6f311a83be9ce0ab65b281f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1347f4e1aab08371499c23dd2b39dfdc3aa3371f1db258ffa36ad557513a915e30b70e470df5f37d5766df38ca106dc54cbaad146f09cb135dfa1c41cab5e5f7
|
7
|
+
data.tar.gz: 1bb6c111325ab23cbe83f3c1903701740c31573f1baa80760c03f467559c07111b81ab80fc99afbda6de0445e5dab9e1c4cf58f96fb92e24a8552f7e1946a1d6
|
@@ -0,0 +1,113 @@
|
|
1
|
+
name: PlantUML Version Sync
|
2
|
+
|
3
|
+
on:
|
4
|
+
schedule:
|
5
|
+
# Check for new PlantUML releases daily at 6 AM UTC
|
6
|
+
- cron: '0 6 * * *'
|
7
|
+
workflow_dispatch:
|
8
|
+
# Allow manual triggering
|
9
|
+
|
10
|
+
jobs:
|
11
|
+
check-plantuml-version:
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
|
14
|
+
steps:
|
15
|
+
- name: Checkout repository
|
16
|
+
uses: actions/checkout@v4
|
17
|
+
with:
|
18
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
19
|
+
|
20
|
+
- name: Set up Ruby
|
21
|
+
uses: ruby/setup-ruby@v1
|
22
|
+
with:
|
23
|
+
ruby-version: '3.1'
|
24
|
+
bundler-cache: true
|
25
|
+
|
26
|
+
- name: Get current PlantUML version
|
27
|
+
id: current-version
|
28
|
+
run: |
|
29
|
+
CURRENT_VERSION=$(ruby -e "require './lib/metanorma/plugin/plantuml/version'; puts Metanorma::Plugin::Plantuml::PLANTUML_JAR_VERSION")
|
30
|
+
echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
|
31
|
+
|
32
|
+
- name: Get latest PlantUML release
|
33
|
+
id: latest-version
|
34
|
+
run: |
|
35
|
+
LATEST_VERSION=$(curl -s https://api.github.com/repos/plantuml/plantuml/releases/latest | jq -r .tag_name | sed 's/^v//')
|
36
|
+
echo "version=$LATEST_VERSION" >> $GITHUB_OUTPUT
|
37
|
+
|
38
|
+
- name: Compare versions
|
39
|
+
id: compare
|
40
|
+
run: |
|
41
|
+
if [ "${{ steps.current-version.outputs.version }}" != "${{ steps.latest-version.outputs.version }}" ]; then
|
42
|
+
echo "needs_update=true" >> $GITHUB_OUTPUT
|
43
|
+
echo "Current version: ${{ steps.current-version.outputs.version }}"
|
44
|
+
echo "Latest version: ${{ steps.latest-version.outputs.version }}"
|
45
|
+
else
|
46
|
+
echo "needs_update=false" >> $GITHUB_OUTPUT
|
47
|
+
echo "PlantUML version is up to date"
|
48
|
+
fi
|
49
|
+
|
50
|
+
- name: Update version file
|
51
|
+
if: steps.compare.outputs.needs_update == 'true'
|
52
|
+
run: |
|
53
|
+
NEW_VERSION="${{ steps.latest-version.outputs.version }}"
|
54
|
+
sed -i "s/PLANTUML_JAR_VERSION = \".*\"/PLANTUML_JAR_VERSION = \"$NEW_VERSION\"/" lib/metanorma/plugin/plantuml/version.rb
|
55
|
+
|
56
|
+
- name: Update gem version
|
57
|
+
if: steps.compare.outputs.needs_update == 'true'
|
58
|
+
run: |
|
59
|
+
# Increment patch version using semantic versioning
|
60
|
+
CURRENT_GEM_VERSION=$(ruby -e "require './lib/metanorma/plugin/plantuml/version'; puts Metanorma::Plugin::Plantuml::VERSION")
|
61
|
+
NEW_GEM_VERSION=$(ruby -e "
|
62
|
+
require 'rubygems'
|
63
|
+
current_version = Gem::Version.new('$CURRENT_GEM_VERSION')
|
64
|
+
segments = current_version.segments
|
65
|
+
segments[2] = (segments[2] || 0) + 1
|
66
|
+
puts segments.join('.')
|
67
|
+
")
|
68
|
+
sed -i "s/VERSION = \".*\"/VERSION = \"$NEW_GEM_VERSION\"/" lib/metanorma/plugin/plantuml/version.rb
|
69
|
+
echo "Updated gem version from $CURRENT_GEM_VERSION to $NEW_GEM_VERSION"
|
70
|
+
|
71
|
+
- name: Remove old JAR and download new one
|
72
|
+
if: steps.compare.outputs.needs_update == 'true'
|
73
|
+
run: |
|
74
|
+
rm -f data/plantuml.jar
|
75
|
+
bundle exec rake download_jar
|
76
|
+
|
77
|
+
- name: Verify new JAR works
|
78
|
+
if: steps.compare.outputs.needs_update == 'true'
|
79
|
+
run: |
|
80
|
+
if [ -f "data/plantuml.jar" ]; then
|
81
|
+
echo "PlantUML JAR downloaded successfully"
|
82
|
+
java -jar data/plantuml.jar -version || echo "Version check completed"
|
83
|
+
else
|
84
|
+
echo "Failed to download PlantUML JAR"
|
85
|
+
exit 1
|
86
|
+
fi
|
87
|
+
|
88
|
+
- name: Create Pull Request
|
89
|
+
if: steps.compare.outputs.needs_update == 'true'
|
90
|
+
uses: peter-evans/create-pull-request@v5
|
91
|
+
with:
|
92
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
93
|
+
commit-message: |
|
94
|
+
Update PlantUML to version ${{ steps.latest-version.outputs.version }}
|
95
|
+
|
96
|
+
- Updated PLANTUML_JAR_VERSION to ${{ steps.latest-version.outputs.version }}
|
97
|
+
- Downloaded new PlantUML JAR file
|
98
|
+
- Incremented gem version
|
99
|
+
title: "Update PlantUML to version ${{ steps.latest-version.outputs.version }}"
|
100
|
+
body: |
|
101
|
+
This PR updates PlantUML to the latest version ${{ steps.latest-version.outputs.version }}.
|
102
|
+
|
103
|
+
Changes:
|
104
|
+
- Updated `PLANTUML_JAR_VERSION` in `lib/metanorma/plugin/plantuml/version.rb`
|
105
|
+
- Downloaded new PlantUML JAR to `data/plantuml.jar`
|
106
|
+
- Incremented gem version
|
107
|
+
|
108
|
+
This update was created automatically by the PlantUML version sync workflow.
|
109
|
+
branch: update-plantuml-${{ steps.latest-version.outputs.version }}
|
110
|
+
base: main
|
111
|
+
labels: |
|
112
|
+
enhancement
|
113
|
+
automated
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Auto-generated by Cimas: Do not edit it manually!
|
2
|
+
# See https://github.com/metanorma/cimas
|
3
|
+
name: rake
|
4
|
+
|
5
|
+
on:
|
6
|
+
push:
|
7
|
+
branches: [ master, main ]
|
8
|
+
tags: [ v* ]
|
9
|
+
pull_request:
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
rake:
|
13
|
+
uses: metanorma/ci/.github/workflows/plantuml-rake.yml@main
|
14
|
+
secrets:
|
15
|
+
pat_token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# Auto-generated by Cimas: Do not edit it manually!
|
2
|
+
# See https://github.com/metanorma/cimas
|
3
|
+
name: release
|
4
|
+
|
5
|
+
on:
|
6
|
+
workflow_dispatch:
|
7
|
+
inputs:
|
8
|
+
next_version:
|
9
|
+
description: |
|
10
|
+
Next release version. Possible values: x.y.z, major, minor, patch (or pre|rc|etc).
|
11
|
+
Also, you can pass 'skip' to skip 'git tag' and do 'gem push' for the current version
|
12
|
+
required: true
|
13
|
+
default: 'skip'
|
14
|
+
repository_dispatch:
|
15
|
+
types: [ do-release ]
|
16
|
+
|
17
|
+
jobs:
|
18
|
+
release:
|
19
|
+
uses: metanorma/ci/.github/workflows/rubygems-release.yml@main
|
20
|
+
with:
|
21
|
+
next_version: ${{ github.event.inputs.next_version }}
|
22
|
+
secrets:
|
23
|
+
rubygems-api-key: ${{ secrets.METANORMA_CI_RUBYGEMS_API_KEY }}
|
24
|
+
pat_token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
|
25
|
+
|
data/Gemfile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
Encoding.default_external = Encoding::UTF_8
|
2
|
+
Encoding.default_internal = Encoding::UTF_8
|
3
|
+
|
4
|
+
source "https://rubygems.org"
|
5
|
+
git_source(:github) { |repo| "https://github.com/#{repo}" }
|
6
|
+
|
7
|
+
gemspec
|
8
|
+
|
9
|
+
begin
|
10
|
+
eval_gemfile("Gemfile.devel")
|
11
|
+
rescue StandardError
|
12
|
+
nil
|
13
|
+
end
|
14
|
+
|
15
|
+
gem "byebug"
|
16
|
+
gem "debug"
|
17
|
+
gem "metanorma"
|
18
|
+
gem "metanorma-standoc", github: "metanorma/metanorma-standoc", branch: "feature/extract-plantuml"
|
19
|
+
gem "rake"
|
20
|
+
gem "rspec"
|
21
|
+
gem "rspec-html-matchers"
|
22
|
+
gem "rubocop"
|
23
|
+
gem "rubocop-performance"
|
24
|
+
gem "simplecov"
|
25
|
+
gem "timecop"
|
26
|
+
gem "vcr"
|
27
|
+
gem "webmock"
|
28
|
+
gem "canon"
|
data/LICENSE
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
BSD 2-Clause License
|
2
|
+
|
3
|
+
Copyright (c) 2025, Ribose
|
4
|
+
All rights reserved.
|
5
|
+
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
8
|
+
|
9
|
+
* Redistributions of source code must retain the above copyright notice, this
|
10
|
+
list of conditions and the following disclaimer.
|
11
|
+
|
12
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
14
|
+
and/or other materials provided with the distribution.
|
15
|
+
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
17
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
18
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
19
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
20
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
21
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
22
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
23
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
24
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
25
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.adoc
ADDED
@@ -0,0 +1,374 @@
|
|
1
|
+
= Metanorma PlantUML plugin (metanorma-plugin-plantuml)
|
2
|
+
|
3
|
+
image:https://github.com/metanorma/metanorma-plugin-plantuml/workflows/rake/badge.svg["Build Status", link="https://github.com/metanorma/metanorma-plugin-plantuml/actions?workflow=rake"]
|
4
|
+
|
5
|
+
== Purpose
|
6
|
+
|
7
|
+
This is a Metanorma plugin to enable usage of PlantUML diagrams in Metanorma
|
8
|
+
documents.
|
9
|
+
|
10
|
+
It provides a Ruby API that wraps a bundled PlantUML JAR file.
|
11
|
+
|
12
|
+
== PlantUML
|
13
|
+
|
14
|
+
PlantUML is a popular tool that allows users to create rich diagrams from plain
|
15
|
+
text descriptions, including:
|
16
|
+
|
17
|
+
* UML diagrams
|
18
|
+
|
19
|
+
** Sequence diagram
|
20
|
+
** Usecase diagram
|
21
|
+
** Class diagram
|
22
|
+
** Object diagram
|
23
|
+
** Activity diagram
|
24
|
+
** Component diagram
|
25
|
+
** Deployment diagram
|
26
|
+
** State diagram
|
27
|
+
** Timing diagram
|
28
|
+
|
29
|
+
It also supports the following non-UML diagrams:
|
30
|
+
|
31
|
+
* JSON Data
|
32
|
+
* YAML Data
|
33
|
+
* Network diagram (nwdiag)
|
34
|
+
* Wireframe graphical interface
|
35
|
+
* Archimate diagram
|
36
|
+
* Specification and Description Language (SDL)
|
37
|
+
* Ditaa diagram
|
38
|
+
* Gantt diagram
|
39
|
+
* MindMap diagram
|
40
|
+
* Work Breakdown Structure diagram
|
41
|
+
* Mathematic with AsciiMath or JLaTeXMath notation
|
42
|
+
* Entity Relationship diagram
|
43
|
+
|
44
|
+
For more details, please refer to the
|
45
|
+
https://www.plantuml.net[official PlantUML website].
|
46
|
+
|
47
|
+
The official PlantUML Language Reference Guide is available at:
|
48
|
+
|
49
|
+
* https://pdf.plantuml.net/PlantUML_Language_Reference_Guide_en.pdf
|
50
|
+
|
51
|
+
|
52
|
+
== Installation
|
53
|
+
|
54
|
+
[source,console]
|
55
|
+
----
|
56
|
+
$ gem install metanorma-plugin-plantuml
|
57
|
+
----
|
58
|
+
|
59
|
+
|
60
|
+
== Usage
|
61
|
+
|
62
|
+
This plugin enables PlantUML diagram generation in Metanorma documents through
|
63
|
+
the `plantuml` block directive.
|
64
|
+
|
65
|
+
|
66
|
+
=== Basic syntax
|
67
|
+
|
68
|
+
[source,asciidoc]
|
69
|
+
----
|
70
|
+
[plantuml]
|
71
|
+
....
|
72
|
+
@startuml
|
73
|
+
Alice -> Bob: Hello
|
74
|
+
Bob -> Alice: Hi there
|
75
|
+
@enduml
|
76
|
+
....
|
77
|
+
----
|
78
|
+
|
79
|
+
=== Supported diagram types
|
80
|
+
|
81
|
+
PlantUML supports various diagram types, each with its own `@start` and `@end` directives:
|
82
|
+
|
83
|
+
`@startuml` / `@enduml`:: UML diagrams (sequence, class, activity, etc.)
|
84
|
+
`@startmindmap` / `@endmindmap`:: Mind map diagrams
|
85
|
+
`@startgantt` / `@endgantt`:: Gantt charts
|
86
|
+
`@startsalt` / `@endsalt`:: Wireframe diagrams
|
87
|
+
`@startdot` / `@enddot`:: Graphviz DOT diagrams
|
88
|
+
`@startditaa` / `@endditaa`:: ASCII art diagrams
|
89
|
+
`@startjson` / `@endjson`:: JSON data visualization
|
90
|
+
`@startyaml` / `@endyaml`:: YAML data visualization
|
91
|
+
|
92
|
+
.Sequence diagram
|
93
|
+
[example]
|
94
|
+
====
|
95
|
+
[source,asciidoc]
|
96
|
+
----
|
97
|
+
[plantuml]
|
98
|
+
....
|
99
|
+
@startuml sequence-example
|
100
|
+
participant Alice
|
101
|
+
participant Bob
|
102
|
+
|
103
|
+
Alice -> Bob: Authentication Request
|
104
|
+
Bob --> Alice: Authentication Response
|
105
|
+
@enduml
|
106
|
+
....
|
107
|
+
----
|
108
|
+
====
|
109
|
+
|
110
|
+
.Mind map
|
111
|
+
[example]
|
112
|
+
====
|
113
|
+
[source,asciidoc]
|
114
|
+
----
|
115
|
+
[plantuml]
|
116
|
+
....
|
117
|
+
@startmindmap
|
118
|
+
* Metanorma
|
119
|
+
** Standards
|
120
|
+
*** ISO
|
121
|
+
*** IEC
|
122
|
+
*** ITU
|
123
|
+
** Formats
|
124
|
+
*** PDF
|
125
|
+
*** HTML
|
126
|
+
*** Word
|
127
|
+
@endmindmap
|
128
|
+
....
|
129
|
+
----
|
130
|
+
====
|
131
|
+
|
132
|
+
=== Format options
|
133
|
+
|
134
|
+
==== Single format specification
|
135
|
+
|
136
|
+
Specify the output format using the `format` attribute:
|
137
|
+
|
138
|
+
[source,asciidoc]
|
139
|
+
----
|
140
|
+
[plantuml,format=svg]
|
141
|
+
....
|
142
|
+
@startuml
|
143
|
+
Alice -> Bob: Hello
|
144
|
+
@enduml
|
145
|
+
....
|
146
|
+
----
|
147
|
+
|
148
|
+
Supported formats:
|
149
|
+
|
150
|
+
`png`:: (default) Portable Network Graphics
|
151
|
+
`svg`:: Scalable Vector Graphics
|
152
|
+
`pdf`:: Portable Document Format
|
153
|
+
`txt`:: ASCII art text output
|
154
|
+
`eps`:: Encapsulated PostScript
|
155
|
+
|
156
|
+
==== Multiple format generation
|
157
|
+
|
158
|
+
Generate multiple formats simultaneously using the `formats` attribute:
|
159
|
+
|
160
|
+
[source,asciidoc]
|
161
|
+
----
|
162
|
+
[plantuml,formats="png,svg,pdf"]
|
163
|
+
....
|
164
|
+
@startuml
|
165
|
+
Alice -> Bob: Hello
|
166
|
+
@enduml
|
167
|
+
....
|
168
|
+
----
|
169
|
+
|
170
|
+
==== Document-level format configuration
|
171
|
+
|
172
|
+
Set the default format for all PlantUML diagrams in your document:
|
173
|
+
|
174
|
+
[source,asciidoc]
|
175
|
+
----
|
176
|
+
:plantuml-image-format: svg
|
177
|
+
|
178
|
+
[plantuml]
|
179
|
+
....
|
180
|
+
@startuml
|
181
|
+
Alice -> Bob: Hello
|
182
|
+
@enduml
|
183
|
+
....
|
184
|
+
----
|
185
|
+
|
186
|
+
=== Image attributes
|
187
|
+
|
188
|
+
Standard AsciiDoc image attributes are supported:
|
189
|
+
|
190
|
+
[source,asciidoc]
|
191
|
+
----
|
192
|
+
[plantuml,id=my-diagram,title="My Sequence Diagram",width=600,height=400]
|
193
|
+
....
|
194
|
+
@startuml
|
195
|
+
Alice -> Bob: Hello
|
196
|
+
@enduml
|
197
|
+
....
|
198
|
+
----
|
199
|
+
|
200
|
+
Supported attributes:
|
201
|
+
|
202
|
+
`id`:: Element identifier
|
203
|
+
`title`:: Image title/caption
|
204
|
+
`alt`:: Alternative text
|
205
|
+
`width`:: Image width
|
206
|
+
`height`:: Image height
|
207
|
+
`align`:: Alignment (left, center, right)
|
208
|
+
`float`:: Float positioning
|
209
|
+
`role`:: CSS class/role
|
210
|
+
|
211
|
+
=== Filename specification
|
212
|
+
|
213
|
+
Specify custom filenames within the PlantUML source:
|
214
|
+
|
215
|
+
[source,asciidoc]
|
216
|
+
----
|
217
|
+
[plantuml]
|
218
|
+
....
|
219
|
+
@startuml my-custom-name
|
220
|
+
Alice -> Bob: Hello
|
221
|
+
@enduml
|
222
|
+
....
|
223
|
+
----
|
224
|
+
|
225
|
+
This generates `my-custom-name.png` (or specified format) instead of an
|
226
|
+
auto-generated filename.
|
227
|
+
|
228
|
+
|
229
|
+
=== Configuration options
|
230
|
+
|
231
|
+
==== Disable PlantUML processing
|
232
|
+
|
233
|
+
Disable PlantUML processing document-wide:
|
234
|
+
|
235
|
+
[source,asciidoc]
|
236
|
+
----
|
237
|
+
:plantuml-disabled:
|
238
|
+
|
239
|
+
[plantuml]
|
240
|
+
....
|
241
|
+
@startuml
|
242
|
+
Alice -> Bob: Hello
|
243
|
+
@enduml
|
244
|
+
....
|
245
|
+
----
|
246
|
+
|
247
|
+
When disabled, PlantUML blocks are rendered as code listings instead of diagrams.
|
248
|
+
|
249
|
+
==== Environment variable
|
250
|
+
|
251
|
+
Disable PlantUML processing via environment variable:
|
252
|
+
|
253
|
+
[source,console]
|
254
|
+
----
|
255
|
+
$ PLANTUML_DISABLED=true metanorma document.adoc
|
256
|
+
----
|
257
|
+
|
258
|
+
=== File organization
|
259
|
+
|
260
|
+
Generated PlantUML images are stored in the `_plantuml_images/` directory
|
261
|
+
relative to your document location. This directory is automatically created if
|
262
|
+
it doesn't exist.
|
263
|
+
|
264
|
+
== Development
|
265
|
+
|
266
|
+
=== Architecture
|
267
|
+
|
268
|
+
This plugin follows a layered architecture that separates concerns between
|
269
|
+
Metanorma integration and PlantUML execution:
|
270
|
+
|
271
|
+
[source]
|
272
|
+
----
|
273
|
+
Metanorma Document
|
274
|
+
↓
|
275
|
+
BlockProcessor ← (processes [plantuml] blocks)
|
276
|
+
↓
|
277
|
+
Backend ← (Metanorma integration, paths, validation)
|
278
|
+
↓
|
279
|
+
Wrapper ← (Java/JAR execution, file I/O)
|
280
|
+
↓
|
281
|
+
PlantUML JAR ← (diagram generation)
|
282
|
+
----
|
283
|
+
|
284
|
+
`BlockProcessor`:: Processes `[plantuml]` blocks in Metanorma documents and
|
285
|
+
integrates with the Metanorma rendering pipeline.
|
286
|
+
|
287
|
+
`Backend`:: Handles Metanorma-specific logic including document paths, PlantUML
|
288
|
+
source validation, filename extraction, and attribute mapping.
|
289
|
+
|
290
|
+
`Wrapper`:: Provides low-level PlantUML JAR execution with cross-platform Java
|
291
|
+
handling, file I/O operations, and format conversion.
|
292
|
+
|
293
|
+
|
294
|
+
=== Version mapping
|
295
|
+
|
296
|
+
This gem uses semantic versioning independent of the PlantUML JAR version.
|
297
|
+
|
298
|
+
The following table shows the relationship between gem versions and bundled
|
299
|
+
PlantUML versions:
|
300
|
+
|
301
|
+
[cols="1,1,1", options="header"]
|
302
|
+
|===
|
303
|
+
| Gem version | PlantUML version | Notes
|
304
|
+
|
305
|
+
| 1.0.0 | 1.2025.4 | Latest release with updated architecture
|
306
|
+
|===
|
307
|
+
|
308
|
+
This approach allows the gem to follow standard semantic versioning practices
|
309
|
+
while clearly documenting which PlantUML version is bundled with each release.
|
310
|
+
|
311
|
+
=== Updating PlantUML version
|
312
|
+
|
313
|
+
This gem bundles a specific version of PlantUML JAR file. To update to a newer
|
314
|
+
version:
|
315
|
+
|
316
|
+
. Check the latest PlantUML release at
|
317
|
+
https://github.com/plantuml/plantuml/releases
|
318
|
+
|
319
|
+
. Update the version in `lib/metanorma/plugin/plantuml/version.rb`:
|
320
|
+
+
|
321
|
+
[source,ruby]
|
322
|
+
----
|
323
|
+
PLANTUML_JAR_VERSION = "1.2025.4" # Update to latest version
|
324
|
+
VERSION = "1.0.1" # Increment patch version
|
325
|
+
----
|
326
|
+
|
327
|
+
. Clean the old JAR file:
|
328
|
+
+
|
329
|
+
[source,console]
|
330
|
+
----
|
331
|
+
$ bundle exec rake clean_jar
|
332
|
+
----
|
333
|
+
|
334
|
+
. Download the new JAR file:
|
335
|
+
+
|
336
|
+
[source,console]
|
337
|
+
----
|
338
|
+
$ bundle exec rake download_jar
|
339
|
+
----
|
340
|
+
|
341
|
+
. Run tests to ensure everything works:
|
342
|
+
+
|
343
|
+
[source,console]
|
344
|
+
----
|
345
|
+
$ bundle exec rake spec
|
346
|
+
----
|
347
|
+
|
348
|
+
. Update the gem version by incrementing the patch version (e.g., `1.0.0` →
|
349
|
+
`1.0.1`) for PlantUML updates, or increment minor/major versions for gem feature
|
350
|
+
updates.
|
351
|
+
|
352
|
+
=== Available rake tasks
|
353
|
+
|
354
|
+
[source,console]
|
355
|
+
----
|
356
|
+
$ bundle exec rake download_jar # Download PlantUML JAR file
|
357
|
+
$ bundle exec rake clean_jar # Remove downloaded JAR file
|
358
|
+
$ bundle exec rake spec # Run tests
|
359
|
+
----
|
360
|
+
|
361
|
+
== Documentation
|
362
|
+
|
363
|
+
Please refer to https://www.metanorma.org.
|
364
|
+
|
365
|
+
== Copyright and license
|
366
|
+
|
367
|
+
Copyright Ribose.
|
368
|
+
|
369
|
+
PlantUML is open-sourced under multiple licenses. For more details, please refer
|
370
|
+
to the PlantUML repository at https://github.com/plantuml/plantuml.
|
371
|
+
|
372
|
+
For the purposes of this plugin, it is distributed under the MIT license.
|
373
|
+
|
374
|
+
Licensed under the 2-Clause BSD License.
|
data/Rakefile
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
require_relative "lib/metanorma/plugin/plantuml/version"
|
4
|
+
|
5
|
+
RSpec::Core::RakeTask.new(:spec)
|
6
|
+
|
7
|
+
task default: [
|
8
|
+
"data/plantuml.jar",
|
9
|
+
:spec,
|
10
|
+
]
|
11
|
+
|
12
|
+
def uri_open(url)
|
13
|
+
require 'open-uri'
|
14
|
+
URI.parse(url).open
|
15
|
+
end
|
16
|
+
|
17
|
+
file "data/plantuml.jar" do |file|
|
18
|
+
ver = Metanorma::Plugin::Plantuml::PLANTUML_JAR_VERSION
|
19
|
+
url = "https://github.com/plantuml/plantuml/releases/download/v#{ver}/plantuml-#{ver}.jar"
|
20
|
+
puts "Downloading PlantUML JAR... #{url}"
|
21
|
+
|
22
|
+
FileUtils.mkdir_p(File.dirname(file.name))
|
23
|
+
|
24
|
+
File.open(file.name, "wb") do |f|
|
25
|
+
f.write uri_open(url).read
|
26
|
+
end
|
27
|
+
|
28
|
+
puts "PlantUML JAR downloaded to #{file.name}"
|
29
|
+
end
|
30
|
+
|
31
|
+
desc "Download PlantUML JAR file"
|
32
|
+
task :download_jar => "data/plantuml.jar"
|
33
|
+
|
34
|
+
desc "Clean downloaded JAR file"
|
35
|
+
task :clean_jar do
|
36
|
+
FileUtils.rm_f("data/plantuml.jar")
|
37
|
+
puts "Removed data/plantuml.jar"
|
38
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "metanorma/plugin/plantuml"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/data/plantuml.jar
ADDED
Binary file
|