Compare commits

...

237 Commits

Author SHA1 Message Date
Carlo Sciolla 5889166b6c
Prepping for v1.4.1 2019-09-03 23:24:56 +02:00
Carlo Sciolla 7a1d7ab1ca
Merge branch 'fix-105' into develop 2019-09-03 23:13:06 +02:00
Carlo Sciolla bea66129a9
Fix note syntax in tests 2019-09-03 23:12:48 +02:00
Carlo Sciolla 4f899a4495
Ensure base64 encoding happens after coding the string with UTF8 (#111)
* Fixes #110

Ensure base64 encoding happens after coding the string with UTF8

* Avoid line breaks in base64 encoding
2019-09-03 23:06:47 +02:00
Carlo Sciolla 252e2c3ce8
Disabling master again 2019-09-03 23:06:47 +02:00
Carlo Sciolla 11b78ff62e
Trying to re-enable builds against Emacs master 2019-09-03 23:06:47 +02:00
Carlo Sciolla 4349011ed7
Aesthitics, just aesthetics 2019-09-03 23:06:46 +02:00
Carlo Sciolla 2954c15322
Fix emacs 26 build 2019-09-03 23:06:46 +02:00
Carlo Sciolla a6545435cd
Bumping java version for CI 2019-09-03 23:06:46 +02:00
Carlo Sciolla 1a11576f4a
Bump version after release 2019-09-03 23:06:45 +02:00
Carlo Sciolla df0d718981
Prepping for the new release 2019-09-03 23:06:45 +02:00
Carlo Sciolla 271f468edd
Bump version 2019-09-03 23:06:45 +02:00
Carlo Sciolla b0be4182fb
Fix tests 2019-09-03 23:06:44 +02:00
Carlo Sciolla 76b14086e8
Ignore java warnings 2019-09-03 23:06:44 +02:00
Carlo Sciolla f04480dcba
Use UTC timezone when setting dates, to align with MELPA 2019-09-03 23:06:44 +02:00
Carlo Sciolla 2bd72f7ae6
Use `car` instead of `first` 2019-09-03 23:06:43 +02:00
Carlo Sciolla 914e0526d9
Avoid zero-padding of hours to mimic MELPA 2019-09-03 23:06:43 +02:00
Carlo Sciolla 60e4d3ec6e
Better version management 2019-09-03 23:06:43 +02:00
Felix Weilbach 7eb6167eb8
Added run mode EXECUTABLE (#102) 2019-09-03 23:06:42 +02:00
Carlo Sciolla 19e268c0cb
Ensure base64 encoding happens after coding the string with UTF8 (#111)
* Fixes #110

Ensure base64 encoding happens after coding the string with UTF8

* Avoid line breaks in base64 encoding
2019-08-30 22:54:26 +02:00
Carlo Sciolla 2f8170b30b
Disabling master again 2019-08-25 11:03:29 +02:00
Carlo Sciolla 14daefbb2f
Trying to re-enable builds against Emacs master 2019-08-25 10:37:51 +02:00
Carlo Sciolla 47156fac58
Aesthitics, just aesthetics 2019-08-22 16:03:53 +02:00
Carlo Sciolla 95428d2e2e
Fix emacs 26 build 2019-08-22 11:31:36 +02:00
Carlo Sciolla b43249e1aa
Bumping java version for CI 2019-08-21 17:20:22 +02:00
Carlo Sciolla 39a109ffe6
Bump version after release 2019-08-21 16:47:52 +02:00
Carlo Sciolla b39c310e9c
Prepping for the new release 2019-08-21 16:42:54 +02:00
Carlo Sciolla f7e3af35e8
Merge branch 'develop' 2019-08-21 16:41:38 +02:00
Carlo Sciolla ae8593d662
Bump version 2019-08-21 14:34:02 +02:00
Carlo Sciolla 36e0abac58
Merge branch 'issue106' into develop 2019-08-21 14:31:52 +02:00
Carlo Sciolla beb4dfc726
Fix tests 2019-08-21 14:27:26 +02:00
Carlo Sciolla 7c1d6d3891
Merge branch 'issue107' into develop 2019-08-21 14:19:54 +02:00
Carlo Sciolla 08b783aee6
Ignore java warnings 2019-08-21 14:18:20 +02:00
Carlo Sciolla 04110d0110
Use UTC timezone when setting dates, to align with MELPA 2019-08-21 12:11:36 +02:00
Carlo Sciolla 5a6ed6c5a2
Use `car` instead of `first` 2019-08-21 11:29:20 +02:00
Carlo Sciolla 4a908c2279
Avoid zero-padding of hours to mimic MELPA 2019-08-21 11:19:37 +02:00
Carlo Sciolla a822c551b8
Better version management 2019-08-21 10:55:50 +02:00
Felix Weilbach 9cba6835fd Added run mode EXECUTABLE (#102) 2019-08-19 14:10:35 +02:00
Michael Steiner cbd7fa4c6b - give user some control to override in comments level of indentation
Signed-off-by: Michael Steiner <michael.steiner@intel.com>
2019-08-12 12:01:26 -07:00
Michael Steiner 80b554e871 - allow for white-space and comments after all begin/end indent regexps
- make end indent regexp symmetrical to being regexp allowing for selective
  change (e.g., disactivation via non-matching regexp) what is leads to
  indentation

Signed-off-by: Michael Steiner <michael.steiner@intel.com>
2019-08-12 12:01:12 -07:00
Michael Steiner c32493229d more robust matching of notes
Signed-off-by: Michael Steiner <michael.steiner@intel.com>
2019-08-12 10:17:50 -07:00
Carlo Sciolla 1e5f8beedd
Fix switching between modes (#104)
Giving a default value to `plantuml-exec-mode` local var at startup time
is wrong. This change keeps the local var to `nil` and resorts to the
customizable `plantuml-default-exec-mode`. The local var can be set by users
at will on a buffer local level, but without such an explicit opt-in then the
default value is always used
2019-08-12 17:40:00 +02:00
Carlo Sciolla d11bd57f31
Removed broken link 2019-08-12 17:14:45 +02:00
Carlo Sciolla 0ae3aed095
Avoid breaking long lines on base64 encoding
Spotted by @alexvs11 as a solution to #101
2019-08-03 16:03:25 +02:00
Carlo Sciolla 648feb5b12
New release 2019-08-03 15:59:00 +02:00
Carlo Sciolla 56bb65342a
Updated changelog 2019-08-03 15:56:41 +02:00
Carlo Sciolla 15ced4ae26
Fix interactive `plantuml-set-exec-mode`
Fixes #97
2019-08-03 15:47:00 +02:00
Carlo Sciolla e9c8e76ff2
Re-enable coverage. Not sure when it actually broke. 2019-05-31 11:39:09 +02:00
Carlo Sciolla 27d48942a6
🆕Multiple run modes, now including JAR and SERVER (#96)
It is now possible to support many execution modes, currently available are:

- `jar`: the traditional way of running PlantUML from `plantuml-mode`
- `server`: ask a [`plantuml-server`](https://github.com/plantuml/plantuml-server) instance to run the preview (defaults to https://www.plantuml.com/plantuml)
2019-05-31 10:53:40 +02:00
Carlo Sciolla 698a248549
Merge branch 'master' into develop 2019-05-10 08:58:43 +02:00
Carlo Sciolla a2617017fd
We actually use dash 2019-05-10 08:57:46 +02:00
Carlo Sciolla b3cfafbf99
Merge branch 'develop' 2019-05-09 22:08:47 +02:00
Carlo Sciolla 8503f9d96a
Fixed relnotes 2019-05-09 22:07:35 +02:00
Carlo Sciolla 8f12855be9
Updated relnote 2019-05-09 22:06:21 +02:00
Carlo Sciolla c14684dc3a
Added capability to automatically download the PlantUML jar path (#95)
* Added capability to automatically download the PlantUML jar path

As an effort to ease the first user setup, a new function is added to download the latest
PlantUML JAR release into `plantuml-jar-path` from Maven central.
2019-05-09 22:04:51 +02:00
Carlo Sciolla 9bd2dc86aa
Added Stale for more prompt reactions and better housekeeping 2019-05-06 15:59:11 +02:00
Carlo Sciolla 689c6a6950
CI downloads plantuml (#94)
Fixes #73

Now the latest version of PlantUML is downloaded as part of the CI script. This has two consequences:

we always test against the latest and greatest PlantUML version.
PlantUML evolves at a much higher pace than plantuml-mode. This allows for some sanity check of our code with the upstream project.

builds are not reproducible
As a side effect of always downloading a (potentially) new PlantUML version, re-running the build for an old commit can lead to different outcomes. This is usually a big no-no but given the limited efforts currently spent on plantuml-mode I find it more convenient to immediately raise a flag if a new version of PlantUML causes issues.
2019-05-06 12:14:25 +02:00
Carlo Sciolla 92c490d3fc
New relnote addition 2019-05-03 17:52:26 +02:00
wailo 56f5cf7276 Improving preview functionality. No buffer switch. (#93)
* Improving preview functionality. No buffer switch.

- Using temp buffer instead of new buffer.
- Windows layout is retained. No need to switch buffer after every preview
2019-05-03 17:50:55 +02:00
Carlo Sciolla 2b84a2df52
Upped version 2019-03-16 12:58:06 +01:00
Carlo Sciolla 0e54f437f6
Added tests for Information Engineering (IE) notation 2019-03-16 12:55:56 +01:00
ReneSchmelzer ef4eecefae Rsch/indentation/multiple start regexs (#88)
* fix version

* split indentation rexgexs

Split the regexs as a preparation for improvement and enhancement.
No explicit enhancement was intended, although the
`plantuml-indent-regexp-block-start' covers more blocks now.

* enhance and test regexs for groups

Changed `plantuml-indent-regexp-group-start' to cover all cases
mentioned on sequence diagram page of the plantuml website. Added
tests for all elements-with and without label (text following the
keyword).

* add support and test for box/end box blocks

* indentation test for a nested interface block

* correction of () at end of file

* indentation test for deployment diagram

* file “Cask”: added dependency to dash

* indentation tests for diagram commons

* add indentation tests for component diagrams

* regex corrections and added indentation tests for class diagrams

correct indentation regexs found by tests for class diagrams

* add indentation tests for object diagrams

* add indentation tests for state diagrams

* enhance indentation class diagram test: abstract class and interface

* move indentation tests to diagram test files

* mv test/plantuml-indentation-test.el -> test/plantuml-indentation-basics-test.el

* add indentation sequence diagram tests and mv basics tests to diagram tests

* add indentation for ref-groups

* improved indentation for ref-groups

* support indentation for activity diagrams - current/old style

* indentation support for notes

* rm not used regexs

* indentation support for plantuml macros

* correction: … → etc.
2019-03-16 10:53:17 +01:00
Carlo Sciolla 366ecb605a
Support block indentation for abstract classes
Fixes #83
2019-01-08 23:06:58 +01:00
Carlo Sciolla de5d9b3dd7
Keep docu for new changes 2019-01-08 22:51:24 +01:00
Carlo Sciolla 56d668c54e
Added extra keywords to the indentation block start regex
Keywords added:
- `folder`
- `frame`
- `cloud`

Fixes #78
2019-01-08 22:47:51 +01:00
Carlo Sciolla 0374482cf7
Added new version note 2019-01-07 22:25:02 +01:00
Carlo Sciolla 6c0b9634bd
minor code formatting stuff 2019-01-07 22:15:02 +01:00
ReneSchmelzer ae97b806bc Rsch/indentation/fix and enhance (#85)
* fixed indentation code and added de-/activate to indentation

* added tests for indentation changes

* changed indentation code and tests

- more changes to plantuml-indent-regexs
- added more test
- changed function to determine indentation level and tests accordingly
- changed plantuml-indent-line and tests accordingly
- changed test names and doc strings to be more consistent

* more indentation tests, corrected regex for par block

- the par block usually does not have any label
- added database to start regex and added a test
- added block tests
2019-01-07 21:23:04 +01:00
niklascarlsson 49f707b20c Rewrite start-process to remove eval-and-compile (#82)
Wrapping the defcustoms in eval-and-compile made the code compileable
but not customizable for the user.

Rewriting the start-process into a function instead of a macro makes it
possible to remove the eval-and-compiles.
2019-01-07 21:15:41 +01:00
Carlo Sciolla b358a53bb0
Be fairer to the codecov 2018-08-16 13:35:27 +02:00
Carlo Sciolla 82ab084c86
Proper changelog needs to include indentation support 2018-08-16 12:12:47 +02:00
Alpha TAN f416fe76f2
1) Fixed the comiling error when installing with melpa, surround the `defcustom-list` with `(eval-and-compile ...)` block ; 2) update the version number to 1.2.7 ; 2018-08-16 12:03:29 +02:00
Carlo Sciolla 7d09b36773
Remove all compilation warnings 2018-08-16 12:02:30 +02:00
Carlo Sciolla 6c0455b5e2
Make indentation work 2018-08-16 11:32:44 +02:00
Carlo Sciolla 5c8a95850b
Allow custom jar location for test execution
Tests are still broken though
2018-08-16 09:25:24 +02:00
Raymond Huang da2c301c1a Add autoindent support (#75)
Add indent-line implementation
2018-08-14 23:08:29 +02:00
Carlo Sciolla c5b8d63612
Skipping tests against Emacs master 2018-08-14 22:56:58 +02:00
Carlo Sciolla 3df9bf31a7
Remove support for emacs 24 2018-08-14 21:59:34 +02:00
Carlo Sciolla 9d6b6a03a6
More descriptive steps + ensure Cask is found on path
See https://circleci.com/docs/2.0/env-vars/#using-bash_env-to-set-environment-variables
2018-08-14 21:52:16 +02:00
Carlo Sciolla 4f4b8ffe91
Command changed, need to sync up the test 2018-08-14 21:42:28 +02:00
Carlo Sciolla 9445f0db7d
Install prerequisite software 2018-08-14 21:34:27 +02:00
Carlo Sciolla 6a515fc360
Add make to the list of installed packages 2018-08-14 21:28:13 +02:00
Carlo Sciolla ecc9b14af7
Merge pull request #74 from alphatan/master
Custom variable `plantuml-jar-args` to control which arguments are passed to PlantUML jar
2018-08-11 11:53:47 +02:00
Alpha TAN 2c1d5a33a6 1) Introduced custom variable `plantuml-jar-args' to control which arguments are passed to PlantUML jar ; 2) Fix the warning of failing to specify types of 'defcustom' variables ; 2018-07-17 15:03:32 +08:00
Carlo Sciolla cfb408fc84
Removed travis, moved to CircleCI 2018-03-18 23:12:47 +01:00
Carlo Sciolla 06725c7ce7
Disable broken test
Unicode testing appears to be broken only when run under ERT runner
2018-03-18 23:05:31 +01:00
Carlo Sciolla 877afb3292
there is no ecukes yet 2018-03-18 23:05:31 +01:00
Carlo Sciolla 2677913ec3
Fix build 2018-03-18 23:05:31 +01:00
Carlo Sciolla 07c90ab258
Need java for pretty much everything 2018-03-18 23:05:31 +01:00
Carlo Sciolla 75ffccdc91
Support CircleCI
And by the way, use coveralls.io
2018-03-18 23:05:31 +01:00
Carlo Sciolla 788f64dd5f
Merge pull request #67 from Sunhick/master
updated plantuml.jar binary
2018-03-18 23:04:27 +01:00
Sunil 71acb1cf87
updated plantuml.jar binary
Brings in new plantuml features like support for monochrome etc.
2018-02-15 20:45:19 -08:00
Carlo Sciolla fce628885b
Initialize plantuml-mode before tests 2017-08-19 21:46:16 +02:00
Carlo Sciolla 03fef302ec
Done with merge stuff 2017-08-19 21:40:04 +02:00
Carlo Sciolla dee0a46c08
Fixed Makefile after merge 2017-08-19 21:33:34 +02:00
Carlo Sciolla 2b1b6055fc
Fixed travis configuration after merge 2017-08-19 21:27:33 +02:00
Carlo Sciolla 5a2e8d0dd2
Merged with develop 2017-08-19 19:33:36 +02:00
Carlo Sciolla 445d853211
Extra docs for latest releases 2017-08-19 19:31:30 +02:00
Carlo Sciolla 3e017a1a3a
Merge branch 'fix/51' into develop 2017-08-19 19:23:25 +02:00
Carlo Sciolla da9d39c947
#51 Evaluate the `plantuml-java-args` defcustom at compile time
`defcustom`s are not executed at byte-compile time. Wrapping the
`defcustom` in an `eval-and-compile` form does the trick.
2017-08-19 19:20:04 +02:00
Carlo Sciolla 5c57f05086
Better clean target for make 2017-08-19 18:23:45 +02:00
Carlo Sciolla 4ba8359045
#60 Upgrading license to GPLv3+ 2017-08-18 12:17:57 +02:00
Carlo Sciolla ecb4428218
#60 Upgrading license to GPLv3+ 2017-08-18 12:16:12 +02:00
Carlo Sciolla 15d1e41972
WIP 2017-08-18 12:11:09 +02:00
Carlo Sciolla 16b754f643
Create folders to avoid emacs prompts 2017-07-08 11:44:53 +02:00
Carlo Sciolla 6a210b7bb1
Try to test the install process 2017-07-08 11:35:40 +02:00
Carlo Sciolla 1011229c85
Start investigating #51 2017-07-07 21:18:37 +02:00
Carlo Sciolla 1c3a5f53ff
#55 fix doku on `org-mode` integration 2017-05-10 22:57:49 +02:00
Carlo Sciolla f0632ea3fe
Added missing test file 2016-12-25 21:17:02 +01:00
Carlo Sciolla 00c4c31052
Disable failing travis build (temporarily) 2016-12-25 21:15:52 +01:00
Carlo Sciolla d24e464877
Prepare for release v1.2.3 2016-12-25 21:15:52 +01:00
Carlo Sciolla e671431ee1
#50 switch output type when needed 2016-12-25 21:15:52 +01:00
Carlo Sciolla 8daf8e24fa
#50 use different tests for different outputs 2016-12-25 21:15:15 +01:00
Carlo Sciolla 457ca82471
#50 use different tests for different outputs 2016-12-25 21:14:24 +01:00
Carlo Sciolla 160c865e2b
#50 Added support for unicode rendering 2016-12-25 21:13:40 +01:00
Carlo Sciolla 4bdff5676d
#50 use UTF-8 in `start-process`; test against a txt file generated by PlantUML instead of a hand-made one 2016-12-25 21:12:58 +01:00
Carlo Sciolla 1adc022ab4
#50 Factored out preview assertion function 2016-12-25 21:12:11 +01:00
Carlo Sciolla d44445f053
use a newer version of evm 2016-12-25 21:12:11 +01:00
Carlo Sciolla e974c7406b
only test on newer Emacs releases 2016-12-25 21:12:11 +01:00
Carlo Sciolla cd17ffdb0b
Added travis badge 2016-12-25 21:12:11 +01:00
Carlo Sciolla 5ae2d7dca3
prepare for Travis builds 2016-12-25 21:12:11 +01:00
Carlo Sciolla e9241e7f8c
#49 Added related projects in the README 2016-12-25 21:12:11 +01:00
Carlo Sciolla 2e9dc3acc1
prepare for v1.2.2 2016-12-25 21:10:59 +01:00
Carlo Sciolla 4931a52522
prepare for v1.2.1 2016-12-25 21:10:59 +01:00
Carlo Sciolla 7c7e620810
Prepping for v1.2.0 2016-12-25 21:10:59 +01:00
Carlo Sciolla 1db264f540
Prepare for v1.1.1 2016-12-25 21:10:59 +01:00
Carlo Sciolla 73442f1222 Merge pull request #47 from 7mamu4/add-interactive-parameter-for-region
plantuml-preview-region: add interactive parameter for region
2016-12-25 21:03:29 +01:00
Carlo Sciolla c7e83c2607
Disable failing travis build (temporarily) 2016-12-25 20:47:49 +01:00
Carlo Sciolla eb380bac56
Prepare for release v1.2.3 2016-12-25 20:42:24 +01:00
Carlo Sciolla 9355343797
#50 switch output type when needed 2016-12-25 20:30:50 +01:00
Carlo Sciolla 343bc5a753
#50 use different tests for different outputs 2016-12-25 20:28:54 +01:00
Carlo Sciolla 4d2bffd2cc
#50 use different tests for different outputs 2016-12-25 20:28:40 +01:00
Carlo Sciolla 9ac32f1c19
#50 Added support for unicode rendering 2016-12-25 20:13:23 +01:00
Carlo Sciolla b5e880790b
#50 use UTF-8 in `start-process`; test against a txt file generated by PlantUML instead of a hand-made one 2016-12-25 19:31:01 +01:00
Carlo Sciolla 06a12c3d16
#50 Added (failing) unit test for unicode support 2016-12-25 19:14:32 +01:00
Carlo Sciolla f8148e9d5f
#50 Factored out preview assertion function 2016-12-25 18:29:48 +01:00
Carlo Sciolla e3e95fe1d5
use a newer version of evm 2016-12-25 18:18:50 +01:00
Carlo Sciolla e51c6e6054
only test on newer Emacs releases 2016-12-25 18:14:39 +01:00
Carlo Sciolla 60292608a7
Added travis badge 2016-12-25 18:08:58 +01:00
Carlo Sciolla d136899d89
prepare for Travis builds 2016-12-25 18:05:15 +01:00
Carlo Sciolla 7a3bdf78c1
#49 Added related projects in the README 2016-12-25 17:40:44 +01:00
Carlo Sciolla 8752e703de
Working test setup which also tests preview 2016-12-25 17:37:18 +01:00
Carlo Sciolla 535ed29d16
Ignore the cask folder 2016-12-25 17:37:18 +01:00
Carlo Sciolla 4f8e937dc2
Added Cask and ert-runner infrastructure 2016-12-25 17:37:18 +01:00
Matthias Müller e140eba7b1 plantuml-preview-region: add interactive parameter for region
plantuml-preview-region:
Add the begin and end of the region to the parameters of function
This allows using the function programatically
without modification of the mark.

plantuml-preview:
Adjust plantuml-preview-region function call.
2016-11-12 01:48:47 +01:00
Carlo Sciolla a143ab5d7d
Working test setup which also tests preview 2016-11-11 12:53:41 +01:00
Carlo Sciolla 1b8100d9b0
Ignore the cask folder 2016-11-11 11:52:23 +01:00
Carlo Sciolla 37dfe8c9fd
Added Cask and ert-runner infrastructure 2016-11-11 11:51:49 +01:00
Carlo Sciolla 87417ad75b
prepare for v1.2.2 2016-11-11 11:05:24 +01:00
Carlo Sciolla 676f4b6040
Merge branch 'develop' 2016-11-11 11:03:54 +01:00
Carlo Sciolla 5cb8d2336a
merged with current develop branch 2016-11-11 11:03:04 +01:00
Carlo Sciolla ba7420b587
prepare for v1.2.1 2016-11-11 09:19:47 +01:00
Carlo Sciolla 76a96af6e8
merged develop 2016-11-11 09:17:16 +01:00
Carlo Sciolla 673e524443
Expand file names before any `shell-quote-argument` happens to support ~ in paths 2016-11-11 09:12:58 +01:00
Carlo Sciolla 64af0f1cc3
Untabified 2016-11-11 08:53:52 +01:00
Carlo Sciolla 2716f27034 Prepping for v1.2.0 2016-11-09 12:21:12 +01:00
Carlo Sciolla 408ea2d48b Merge branch 'pr/42' into develop 2016-11-09 12:19:48 +01:00
Carlo Sciolla f796d9d73b Prepare for v1.1.1 2016-11-08 12:33:24 +01:00
Carlo Sciolla 01cd430a1e Merge branch 'pr/41' into develop 2016-11-08 11:29:12 +01:00
Andrew Lyu 6ba5a10988 Remove duplicate rows 2016-11-08 08:27:19 +01:00
Andrew Lyu 68e5e52584 Remove duplicate rows 2016-11-08 08:26:47 +01:00
Andrew Lyu f43e67b091 Remove duplicate rows 2016-11-08 08:26:06 +01:00
Your Name 5629fe1ce7 Fixed regexp match pattern to truely match suffixes .plantuml .pum .plu. 2016-11-08 08:26:06 +01:00
Carlo Sciolla 00a983033f Merge branch 'pr/44' into develop 2016-11-08 08:23:59 +01:00
Andrew Lyu 0cfd6d9e38 Remove duplicate rows 2016-11-08 08:23:38 +01:00
Matthias Müller 9c509f879d Add plantuml-preview-current-block
Add a function that allows to preview the current block.
The current block is defined to be the region beginning
at previous "@startuml" and ending at "@enduml".
The prefix argument is handled according to the existing
prview functions.
2016-10-26 01:03:37 +02:00
Your Name 6f25902e84 Merge remote-tracking branch 'upstream/develop' into cygwin-native-java 2016-10-23 07:33:43 -05:00
Your Name 47c7e7c67d Merge remote-tracking branch 'upstream/develop' into windows 2016-10-23 07:31:11 -05:00
Carlo Sciolla f17a6822d0 Merge pull request #38 from abcdec/mode-regexp-match-fix
Fixed regexp match pattern to truely match suffixes .plantuml .pum .plu.
2016-10-23 09:40:47 +02:00
Your Name 9c50cd7103 Replaced shell-command with call-process. this fixes a couple issues: (1) when the mode is first loaded and plantuml-init is executed, Emacs window is split into two, which is not necessary. (2) under cygwin emacs and windows native Java combination, shell-quote-argument is cauisng file path format change and making Java unable to load jar file. file-exists-p is also skipped if cygwin emacs is running. 2016-10-22 14:15:22 -05:00
Your Name a4a017008b Fixed regexp match pattern to truely match suffixes .plantuml .pum .plu. 2016-10-22 09:13:52 -05:00
Your Name bfdf6ba04a Removed shell-quote-argument for Windows native Emacs to load jar file properly. 2016-10-22 09:06:15 -05:00
Carlo Sciolla 2b7d796886 Fixed plantuml invocation 2016-10-18 19:25:15 +02:00
Carlo Sciolla 0011cae6a4 Fix new version number in preamble 2016-10-18 17:01:46 +02:00
Carlo Sciolla b667968195 Merged feature/nosplash 2016-10-18 16:28:53 +02:00
Carlo Sciolla e944b7ae61 As per @adm code review 2016-10-18 16:05:22 +02:00
Carlo Sciolla 1c8cea4c29 Removed reference to the old puml-mode 2016-10-18 15:22:41 +02:00
Carlo Sciolla 60fbee8d6f Version bumps count from 0 2016-10-18 13:18:58 +02:00
Carlo Sciolla ef8bdbc7c1 #33 Emacs has an identity function after all, no need to replicate it 2016-10-18 12:46:39 +02:00
Carlo Sciolla 16df886fb3 #33 Reuse the same command line args wherever a command is issued; make PlantUML headless by default 2016-10-18 11:46:30 +02:00
Alexandre Duret-Lutz f108d393ae Fix the syntax table to allow single-line comments. 2016-10-17 22:19:03 +02:00
Carlo Sciolla ac04fed19b Added issue template for better descriptions 2016-10-17 16:33:24 +02:00
Carlo Sciolla d7067729fa Prepare for release v1.0.1 2016-10-17 16:27:10 +02:00
Carlo Sciolla 1ef4fcef2e Merge branch pull request #29 into develop 2016-10-17 16:23:32 +02:00
Syohei YOSHIDA 314674796f Don't call hook two times
define-derived-mode macro puts run-hook code after body so it is not
necessary to call it manually.
2016-10-17 16:22:53 +02:00
Syohei YOSHIDA 40e2ff222c Fix regexp of auto-mode-alist
And use "\'" end of string anchor instead of "$".
2016-10-17 16:22:53 +02:00
Carlo Sciolla ab55d31080 Merge branch 'pr/30' into develop 2016-10-17 16:15:39 +02:00
Syohei YOSHIDA fff8719b04 Don't call hook two times
define-derived-mode macro puts run-hook code after body so it is not
necessary to call it manually.
2016-10-17 16:15:17 +02:00
Carlo Sciolla a62da47363 Merge branch 'pr/31_syohex-hook' 2016-10-17 16:09:19 +02:00
Syohei YOSHIDA 8aa6315508 Don't call hook two times
define-derived-mode macro puts run-hook code after body so it is not
necessary to call it manually.
2016-10-17 15:39:54 +09:00
Syohei YOSHIDA 940a1a7937 Fix regexp of auto-mode-alist
And use "\'" end of string anchor instead of "$".
2016-10-17 15:21:00 +09:00
Your Name 04a2e7d5d9 Delay mode variable initialization until mode is loaded. 2016-10-16 13:37:20 -05:00
Your Name b931a42237 autoload does not seem to be functioning in latest update 2016-10-16 13:07:01 -05:00
Carlo Sciolla 9001192acf #26 Rewritten the changelog to point out which versions came from puml-mode 2016-10-16 16:57:09 +02:00
Carlo Sciolla 141c55dfc9 #26 Better docs, including migration from ~/Development/Sandbox/puml-mode 2016-10-14 22:11:11 +02:00
Carlo Sciolla e3ec4bee55 #26 add a custom variable to suppress the deprecation warning 2016-10-14 21:37:53 +02:00
Carlo Sciolla df46435ba9 #26 Removed warning from init 2016-10-14 21:27:20 +02:00
Carlo Sciolla a324da362a #26 Use a custom variable for which java command to use to fire up PlantUML 2016-10-14 15:37:02 +02:00
Carlo Sciolla cba96b7204 Fixed doku to point to the correct function 2016-10-14 12:15:00 +02:00
Carlo Sciolla ae0f58295c Fixed bug in which no mark is active but previous marks would trigger preview on a region instead of the whole buffer. Possibly related to #26 2016-10-14 00:20:25 +02:00
Carlo Sciolla 4bdb8ebb92 Removed unused code 2016-10-13 23:58:41 +02:00
Carlo Sciolla cdee161b3d Fixed docs 2016-10-10 20:35:06 +02:00
Carlo Sciolla 0aabb908f8 Minor aesthetics 2016-10-10 20:31:11 +02:00
Carlo Sciolla a60290a0a9 Migrate filename to be plantuml-mode 2016-10-10 20:31:11 +02:00
Carlo Sciolla e1c3a06f41 Migrate function names to be again plantuml 2016-10-10 20:31:11 +02:00
Carlo Sciolla b13aa74542 Added deprecation notice 2016-10-10 20:31:11 +02:00
Carlo Sciolla bbbb5c58ae Added preview region functionality 2016-10-10 20:05:27 +02:00
Carlo Sciolla b7be36f6d2 Merging plantuml-mode 2016-10-10 19:42:40 +02:00
Carlo Sciolla ae1cd8eb21 Bumped version number 2016-07-19 09:36:39 +02:00
Carlo Sciolla 3f6e3773f3 Merge pull request #25 from syohex/fix-package
Fix package
2016-07-19 09:33:38 +02:00
Syohei YOSHIDA beb8900b10 Specify minimum Emacs version
This is for using prog-mode and lexical-binding.
2016-07-08 14:09:40 +09:00
Syohei YOSHIDA dca9fa42b6 Add autoload cookie to auto-mode-alist setting 2016-07-08 11:32:08 +09:00
Syohei YOSHIDA 093c1795d2 Fix unused variable name for byte-compile warning 2016-07-08 11:31:06 +09:00
Carlo Sciolla f5ff58bb4f Merge pull request #23 from lucafavatella/version-definition
Update version number in header and `defvar`
2016-06-06 08:16:24 +02:00
Luca Favatella 2b9a998e55 Review version definition
Prefer `defconst` as it is more robust for constants. Refs:

  * https://www.gnu.org/software/emacs/manual/html_mono/elisp.html#index-defconst
  * http://endlessparentheses.com/what-s-a-defconst-and-why-you-should-use-it.html
2016-06-05 17:36:31 +01:00
Luca Favatella f871199960 Refresh version number 2016-06-05 17:36:11 +01:00
Carlo Sciolla b31063125b #20 Added usage documentation 2016-05-07 07:50:43 +02:00
Carlo Sciolla 463aa0d54b Better docs for the C-u prefix magic numbers 2016-03-24 23:25:51 +01:00
Carlo Sciolla 56cd3f393d Prepare for version bump 2016-03-24 22:34:50 +01:00
Carlo Sciolla dc3e32c3ca Minor cosmetics 2016-03-24 22:31:33 +01:00
Carlo Sciolla a42e8b5734 Merge pull request #18 from jmeeks/master
allow puml-preview to open in other window, frame
2016-03-24 22:31:23 +01:00
Carlo Sciolla 2ff075b23c Merge pull request #17 from driftcrow/patch-1
Update puml-mode.el
2016-03-24 22:31:17 +01:00
Jonathan Meeks 4bb8b2a04e allow puml-preview to open in other window, frame 2016-03-21 10:32:17 -05:00
driftcrow 1b1cf79278 Update puml-mode.el
support for Asia language
2016-03-10 20:58:20 +08:00
Carlo Sciolla 966064f371 Merge pull request #13 from leafac/patch-1
Fix `Enable the major mode` for `.plantuml` file extension
2016-01-04 11:18:19 +01:00
Leandro Facchinetti 44af621c43 Fix `Enable the major mode`
From `subr.el`:

    (add-to-list LIST-VAR ELEMENT &optional APPEND COMPARE-FN)
2015-12-28 16:10:38 -05:00
Carlo Sciolla 9d3b5e326d Single line works but only if ended by another quote char 2015-12-12 17:23:02 +01:00
Carlo Sciolla 84ca5f1e8e Multiline works, single line doesn't 2015-12-12 17:18:24 +01:00
Carlo Sciolla 151e0fd9df Trying to integrate comments as per PR #12 2015-12-12 16:45:43 +01:00
Carlo Sciolla 664bc47000 Merge done, new version signalled 2015-12-07 17:43:36 +01:00
Carlo Sciolla 2842aad15a Merging pull request 2015-12-07 17:06:19 +01:00
Carlo Sciolla a20265d5f6 Added troubleshooting docs 2015-12-07 16:56:20 +01:00
David Vazquez 82cc6b8fc7 Merge branch 'master' into customizable-output-type 2015-09-26 16:19:20 +02:00
David Vazquez 7ff5e2bb3d Fix the output type UTXT
Only set the coding for the output buffer of the process to binary if
the output is an image.
2015-09-26 13:05:00 +02:00
David Vazquez e886aff9c5 Use utxt as default output type if can't display images
for example, if it is in terminal node (-nw)
2015-09-26 12:42:34 +02:00
David Vazquez 13fc1b1cbe Customizable output type
Define a variable `puml-output-type' that the user can customize per
buffer. It does also define a `puml-set-output-type' command to set the
output type for the current buffer interactively.
2015-09-26 12:39:16 +02:00
David Vazquez c352acb1c2 Merge remote-tracking branch 'origin/define-derived-mode' into customizable-output-type 2015-09-26 12:11:52 +02:00
35 changed files with 4419 additions and 543 deletions

56
.circleci/config.yml Normal file
View File

@ -0,0 +1,56 @@
version: 2.0
# Default actions to perform on each Emacs version
default: &default-steps
steps:
- run:
name: Update APT packages
command: apt-get update
- run:
name: Install prerequisites
command: apt-get install -y openjdk-11-jre make python git
- checkout
- run:
# Note: this makes it hard to reproduce builds but easier to spot incompatibilities with
# newer PlantUML releases. Current trade off seems acceptable.
name: Download the latest PlantUML release
command: sh ./bin/download-plantuml.sh
- run:
name: Install cask
command: curl -fsSL https://raw.githubusercontent.com/cask/cask/master/go | python
- run:
name: Make Cask available on the path
command: echo 'export PATH="/root/.cask/bin:$PATH"' >> $BASH_ENV
- run:
name: Run the tests
command: make
# Enumerated list of Emacs versions
jobs:
test-emacs-25:
docker:
- image: silex/emacs:25
entrypoint: bash
<<: *default-steps
test-emacs-26:
docker:
- image: silex/emacs:26
entrypoint: bash
<<: *default-steps
test-emacs-master:
docker:
- image: silex/emacs:master
entrypoint: bash
<<: *default-steps
# Executing in parallel
workflows:
version: 2
ci-test-matrix:
jobs:
- test-emacs-25
- test-emacs-26
# Testing against master currently hangs on CircleCI
# - test-emacs-master

8
.github/ISSUE_TEMPLATE vendored Normal file
View File

@ -0,0 +1,8 @@
# Summary
> Write here the summary of your changes
# Checklist for pull requests
- [ ] I'm fine with my code being released under the GPLv2 license
- [ ] the pull request is filed against the `develop` branch instead of `master`

17
.github/stale.yml vendored Normal file
View File

@ -0,0 +1,17 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 90
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 10
# Issues with these labels will never be considered stale
exemptLabels:
- help-wanted
- enhancement
# Label to use when marking an issue as stale
staleLabel: wontfix
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.cask
.coveralls.yml

12
Cask Normal file
View File

@ -0,0 +1,12 @@
(source gnu)
(source melpa)
(package-file "plantuml-mode.el")
(development
(depends-on "f")
(depends-on "dash")
(depends-on "ecukes")
(depends-on "ert-runner")
(depends-on "el-mock")
(depends-on "undercover"))

View File

@ -1,281 +1,622 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Version 3, 29 June 2007
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
TERMS AND CONDITIONS
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
0. Definitions.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
"This License" refers to version 3 of the GNU General Public License.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
A "covered work" means either the unmodified Program or a work based
on the Program.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
1. Source Code.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
The Corresponding Source for a work in source code form is that
same work.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
2. Basic Permissions.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
13. Use with the GNU Affero General Public License.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
14. Revised Versions of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
NO WARRANTY
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
15. Disclaimer of Warranty.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
@ -287,15 +628,15 @@ free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@ -303,37 +644,31 @@ the "copyright" line and a pointer to where the full notice is found.
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

31
Makefile Normal file
View File

@ -0,0 +1,31 @@
#
# Programs used in the make goals
#
export CASK ?= cask
export EMACS ?= emacs
#
# General configuration
#
export CASK_DIR ?= `${CASK} package-directory`
export BATCH = --batch -q -l .emacs/init.el
export COVERALLS_REPO_TOKEN = 61YFD7RG1RRJTs0kEuj1aZX7VBgUPiMNO
all: version test
version:
$(EMACS) $(BATCH) --version
test: install unit
unit:
${CASK} exec ert-runner
install:
${CASK} install
clean:
rm -Rf .emacs.d
rm -Rf .cask
.PHONY: all test unit install clean

163
README.md
View File

@ -1,10 +1,9 @@
[![MELPA](http://melpa.org/packages/puml-mode-badge.svg)](http://melpa.org/#/puml-mode) [![MELPA Stable](http://stable.melpa.org/packages/puml-mode-badge.svg)](http://stable.melpa.org/#/puml-mode)
[![MELPA](http://melpa.org/packages/plantuml-mode-badge.svg)](http://melpa.org/#/plantuml-mode) [![MELPA Stable](http://stable.melpa.org/packages/plantuml-mode-badge.svg)](http://stable.melpa.org/#/plantuml-mode) [![CircleCI](https://circleci.com/gh/skuro/plantuml-mode.svg?style=svg)](https://circleci.com/gh/skuro/plantuml-mode) [![Coverage Status](https://coveralls.io/repos/github/skuro/plantuml-mode/badge.svg?branch=HEAD)](https://coveralls.io/github/skuro/plantuml-mode?branch=HEAD)
PlantUML mode for Emacs
=======================
# PlantUML mode for Emacs
<img src="https://raw.githubusercontent.com/skuro/puml-mode/master/banner.png"
alt="puml-mode in action" title="Behold the beauty of text-based UML diagrams!" />
<img src="https://raw.githubusercontent.com/skuro/plantuml-mode/master/banner.png"
alt="plantuml-mode in action" title="Behold the beauty of text-based UML diagrams!" />
> “Pummel me all you want," I say. "Pummel me to death, in fact. My answers will not change."
> The Invierno step back, frowning. "You must love her very much," he says, not unkindly.”
@ -12,67 +11,163 @@ PlantUML mode for Emacs
> from [The Bitter Kingdom - Fire and Thorns #3](https://www.goodreads.com/book/show/11431896-the-bitter-kingdom)
A [PlantUml](http://plantuml.sourceforge.net/) major mode for Emacs.
A [PlantUML](http://plantuml.sourceforge.net/) major mode for Emacs.
Installation
============
# Installation
Make sure you have [MELPA](http://melpa.org/) enabled in your ``emacs.d``. Then, you can just
M-x package-install<RET>
puml-mode<RET>
plantuml-mode<RET>
Also, to enable preview you need to tell `puml-mode` where to locate the PlantUML JAR file. By default it will look for it in `~/plantuml.jar`, but you can specify any location with:
Also, to enable preview you need to tell `plantuml-mode` where to locate the PlantUML JAR file. By default it will look for it in `~/plantuml.jar`, but you can specify any location with:
M-x customize-variable<RET>
puml-plantuml-jar-path<RET>
plantuml-jar-path<RET>
Features
========
You can also download the latest version of PlantUML straight into `plantuml-jar-path`:
M-x plantuml-download-jar<RET>
# Features
- Syntax highlight
- Autocompletion
- Preview
- Preview of buffer or region
- [EXPERIMENTAL] Use either local JAR or remote server for preview
Enable the major mode
=====================
# Enable the major mode
You can automatically enable `puml-mode` for files with extension `.puml` or `plantuml` by adding the following to your `.emacsrc`:
You can automatically enable `plantuml-mode` for files with extension `.plantuml` by adding the following to your `.emacsrc`:
;; Enable puml-mode for PlantUML files
(add-to-list 'auto-mode-alist
'("\\.puml\\'" . puml-mode)
'("\\.plantuml\\'" . puml-mode))
;; Enable plantuml-mode for PlantUML files
(add-to-list 'auto-mode-alist '("\\.plantuml\\'" . plantuml-mode))
Of course, you can always enable manually the major mode by typing `M-x puml-mode` once in the desired PlantUML file buffer.
Of course, you can always enable manually the major mode by typing `M-x plantuml-mode` once in the desired PlantUML file buffer.
Usage
=====
# Usage
You can either tell `puml-mode` to autocomplete the word before the cursor by typing `M-x puml-complete-symbol`. This will open a popup with all the available completions as found in the list of keywords given by running PlantUML with the `-language` flag.
You can tell `plantuml-mode` to autocomplete the word before the cursor by typing `M-x plantuml-complete-symbol`. This will open a popup with all the available completions as found in the list of keywords given by running PlantUML with the `-language` flag.
To render the PlantUML diagram within Emacs, you can also hit `M-x puml-preview`. This will run PlantUML and display the result in the `*PUML-Preview*` buffer. The format used to render the diagram is automagically chosen from what's supported by your Emacs. It will be one of the following, in order of preference:
To render the PlantUML diagram within Emacs, you can hit `M-x plantuml-preview`. This will run PlantUML and display the result in the `*PLANTUML-Preview*` buffer. The format used to render the diagram is automagically chosen from what's supported by your Emacs. It will be one of the following, in order of preference:
- SVG
- PNG
- Unicode ASCII art
Default key bindings
====================
The diagram will be either created from the selected region if one is available in the current buffer, or using the whole buffer otherwise.
If you want to force a specific output format, you can customize the variable `plantuml-output-type` to the value you prefer.
## Default key bindings
The following shortcuts are enabled by default:
C-c C-c renders a PlantUML diagram from the current buffer in the best supported format
C-c C-c plantuml-preview: renders a PlantUML diagram from the current buffer in the best supported format
Credits
=======
C-u C-c C-c plantuml-preview in other window
C-u C-u C-c C-c plantuml-preview in other frame
## Integration with `org-mode`
You can use `plantuml-mode` to edit PlantUML source snippets within an [`org-mode`](http://orgmode.org/) document. To do so, you need to first register it with the `plantuml` language:
```
(add-to-list
'org-src-lang-modes '("plantuml" . plantuml))
```
Then you can edit a `plantuml` code block with `plantuml-mode` by hitting `C-'` while inside of the code block itself:
```elisp
#+BEGIN_SRC plantuml
<hit C-c ' here to open a plantuml-mode buffer>
#+END_SRC
```
When in the `plantuml-mode` buffer you can then hit again `C-'` to return to the original `org-mode` document.
# Execution modes
**EXPERIMENTAL**
As of `v1.3.0` support is added for switching execution mode. The following two modes are available:
- `jar` (default) to run PlantUML as a local JAR file. This is the traditional system used by `plantuml-mode`
- `server` (experimental) to let an instance of [`plantuml-server`](https://github.com/plantuml/plantuml-server) render the preview
- `executable` to run PlantUML as a local executable file. This is useful if your package manager provides a executable for PlantUML.
You can customize `plantuml-default-exec-mode` or run `plantuml-set-exec-mode` from a `plantuml-mode` buffer to switch modes.
## Configure server rendering
When selecting `server` execution modes, you can customize the following variable to set the server to use for rendering:
```
plantuml-server-url
```
It defaults to `"https://www.plantuml.com/plantuml"`.
# Migration from `puml-mode`
If you were previously using `puml-mode`, you should change any reference to a `puml-..` variable or function to its `plantuml-..` counterpart. Most notably, `puml-plantuml-jar-path` is now just `plantuml-jar-path`.
## Deprecation warning
If `puml-mode` is still being loaded by your Emacs, a Warning will be shown any time you open a PlantUML file. This is to remind you that you are running deprecated software. If you want to suppress the (intentionally) annoying warning, you can customize the variable `plantuml-suppress-deprecation-warning`.
# Troubleshooting
## Debug messages
As of `v0.6.2` the following commands have been added to help resolving problems:
```
plantuml-enable-debug
plantuml-disable-debug
```
With debug enabled, the actual command used to invoke PlantUML is printed into a buffer called `*PLANTUML Messages*`. You can inspect that buffer to make sure that PlantUML is properly set up, or use it to supply extra information when opening [issues](https://github.com/skuro/plantuml-mode/issues).
## Blank previews
If you are using SVG rendering and `plantuml-preview` shows you an empty buffer, chances are something is wrong with the PlantUML output. While inside the preview buffer, hit `C-c C-c` to switch to
the textual mode and see if the output is valid SVG.
## Development
Development happens mostly on the `develop` branch, which is released on MELPA at every commit. The `master` branch is used to generate tags which are then released to [MELPA
stable](https://stable.melpa.org).
In order to contribute to `plantuml-mode` make sure to:
- agree with the [GPLv3+ licencing terms](#License) as they are mandated by Emacs
- install [`cask`](https://github.com/cask/cask)
- always test your code and run the full test suite with `cask exec ert-runner` (or just by `make`)
- ensure you always target `develop` in your pull requests
For collaborators who have merge access to the repo:
- make sure [`set-version.sh`](./blob/develop/bin/set-version.sh) is run as part of your [`pre-commit` git hooks](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks)
- always merge PRs on the command line
- when releasing a new stable version, add the proper entry in the changelog within `plantuml-mode.el` to ensure the right version is set for `plantuml-mode-version`
# Credits
This project stemmed from the great work of [Zhang Weize](http://zhangweize.wordpress.com/2010/09/20/update-plantuml-mode/),
and the current code still borrows a lot from it.
Thanks to [Pavel G. Koukoushkin](https://github.com/svargellin) for implementing the preview functionality.
Thanks to [Raymond Huang](https://github.com/rymndhng) for implementing the first drop of the indentation support.
License
=======
Thanks to [all the awesome contributors](https://github.com/skuro/plantuml-mode/graphs/contributors), you rock!
Released under the terms of [GPLv2](http://www.gnu.org/licenses/gpl-2.0.html). See [LICENSE.txt](https://github.com/skuro/plantuml-mode/blob/master/LICENSE.txt).
# See also
- [PlantUML](http://plantuml.com/)
- [`flycheck-plantuml`](https://github.com/alexmurray/flycheck-plantuml)
# License
Released under the terms of [GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html) or (at your option) any later version. See [LICENSE.txt](https://github.com/skuro/plantuml-mode/blob/master/LICENSE.txt).

20
bin/download-plantuml.sh Executable file
View File

@ -0,0 +1,20 @@
#!/bin/sh
# Where the script is executed
CURRENT_PATH="$(dirname "$(readlink -f "$0")")"
# Where to download the file
OUTPUT_PATH="${CURRENT_PATH}/plantuml.jar"
# Retrieve the list of versions, in XML format, only one result (the latest)
VERSIONS_URL='https://search.maven.org/solrsearch/select?q=g:net.sourceforge.plantuml+AND+a:plantuml&core=gav&start=0&rows=1&wt=xml'
# Only match the contents of the version (name="v") XML tag
LATEST_VERSION="$(curl -s "${VERSIONS_URL}" | grep -oP '(?<=<str name="v">).*(?=</str>)')"
# Compose the download link
DOWNLOAD_URL="https://search.maven.org/remotecontent?filepath=net/sourceforge/plantuml/plantuml/${LATEST_VERSION}/plantuml-${LATEST_VERSION}.jar"
# finally, download the JAR file
echo "Downloading PlantUML v${LATEST_VERSION} into ${OUTPUT_PATH}"
curl -so "${OUTPUT_PATH}" "${DOWNLOAD_URL}" 2>/dev/null

33
bin/set-version.sh Executable file
View File

@ -0,0 +1,33 @@
#!/bin/bash
# Retrieves the version from the changelog in plantuml-mode.el
function grab_version(){
grep ';; version' plantuml-mode.el | \
head -n1 | \
cut -f3 -d' ' | \
tr -d ','
}
# Updates the version in-place
function update_version(){
NEW_VERSION="${1}"
sed -i -E "s/plantuml-mode-version \"[0-9\.]+\"/plantuml-mode-version \"${1}\"/" plantuml-mode.el
}
case "$(git rev-parse --abbrev-ref HEAD)" in
'master')
VERSION="$(grab_version)"
update_version "${VERSION}"
git add plantuml-mode.el
;;
'develop')
VERSION="$(TZ='UTC' date '+%Y%m%d.%-H%M')" # MELPA style
update_version "${VERSION}"
git add plantuml-mode.el
;;
*)
## do nothing
;;
esac

736
plantuml-mode.el Normal file
View File

@ -0,0 +1,736 @@
;;; plantuml-mode.el --- Major mode for PlantUML -*- lexical-binding: t; -*-
;; Filename: plantuml-mode.el
;; Description: Major mode for PlantUML diagrams sources
;; Compatibility: Tested with Emacs 25 through 27 (current master)
;; Author: Zhang Weize (zwz)
;; Maintainer: Carlo Sciolla (skuro)
;; Keywords: uml plantuml ascii
;; Version: 1.2.9
;; Package-Version: 1.2.9
;; Package-Requires: ((dash "2.0.0") (emacs "25.0"))
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;;
;; A major mode for plantuml, see: http://plantuml.sourceforge.net/
;; Plantuml is an open-source tool in java that allows to quickly write :
;; - sequence diagram,
;; - use case diagram,
;; - class diagram,
;; - activity diagram,
;; - component diagram,
;; - state diagram
;; - object diagram
;;; Change log:
;;
;; version 1.4.1, 2019-09-03 Better indentation; more bugfixing; actually adding `executable' mode
;; version 1.4.0, 2019-08-21 Added `executable' exec mode to use locally installed `plantuml' binaries, various bugfixes
;; version 1.3.1, 2019-08-02 Fixed interactive behavior of `plantuml-set-exec-mode'
;; version 1.3.0, 2019-05-31 Added experimental support for multiple rendering modes and, specifically, preview using a PlantUML server
;; version 1.2.11, 2019-04-09 Added `plantuml-download-jar'
;; version 1.2.10, 2019-04-03 Avoid messing with window layouts and buffers -- courtesy of https://github.com/wailo
;; version 1.2.9, Revamped indentation support, now working with a greater number of keywords
;; version 1.2.8, 2019-01-07 Support indentation for activate / deactivate blocks; allow customization of `plantuml-java-args'
;; version 1.2.7, 2018-08-15 Added support for indentation; Fixed the comiling error when installing with melpa
;; version 1.2.6, 2018-07-17 Introduced custom variable `plantuml-jar-args' to control which arguments are passed to PlantUML jar. Fix the warning of failing to specify types of 'defcustom' variables
;; version 1.2.5, 2017-08-19 #53 Fixed installation warnings
;; version 1.2.4, 2017-08-18 #60 Licensed with GPLv3+ to be compatible with Emacs
;; version 1.2.3, 2016-12-25 #50 unicode support in generated output
;; version 1.2.2, 2016-11-11 Fixed java commands handling under windows; support spaces in `plantuml-jar-path'
;; version 1.2.1, 2016-11-11 Support for paths like `~/.plantuml/plantuml.jar' for `plantuml-jar-path' (the tilde was previously unsupported)
;; version 1.2.0, 2016-11-09 Added `plantuml-preview-current-buffer', courtesy of @7mamu4
;; version 1.1.1, 2016-11-08 Fix process handling with Windows native emacs; better file extention match for autoloading the mode
;; version 1.1.0, 2016-10-18 Make PlantUML run headless by default; introduced custom variable `plantuml-java-args' to control which arguments are passed to Plantuml.
;; version 1.0.1, 2016-10-17 Bugfix release: proper auto-mode-alist regex; init delayed at mode load; avoid calling hooks twice.
;; version 1.0.0, 2016-10-16 Moved the mode to plantuml-mode, superseding zwz/plantuml-mode and skuro/puml-mode. Added preview for the currently selected region.
;; version 0.6.7, 2016-10-11 [from puml-mode] Added deprecation warning in favor of plantuml-mode
;; version 0.6.6, 2016-07-19 [from puml-mode] Added autoload, minor bug fixes
;; version 0.6.5, 2016-03-24 [from puml-mode] Added UTF8 support and open in new window / frame shortcuts
;; version 0.6.4, 2015-12-12 [from puml-mode] Added support for comments (single and multiline) -- thanks to https://github.com/nivekuil
;; version 0.6.3, 2015-11-07 [from puml-mode] Added per-buffer configurability of output type (thanks to https://github.com/davazp)
;; version 0.6.2, 2015-11-07 [from puml-mode] Added debugging capabilities to improve issue analysis
;; version 0.6.1, 2015-09-26 [from puml-mode] Bugfix: use eq to compare symbols instead of cl-equalp
;; version 0.6, 2015-09-26 [from puml-mode] Fixed PNG preview
;; version 0.5, 2015-09-21 [from puml-mode] Added preview capabilities
;; version 0.4, 2015-06-14 [from puml-mode] Use a puml- prefix to distinguish from the other plantuml-mode
;; version 0.3, 2015-06-13 [from puml-mode] Compatibility with Emacs 24.x
;; version 0.2, 2010-09-20 [from puml-mode] Initialize the keywords from the -language output of plantuml.jar instead of the hard-coded way.
;; version 0.1, 2010-08-25 [from puml-mode] First version
;;; Code:
(require 'thingatpt)
(require 'dash)
(require 'xml)
(defgroup plantuml-mode nil
"Major mode for editing plantuml file."
:group 'languages)
(defcustom plantuml-jar-path
(expand-file-name "~/plantuml.jar")
"The location of the PlantUML executable JAR."
:type 'string
:group 'plantuml)
(defcustom plantuml-executable-path
"plantuml"
"The location of the PlantUML executable."
:type 'string
:group 'plantuml)
(defvar plantuml-mode-hook nil "Standard hook for plantuml-mode.")
(defconst plantuml-mode-version "1.4.1" "The plantuml-mode version string.")
(defvar plantuml-mode-debug-enabled nil)
(defvar plantuml-font-lock-keywords nil)
(defvar plantuml-mode-map
(let ((keymap (make-sparse-keymap)))
(define-key keymap (kbd "C-c C-c") 'plantuml-preview)
keymap)
"Keymap for plantuml-mode.")
(defcustom plantuml-java-command "java"
"The java command used to execute PlantUML."
:type 'string
:group 'plantuml)
(defcustom plantuml-java-args (list "-Djava.awt.headless=true" "-jar" "--illegal-access=deny")
"The parameters passed to `plantuml-java-command' when executing PlantUML."
:type '(repeat string)
:group 'plantuml)
(defcustom plantuml-jar-args (list "-charset" "UTF-8" )
"The parameters passed to `plantuml.jar', when executing PlantUML."
:type '(repeat string)
:group 'plantuml)
(defcustom plantuml-server-url "https://www.plantuml.com/plantuml"
"The base URL of the PlantUML server."
:type 'string
:group 'plantuml)
(defcustom plantuml-executable-args (list "-headless")
"The parameters passed to plantuml executable when executing PlantUML."
:type '(repeat string)
:group 'plantuml)
(defcustom plantuml-default-exec-mode 'server
"Default execution mode for PlantUML. Valid values are:
- `jar': run PlantUML as a JAR file (requires a local install of the PlantUML JAR file, see `plantuml-jar-path'"
:type 'symbol
:group 'plantuml
:options '(jar server executable))
(defcustom plantuml-suppress-deprecation-warning t
"To silence the deprecation warning when `puml-mode' is found upon loading."
:type 'boolean
:group 'plantuml)
(defun plantuml-jar-render-command (&rest arguments)
"Create a command line to execute PlantUML with arguments (as ARGUMENTS)."
(let* ((cmd-list (append plantuml-java-args (list (expand-file-name plantuml-jar-path)) plantuml-jar-args arguments))
(cmd (mapconcat 'identity cmd-list "|")))
(plantuml-debug (format "Command is [%s]" cmd))
cmd-list))
;;; syntax table
(defvar plantuml-mode-syntax-table
(let ((synTable (make-syntax-table)))
(modify-syntax-entry ?\/ ". 14c" synTable)
(modify-syntax-entry ?' "< 23" synTable)
(modify-syntax-entry ?\n ">" synTable)
(modify-syntax-entry ?\r ">" synTable)
(modify-syntax-entry ?! "w" synTable)
(modify-syntax-entry ?@ "w" synTable)
(modify-syntax-entry ?# "'" synTable)
synTable)
"Syntax table for `plantuml-mode'.")
(defvar plantuml-types nil)
(defvar plantuml-keywords nil)
(defvar plantuml-preprocessors nil)
(defvar plantuml-builtins nil)
;; keyword completion
(defvar plantuml-kwdList nil "The plantuml keywords.")
;; PlantUML execution mode
(defvar-local plantuml-exec-mode nil
"The Plantuml execution mode override. See `plantuml-default-exec-mode' for acceptable values.")
(defun plantuml-set-exec-mode (mode)
"Set the execution mode MODE for PlantUML."
(interactive (let* ((completion-ignore-case t)
(supported-modes '("jar" "server" "executable")))
(list (completing-read (format "Exec mode [%s]: " plantuml-exec-mode)
supported-modes
nil
t
nil
nil
plantuml-exec-mode))))
(if (member mode '("jar" "server" "executable"))
(setq plantuml-exec-mode (intern mode))
(error (concat "Unsupported mode:" mode))))
(defun plantuml-get-exec-mode ()
"Retrieves the currently active PlantUML exec mode."
(or plantuml-exec-mode
plantuml-default-exec-mode))
(defun plantuml-enable-debug ()
"Enables debug messages into the *PLANTUML Messages* buffer."
(interactive)
(setq plantuml-mode-debug-enabled t))
(defun plantuml-disable-debug ()
"Stops any debug messages to be added into the *PLANTUML Messages* buffer."
(interactive)
(setq plantuml-mode-debug-enabled nil))
(defun plantuml-debug (msg)
"Writes msg (as MSG) into the *PLANTUML Messages* buffer without annoying the user."
(if plantuml-mode-debug-enabled
(let* ((log-buffer-name "*PLANTUML Messages*")
(log-buffer (get-buffer-create log-buffer-name)))
(save-excursion
(with-current-buffer log-buffer
(goto-char (point-max))
(insert msg)
(insert "\n"))))))
(defun plantuml-download-jar ()
"Download the latest PlantUML JAR file and install it into `plantuml-jar-path'."
(interactive)
(if (y-or-n-p (format "Download the latest PlantUML JAR file into %s? " plantuml-jar-path))
(if (or (not (file-exists-p plantuml-jar-path))
(y-or-n-p (format "The PlantUML jar file already exists at %s, overwrite? " plantuml-jar-path)))
(with-current-buffer (url-retrieve-synchronously "https://search.maven.org/solrsearch/select?q=g:net.sourceforge.plantuml+AND+a:plantuml&core=gav&start=0&rows=1&wt=xml")
(mkdir (file-name-directory plantuml-jar-path) t)
(let* ((parse-tree (xml-parse-region))
(doc (->> parse-tree
(assq 'response)
(assq 'result)
(assq 'doc)))
(strs (xml-get-children doc 'str))
(version (->> strs
(--filter (string-equal "v" (xml-get-attribute it 'name)))
(car)
(xml-node-children)
(car))))
(message (concat "Downloading PlantUML v" version " into " plantuml-jar-path))
(url-copy-file (format "https://search.maven.org/remotecontent?filepath=net/sourceforge/plantuml/plantuml/%s/plantuml-%s.jar" version version) plantuml-jar-path t)
(kill-buffer)))
(message "Aborted."))
(message "Aborted.")))
(defun plantuml-jar-get-language (buf)
"Retrieve the language specification from the PlantUML JAR file and paste it into BUF."
(unless (or (eq system-type 'cygwin) (file-exists-p plantuml-jar-path))
(error "Could not find plantuml.jar at %s" plantuml-jar-path))
(with-current-buffer buf
(let ((cmd-args (append (list plantuml-java-command nil t nil)
(plantuml-jar-render-command "-language"))))
(apply 'call-process cmd-args)
(goto-char (point-min)))))
(defun plantuml-server-get-language (buf)
"Retrieve the language specification from the PlantUML server and paste it into BUF."
(let ((lang-url (concat plantuml-server-url "/language")))
(with-current-buffer buf
(url-insert-file-contents lang-url))))
(defun plantuml-executable-get-language (buf)
"Retrieve the language specification from the PlantUML executable and paste it into BUF."
(with-current-buffer buf
(let ((cmd-args (append (list plantuml-executable-path nil t nil) (list "-language"))))
(apply 'call-process cmd-args)
(goto-char (point-min)))))
(defun plantuml-get-language (mode buf)
"Retrieve the language spec using the preferred PlantUML execution mode MODE. Paste the result into BUF."
(let ((get-fn (pcase mode
('jar #'plantuml-jar-get-language)
('server #'plantuml-server-get-language)
('executable #'plantuml-executable-get-language))))
(if get-fn
(funcall get-fn buf)
(error "Unsupported execution mode %s" mode))))
(defun plantuml-init (mode)
"Initialize the keywords or builtins from the cmdline language output. Use exec mode MODE to load the language details."
(with-temp-buffer
(plantuml-get-language mode (current-buffer))
(let ((found (search-forward ";" nil t))
(word "")
(count 0)
(pos 0))
(while found
(forward-char)
(setq word (current-word))
(if (string= word "EOF") (setq found nil)
;; else
(forward-line)
(setq count (string-to-number (current-word)))
(beginning-of-line 2)
(setq pos (point))
(forward-line count)
(cond ((string= word "type")
(setq plantuml-types
(split-string
(buffer-substring-no-properties pos (point)))))
((string= word "keyword")
(setq plantuml-keywords
(split-string
(buffer-substring-no-properties pos (point)))))
((string= word "preprocessor")
(setq plantuml-preprocessors
(split-string
(buffer-substring-no-properties pos (point)))))
(t (setq plantuml-builtins
(append
plantuml-builtins
(split-string
(buffer-substring-no-properties pos (point)))))))
(setq found (search-forward ";" nil nil)))))))
(defconst plantuml-preview-buffer "*PLANTUML Preview*")
(defvar plantuml-output-type
(if (not (display-images-p))
"txt"
(cond ((image-type-available-p 'svg) "svg")
((image-type-available-p 'png) "png")
(t "txt")))
"Specify the desired output type to use for generated diagrams.")
(defun plantuml-read-output-type ()
"Read from the minibuffer a output type."
(let* ((completion-ignore-case t)
(available-types
(append
(and (image-type-available-p 'svg) '("svg"))
(and (image-type-available-p 'png) '("png"))
'("txt"))))
(completing-read (format "Output type [%s]: " plantuml-output-type)
available-types
nil
t
nil
nil
plantuml-output-type)))
(defun plantuml-set-output-type (type)
"Set the desired output type (as TYPE) for the current buffer.
If the
major mode of the current buffer mode is not plantuml-mode, set the
default output type for new buffers."
(interactive (list (plantuml-read-output-type)))
(setq plantuml-output-type type))
(defun plantuml-is-image-output-p ()
"Return non-nil if the diagram output format is an image, false if it's text based."
(not (equal "txt" plantuml-output-type)))
(defun plantuml-jar-output-type-opt (output-type)
"Create the flag to pass to PlantUML according to OUTPUT-TYPE.
Note that output type `txt' is promoted to `utxt' for better rendering."
(concat "-t" (pcase output-type
("txt" "utxt")
(_ output-type))))
(defun plantuml-jar-start-process (buf)
"Run PlantUML as an Emacs process and puts the output into the given buffer (as BUF)."
(apply #'start-process
"PLANTUML" buf plantuml-java-command
`(,@plantuml-java-args
,(expand-file-name plantuml-jar-path)
,(plantuml-jar-output-type-opt plantuml-output-type)
,@plantuml-jar-args
"-p")))
(defun plantuml-executable-start-process (buf)
"Run PlantUML as an Emacs process and puts the output into the given buffer (as BUF)."
(apply #'start-process
"PLANTUML" buf plantuml-executable-path
`(,@plantuml-executable-args
,(plantuml-jar-output-type-opt plantuml-output-type)
"-p")))
(defun plantuml-update-preview-buffer (prefix buf)
"Show the preview in the preview buffer BUF.
Window is selected according to PREFIX:
- 4 (when prefixing the command with C-u) -> new window
- 16 (when prefixing the command with C-u C-u) -> new frame.
- else -> new buffer"
(let ((imagep (and (display-images-p)
(plantuml-is-image-output-p))))
(cond
((= prefix 16) (switch-to-buffer-other-frame buf))
((= prefix 4) (switch-to-buffer-other-window buf))
(t (display-buffer buf)))
(when imagep
(with-current-buffer buf
(image-mode)
(set-buffer-multibyte t)))))
(defun plantuml-jar-preview-string (prefix string buf)
"Preview the diagram from STRING by running the PlantUML JAR.
Put the result into buffer BUF. Window is selected according to PREFIX:
- 4 (when prefixing the command with C-u) -> new window
- 16 (when prefixing the command with C-u C-u) -> new frame.
- else -> new buffer"
(let* ((process-connection-type nil)
(ps (plantuml-jar-start-process buf)))
(process-send-string ps string)
(process-send-eof ps)
(set-process-sentinel ps
(lambda (_ps event)
(unless (equal event "finished\n")
(error "PLANTUML Preview failed: %s" event))
(plantuml-update-preview-buffer prefix buf)))))
(defun plantuml-server-encode-url (string)
"Encode the string STRING into a URL suitable for PlantUML server interactions."
(let* ((coding-system (or buffer-file-coding-system
"utf8"))
(encoded-string (base64-encode-string (encode-coding-string string coding-system) t)))
(concat plantuml-server-url "/" plantuml-output-type "/-base64-" encoded-string)))
(defun plantuml-server-preview-string (prefix string buf)
"Preview the diagram from STRING as rendered by the PlantUML server.
Put the result into buffer BUF and place it according to PREFIX:
- 4 (when prefixing the command with C-u) -> new window
- 16 (when prefixing the command with C-u C-u) -> new frame.
- else -> new buffer"
(let* ((url-request-location (plantuml-server-encode-url string)))
(save-current-buffer
(save-match-data
(url-retrieve url-request-location
(lambda (status)
;; TODO: error check
(goto-char (point-min))
;; skip the HTTP headers
(while (not (looking-at "\n"))
(forward-line))
(kill-region (point-min) (+ 1 (point)))
(copy-to-buffer buf (point-min) (point-max))
(plantuml-update-preview-buffer prefix buf)))))))
(defun plantuml-executable-preview-string (prefix string buf)
"Preview the diagram from STRING by running the PlantUML JAR.
Put the result into buffer BUF. Window is selected according to PREFIX:
- 4 (when prefixing the command with C-u) -> new window
- 16 (when prefixing the command with C-u C-u) -> new frame.
- else -> new buffer"
(let* ((process-connection-type nil)
(ps (plantuml-executable-start-process buf)))
(process-send-string ps string)
(process-send-eof ps)
(set-process-sentinel ps
(lambda (_ps event)
(unless (equal event "finished\n")
(error "PLANTUML Preview failed: %s" event))
(plantuml-update-preview-buffer prefix buf)))))
(defun plantuml-exec-mode-preview-string (prefix mode string buf)
"Preview the diagram from STRING using the execution mode MODE.
Put the result into buffer BUF, selecting the window according to PREFIX:
- 4 (when prefixing the command with C-u) -> new window
- 16 (when prefixing the command with C-u C-u) -> new frame.
- else -> new buffer"
(let ((preview-fn (pcase mode
('jar #'plantuml-jar-preview-string)
('server #'plantuml-server-preview-string)
('executable #'plantuml-executable-preview-string))))
(if preview-fn
(funcall preview-fn prefix string buf)
(error "Unsupported execution mode %s" mode))))
(defun plantuml-preview-string (prefix string)
"Preview diagram from PlantUML sources (as STRING), using prefix (as PREFIX)
to choose where to display it."
(let ((b (get-buffer plantuml-preview-buffer)))
(when b
(kill-buffer b)))
(let* ((imagep (and (display-images-p)
(plantuml-is-image-output-p)))
(buf (get-buffer-create plantuml-preview-buffer))
(coding-system-for-read (and imagep 'binary))
(coding-system-for-write (and imagep 'binary)))
(plantuml-exec-mode-preview-string prefix (plantuml-get-exec-mode) string buf)))
(defun plantuml-preview-buffer (prefix)
"Preview diagram from the PlantUML sources in the current buffer.
Uses prefix (as PREFIX) to choose where to display it:
- 4 (when prefixing the command with C-u) -> new window
- 16 (when prefixing the command with C-u C-u) -> new frame.
- else -> new buffer"
(interactive "p")
(plantuml-preview-string prefix (buffer-string)))
(defun plantuml-preview-region (prefix begin end)
"Preview diagram from the PlantUML sources in from BEGIN to END.
Uses the current region when called interactively.
Uses prefix (as PREFIX) to choose where to display it:
- 4 (when prefixing the command with C-u) -> new window
- 16 (when prefixing the command with C-u C-u) -> new frame.
- else -> new buffer"
(interactive "p\nr")
(plantuml-preview-string prefix (concat "@startuml\n"
(buffer-substring-no-properties
begin end)
"\n@enduml")))
(defun plantuml-preview-current-block (prefix)
"Preview diagram from the PlantUML sources from the previous @startuml to the next @enduml.
Uses prefix (as PREFIX) to choose where to display it:
- 4 (when prefixing the command with C-u) -> new window
- 16 (when prefixing the command with C-u C-u) -> new frame.
- else -> new buffer"
(interactive "p")
(save-restriction
(narrow-to-region
(search-backward "@startuml") (search-forward "@enduml"))
(plantuml-preview-buffer prefix)))
(defun plantuml-preview (prefix)
"Preview diagram from the PlantUML sources.
Uses the current region if one is active, or the entire buffer otherwise.
Uses prefix (as PREFIX) to choose where to display it:
- 4 (when prefixing the command with C-u) -> new window
- 16 (when prefixing the command with C-u C-u) -> new frame.
- else -> new buffer"
(interactive "p")
(if mark-active
(plantuml-preview-region prefix (region-beginning) (region-end))
(plantuml-preview-buffer prefix)))
(defun plantuml-init-once (&optional mode)
"Ensure initialization only happens once. Use exec mode MODE to load the language details or by first querying `plantuml-get-exec-mode'."
(let ((mode (or mode (plantuml-get-exec-mode))))
(unless plantuml-kwdList
(plantuml-init mode)
(defvar plantuml-types-regexp (concat "^\\s *\\(" (regexp-opt plantuml-types 'words) "\\|\\<\\(note\\s +over\\|note\\s +\\(left\\|right\\|bottom\\|top\\)\\s +\\(of\\)?\\)\\>\\|\\<\\(\\(left\\|center\\|right\\)\\s +\\(header\\|footer\\)\\)\\>\\)"))
(defvar plantuml-keywords-regexp (concat "^\\s *" (regexp-opt plantuml-keywords 'words) "\\|\\(<\\|<|\\|\\*\\|o\\)\\(\\.+\\|-+\\)\\|\\(\\.+\\|-+\\)\\(>\\||>\\|\\*\\|o\\)\\|\\.\\{2,\\}\\|-\\{2,\\}"))
(defvar plantuml-builtins-regexp (regexp-opt plantuml-builtins 'words))
(defvar plantuml-preprocessors-regexp (concat "^\\s *" (regexp-opt plantuml-preprocessors 'words)))
;; Below are the regexp's for indentation.
;; Notes:
;; - there is some control on what it is indented by overriding some of below
;; X-start and X-end regexp before plantuml-mode is loaded. E.g., to disable
;; indentation on activate, you might define in your .emacs something like
;; (setq plantuml-indent-regexp-activate-start
;; "NEVER MATCH THIS EXPRESSION"); define _before_ load plantuml-mode!
;; (setq plantuml-indent-regexp-activate-end
;; "NEVER MATCH THIS EXPRESSION"); define _before_ load plantuml-mode!
;; - due to the nature of using (context-insensitive) regexp, indentation have
;; following limitations
;; - commands commented out by /' ... '/ will _not_ be ignored
;; and potentially lead to miss-indentation
;; - you can though somewhat correct mis-indentation by adding in '-comment lines
;; PLANTUML_MODE_INDENT_INCREASE and/or PLANTUML_MODE_INDENT_DECREASE
;; to increase and/or decrease the level of indentation
;; (Note: the line with the comment should not contain any text matching other indent
;; regexp or this user-control instruction will be ignored; also at most will count
;; per line ...)
(defvar plantuml-indent-regexp-block-start "^.*{\s*$"
"Indentation regex for all plantuml elements that might define a {} block.
Plantuml elements like skinparam, rectangle, sprite, package, etc.
The opening { has to be the last visible character in the line (whitespace
might follow).")
(defvar plantuml-indent-regexp-note-start "^\s*\\(floating\s+\\)?[hr]?note\s+\\(right\\|left\\|top\\|bottom\\|over\\)[^:]*?$" "simplyfied regex; note syntax is especially inconsistent across diagrams")
(defvar plantuml-indent-regexp-group-start "^\s*\\(alt\\|else\\|opt\\|loop\\|par\\|break\\|critical\\|group\\)\\(?:\s+.+\\|$\\)"
"Indentation regex for plantuml group elements that are defined for sequence diagrams.
Two variants for groups: keyword is either followed by whitespace and some text
or it is followed by line end.")
(defvar plantuml-indent-regexp-activate-start "^\s*activate\s+.+$")
(defvar plantuml-indent-regexp-box-start "^\s*box\s+.+$")
(defvar plantuml-indent-regexp-ref-start "^\s*ref\s+over\s+[^:]+?$")
(defvar plantuml-indent-regexp-title-start "^\s*title\s*\\('.*\\)?$")
(defvar plantuml-indent-regexp-header-start "^\s*\\(?:\\(?:center\\|left\\|right\\)\s+header\\|header\\)\s*\\('.*\\)?$")
(defvar plantuml-indent-regexp-footer-start "^\s*\\(?:\\(?:center\\|left\\|right\\)\s+footer\\|footer\\)\s*\\('.*\\)?$")
(defvar plantuml-indent-regexp-legend-start "^\s*\\(?:legend\\|legend\s+\\(?:bottom\\|top\\)\\|legend\s+\\(?:center\\|left\\|right\\)\\|legend\s+\\(?:bottom\\|top\\)\s+\\(?:center\\|left\\|right\\)\\)\s*\\('.*\\)?$")
(defvar plantuml-indent-regexp-oldif-start "^.*if\s+\".*\"\s+then\s*\\('.*\\)?$" "used in current activity diagram, sometimes already mentioned as deprecated")
(defvar plantuml-indent-regexp-macro-start "^\s*!definelong.*$")
(defvar plantuml-indent-regexp-user-control-start "^.*'.*\s*PLANTUML_MODE_INDENT_INCREASE\s*.*$")
(defvar plantuml-indent-regexp-start (list plantuml-indent-regexp-block-start
plantuml-indent-regexp-group-start
plantuml-indent-regexp-activate-start
plantuml-indent-regexp-box-start
plantuml-indent-regexp-ref-start
plantuml-indent-regexp-legend-start
plantuml-indent-regexp-note-start
plantuml-indent-regexp-oldif-start
plantuml-indent-regexp-title-start
plantuml-indent-regexp-header-start
plantuml-indent-regexp-footer-start
plantuml-indent-regexp-macro-start
plantuml-indent-regexp-oldif-start
plantuml-indent-regexp-user-control-start))
(defvar plantuml-indent-regexp-block-end "^\s*\\(?:}\\|endif\\|else\s*.*\\|end\\)\s*\\('.*\\)?$")
(defvar plantuml-indent-regexp-note-end "^\s*\\(end\s+note\\|end[rh]note\\)\s*\\('.*\\)?$")
(defvar plantuml-indent-regexp-group-end "^\s*end\s*\\('.*\\)?$")
(defvar plantuml-indent-regexp-activate-end "^\s*deactivate\s+.+$")
(defvar plantuml-indent-regexp-box-end "^\s*end\s+box\s*\\('.*\\)?$")
(defvar plantuml-indent-regexp-ref-end "^\s*end\s+ref\s*\\('.*\\)?$")
(defvar plantuml-indent-regexp-title-end "^\s*end\s+title\s*\\('.*\\)?$")
(defvar plantuml-indent-regexp-header-end "^\s*endheader\s*\\('.*\\)?$")
(defvar plantuml-indent-regexp-footer-end "^\s*endfooter\s*\\('.*\\)?$")
(defvar plantuml-indent-regexp-legend-end "^\s*endlegend\s*\\('.*\\)?$")
(defvar plantuml-indent-regexp-oldif-end "^\s*\\(endif\\|else\\)\s*\\('.*\\)?$")
(defvar plantuml-indent-regexp-macro-end "^\s*!enddefinelong\s*\\('.*\\)?$")
(defvar plantuml-indent-regexp-user-control-end "^.*'.*\s*PLANTUML_MODE_INDENT_DECREASE\s*.*$")
(defvar plantuml-indent-regexp-end (list plantuml-indent-regexp-block-end
plantuml-indent-regexp-group-end
plantuml-indent-regexp-activate-end
plantuml-indent-regexp-box-end
plantuml-indent-regexp-ref-end
plantuml-indent-regexp-legend-end
plantuml-indent-regexp-note-end
plantuml-indent-regexp-oldif-end
plantuml-indent-regexp-title-end
plantuml-indent-regexp-header-end
plantuml-indent-regexp-footer-end
plantuml-indent-regexp-macro-end
plantuml-indent-regexp-oldif-end
plantuml-indent-regexp-user-control-end))
(setq plantuml-font-lock-keywords
`(
(,plantuml-types-regexp . font-lock-type-face)
(,plantuml-keywords-regexp . font-lock-keyword-face)
(,plantuml-builtins-regexp . font-lock-builtin-face)
(,plantuml-preprocessors-regexp . font-lock-preprocessor-face)
;; note: order matters
))
(setq plantuml-kwdList (make-hash-table :test 'equal))
(mapc (lambda (x) (puthash x t plantuml-kwdList)) plantuml-types)
(mapc (lambda (x) (puthash x t plantuml-kwdList)) plantuml-keywords)
(mapc (lambda (x) (puthash x t plantuml-kwdList)) plantuml-builtins)
(mapc (lambda (x) (puthash x t plantuml-kwdList)) plantuml-preprocessors)
(put 'plantuml-kwdList 'risky-local-variable t)
;; clear memory
(setq plantuml-types nil)
(setq plantuml-keywords nil)
(setq plantuml-builtins nil)
(setq plantuml-preprocessors nil)
(setq plantuml-types-regexp nil)
(setq plantuml-keywords-regexp nil)
(setq plantuml-builtins-regexp nil)
(setq plantuml-preprocessors-regexp nil))))
(defun plantuml-complete-symbol ()
"Perform keyword completion on word before cursor."
(interactive)
(let ((posEnd (point))
(meat (thing-at-point 'symbol))
maxMatchResult)
(when (not meat) (setq meat ""))
(setq maxMatchResult (try-completion meat plantuml-kwdList))
(cond ((eq maxMatchResult t))
((null maxMatchResult)
(message "Can't find completion for \"%s\"" meat)
(ding))
((not (string= meat maxMatchResult))
(delete-region (- posEnd (length meat)) posEnd)
(insert maxMatchResult))
(t (message "Making completion list...")
(with-output-to-temp-buffer "*Completions*"
(display-completion-list
(all-completions meat plantuml-kwdList)))
(message "Making completion list...%s" "done")))))
;; indentation
(defun plantuml-current-block-depth ()
"Trace the current block indentation level by recursively looking back line by line."
(save-excursion
(let ((relative-depth 0))
;; current line
(beginning-of-line)
(if (-any? 'looking-at plantuml-indent-regexp-end)
(setq relative-depth (1- relative-depth)))
;; from current line backwards to beginning of buffer
(while (not (bobp))
(forward-line -1)
(if (-any? 'looking-at plantuml-indent-regexp-end)
(setq relative-depth (1- relative-depth)))
(if (-any? 'looking-at plantuml-indent-regexp-start)
(setq relative-depth (1+ relative-depth))))
(if (<= relative-depth 0)
0
relative-depth))))
(defun plantuml-indent-line ()
"Indent the current line to its desired indentation level.
Restore point to same position in text of the line as before indentation."
(interactive)
;; store position of point in line measured from end of line
(let ((original-position-eol (- (line-end-position) (point))))
(save-excursion
(beginning-of-line)
(indent-line-to (* tab-width (plantuml-current-block-depth))))
;; restore position in text of line
(goto-char (- (line-end-position) original-position-eol))))
;;;###autoload
(add-to-list 'auto-mode-alist '("\\.\\(plantuml\\|pum\\|plu\\)\\'" . plantuml-mode))
;;;###autoload
(define-derived-mode plantuml-mode prog-mode "plantuml"
"Major mode for plantuml.
Shortcuts Command Name
\\[plantuml-complete-symbol] `plantuml-complete-symbol'"
(plantuml-init-once)
(make-local-variable 'plantuml-output-type)
(set (make-local-variable 'comment-start-skip) "\\('+\\|/'+\\)\\s *")
(set (make-local-variable 'comment-start) "/'")
(set (make-local-variable 'comment-end) "'/")
(set (make-local-variable 'comment-multi-line) t)
(set (make-local-variable 'comment-style) 'extra-line)
(set (make-local-variable 'indent-line-function) 'plantuml-indent-line)
(setq font-lock-defaults '((plantuml-font-lock-keywords) nil t)))
(defun plantuml-deprecation-warning ()
"Warns the user about the deprecation of the `puml-mode' project."
(if (and plantuml-suppress-deprecation-warning
(featurep 'puml-mode))
(display-warning :warning
"`puml-mode' is now deprecated and no longer updated, but it's still present in your system. \
You should move your configuration to use `plantuml-mode'. \
See more at https://github.com/skuro/puml-mode/issues/26")))
(add-hook 'plantuml-mode-hook 'plantuml-deprecation-warning)
(provide 'plantuml-mode)
;;; plantuml-mode.el ends here

View File

@ -1,260 +0,0 @@
;;; puml-mode.el --- Major mode for PlantUML
;; Filename: puml-mode.el
;; Description: Major mode for PlantUML diagrams sources
;; Compatibility: Tested with Emacs 24.3 through 24.5 on OS X 10.10
;; Author: Zhang Weize (zwz)
;; Maintainer: Carlo Sciolla (skuro)
;; Keywords: uml plantuml ascii
;; Version: 0.6.2
;; You can redistribute this program and/or modify it under the terms
;; of the GNU General Public License as published by the Free Software
;; Foundation; either version 2
;; NOTE: licensing fixed to GPLv2 as per original author comment
;;; Commentary:
;;
;; A major mode for plantuml, see: http://plantuml.sourceforge.net/
;; Plantuml is an open-source tool in java that allows to quickly write :
;; - sequence diagram,
;; - use case diagram,
;; - class diagram,
;; - activity diagram,
;; - component diagram,
;; - state diagram
;; - object diagram
;;; Change log:
;;
;; version 0.6.2, 2015-11-07 Added debugging capabilities to improve issue analysis
;; version 0.6.1, 2015-09-26 Bugfix: use eq to compare symbols instead of cl-equalp
;; version 0.6, 2015-09-26 Fixed PNG preview
;; version 0.5, 2015-09-21 Added preview capabilities
;; version 0.4, 2015-06-14 Use a puml- prefix to distinguish from the other plantuml-mode
;; version 0.3, 2015-06-13 Compatibility with Emacs 24.x
;; version 0.2, 2010-09-20 Initialize the keywords from the -language output of plantuml.jar instead of the hard-coded way.
;; version 0.1, 2010-08-25 First version
;;; Code:
(require 'thingatpt)
(defgroup puml-mode nil
"Major mode for editing plantuml file."
:group 'languages)
(defcustom puml-plantuml-jar-path
(expand-file-name "~/plantuml.jar")
"The location of the PlantUML executable JAR.")
(defvar puml-mode-hook nil "Standard hook for puml-mode.")
(defvar puml-mode-version "0.6.1" "The puml-mode version string.")
(defvar puml-mode-debug-enabled nil)
(defvar puml-mode-map
(let ((keymap (make-keymap)))
(define-key keymap (kbd "C-c C-c") 'puml-preview)
keymap)
"Keymap for puml-mode.")
;;; syntax table
(defvar puml-mode-syntax-table
(let ((synTable (make-syntax-table)))
(modify-syntax-entry ?' "< b" synTable)
(modify-syntax-entry ?\n "> b" synTable)
(modify-syntax-entry ?! "w" synTable)
(modify-syntax-entry ?@ "w" synTable)
(modify-syntax-entry ?# "'" synTable)
synTable)
"Syntax table for `puml-mode'.")
(defvar puml-plantuml-types nil)
(defvar puml-plantuml-keywords nil)
(defvar puml-plantuml-preprocessors nil)
(defvar puml-plantuml-builtins nil)
;; keyword completion
(defvar puml-plantuml-kwdList nil "The plantuml keywords.")
(defun puml-enable-debug ()
"Enables debug messages into the *PUML Messages* buffer."
(interactive)
(setq puml-mode-debug-enabled t))
(defun puml-disable-debug ()
"Stops any debug messages to be added into the *PUML Messages* buffer."
(interactive)
(setq puml-mode-debug-enabled nil))
(defun puml-debug (msg)
"Writes msg (as MSG) into the *PUML Messages* buffer without annoying the user."
(if puml-mode-debug-enabled
(let* ((log-buffer-name "*PUML Messages*")
(log-buffer (get-buffer-create log-buffer-name)))
(save-excursion
(with-current-buffer log-buffer
(goto-char (point-max))
(insert msg)
(insert "\n"))))))
(defun puml-init ()
"Initialize the keywords or builtins from the cmdline language output."
(unless (file-exists-p puml-plantuml-jar-path)
(error "Could not find plantuml.jar at %s" puml-plantuml-jar-path))
(with-temp-buffer
(shell-command (concat "java -jar "
(shell-quote-argument puml-plantuml-jar-path)
" -language") (current-buffer))
(goto-char (point-min))
(let ((found (search-forward ";" nil t))
(word "")
(count 0)
(pos 0))
(while found
(forward-char)
(setq word (current-word))
(if (string= word "EOF") (setq found nil)
;; else
(forward-line)
(setq count (string-to-number (current-word)))
(beginning-of-line 2)
(setq pos (point))
(forward-line count)
(cond ((string= word "type")
(setq puml-plantuml-types
(split-string
(buffer-substring-no-properties pos (point)))))
((string= word "keyword")
(setq puml-plantuml-keywords
(split-string
(buffer-substring-no-properties pos (point)))))
((string= word "preprocessor")
(setq puml-plantuml-preprocessors
(split-string
(buffer-substring-no-properties pos (point)))))
(t (setq puml-plantuml-builtins
(append
puml-plantuml-builtins
(split-string
(buffer-substring-no-properties pos (point)))))))
(setq found (search-forward ";" nil nil)))))))
(defconst puml-preview-buffer "*PUML Preview*")
(defun puml-output-type ()
"Detects the best output type to use for generated diagrams."
(cond ((image-type-available-p 'svg) 'svg)
((image-type-available-p 'png) 'png)
('utxt)))
(defun puml-is-image-output-p ()
"Return true if the diagram output format is an image, false if it's text based."
(not (eq 'utxt (puml-output-type))))
(defun puml-output-type-opt ()
"Create the flag to pass to PlantUML to produce the selected output format."
(let ((type (puml-output-type)))
(concat "-t" (symbol-name type))))
(defun puml-preview-sentinel (ps event)
"For the PlantUML process (as PS) reacts on the termination event (as EVENT)."
(if (equal event "finished\n")
(progn
(switch-to-buffer puml-preview-buffer)
(when (and (display-images-p)
(puml-is-image-output-p))
(image-mode)))
(warn "PUML Preview failed: %s" event)))
(defun puml-preview ()
"Preview diagram."
(interactive)
(let ((b (get-buffer puml-preview-buffer)))
(when b
(kill-buffer b)))
(let ((process-connection-type nil)
(buf (get-buffer-create puml-preview-buffer))
(coding-system-for-read 'binary)
(coding-system-for-write 'binary)
(command-params (shell-quote-argument puml-plantuml-jar-path)))
(puml-debug "Executing:")
(puml-debug (concat "java -jar " command-params " " (puml-output-type-opt) " -p"))
(let ((ps (start-process "PUML" buf
"java" "-jar" command-params
(puml-output-type-opt) "-p")))
(process-send-region ps (point-min) (point-max))
(process-send-eof ps)
(set-process-sentinel ps 'puml-preview-sentinel))))
(unless puml-plantuml-kwdList
(puml-init)
(defvar puml-plantuml-types-regexp (concat "^\\s *\\(" (regexp-opt puml-plantuml-types 'words) "\\|\\<\\(note\\s +over\\|note\\s +\\(left\\|right\\|bottom\\|top\\)\\s +\\(of\\)?\\)\\>\\|\\<\\(\\(left\\|center\\|right\\)\\s +\\(header\\|footer\\)\\)\\>\\)"))
(defvar puml-plantuml-keywords-regexp (concat "^\\s *" (regexp-opt puml-plantuml-keywords 'words) "\\|\\(<\\|<|\\|\\*\\|o\\)\\(\\.+\\|-+\\)\\|\\(\\.+\\|-+\\)\\(>\\||>\\|\\*\\|o\\)\\|\\.\\{2,\\}\\|-\\{2,\\}"))
(defvar puml-plantuml-builtins-regexp (regexp-opt puml-plantuml-builtins 'words))
(defvar puml-plantuml-preprocessors-regexp (concat "^\\s *" (regexp-opt puml-plantuml-preprocessors 'words)))
(setq puml-font-lock-keywords
`(
(,puml-plantuml-types-regexp . font-lock-type-face)
(,puml-plantuml-keywords-regexp . font-lock-keyword-face)
(,puml-plantuml-builtins-regexp . font-lock-builtin-face)
(,puml-plantuml-preprocessors-regexp . font-lock-preprocessor-face)
;; note: order matters
))
(setq puml-plantuml-kwdList (make-hash-table :test 'equal))
(mapc (lambda (x) (puthash x t puml-plantuml-kwdList)) puml-plantuml-types)
(mapc (lambda (x) (puthash x t puml-plantuml-kwdList)) puml-plantuml-keywords)
(mapc (lambda (x) (puthash x t puml-plantuml-kwdList)) puml-plantuml-builtins)
(mapc (lambda (x) (puthash x t puml-plantuml-kwdList)) puml-plantuml-preprocessors)
(put 'puml-plantuml-kwdList 'risky-local-variable t)
;; clear memory
(setq puml-plantuml-types nil)
(setq puml-plantuml-keywords nil)
(setq puml-plantuml-builtins nil)
(setq puml-plantuml-preprocessors nil)
(setq puml-plantuml-types-regexp nil)
(setq puml-plantuml-keywords-regexp nil)
(setq puml-plantuml-builtins-regexp nil)
(setq puml-plantuml-preprocessors-regexp nil))
(defun puml-complete-symbol ()
"Perform keyword completion on word before cursor."
(interactive)
(let ((posEnd (point))
(meat (thing-at-point 'symbol))
maxMatchResult)
(when (not meat) (setq meat ""))
(setq maxMatchResult (try-completion meat puml-plantuml-kwdList))
(cond ((eq maxMatchResult t))
((null maxMatchResult)
(message "Can't find completion for \"%s\"" meat)
(ding))
((not (string= meat maxMatchResult))
(delete-region (- posEnd (length meat)) posEnd)
(insert maxMatchResult))
(t (message "Making completion list...")
(with-output-to-temp-buffer "*Completions*"
(display-completion-list
(all-completions meat puml-plantuml-kwdList)))
(message "Making completion list...%s" "done")))))
(add-to-list 'auto-mode-alist '("\\.pum$" . puml-mode))
;;;###autoload
(define-derived-mode puml-mode prog-mode "puml"
"Major mode for plantuml.
Shortcuts Command Name
\\[puml-complete-symbol] `puml-complete-symbol'"
(setq font-lock-defaults '((puml-font-lock-keywords) nil t)))
(provide 'puml-mode)
;;; puml-mode.el ends here

View File

@ -0,0 +1,34 @@
;;; plantuml-config-test.el --- tests for plantuml-mode configuration knobs -*- lexical-binding: t; -*-
;; Author: Carlo Sciolla
;; Maintainer: Carlo Sciolla
;; URL: https://github.com/skuro/plantuml-mode
;;; Commentary:
;; Test user-accessible configuration knobs
;;; Code:
(require 'plantuml-mode)
(ert-deftest plantuml-config-test/set-exec-mode-happy-path ()
"Test switching execution modes"
(let ((orig-mode plantuml-exec-mode))
;; happy flows:
(plantuml-set-exec-mode "server")
(should (equal 'server plantuml-exec-mode))
(plantuml-set-exec-mode "jar")
(should (equal 'jar plantuml-exec-mode))
(plantuml-set-exec-mode "executable")
(should (equal 'executable plantuml-exec-mode))
(setq plantuml-exec-mode orig-mode)))
(ert-deftest plantuml-config-test/set-exec-mode-wrong-mode ()
"Test setting the exec mode with the wrong text"
(should-error (plantuml-set-exec-mode "turing-machine")))
(provide 'plantuml-mode-config-test)
;;; plantuml-config-test.el ends here

View File

@ -0,0 +1,281 @@
;;; plantuml-indentation-activity-old-test.el --- PlantUML Mode indentation tests -*- lexical-binding: t; -*-
;; Author: René Schmelzer
;; Maintainer: Carlo Sciolla (skuro)
;; URL: https://github.com/skuro/plantuml-mode
;;; Commentary:
;; Test indentation for activity (old version) diagrams.
;;; Code:
(ert-deftest plantuml-test-indentation/activity-old-diagram/branches ()
"Test correct indentation of plantuml activity-old diagram elements: branches.
These code examples are taken from www.plantuml.com"
(plantuml-test-indent-block
"
if \"Some Test\" then
-->[true] \"Some Activity\"
--> \"Another activity\"
-right-> (*)
else
->[false] \"Something else\"
-->[Ending process] (*)
endif
(*) --> \"check input\"
If \"input is verbose\" then
--> [Yes] \"turn on verbosity\"
--> \"run command\"
else
--> \"run command\"
Endif
-->(*)
"
"
if \"Some Test\" then
-->[true] \"Some Activity\"
--> \"Another activity\"
-right-> (*)
else
->[false] \"Something else\"
-->[Ending process] (*)
endif
(*) --> \"check input\"
If \"input is verbose\" then
--> [Yes] \"turn on verbosity\"
--> \"run command\"
else
--> \"run command\"
Endif
-->(*)
"
))
(ert-deftest plantuml-test-indentation/activity-old-diagram/more-on-branches ()
"Test correct indentation of plantuml activity-old diagram elements: more on branches.
These code examples are taken from www.plantuml.com"
(plantuml-test-indent-block
"
(*) --> if \"Some Test\" then
-->[true] \"activity 1\"
if \"\" then
-> \"activity 3\" as a3
else
if \"Other test\" then
-left-> \"activity 5\"
else
--> \"activity 6\"
endif
endif
else
->[false] \"activity 2\"
endif
a3 --> if \"last test\" then
--> \"activity 7\"
else
-> \"activity 8\"
endif
"
"
(*) --> if \"Some Test\" then
-->[true] \"activity 1\"
if \"\" then
-> \"activity 3\" as a3
else
if \"Other test\" then
-left-> \"activity 5\"
else
--> \"activity 6\"
endif
endif
else
->[false] \"activity 2\"
endif
a3 --> if \"last test\" then
--> \"activity 7\"
else
-> \"activity 8\"
endif
"
))
(ert-deftest plantuml-test-indentation/activity-old-diagram/partitions ()
"Test correct indentation of plantuml activity-old diagram elements: partitions.
These code examples are taken from www.plantuml.com"
(plantuml-test-indent-block
"
partition Conductor {
(*) --> \"Climbs on Platform\"
--> === S1 ===
--> Bows
}
partition Audience #LightSkyBlue {
=== S1 === --> Applauds
}
partition Conductor {
Bows --> === S2 ===
--> WavesArmes
Applauds --> === S2 ===
}
partition Orchestra #CCCCEE {
WavesArmes --> Introduction
--> \"Play music\"
}
"
"
partition Conductor {
(*) --> \"Climbs on Platform\"
--> === S1 ===
--> Bows
}
partition Audience #LightSkyBlue {
=== S1 === --> Applauds
}
partition Conductor {
Bows --> === S2 ===
--> WavesArmes
Applauds --> === S2 ===
}
partition Orchestra #CCCCEE {
WavesArmes --> Introduction
--> \"Play music\"
}
"))
(ert-deftest plantuml-test-indentation/activity-old-diagram/complete-example ()
"Test correct indentation of plantuml activity-old diagram elements: complete example.
These code examples are taken from www.plantuml.com"
(plantuml-test-indent-block
"
title Servlet Container
(*) --> \"ClickServlet.handleRequest()\"
--> \"new Page\"
if \"Page.onSecurityCheck\" then
->[true] \"Page.onInit()\"
if \"isForward?\" then
->[no] \"Process controls\"
if \"continue processing?\" then
-->[yes] ===RENDERING===
else
-->[no] ===REDIRECT_CHECK===
endif
else
-->[yes] ===RENDERING===
endif
if \"is Post?\" then
-->[yes] \"Page.onPost()\"
--> \"Page.onRender()\" as render
--> ===REDIRECT_CHECK===
else
-->[no] \"Page.onGet()\"
--> render
endif
else
-->[false] ===REDIRECT_CHECK===
endif
if \"Do redirect?\" then
->[yes] \"redirect request\"
--> ==BEFORE_DESTROY===
else
if \"Do Forward?\" then
-left->[yes] \"Forward request\"
--> ==BEFORE_DESTROY===
else
-right->[no] \"Render page template\"
--> ==BEFORE_DESTROY===
endif
endif
--> \"Page.onDestroy()\"
-->(*)
"
"
title Servlet Container
(*) --> \"ClickServlet.handleRequest()\"
--> \"new Page\"
if \"Page.onSecurityCheck\" then
->[true] \"Page.onInit()\"
if \"isForward?\" then
->[no] \"Process controls\"
if \"continue processing?\" then
-->[yes] ===RENDERING===
else
-->[no] ===REDIRECT_CHECK===
endif
else
-->[yes] ===RENDERING===
endif
if \"is Post?\" then
-->[yes] \"Page.onPost()\"
--> \"Page.onRender()\" as render
--> ===REDIRECT_CHECK===
else
-->[no] \"Page.onGet()\"
--> render
endif
else
-->[false] ===REDIRECT_CHECK===
endif
if \"Do redirect?\" then
->[yes] \"redirect request\"
--> ==BEFORE_DESTROY===
else
if \"Do Forward?\" then
-left->[yes] \"Forward request\"
--> ==BEFORE_DESTROY===
else
-right->[no] \"Render page template\"
--> ==BEFORE_DESTROY===
endif
endif
--> \"Page.onDestroy()\"
-->(*)
"
))
(provide 'plantuml-indentation-activity-old-test)
;;; plantuml-indentation-activity-old-test.el ends here

View File

@ -0,0 +1,263 @@
;;; plantuml-indentation-basics-test.el --- PlantUML Mode indentation tests -*- lexical-binding: t; -*-
;; Author: Raymond Huang (rymndhng)
;; Maintainer: Carlo Sciolla (skuro)
;; URL: https://github.com/skuro/plantuml-mode
;;; Commentary:
;; Test basics like single correct indentation depth etc. Focus is not on diagram contents
;; and context; such things are tested in the diagram specific indentation tests.
;; Test setup is inspired/taken from clojure-mode-indentation-tests
;;; Code:
(defun plantuml-test-add-text-and-position-cursor (txt)
"Test helper for `plantuml-mode' tests.
Add TXT into the buffer, move cursor to the position of the marker
?| and delete the marker."
(insert txt)
(goto-char (point-min))
(search-forward "|")
(delete-char -1))
(defun plantuml-test-assert-block-depth (expected txt)
"Test helper for `plantuml-mode' tests.
Assert the EXPECTED indentation level for the given TXT."
(with-temp-buffer
(plantuml-test-add-text-and-position-cursor txt)
(let ((actual (plantuml-current-block-depth)))
(should (equal expected actual)))))
(ert-deftest plantuml-test-current-block-depth_bob ()
"Test `plantuml-current-block-depth' level 0 at beginning of buffer."
(setq-local plantuml-jar-path plantuml-test-jar-path)
(plantuml-init-once)
(plantuml-test-assert-block-depth 0 "|
activate p1
activate p2
foo
deactivate p2
deactivate p1
"))
(ert-deftest plantuml-test-current-block-depth_0 ()
"Test `plantuml-current-block-depth' level 0 at beginning of first line."
(setq-local plantuml-jar-path plantuml-test-jar-path)
(plantuml-init-once)
(plantuml-test-assert-block-depth 0 "
|activate p1
activate p2
foo
deactivate p2
deactivate p1
"))
(ert-deftest plantuml-test-current-block-depth_1 ()
"Test `plantuml-current-block-depth' level 0 at middle of first line."
(setq-local plantuml-jar-path plantuml-test-jar-path)
(plantuml-init-once)
(plantuml-test-assert-block-depth 0 "
acti|vate p1
activate p2
foo
deactivate p2
deactivate p1
"))
(ert-deftest plantuml-test-current-block-depth_2 ()
"Test `plantuml-current-block-depth' level 0 at end of first line"
(setq-local plantuml-jar-path plantuml-test-jar-path)
(plantuml-init-once)
(plantuml-test-assert-block-depth 0 "
activate p1|
activate p2
foo
deactivate p2
deactivate p1
"))
(ert-deftest plantuml-test-current-block-depth_3 ()
"Test `plantuml-current-block-depth' level 1 at beginning of 2nd line."
(plantuml-test-assert-block-depth 1 "
activate p1
|activate p2
foo
deactivate p2
deactivate p1
"))
(ert-deftest plantuml-test-current-block-depth_4 ()
"Test `plantuml-current-block-depth' level 2 at beginning of 3rd line."
(plantuml-test-assert-block-depth 2 "
activate p1
activate p2
|foo
deactivate p2
deactivate p1
"))
(ert-deftest plantuml-test-current-block-depth_5 ()
"Test `plantuml-current-block-depth' level 1 at beginning of 4th line."
(plantuml-test-assert-block-depth 1 "
activate p1
activate p2
foo
|deactivate p2
deactivate p1
"))
(ert-deftest plantuml-test-current-block-depth_6 ()
"Test `plantuml-current-block-depth' level 0 at beginning of 5th line."
(plantuml-test-assert-block-depth 0 "
activate p1
activate p2
foo
deactivate p2
|deactivate p1
"))
(ert-deftest plantuml-test-current-block-depth_eob ()
"Test `plantuml-current-block-depth' level 0 at end of buffer."
(plantuml-test-assert-block-depth 0 "
activate p1
activate p2
foo
deactivate p2
deactivate p1
|"))
(defun plantuml-test-indent-line (before after)
"The common code for the line indentation tests.
BEFORE is the text to be inserted into a temporary buffer.
AFTER is the expected text after indentation.
Both, BEFORE and AFTER need to specify point with char |. The
temporary buffer will be put into `plantuml-mode', the char |
representing point will be removed from text. The line with the
removed | will be indented (just this line!) with two spaces for each
level of indentation.
Finally,
1) the indented line will be compared with the same line in AFTER
2) the position of point in the indented line will be compared with
the position of | in AFTER."
(let* ((expected-cursor-pos (1+ (s-index-of "|" after)))
(expected-state (delete ?| after)))
(with-temp-buffer
;; fix the JAR location prior to mode initialization
;; for some reason, plantuml-mode disregards the setq-local
(setq-local plantuml-jar-path plantuml-test-jar-path)
(plantuml-init-once)
(plantuml-test-add-text-and-position-cursor before)
(plantuml-mode)
;; use 2 spaces instead of one tab for indentation
(setq-local indent-tabs-mode nil)
(setq-local tab-width 2)
(indent-according-to-mode)
(should (equal expected-state (buffer-string)))
(should (equal expected-cursor-pos (point))))))
(ert-deftest plantuml-test-line-indentation/empty-line-l0 ()
"Test correct indentation of empty line - indentation level 0."
(plantuml-test-indent-line "|" "|"))
(ert-deftest plantuml-test-line-indentation/bol-notindent-l0 ()
"Test correct indentation of a not indented line with point at beginning of line - indentation level 0."
(plantuml-test-indent-line "|participant A"
"|participant A"))
(ert-deftest plantuml-test-line-indentation/mol-notindent-l0 ()
"Test correct indentation of a not indented line with point at middle of line - indentation level 0."
(plantuml-test-indent-line "parti|cipant"
"parti|cipant"))
(ert-deftest plantuml-test-line-indentation/eol-notindent-l0 ()
"Test correct indentation of a not indented line with point at end of line - indentation level 0."
(plantuml-test-indent-line "participant A|"
"participant A|"))
(ert-deftest plantuml-test-line-indentation/bol-indented-l0 ()
"Test correct indentation of an indented line with point at beginning of line - indentation level 0."
(plantuml-test-indent-line " |participant A"
"|participant A"))
(ert-deftest plantuml-test-line-indentation/mol-indented-l0 ()
"Test correct indentation of an indented line with point at middle of line - indentation level 0."
(plantuml-test-indent-line " parti|cipant"
"parti|cipant"))
(ert-deftest plantuml-test-line-indentation/eol-indented-l0 ()
"Test correct indentation of an indented line with point at end of line - indentation level 0."
(plantuml-test-indent-line " participant A|"
"participant A|"))
(ert-deftest plantuml-test-line-indentation/empty-line-l1 ()
"Test correct indentation of empty line - indentation level 1."
(plantuml-test-indent-line
"opt A
|"
"opt A
|"))
(ert-deftest plantuml-test-line-indentation/bol-notindent-l1 ()
"Test correct indentation of a not indented line with point at beginning of line - indentation level 1."
(plantuml-test-indent-line "opt A
|foofoo"
"opt A
|foofoo"))
(ert-deftest plantuml-test-line-indentation/mol-notindent-l1 ()
"Test correct indentation of a not indented line with point at middle of line - indentation level 1."
(plantuml-test-indent-line "opt A
foo|foo"
"opt A
foo|foo"))
(ert-deftest plantuml-test-line-indentation/eol-notindent-l1 ()
"Test correct indentation of a not indented line with point at end of line - indentation level 1."
(plantuml-test-indent-line "opt A
foofoo|"
"opt A
foofoo|"))
(ert-deftest plantuml-test-line-indentation/bol-indented-l1 ()
"Test correct indentation of an indented line with point at beginning of line - indentation level 1."
(plantuml-test-indent-line " opt A
|foofoo"
" opt A
|foofoo"))
(ert-deftest plantuml-test-line-indentation/mol-indented-l1 ()
"Test correct indentation of an indented line with point at middle of line - indentation level 1."
(plantuml-test-indent-line " opt A
foo|foo"
" opt A
foo|foo"))
(ert-deftest plantuml-test-line-indentation/eol-indented-l1 ()
"Test correct indentation of an indented line with point at end of line - indentation level 1."
(plantuml-test-indent-line " opt A
foofoo|"
" opt A
foofoo|"))
(provide 'plantuml-indentation-basics-test)
;;; plantuml-indentation-basics-test.el ends here

View File

@ -0,0 +1,351 @@
;;; plantuml-indentation-class-test.el --- PlantUML Mode indentation tests -*- lexical-binding: t; -*-
;; Author: René Schmelzer
;; Maintainer: Carlo Sciolla (skuro)
;; URL: https://github.com/skuro/plantuml-mode
;;; Commentary:
;; Test indentation for class diagrams.
;;; Code:
(ert-deftest plantuml-test-indentation/class-diagram ()
"Test correct indentation of plantuml class diagram elements.
These code examples are taken from www.plantuml.com"
(plantuml-test-indent-block
"
class Dummy {
String data
void methods()
}
class Flight {
flightNumber : Integer
departureTime : Date
}
class Dummy1 {
{field} A field (despite parentheses)
{method} Some method
}
class Dummy2 {
-field1
#field2
~method1()
+method2()
}
class Dummy3 {
{static} String id
{abstract} void methods()
}
class Foo1 {
You can use
several lines
..
as you want
and group
==
things together.
__
You can have as many groups
as you want
--
End of class
}
class User {
.. Simple Getter ..
+ getName()
+ getAddress()
.. Some setter ..
+ setName()
__ private data __
int age
-- encrypted --
String password
}
class ArrayList {
Object[] elementData
size()
}
enum TimeUnit {
DAYS
HOURS
MINUTES
}
class Dummy4 <<Serializable>> {
String name
}
class Foo<? extends Element> {
int size()
}
abtract class AbstractC {
int size()
}
interface InterfaceC {
int size()
}
package \"Classic Collections\" #DDDDDD {
Object <|-- ArrayList
}
package net.sourceforge.plantuml {
Object <|-- Demo1
Demo1 *- Demo2
}
package foo1 <<Node>> {
class Class1
}
package foo2 <<Rectangle>> {
class Class2
}
package foo3 <<Folder>> {
class Class3
}
package foo4 <<Frame>> {
class Class4
}
package foo5 <<Cloud>> {
class Class5
}
package foo6 <<Database>> {
class Class6
}
package foo1.foo2 {
class ObjectFoo1Foo2
}
package foo1.foo2.foo3 {
class Objectfoo1.foo2.foo3
}
namespace net.dummy #DDDDDD {
.BaseClass <|-- Person
Meeting o-- Person
.BaseClass <|- Meeting
}
namespace net.foo {
net.dummy.Person <|- Person
.BaseClass <|-- Person
net.dummy.Meeting o-- Person
}
set namespaceSeparator ::
class X1::X2::foo {
some info
}
together {
class Together1
class Together2
class Together3
}
"
"
class Dummy {
String data
void methods()
}
class Flight {
flightNumber : Integer
departureTime : Date
}
class Dummy1 {
{field} A field (despite parentheses)
{method} Some method
}
class Dummy2 {
-field1
#field2
~method1()
+method2()
}
class Dummy3 {
{static} String id
{abstract} void methods()
}
class Foo1 {
You can use
several lines
..
as you want
and group
==
things together.
__
You can have as many groups
as you want
--
End of class
}
class User {
.. Simple Getter ..
+ getName()
+ getAddress()
.. Some setter ..
+ setName()
__ private data __
int age
-- encrypted --
String password
}
class ArrayList {
Object[] elementData
size()
}
enum TimeUnit {
DAYS
HOURS
MINUTES
}
class Dummy4 <<Serializable>> {
String name
}
class Foo<? extends Element> {
int size()
}
abtract class AbstractC {
int size()
}
interface InterfaceC {
int size()
}
package \"Classic Collections\" #DDDDDD {
Object <|-- ArrayList
}
package net.sourceforge.plantuml {
Object <|-- Demo1
Demo1 *- Demo2
}
package foo1 <<Node>> {
class Class1
}
package foo2 <<Rectangle>> {
class Class2
}
package foo3 <<Folder>> {
class Class3
}
package foo4 <<Frame>> {
class Class4
}
package foo5 <<Cloud>> {
class Class5
}
package foo6 <<Database>> {
class Class6
}
package foo1.foo2 {
class ObjectFoo1Foo2
}
package foo1.foo2.foo3 {
class Objectfoo1.foo2.foo3
}
namespace net.dummy #DDDDDD {
.BaseClass <|-- Person
Meeting o-- Person
.BaseClass <|- Meeting
}
namespace net.foo {
net.dummy.Person <|- Person
.BaseClass <|-- Person
net.dummy.Meeting o-- Person
}
set namespaceSeparator ::
class X1::X2::foo {
some info
}
together {
class Together1
class Together2
class Together3
}
"))
(ert-deftest plantuml-test-block-indentation/class/package-empty ()
"Test correct indentation of an empty package block."
(plantuml-test-indent-block
"
package APackage ()
interface Inter
"
"
package APackage ()
interface Inter
"))
(ert-deftest platuml-test-block-indentation/class/package-interface-nested ()
"Test correct indentation of two nested blocks, a package and an interface
Note: package is used in deployment and object diagrams as well, see there for more tests."
(plantuml-test-indent-block
"
package foo {
interface Bar {
baz
}
}
"
"
package foo {
interface Bar {
baz
}
}
"))
(provide 'plantuml-indentation-class-test)
;;; plantuml-indentation-class-test.el ends here

View File

@ -0,0 +1,340 @@
;;; plantuml-indentation-commons-test.el --- PlantUML Mode indentation tests -*- lexical-binding: t; -*-
;; Author: René Schmelzer
;; Maintainer: Carlo Sciolla (skuro)
;; URL: https://github.com/skuro/plantuml-mode
;;; Commentary:
;; Test indentation of structures and elements that are common
;; to many/all diagrams.
;;; Code:
(ert-deftest plantuml-test-indentation/commons/skinparam ()
"Test correct indentation of skinparam elements, which are common to many plantuml diagrams:"
(plantuml-test-indent-block
"
skinparam roundcorner 20
skinparam rectangle {
roundCorner<<Concept>> 25
}
"
"
skinparam roundcorner 20
skinparam rectangle {
roundCorner<<Concept>> 25
}
"))
(ert-deftest plantuml-test-indentation/commons/rectangle ()
"Test correct indentation of rectangle elements, which are common to many plantuml diagrams:"
(plantuml-test-indent-block
"
rectangle \"Concept Model\" <<Concept>> {
rectangle \"Example 1\" <<Concept>> as ex1
rectangle \"Another rectangle\"
}
"
"
rectangle \"Concept Model\" <<Concept>> {
rectangle \"Example 1\" <<Concept>> as ex1
rectangle \"Another rectangle\"
}
"))
(ert-deftest plantuml-test-indentation/commons/title ()
"Test correct indentation of title elements, which are common to many plantuml diagrams:"
(plantuml-test-indent-block
"
title
<font color=red>Warning:</font>
Do not use in production.
end title
"
"
title
<font color=red>Warning:</font>
Do not use in production.
end title
" ))
(ert-deftest plantuml-test-indentation/commons/header ()
"Test correct indentation of header elements, which are common to many plantuml diagrams:"
(plantuml-test-indent-block
"
header
this is a header
endheader
center header
this is a centered header
endheader
right header
this is a header on right
endheader
left header
this is a header on left
endheader
center left header
this is no correct header
endheader
header left
this is no correct a header
endheader
"
"
header
this is a header
endheader
center header
this is a centered header
endheader
right header
this is a header on right
endheader
left header
this is a header on left
endheader
center left header
this is no correct header
endheader
header left
this is no correct a header
endheader
" ))
(ert-deftest plantuml-test-indentation/commons/footer ()
"Test correct indentation of footer elements, which are common to many plantuml diagrams:"
(plantuml-test-indent-block
"
footer
this is a footer
endfooter
center footer
this is a centered footer
endfooter
right footer
this is a footer on right
endfooter
left footer
this is a footer on left
endfooter
center left footer
this is no correct footer
endfooter
footer left
this is no correct a footer
endfooter
"
"
footer
this is a footer
endfooter
center footer
this is a centered footer
endfooter
right footer
this is a footer on right
endfooter
left footer
this is a footer on left
endfooter
center left footer
this is no correct footer
endfooter
footer left
this is no correct a footer
endfooter
" ))
(ert-deftest plantuml-test-indentation/commons/legend ()
"Test correct indentation of legend elements, which are common to many plantuml diagrams:"
(plantuml-test-indent-block
"
legend
Short legend
endlegend
legend bottom
bottom legend
endlegend
legend top
top legend
endlegend
legend center
centered legend
endlegend
legend right
legend on right
endlegend
legend left
legend on left
endlegend
legend bottom left
legend on bottom left
endlegend
legend top left
legend on top left
endlegend
legend bottom right
legend on bottom right
endlegend
legend top right
legend on top right
endlegend
"
"
legend
Short legend
endlegend
legend bottom
bottom legend
endlegend
legend top
top legend
endlegend
legend center
centered legend
endlegend
legend right
legend on right
endlegend
legend left
legend on left
endlegend
legend bottom left
legend on bottom left
endlegend
legend top left
legend on top left
endlegend
legend bottom right
legend on bottom right
endlegend
legend top right
legend on top right
endlegend
" ))
(ert-deftest plantuml-test-indentation/commons/legend-noindent ()
"Test the not-indentation of false legend elements."
(plantuml-test-indent-block
"
legend bottom top
this is no correct legend
endlegend
legend right bottom
this is no correct legend
endlegend
legend left top
this is no correct legend
endlegend
legend center right
this is no correct legend
endlegend
legend center left
this is no correct legend
endlegend
legend right left
this is no correct legend
endlegend
"
"
legend bottom top
this is no correct legend
endlegend
legend right bottom
this is no correct legend
endlegend
legend left top
this is no correct legend
endlegend
legend center right
this is no correct legend
endlegend
legend center left
this is no correct legend
endlegend
legend right left
this is no correct legend
endlegend
"
))
(ert-deftest plantuml-test-indentation/commons/multiline-macro ()
"Test the indentation of multiline macro elements."
(plantuml-test-indent-block
"
!define DOUBLE(x) x x
!definelong AUTHEN(x,y)
x -> y : DOUBLE(hello)
y -> x : ok
!enddefinelong
AUTHEN(Bob,Alice)
"
"
!define DOUBLE(x) x x
!definelong AUTHEN(x,y)
x -> y : DOUBLE(hello)
y -> x : ok
!enddefinelong
AUTHEN(Bob,Alice)
"
))
;;; plantuml-indentation-commons-test.el ends here

View File

@ -0,0 +1,69 @@
;;; plantuml-indentation-component-test.el --- PlantUML Mode indentation tests -*- lexical-binding: t; -*-
;; Author: René Schmelzer
;; Maintainer: Carlo Sciolla (skuro)
;; URL: https://github.com/skuro/plantuml-mode
;;; Commentary:
;; Test indentation for component diagrams.
;;; Code:
(ert-deftest plantuml-test-indentation/component-diagram ()
"Test correct indentation of plantuml component diagram elements.
These code examples are taken from www.plantuml.com"
(plantuml-test-indent-block
"
package \"Some Group\" {
HTTP - [First Component]
[Another Component]
}
node \"Other Groups\" {
FTP - [Second Component]
[First Component] --> FTP
}
cloud {
[Example 1]
}
database \"MySql\" {
folder \"This is my folder\" {
[Folder 3]
}
frame \"Foo\" {
[Frame 4]
}
}
"
"
package \"Some Group\" {
HTTP - [First Component]
[Another Component]
}
node \"Other Groups\" {
FTP - [Second Component]
[First Component] --> FTP
}
cloud {
[Example 1]
}
database \"MySql\" {
folder \"This is my folder\" {
[Folder 3]
}
frame \"Foo\" {
[Frame 4]
}
}
"))
(provide 'plantuml-indentation-component-test)
;;; plantuml-indentation-component-test.el ends here

View File

@ -0,0 +1,111 @@
;;; plantuml-indentation-deployment-test.el --- PlantUML Mode indentation tests -*- lexical-binding: t; -*-
;; Author: René Schmelzer
;; Maintainer: Carlo Sciolla (skuro)
;; URL: https://github.com/skuro/plantuml-mode
;;; Commentary:
;; Test indentation for deployment diagrams.
;; Most plantuml code examples are taken from www.plantuml.com
;;; Code:
(ert-deftest plantuml-test-indentation/deployment-diagram ()
"Test correct indentation of plantuml deployment diagram elements."
(plantuml-test-indent-block
"
artifact Foo1 {
folder Foo2
}
folder Foo3 {
artifact Foo4
}
frame Foo5 {
database Foo6
}
cloud vpc {
node ec2 {
stack stack
}
}
node Foo1 {
cloud Foo2
}
cloud Foo3 {
frame Foo4
}
database Foo5 {
storage Foo6
}
storage Foo7 {
storage Foo8
}
"
"
artifact Foo1 {
folder Foo2
}
folder Foo3 {
artifact Foo4
}
frame Foo5 {
database Foo6
}
cloud vpc {
node ec2 {
stack stack
}
}
node Foo1 {
cloud Foo2
}
cloud Foo3 {
frame Foo4
}
database Foo5 {
storage Foo6
}
storage Foo7 {
storage Foo8
}
"))
(ert-deftest plantuml-test-block-indentation/package-database-nested ()
"Test correct indentation of two nested blocks, a package and a database.
Note: package is used in class and object diagrams as well, see there for more tests."
(plantuml-test-indent-block
"
package APackage {
database ADatabase {
A -> B
}
}
"
"
package APackage {
database ADatabase {
A -> B
}
}
"))
(provide 'plantuml-indentation-deployment-test)
;;; plantuml-indentation-deployment-test.el ends here

View File

@ -0,0 +1,58 @@
;;; plantuml-indentation-ie-test.el --- PlantUML Mode indentation tests -*- lexical-binding: t; -*-
;; Author: Carlo Sciolla (skuro)
;; Maintainer: Carlo Sciolla (skuro)
;; URL: https://github.com/skuro/plantuml-mode
;;; Commentary:
;; Test indentation of Information Engineering (IE) notation.
;; See https://github.com/plantuml/plantuml/pull/31
;;; Code:
(ert-deftest plantuml-test-block-indentation/ie-entity ()
"Test correct indentation of an entity block."
(plantuml-test-indent-block
"
entity Entity {
* identifying_attribute
--
* mandatory_attribute
optional_attribute
}
"
"
entity Entity {
* identifying_attribute
--
* mandatory_attribute
optional_attribute
}
"
))
(ert-deftest plantuml-test-indendation/ie-arrows ()
"Test correct indentation of IE-style arrows."
(plantuml-test-indent-block
"
foo1 --{ bar1
foo1 --{ bar2
foo1 --{ bar3
aa --o{ bb
aa --o{ cc
aa --o{ dd
"
"
foo1 --{ bar1
foo1 --{ bar2
foo1 --{ bar3
aa --o{ bb
aa --o{ cc
aa --o{ dd
"))
;;; plantuml-indentation-ie-test.el ends here

View File

@ -0,0 +1,403 @@
;;; plantuml-indentation-notes-test.el --- PlantUML Mode indentation tests -*- lexical-binding: t; -*-
;; Author: René Schmelzer
;; Maintainer: Carlo Sciolla (skuro)
;; URL: https://github.com/skuro/plantuml-mode
;;; Commentary:
;; Test indentation of note elements.
;; Notes are used in almost all diagrams, but not all types of notes
;; are supported in every diagram type.
;;; Code:
(ert-deftest plantuml-test-block-indentation/note-simple ()
"Test correct indentation of a simple note block."
(plantuml-test-indent-block
"
note right: single line note
note right
multi line note
end note
"
"
note right: single line note
note right
multi line note
end note
"
))
(ert-deftest plantuml-test-block-indentation/note-left-right ()
"Test correct indentation of a note left/right block."
(plantuml-test-indent-block
"
(*) --> \"Some Activity\"
note right: This activity has to be defined
\"Some Activity\" --> (*)
note right
This note is on
several lines
end note
(*) --> \"Some Activity\"
note left: This activity has to be defined
\"Some Activity\" --> (*)
note left
This note is on
several lines
end note
"
"
(*) --> \"Some Activity\"
note right: This activity has to be defined
\"Some Activity\" --> (*)
note right
This note is on
several lines
end note
(*) --> \"Some Activity\"
note left: This activity has to be defined
\"Some Activity\" --> (*)
note left
This note is on
several lines
end note
" ))
(ert-deftest plantuml-test-block-indentation/note-xxx-of ()
"Test correct indentation of a note xxx of block.
plantuml.com:
You can use the note left of, note right of, note top of,
note bottom of keywords to define notes related to a single
object."
(plantuml-test-indent-block
"
note right of Alice: This is displayed right of Alice.
note left of Alice #aqua
This is displayed
left of Alice.
end note
note left of Alice: This is displayed left of Alice.
note right of Alice #aqua
This is displayed
right of Alice.
end note
note right of (Use)
A note can also
be on several lines
end note
note left of HTTP : Web Service only
note right of [First Component]
A note can also
be on several lines
end note
"
"
note right of Alice: This is displayed right of Alice.
note left of Alice #aqua
This is displayed
left of Alice.
end note
note left of Alice: This is displayed left of Alice.
note right of Alice #aqua
This is displayed
right of Alice.
end note
note right of (Use)
A note can also
be on several lines
end note
note left of HTTP : Web Service only
note right of [First Component]
A note can also
be on several lines
end note
"
))
(ert-deftest plantuml-test-block-indentation/note-on-link ()
"Test correct indentation of a note xxx of block.
plantuml.com:
You can also use note left on link, note right on link,
note top on link, note bottom on link if you want to change
the relative position of the note with the label."
(plantuml-test-indent-block
"
class Dummy
Dummy --> Foo : A link
note on link #red: note that is red
Dummy --> Foo2 : Another link
note right on link #blue
this is my note on right link
and in blue
end note
note left on link #00FFFF
this is my note on left link
and in color as number
end note
"
"
class Dummy
Dummy --> Foo : A link
note on link #red: note that is red
Dummy --> Foo2 : Another link
note right on link #blue
this is my note on right link
and in blue
end note
note left on link #00FFFF
this is my note on left link
and in color as number
end note
"
))
(ert-deftest plantuml-test-block-indentation/note-over ()
"Test correct indentation of a note-over block."
(plantuml-test-indent-block
"
note over Alice: This is displayed over Alice.
note over Alice, Bob #FFAAAA: This is displayed over Bob and Alice.
note over Bob, Alice
This is yet another
example of
a long note.
end note
"
"
note over Alice: This is displayed over Alice.
note over Alice, Bob #FFAAAA: This is displayed over Bob and Alice.
note over Bob, Alice
This is yet another
example of
a long note.
end note
"
))
;; Here we have an inconsistency (again) in plantuml syntax
;; single line note as …’ does not contain a ?:
;;
;; (ert-deftest plantuml-test-block-indentation/note-as ()
;; "Test correct indentation of a note-as block."
;; (plantuml-test-indent-block
;; "
;; :Main Admin: as Admin
;; (Use the application) as (Use)
;; User -> (Start)
;; User --> (Use)
;; Admin ---> (Use)
;; note right of Admin : This is an example.
;; note right of (Use)
;; A note can also
;; be on several lines
;; end note
;; note \"This note is connected to several objects.\" as N2 #RED
;; (Start) .. N2
;; N2 .. (Use)
;; note as N3 #blue
;; This note is connected
;; to several objects as well.
;; end note
;; (Start) .. N3
;; N3 .. Admin
;; "
;; "
;; :Main Admin: as Admin
;; (Use the application) as (Use)
;; User -> (Start)
;; User --> (Use)
;; Admin ---> (Use)
;; note right of Admin : This is an example.
;; note right of (Use)
;; A note can also
;; be on several lines
;; end note
;; note \"This note is connected to several objects.\" as N2 #RED
;; (Start) .. N2
;; N2 .. (Use)
;; note as N3 #blue
;; This note is connected
;; to several objects as well.
;; end note
;; (Start) .. N3
;; N3 .. Admin
;; "
;; ))
(ert-deftest plantuml-test-block-indentation/note-floating ()
"Test correct indentation of a floating note block."
(plantuml-test-indent-block
"
floating note left: This is a note
:foo2;
floating note right
This note is on several
//lines// and can
contain <b>HTML</b>
====
* Calling the method \"\"foo()\"\" is prohibited
end note
"
"
floating note left: This is a note
:foo2;
floating note right
This note is on several
//lines// and can
contain <b>HTML</b>
====
* Calling the method \"\"foo()\"\" is prohibited
end note
"
))
(ert-deftest plantuml-test-block-indentation/note-h-r-note ()
"Test correct indentation of a [hr]note block."
(plantuml-test-indent-block
"
caller -> server : conReq
rnote over caller : idle
hnote over caller : idle
caller <- server : conConf
rnote over server
r as rectangle
h as hexagon
endrnote
hnote over server
r as rectangle
h as hexagon
endrnote
"
"
caller -> server : conReq
rnote over caller : idle
hnote over caller : idle
caller <- server : conConf
rnote over server
r as rectangle
h as hexagon
endrnote
hnote over server
r as rectangle
h as hexagon
endrnote
"
))
(ert-deftest plantuml-test-block-indentation/note-creole-html ()
"Test correct indentation of a note block with creole/html."
(plantuml-test-indent-block
"
participant Alice
participant \"The **Famous** Bob\" as Bob
Alice -> Bob : hello --there--
... Some ~~long delay~~ ...
Bob -> Alice : ok
note left
This is **bold**
This is //italics//
This is \"\"monospaced\"\"
This is --stroked--
This is __underlined__
This is ~~waved~~
end note
Alice -> Bob : A //well formatted// message
note right of Alice
This is <back:cadetblue><size:18>displayed</size></back>
__left of__ Alice.
end note
note left of Bob
<u:red>This</u> is <color #118888>displayed</color>
**<color purple>left of</color> <s:red>Alice</strike> Bob**.
end note
note over Alice, Bob
<w:#FF33FF>This is hosted</w> by <img sourceforge.jpg>
end note
"
"
participant Alice
participant \"The **Famous** Bob\" as Bob
Alice -> Bob : hello --there--
... Some ~~long delay~~ ...
Bob -> Alice : ok
note left
This is **bold**
This is //italics//
This is \"\"monospaced\"\"
This is --stroked--
This is __underlined__
This is ~~waved~~
end note
Alice -> Bob : A //well formatted// message
note right of Alice
This is <back:cadetblue><size:18>displayed</size></back>
__left of__ Alice.
end note
note left of Bob
<u:red>This</u> is <color #118888>displayed</color>
**<color purple>left of</color> <s:red>Alice</strike> Bob**.
end note
note over Alice, Bob
<w:#FF33FF>This is hosted</w> by <img sourceforge.jpg>
end note
"
))
;;; plantuml-indentation-notes-test.el ends here

View File

@ -0,0 +1,34 @@
;;; plantuml-indentation-object-test.el --- PlantUML Mode indentation tests -*- lexical-binding: t; -*-
;; Author: René Schmelzer
;; Maintainer: Carlo Sciolla (skuro)
;; URL: https://github.com/skuro/plantuml-mode
;;; Commentary:
;; Test indentation for object diagrams.
;;; Code:
(ert-deftest plantuml-test-indentation/object-diagram ()
"Test correct indentation of plantuml object diagram elements.
These code examples are taken from www.plantuml.com
Note: object diagrams use many elements defined for class diagrams."
(plantuml-test-indent-block
"
object user {
name = \"Dummy\"
id = 123
}
"
"
object user {
name = \"Dummy\"
id = 123
}
"))
(provide 'plantuml-indentation-object-test)
;;; plantuml-indentation-object-test.el ends here

View File

@ -0,0 +1,362 @@
;;; plantuml-indentation-sequence-test.el --- PlantUML Mode indentation tests -*- lexical-binding: t; -*-
;; Author: René Schmelzer
;; Maintainer: Carlo Sciolla (skuro)
;; URL: https://github.com/skuro/plantuml-mode
;;; Commentary:
;; Test indentation for sequence diagrams.
;;; Code:
(ert-deftest platuml-test-block-indentation/sequence/box ()
"Test correct indentation of a box block"
(plantuml-test-indent-block
"
box \"Device with USB connector\"
actor Human
participant UsbDetector
end box
"
"
box \"Device with USB connector\"
actor Human
participant UsbDetector
end box
" ))
(ert-deftest platuml-test-block-indentation/sequence/ref ()
"Test correct indentation of a ref block"
(plantuml-test-indent-block
"
participant Alice
actor Bob
participant \"Great Cesar\"
ref over Alice, Bob : init
Alice -> Bob : hello
ref over Bob, \"Great Cesar\"
This can be on
several lines
end ref
ref over Bob
This is a ref over Bob
end ref
ref over \"Great Cesar\"
This is a ref over \"Great Cesar\"
end ref
"
"
participant Alice
actor Bob
participant \"Great Cesar\"
ref over Alice, Bob : init
Alice -> Bob : hello
ref over Bob, \"Great Cesar\"
This can be on
several lines
end ref
ref over Bob
This is a ref over Bob
end ref
ref over \"Great Cesar\"
This is a ref over \"Great Cesar\"
end ref
" ))
(ert-deftest plantuml-test-block-indentation/sequence/alt-end ()
"Test correct indentation of an alt-end block.
The alt-keyword is NOT followed by some text."
(plantuml-test-indent-block
"
alt
A -> B
end
"
"
alt
A -> B
end
" ))
(ert-deftest plantuml-test-block-indentation/sequence/alt-end-with-label ()
"Test correct indentation of an alt-end block.
The alt-keyword is followed by some text."
(plantuml-test-indent-block
"
alt choice 1
A -> B
end
"
"
alt choice 1
A -> B
end
" ))
(ert-deftest plantuml-test-block-indentation/sequence/alt-else-end ()
"Test correct indentation of an alt-else-end block."
(plantuml-test-indent-block
"
alt choice 1
A -> B
else
B -> C
end
"
"
alt choice 1
A -> B
else
B -> C
end
" ))
(ert-deftest plantuml-test-block-indentation/sequence/opt ()
"Test correct indentation of an opt block.
The opt-keyword is NOT followed by some text."
(plantuml-test-indent-block
"
opt
A -> B
end
"
"
opt
A -> B
end
" ))
(ert-deftest plantuml-test-block-indentation/sequence/opt-with-label ()
"Test correct indentation of an opt block.
The opt-keyword is followed by some text."
(plantuml-test-indent-block
"
opt event triggered
A -> B
end
"
"
opt event triggered
A -> B
end
" ))
(ert-deftest plantuml-test-block-indentation/sequence/par ()
"Test correct indentation of a par block.
The par-keyword is NOT followed by some text."
(plantuml-test-indent-block
"
par
A -> B
else
C -> B
end
"
"
par
A -> B
else
C -> B
end
" ))
(ert-deftest plantuml-test-block-indentation/sequence/par-with-label ()
"Test correct indentation of a par block.
The par-keyword is followed by some text."
(plantuml-test-indent-block
"
par a text label
A -> B
else
C -> B
end
"
"
par a text label
A -> B
else
C -> B
end
" ))
(ert-deftest plantuml-test-block-indentation/sequence/group ()
"Test correct indentation of a group block.
The group-keyword is NOT followed by some text."
(plantuml-test-indent-block
"
group
A -> B
else
C -> B
end
"
"
group
A -> B
else
C -> B
end
" ))
(ert-deftest plantuml-test-block-indentation/sequence/group-with-label ()
"Test correct indentation of a group block.
The group-keyword is followed by some text."
(plantuml-test-indent-block
"
group my own label
A -> B
else
C -> B
end
"
"
group my own label
A -> B
else
C -> B
end
" ))
(ert-deftest plantuml-test-block-indentation/sequence/critical ()
"Test correct indentation of a critical block.
The critical-keyword is NOT followed by some text."
(plantuml-test-indent-block
"
critical
A -> B
else
C -> B
end
"
"
critical
A -> B
else
C -> B
end
" ))
(ert-deftest plantuml-test-block-indentation/sequence/critical-with-label ()
"Test correct indentation of a critical block.
The critical-keyword is followed by some text."
(plantuml-test-indent-block
"
critical my own label
A -> B
else
C -> B
end
"
"
critical my own label
A -> B
else
C -> B
end
" ))
(ert-deftest plantuml-test-block-indentation/sequence/activate-deactivate ()
"Test correct indentation of an activate-deactivate block."
(plantuml-test-indent-block
"
activate participant_1
participant_1 -> participant_2 : f()
deactivate participant_1
"
"
activate participant_1
participant_1 -> participant_2 : f()
deactivate participant_1
"))
(ert-deftest plantuml-test-block-indentation/sequence/activate-deactivate-nested ()
"Test correct indentation of two nested activate-deactivate blocks."
(plantuml-test-indent-block
"
activate participant_1
activate participant_2
participant_1 -> participant_2 : f()
deactivate participant_2
deactivate participant_1
"
"
activate participant_1
activate participant_2
participant_1 -> participant_2 : f()
deactivate participant_2
deactivate participant_1
"))
(ert-deftest plantuml-test-indentation/sequence-diagram ()
"Test correct indentation of plantuml sequence diagram elements.
These code examples are taken from www.plantuml.com."
(plantuml-test-indent-block
"
Alice -> Bob: Authentication Request
alt successful case
Bob -> Alice: Authentication Accepted
else some kind of failure
Bob -> Alice: Authentication Failure
group My own label
Alice -> Log : Log attack start
loop 1000 times
Alice -> Bob: DNS Attack
end
Alice -> Log : Log attack end
end
else Another type of failure
Bob -> Alice: Please repeat
end
"
"
Alice -> Bob: Authentication Request
alt successful case
Bob -> Alice: Authentication Accepted
else some kind of failure
Bob -> Alice: Authentication Failure
group My own label
Alice -> Log : Log attack start
loop 1000 times
Alice -> Bob: DNS Attack
end
Alice -> Log : Log attack end
end
else Another type of failure
Bob -> Alice: Please repeat
end
"))
(provide 'plantuml-indentation-sequence-test)
;;; plantuml-indentation-sequence-test.el ends here

View File

@ -0,0 +1,119 @@
;;; plantuml-indentation-state-test.el --- PlantUML Mode indentation tests -*- lexical-binding: t; -*-
;; Author: René Schmelzer
;; Maintainer: Carlo Sciolla (skuro)
;; URL: https://github.com/skuro/plantuml-mode
;;; Commentary:
;; Test indentation for state diagrams.
;;; Code:
(ert-deftest plantuml-test-indentation/state-diagram ()
"Test correct indentation of plantuml state diagram elements.
These code examples are taken from www.plantuml.com"
(plantuml-test-indent-block
"
state NotShooting {
[*] --> Idle
Idle --> Configuring : EvConfig
Configuring --> Idle : EvConfig
}
state Configuring {
[*] --> NewValueSelection
NewValueSelection --> NewValuePreview : EvNewValue
NewValuePreview --> NewValueSelection : EvNewValueRejected
NewValuePreview --> NewValueSelection : EvNewValueSaved
state NewValuePreview {
State1 -> State2
}
}
state State3 {
state \"Accumulate Enough Data\\nLong State Name\" as long1
long1 : Just a test
[*] --> long1
long1 --> long1 : New Data
long1 --> ProcessData : Enough Data
}
state Active {
[*] -> NumLockOff
NumLockOff --> NumLockOn : EvNumLockPressed
NumLockOn --> NumLockOff : EvNumLockPressed
--
[*] -> CapsLockOff
CapsLockOff --> CapsLockOn : EvCapsLockPressed
CapsLockOn --> CapsLockOff : EvCapsLockPressed
--
[*] -> ScrollLockOff
ScrollLockOff --> ScrollLockOn : EvCapsLockPressed
ScrollLockOn --> ScrollLockOff : EvCapsLockPressed
}
state \"Not Shooting State\" as NotShooting {
state \"Idle mode\" as Idle
state \"Configuring mode\" as Configuring
[*] --> Idle
Idle --> Configuring : EvConfig
Configuring --> Idle : EvConfig
}
"
"
state NotShooting {
[*] --> Idle
Idle --> Configuring : EvConfig
Configuring --> Idle : EvConfig
}
state Configuring {
[*] --> NewValueSelection
NewValueSelection --> NewValuePreview : EvNewValue
NewValuePreview --> NewValueSelection : EvNewValueRejected
NewValuePreview --> NewValueSelection : EvNewValueSaved
state NewValuePreview {
State1 -> State2
}
}
state State3 {
state \"Accumulate Enough Data\\nLong State Name\" as long1
long1 : Just a test
[*] --> long1
long1 --> long1 : New Data
long1 --> ProcessData : Enough Data
}
state Active {
[*] -> NumLockOff
NumLockOff --> NumLockOn : EvNumLockPressed
NumLockOn --> NumLockOff : EvNumLockPressed
--
[*] -> CapsLockOff
CapsLockOff --> CapsLockOn : EvCapsLockPressed
CapsLockOn --> CapsLockOff : EvCapsLockPressed
--
[*] -> ScrollLockOff
ScrollLockOff --> ScrollLockOn : EvCapsLockPressed
ScrollLockOn --> ScrollLockOff : EvCapsLockPressed
}
state \"Not Shooting State\" as NotShooting {
state \"Idle mode\" as Idle
state \"Configuring mode\" as Configuring
[*] --> Idle
Idle --> Configuring : EvConfig
Configuring --> Idle : EvConfig
}
"))
(provide 'plantuml-indentation-state-test)
;;; plantuml-indentation-state-test.el ends here

View File

@ -0,0 +1,24 @@
;;; plantuml-mode-custom-jar-location-test.el --- PlantUML Mode JAR location tests -*- lexical-binding: t; -*-
;; Author: Carlo Sciolla (skuro)
;; Maintainer: Carlo Sciolla (skuro)
;; URL: https://github.com/skuro/plantuml-mode
;;; Commentary:
;;; Code:
(ert-deftest custom-jar-location ()
(setq-local plantuml-jar-path "~/.plantuml/plantuml.jar")
(should (equal `("-Djava.awt.headless=true" "-jar" "--illegal-access=deny"
,(expand-file-name "~/.plantuml/plantuml.jar")
"-charset" "UTF-8")
(plantuml-jar-render-command)))
(setq-local plantuml-jar-path "/path/with spaces/plantuml.jar")
(should (equal `("-Djava.awt.headless=true" "-jar" "--illegal-access=deny" "/path/with spaces/plantuml.jar" "-charset" "UTF-8")
(plantuml-jar-render-command))))
(provide 'plantuml-mode-custom-jar-location-test)
;;; plantuml-mode-custom-jar-location-test.el ends here

View File

@ -0,0 +1,35 @@
;;; plantuml-mode-test.el --- PlantUML Mode tests -*- lexical-binding: t; -*-
;; Author: Carlo Sciolla (skuro)
;; Maintainer: Carlo Sciolla (skuro)
;; URL: https://github.com/skuro/plantuml-mode
;;; Commentary:
;;; Code:
(ert-deftest initial-jar-location ()
(should (equal (expand-file-name "~/plantuml.jar")
plantuml-jar-path)))
(ert-deftest can-unload-plantuml ()
(unload-feature 'plantuml-mode t)
(should (eq nil (boundp 'plantuml-jar-path)))
(load-plantuml-mode)
(should (not (eq nil (boundp 'plantuml-jar-path)))))
(ert-deftest debug-install-issues ()
(unload-feature 'plantuml-mode t)
(condition-case nil
(require 'package)
(add-to-list 'package-archives
'("melpa" . "https://melpa.milkbox.net/packages/"))
(package-install "plantuml-mode")
(unload-feature 'plantuml-mode t))
(load-plantuml-mode))
(provide 'plantuml-mode-test)
;;; plantuml-mode-test.el ends here

View File

@ -0,0 +1,34 @@
;;; plantuml-mode-preview-test.el --- PlantUML Mode preview tests -*- lexical-binding: t; -*-
;; Author: Carlo Sciolla (skuro)
;; Maintainer: Carlo Sciolla (skuro)
;; URL: https://github.com/skuro/plantuml-mode
;;; Commentary:
;;; Code:
(defun assert-preview (puml output &optional format mode)
(if format
(setq plantuml-output-type format)
(setq plantuml-output-type "txt"))
(if mode
(setq plantuml-exec-mode mode)
(setq plantuml-exec-mode 'jar))
(plantuml-preview-string 42 (read-test-file puml))
(sleep-for 3)
(should (equal (format-preview-output (replace-regexp-in-string " " "~" (read-test-file output)))
(format-preview-output (replace-regexp-in-string " " "~" (read-preview-buffer))))))
(ert-deftest preview-txt-test ()
(setq-local plantuml-jar-path plantuml-test-jar-path)
(assert-preview "a-b.puml" "a-b.txt"))
;; for unknown reason, unicode preview brakes on ert-runner but works locally :-/
;;(ert-deftest preview-unicode-test ()
;; (setq-local plantuml-jar-path plantuml-test-jar-path)
;; (assert-preview "unicode.puml" "unicode.txt"))
(provide 'plantuml-mode-preview-test)
;;; plantuml-mode-preview-test.el ends here

BIN
test/resources/a-b.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

5
test/resources/a-b.puml Normal file
View File

@ -0,0 +1,5 @@
@startuml
A -> B
@enduml

8
test/resources/a-b.txt Normal file
View File

@ -0,0 +1,8 @@
┌─┐ ┌─┐
│A│ │B│
└┬┘ └┬┘
│ │
│───────────>│
┌┴┐ ┌┴┐
│A│ │B│
└─┘ └─┘

27
test/resources/init.el Normal file
View File

@ -0,0 +1,27 @@
;; Used to test `plantuml-mode' installations
(setq user-emacs-directory "./.emacs.d")
(require 'subr-x)
(setq local-repository
(concat
(string-trim (shell-command-to-string "cask package-directory"))
"/../testing"))
(custom-set-variables `(package-archive-upload-base ,local-repository))
(require 'package-x)
(defun -package-upload (file)
(with-temp-buffer
(insert-file-contents file)
(let ((pkg-desc (package-buffer-info)))
(package-upload-buffer-internal pkg-desc "el"))))
(-package-upload "plantuml-mode.el")
(setq package-archives `(("local" . ,local-repository)))
(package-initialize)
(package-install 'plantuml-mode)
(require 'plantuml-mode)
(message
(concat "Successfully installed plantuml-mode v" plantuml-mode-version))

View File

@ -0,0 +1,5 @@
@startuml
lang -> 日本語
@enduml

View File

@ -0,0 +1,8 @@
┌────┐ ┌───┐
│lang│ │日本語│
└─┬──┘ └─┬─┘
│ │
│ ─────────────>│
┌─┴──┐ ┌─┴─┐
│lang│ │日本語│
└────┘ └───┘

View File

@ -0,0 +1,145 @@
/' This is a manual test for you to test different use-cases '/
participant API
participant Instance
alt deploy success
Instance -> API: Deploy successful
else deploy failure
Instance -> API: Deploy failed
else deploy timeout
Instance -> API: Deploy failed
end
package "kuaishow-common-proto" {
component Kwai
component KwaiGo
component AcFun
}
package "kwaigo-log-proto" {
[KwaiGo] ..> [KwaiGo Client->Data] : split
}
package "kwaigo-api-proto" {
[KwaiGo] ..> [KwaiGo Client->Server] : split
}
cloud "log server\n" {
[KwaiGo Client->Data] -->[KwaiGo Log Server] : upload
}
cloud "api server\n" {
[KwaiGo Api Server]
}
[KwaiGo Client->Server] --> [KwaiGo Api Server] : request
[KwaiGo Api Server] --> [KwaiGo Client->Server] : response
database "LogSql" {
folder "Log" {
[ReportEvent]
}
frame "event" {
[EventPackage]
}
frame "stat" {
[StatPackage]
}
}
[KwaiGo Log Server] --> [ReportEvent] : save
[ReportEvent] --> [EventPackage]
[ReportEvent] --> [StatPackage]
database "ApiSql" {
folder "kwaigo" {
[KwaiGoData]
}
frame "user" {
[UserData]
}
frame "photo" {
[PhotoData]
}
}
[KwaiGo Api Server] --> [KwaiGoData] : request
[KwaiGoData] --> [KwaiGo Api Server] : compute
[KwaiGoData] --> [UserData]
[KwaiGoData] --> [PhotoData]
Nobody -> [APIGateway]
package APackage {
A -> B
B -> A
}
package "APP Stack" {
[APIGateway] --> [Lambda]
}
package haha {}
package "Streams Stack" {
database Kinesis
[Lambda] --> Kinesis
}
package foo {
package bar {
foo --> bar
}
package bar {
foo --> bar
}
}
package "Roles And Policies" {
[Lambda] --> [IAM Roles]
[APIGateway] --> [IAM Roles]
}
package "SharedResources" {
[Lambda] ----> [LambdaCodeBucket]
note as N1
This belongs to a separate set
of resources we should clean up
separately.
end note
}
note right of Lambda
This thing is end of life
end note
note left of Nobody
There is no traffic coming
into the service.
end note
@startuml
participant API
participant Instance
alt deploy success
Instance -> API: Deploy successful
else deploy failure
Instance -> API: Deploy failed
else deploy timeout
Instance -> API: Deploy failed
end
@enduml

75
test/test-helper.el Normal file
View File

@ -0,0 +1,75 @@
;;; test-helper.el --- PlantUML Mode test initialization -*- lexical-binding: t; -*-
;; Author: Carlo Sciolla (skuro)
;; Maintainer: Carlo Sciolla (skuro)
;; URL: https://github.com/skuro/plantuml-mode
;;; Commentary:
;;; Code:
(require 'f)
(defvar package-test-path
(f-dirname (f-this-file)))
(defvar package-code-path
(f-parent package-test-path))
(defvar plantuml-test-resources-path
(f-join package-code-path "test/resources"))
(defvar plantuml-test-jar-path
(f-join package-code-path "bin/plantuml.jar"))
(defun read-buffer (bufname)
(with-current-buffer (get-buffer bufname)
(buffer-string)))
(defun read-preview-buffer ()
(read-buffer plantuml-preview-buffer))
(defun read-test-file (path)
(f-read (f-join plantuml-test-resources-path path) 'utf-8))
(defun load-plantuml-mode ()
(require 'plantuml-mode (f-expand "plantuml-mode.el" package-code-path)))
(defun format-preview-output (s)
"Make the preview output as S more readable in test output."
(concat "\n" s))
(defun plantuml-test-indent-block (before after)
"The common code for the block indentation tests.
BEFORE is the text block to be inserted into a temporary buffer.
AFTER is the expected text block after indentation.
The temporary buffer will be put into `plantuml-mode'. The whole buffer
will be indented with two spaces for each level of indentation.
Finally, the indented text in the buffer will be compared with AFTER."
(with-temp-buffer
;; fix the JAR location prior to mode initialization
;; for some reason, plantuml-mode disregards the setq-local
(setq plantuml-jar-path plantuml-test-jar-path)
(plantuml-init-once 'jar)
(insert before)
(goto-char (point-min))
(plantuml-mode)
;; use 2 spaces instead of one tab for indentation
(setq indent-tabs-mode nil)
(setq tab-width 2)
(indent-region (point-min) (point-max))
(should (equal (buffer-string) after))))
;; enable code coverage
(when (require 'undercover nil t)
(undercover "plantuml-mode.el"))
(load-plantuml-mode)
;;; test-helper.el ends here