kramdown-plantuml 1.0.5 → 1.1.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.
@@ -43,8 +43,10 @@ initialize() {
43
43
  }
44
44
 
45
45
  generate_variables() {
46
- # Replace + in the version number with a dot.
47
- version="${version/+/.}"
46
+ # Replace '+'' in the version number with '.'.
47
+ version="${version//+/.}"
48
+ # Replace '-' in the version number with '.'.
49
+ version="${version//-/.}"
48
50
 
49
51
  if [[ "$ref" == refs/tags/* ]]; then
50
52
  # Override GitVersion's version on tags, just to be sure.
@@ -0,0 +1,19 @@
1
+ name: amend
2
+
3
+ on:
4
+ issue_comment:
5
+ types: [created]
6
+
7
+ jobs:
8
+ amend:
9
+ if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/amend')
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v2
13
+ with:
14
+ persist-credentials: false
15
+ - name: amend
16
+ env:
17
+ GITHUB_TOKEN: ${{ secrets.PUBLIC_REPO_TOKEN }}
18
+ GITHUB_CONTEXT: ${{ toJSON(github) }}
19
+ run: .github/scripts/amend.sh --user payex-dev --verbose
@@ -8,7 +8,6 @@ on:
8
8
 
9
9
  jobs:
10
10
  test:
11
- name: No Java
12
11
  runs-on: ubuntu-latest
13
12
  container:
14
13
  image: ruby:2.7.2
@@ -19,5 +18,5 @@ jobs:
19
18
  - name: Bundle install
20
19
  run: bundle install --jobs 4 --retry 3
21
20
 
22
- - name: Test with Rake
21
+ - name: RSpec
23
22
  run: bundle exec rspec --tag no_java
@@ -8,19 +8,16 @@ on:
8
8
 
9
9
  jobs:
10
10
  test:
11
- name: No PlantUML
12
11
  runs-on: ubuntu-latest
13
12
 
14
13
  steps:
15
14
  - uses: actions/checkout@v2
16
15
 
17
16
  - name: Set up Ruby 2.7
18
- uses: actions/setup-ruby@v1
17
+ uses: ruby/setup-ruby@v1
19
18
  with:
20
- ruby-version: 2.7.x
19
+ ruby-version: 2.7
20
+ bundler-cache: true
21
21
 
22
- - name: Bundle install
23
- run: bundle install --jobs 4 --retry 3
24
-
25
- - name: Test with Rake
22
+ - name: RSpec
26
23
  run: bundle exec rspec --tag no_plantuml
@@ -1,10 +1,6 @@
1
1
  name: Ruby Gem
2
2
 
3
- on:
4
- push:
5
- branches: ['*']
6
- tags: ['*']
7
- pull_request:
3
+ on: [push, pull_request, pull_request_target]
8
4
 
9
5
  jobs:
10
6
  version:
@@ -19,19 +15,19 @@ jobs:
19
15
  fetch-depth: 0
20
16
 
21
17
  - name: Setup GitVersion
22
- uses: gittools/actions/gitversion/setup@v0.9.4
18
+ uses: gittools/actions/gitversion/setup@v0.9.10
23
19
  with:
24
- versionSpec: '5.3.x'
20
+ versionSpec: '5.x.x'
25
21
 
26
22
  - name: Execute GitVersion
27
23
  id: gitversion
28
- uses: gittools/actions/gitversion/execute@v0.9.4
24
+ uses: gittools/actions/gitversion/execute@v0.9.10
29
25
 
30
26
  - name: Create variables
31
27
  id: variables
32
28
  env:
33
29
  GITHUB_CONTEXT: ${{ toJson(github) }}
34
- run: ./.github/scripts/variables.sh ${{ steps.gitversion.outputs.legacySemVerPadded }}
30
+ run: ./.github/scripts/variables.sh ${{ steps.gitversion.outputs.fullSemVer }}
35
31
 
36
32
  plantuml:
37
33
  needs: version
@@ -41,12 +37,13 @@ jobs:
41
37
  - uses: actions/checkout@v2
42
38
 
43
39
  - name: Setup Java
44
- uses: actions/setup-java@v1
40
+ uses: actions/setup-java@v2
45
41
  with:
42
+ distribution: adopt
46
43
  java-version: 14
47
44
 
48
45
  - name: Cache Maven dependencies
49
- uses: actions/cache@v2
46
+ uses: actions/cache@v2.1.6
50
47
  with:
51
48
  path: ~/.m2/repository
52
49
  key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
@@ -82,30 +79,32 @@ jobs:
82
79
  - name: Version stamp
83
80
  run: sed -i -e 's/0.0.1.dev/${{ needs.version.outputs.version }}/g' ${{ github.workspace }}/lib/kramdown-plantuml/version.rb
84
81
 
85
- - name: Set up Ruby 2.7
86
- uses: actions/setup-ruby@v1
82
+ - name: Setup Ruby 2.7
83
+ uses: ruby/setup-ruby@v1
87
84
  with:
88
- ruby-version: 2.7.x
85
+ ruby-version: 2.7
86
+ bundler-cache: true
89
87
 
90
88
  - name: Setup Graphviz
91
89
  uses: kamiazya/setup-graphviz@v1
92
90
 
93
- - name: Cache Ruby gems
94
- uses: actions/cache@v1
95
- with:
96
- path: vendor/bundle
97
- key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
98
- restore-keys: ${{ runner.os }}-gems-
99
-
100
- - name: Bundle install
101
- run: .github/scripts/bundle-install.sh
102
-
103
91
  - name: rubocop
104
92
  run: bundle exec rubocop --fail-level warning --display-only-fail-level-offenses
105
93
 
94
+ - name: RSPec (debug)
95
+ env:
96
+ DEBUG: 1
97
+ run: bundle exec rspec --tag debug
98
+
106
99
  - name: Test with Rake
107
100
  run: bundle exec rake
108
101
 
102
+ - name: Upload code coverage
103
+ uses: actions/upload-artifact@v2
104
+ with:
105
+ name: coverage
106
+ path: ./coverage
107
+
109
108
  - name: Codecov upload
110
109
  run: bundle exec rake codecov:upload || echo 'Codecov upload failed'
111
110
 
@@ -113,7 +112,7 @@ jobs:
113
112
  id: gem
114
113
  run: .github/scripts/build-gem.sh
115
114
 
116
- - name: Upload artifact
115
+ - name: Upload gem
117
116
  uses: actions/upload-artifact@v2-preview
118
117
  with:
119
118
  name: ${{ steps.gem.outputs.name }}
@@ -128,27 +127,44 @@ jobs:
128
127
  publish-dev:
129
128
  needs: [version, gem]
130
129
  runs-on: ubuntu-latest
130
+ if: |
131
+ (github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]') ||
132
+ (github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]')
131
133
 
132
134
  steps:
133
135
  - uses: actions/checkout@v2
136
+ if: ${{ github.event_name != 'pull_request_target' }}
137
+
138
+ - uses: actions/checkout@v2
139
+ if: ${{ github.event_name == 'pull_request_target' }}
140
+ with:
141
+ ref: ${{ github.event.pull_request.head.sha }}
134
142
 
135
143
  - uses: actions/download-artifact@v2
136
144
  with:
137
145
  name: ${{ needs.gem.outputs.name }}
138
146
 
139
147
  - name: Set up Ruby 2.7
140
- uses: actions/setup-ruby@v1
148
+ uses: ruby/setup-ruby@v1
141
149
  with:
142
- ruby-version: 2.7.x
150
+ ruby-version: 2.7
151
+ bundler-cache: true
143
152
 
144
153
  - name: Setup Graphviz
145
154
  uses: kamiazya/setup-graphviz@v1
146
155
 
147
156
  - name: Publish to GPR
148
- run: .github/scripts/publish-gem.sh --gem ${{ needs.gem.outputs.name }} --token ${{ secrets.GITHUB_TOKEN }} --owner SwedbankPay --verbose
157
+ run: .github/scripts/publish-gem.sh --gem ${{ needs.gem.outputs.name }} --token "${{ secrets.GPR_TOKEN }}" --owner SwedbankPay --verbose
149
158
 
150
159
  - name: Test gem
151
- run: .github/scripts/test-gem.sh --workdir "${{ github.workspace }}/spec/fixture" --version ${{ needs.version.outputs.version }} --token "${{ secrets.GITHUB_TOKEN }}" --verbose
160
+ run: .github/scripts/test-gem.sh --workdir "${{ github.workspace }}/spec/fixture" --version ${{ needs.version.outputs.version }} --token "${{ secrets.GPR_TOKEN }}" --verbose
161
+
162
+ - name: Upload Jekyll site
163
+ uses: actions/upload-artifact@v2-preview
164
+ if: always()
165
+ with:
166
+ name: site
167
+ path: ${{ github.workspace }}/spec/fixture/_site
152
168
 
153
169
  publish-prod:
154
170
  needs: [version, gem]
@@ -1,10 +1,6 @@
1
1
  name: Shell
2
2
 
3
- on:
4
- push:
5
- branches: ['*']
6
- tags: ['*']
7
- pull_request:
3
+ on: [push, pull_request]
8
4
 
9
5
  jobs:
10
6
  shellcheck:
data/.gitignore CHANGED
@@ -13,3 +13,7 @@ Gemfile.lock
13
13
  /bin/
14
14
  .jekyll-cache
15
15
  _site
16
+ .classpath
17
+ .project
18
+ .settings
19
+ .vscode
data/.rubocop.yml CHANGED
@@ -1,4 +1,5 @@
1
1
  AllCops:
2
+ TargetRubyVersion: 2.5
2
3
  NewCops: enable
3
4
  Exclude:
4
5
  - "Rakefile"
data/GitVersion.yml ADDED
@@ -0,0 +1,5 @@
1
+ mode: ContinuousDeployment
2
+
3
+ branches:
4
+ main:
5
+ mode: ContinuousDelivery
data/README.md CHANGED
@@ -1,11 +1,12 @@
1
1
  # Kramdown::PlantUml
2
2
 
3
3
  [![Gem Version][gem-badge]][gem-url]
4
- ![Build][build-badge]
5
- ![No Java][no-java-build-badge]
6
- ![No PlantUML][no-plantuml-badge]
4
+ [![Ruby Gem][ruby-badge]][ruby-workflow]
5
+ [![No Java][no-java-badge]][no-java-workflow]
6
+ [![No PlantUML][no-plantuml-badge]][no-plantuml-workflow]
7
+ [![Shell][shell-badge]][shell-workflow]
8
+ [![Codecov][codecov-badge]][codecov]
7
9
  [![License][license-badge]][license]
8
- [![Dependabot Status][dependabot-badge]][dependabot]
9
10
  [![CLA assistant][cla-badge]][cla]
10
11
  [![Contributor Covenant][coc-badge]][coc]
11
12
 
@@ -42,6 +43,17 @@ Which in place will be rendered as the following:
42
43
 
43
44
  ![Rendered SVG Diagram][diagram-svg]
44
45
 
46
+ If you configure theming (described below), the generated HTML will contain the
47
+ name of the configured theme:
48
+
49
+ ```html
50
+ <div class="plantuml theme-spacelab">
51
+ <svg>
52
+ <!-- Snip converted SVG code -->
53
+ </svg>
54
+ </div>
55
+ ```
56
+
45
57
  ## Installation
46
58
 
47
59
  Add this line to your application's Gemfile:
@@ -73,16 +85,49 @@ Then, `bundle exec jekyll build` or `bundle exec jekyll serve` will execute
73
85
  `kramdown-plantuml`, converting code fenced PlantUML diagrams to beautiful
74
86
  SVG.
75
87
 
76
- ## Development
88
+ ## Requirements
89
+
90
+ `kramdown-plantuml` is dependent on the Java application [PlantUML], which in
91
+ turn is dependent on [Graphviz]. This means that both Java and Graphviz need to
92
+ be installed for `kramdown-plantuml` to work.
93
+
94
+ ## Configuration
95
+
96
+ `kramdown-plantuml` can be configured either directly in the `options` Hash
97
+ provided through Kramdown or by `_config.yml` provided through Jekyll.
98
+
99
+ ### Theming
100
+
101
+ In order to [theme] all PlantUML diagrams fed through `kramdown-plantuml`, you
102
+ can configure a global theme with the `plantuml.theme.name` and
103
+ `plantuml.theme.directory` properties. Only `name` is required and will allow
104
+ any of the built-in themes to be used.
105
+
106
+ The theme is simply inserted into each PlantUML diagram with the `!theme`
107
+ declaration, so this can be centralized in configuration instead of duplicating
108
+ it across all diagrams.
109
+
110
+ Here's an example of how to configure `kramdown-plantuml` to use the `spacelab`
111
+ theme in Jekyll's `_config.yml`:
112
+
113
+ ```yaml
114
+ kramdown:
115
+ plantuml:
116
+ theme:
117
+ name: spacelab
118
+ ```
77
119
 
78
- After checking out the repo, run `bin/setup` to install dependencies. You can
79
- also run `bin/console` for an interactive prompt that will allow you to
80
- experiment.
120
+ If you have custom, local themes you'd like to use, you need to provide the
121
+ `directory` in which they are placed alongside the `name` of the theme you'd
122
+ like to use:
81
123
 
82
- To install this gem onto your local machine, run `bundle exec rake install`. To
83
- release a new version, update the version number in `version.rb`, and then run
84
- `bundle exec rake release`, which will create a git tag for the version, push
85
- git commits and tags, and push the `.gem` file to [rubygems.org][gems].
124
+ ```yaml
125
+ kramdown:
126
+ plantuml:
127
+ theme:
128
+ name: my-custom-theme
129
+ directory: path/to/themes
130
+ ```
86
131
 
87
132
  ## Contributing
88
133
 
@@ -91,30 +136,73 @@ intended to be a safe, welcoming space for collaboration, and contributors are
91
136
  expected to adhere to the [code of conduct][coc] and sign the
92
137
  [contributor's license agreement][cla].
93
138
 
139
+ ### Development
140
+
141
+ In order to do development on `kramdown-plantuml`, [clone] or [fork]
142
+ this repository, perform the changes you want and submit a [pull request][pr].
143
+
144
+ The easiest way to develop and test `kramdown-plantuml` is to add it as a
145
+ [Jekyll][jekyll] plugin installed from a local path in your `Gemfile`:
146
+
147
+ ```ruby
148
+ gem 'kramdown-plantuml', path: 'path/to/kramdown-plantuml'
149
+ ```
150
+
151
+ Every time you perform a change to `kramdown-plantuml`, you can then, within
152
+ the directory of your Jekyll site, do a `bundle install` to bring the changes
153
+ in and then start Jekyll up again afterwards with `bundle exec jekyll serve`.
154
+
155
+ #### Tests
156
+
157
+ A few tests are exercised with GitHub Actions every time code is pushed to the
158
+ repository on GitHub. You can execute these tests locally by first installing
159
+ all dependencies as such:
160
+
161
+ ```shell
162
+ bundle install # Installs required Ruby Gems
163
+ bundle exec rake maven:install # Installs the PlantUML .jar file
164
+ ```
165
+
166
+ And then to execute the tests you run the following:
167
+
168
+ ```shell
169
+ bundle exec rake
170
+ ```
171
+
94
172
  ## License
95
173
 
96
174
  The code within this repository is available as open source under the terms of
97
175
  the [Apache 2.0 License][license] and the [contributor's license
98
176
  agreement][cla].
99
177
 
100
- [build-badge]: https://github.com/SwedbankPay/kramdown-plantuml/workflows/Ruby%20Gem/badge.svg?branch=master
101
178
  [cla-badge]: https://cla-assistant.io/readme/badge/SwedbankPay/kramdown-plantuml
102
179
  [cla]: https://cla-assistant.io/SwedbankPay/kramdown-plantuml
180
+ [clone]: https://docs.github.com/en/free-pro-team@latest/github/creating-cloning-and-archiving-repositories/cloning-a-repository
103
181
  [coc-badge]: https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg
104
182
  [coc]: ./CODE_OF_CONDUCT.md
105
- [dependabot-badge]: https://api.dependabot.com/badges/status?host=github&repo=SwedbankPay/kramdown-plantuml
106
- [dependabot]: https://dependabot.com
107
- [diagram-svg]: ./spec/diagram.svg
183
+ [codecov-badge]: https://codecov.io/gh/SwedbankPay/kramdown-plantuml/branch/main/graph/badge.svg?token=U3QJLVG3HY
184
+ [codecov]: https://codecov.io/gh/SwedbankPay/kramdown-plantuml/
185
+ [diagram-svg]: ./spec/examples/diagram.svg
108
186
  [fenced]: https://www.markdownguide.org/extended-syntax/#syntax-highlighting
187
+ [fork]: https://docs.github.com/en/free-pro-team@latest/github/getting-started-with-github/fork-a-repo
109
188
  [gem-badge]: https://badge.fury.io/rb/kramdown-plantuml.svg
110
189
  [gem-url]: https://rubygems.org/gems/kramdown-plantuml
111
190
  [gems]: https://rubygems.org
112
191
  [github]: https://github.com/SwedbankPay/kramdown-plantuml/
192
+ [graphviz]: https://graphviz.org/
113
193
  [jekyll]: https://jekyllrb.com/
114
194
  [kramdown]: https://kramdown.gettalong.org/
115
195
  [license-badge]: https://img.shields.io/github/license/SwedbankPay/kramdown-plantuml
116
196
  [license]: https://opensource.org/licenses/Apache-2.0
117
- [no-java-build-badge]: https://github.com/SwedbankPay/kramdown-plantuml/workflows/No%20Java/badge.svg?branch=master
118
- [no-plantuml-badge]: https://github.com/SwedbankPay/kramdown-plantuml/workflows/No%20PlantUML/badge.svg?branch=master
197
+ [no-java-badge]: https://github.com/SwedbankPay/kramdown-plantuml/actions/workflows/no-java.yml/badge.svg
198
+ [no-java-workflow]: https://github.com/SwedbankPay/kramdown-plantuml/actions/workflows/no-java.yml
199
+ [no-plantuml-badge]: https://github.com/SwedbankPay/kramdown-plantuml/actions/workflows/no-plantuml.yml/badge.svg
200
+ [no-plantuml-workflow]: https://github.com/SwedbankPay/kramdown-plantuml/actions/workflows/no-plantuml.yml
119
201
  [plantuml]: https://plantuml.com/
202
+ [pr]: https://docs.github.com/en/free-pro-team@latest/github/collaborating-with-issues-and-pull-requests/about-pull-requests
203
+ [ruby-badge]: https://github.com/SwedbankPay/kramdown-plantuml/actions/workflows/ruby.yml/badge.svg
204
+ [ruby-workflow]: https://github.com/SwedbankPay/kramdown-plantuml/actions/workflows/ruby.yml
205
+ [shell-badge]: https://github.com/SwedbankPay/kramdown-plantuml/actions/workflows/shell.yml/badge.svg
206
+ [shell-workflow]: https://github.com/SwedbankPay/kramdown-plantuml/actions/workflows/shell.yml
120
207
  [svg]: https://developer.mozilla.org/en-US/docs/Web/SVG
208
+ [theme]: https://plantuml.com/theme
data/Rakefile CHANGED
@@ -6,7 +6,24 @@ require 'rspec/core/rake_task'
6
6
 
7
7
  RSpec::Core::RakeTask.new(:spec) do |t|
8
8
  t.pattern = Dir.glob('spec/**/*_spec.rb')
9
- t.rspec_opts = '--format documentation --tag ~no_plantuml --tag ~no_java'
9
+ t.rspec_opts = '--format documentation --tag ~no_plantuml --tag ~no_java --tag ~debug'
10
+ end
11
+
12
+ namespace :maven do
13
+ task :install do
14
+ require 'fileutils'
15
+
16
+ system 'mvn install'
17
+ bin_dir = File.join __dir__, 'bin'
18
+ target_file = File.join bin_dir, 'plantuml.jar'
19
+ repo_dir = File.expand_path '~/.m2/repository'
20
+ jar_glob = File.join repo_dir, '/**/plantuml*.jar'
21
+ first_jar = Dir[jar_glob].first
22
+ jar_file = File.expand_path first_jar
23
+
24
+ FileUtils.mkdir_p bin_dir
25
+ FileUtils.move(jar_file, target_file)
26
+ end
10
27
  end
11
28
 
12
29
  namespace :codecov do