plantuml-mode/README.md

174 lines
7.8 KiB
Markdown
Raw Permalink Normal View History

2018-08-16 13:35:27 +02:00
[![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)
2016-12-25 18:08:58 +01:00
2016-05-07 07:50:43 +02:00
# PlantUML mode for Emacs
2012-06-11 13:31:49 +02:00
2016-10-10 20:35:06 +02:00
<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!" />
2015-09-21 17:45:42 +02:00
2015-09-21 17:55:06 +02:00
> “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.”
>
2015-09-21 17:55:06 +02:00
> from [The Bitter Kingdom - Fire and Thorns #3](https://www.goodreads.com/book/show/11431896-the-bitter-kingdom)
2012-06-11 13:31:49 +02:00
2015-09-21 17:55:06 +02:00
2015-12-07 16:56:20 +01:00
A [PlantUML](http://plantuml.sourceforge.net/) major mode for Emacs.
2012-06-11 13:31:49 +02:00
2016-05-07 07:50:43 +02:00
# Installation
2015-07-13 23:09:47 +02:00
Make sure you have [MELPA](http://melpa.org/) enabled in your ``emacs.d``. Then, you can just
M-x package-install<RET>
2016-10-10 20:35:06 +02:00
plantuml-mode<RET>
2015-07-13 23:09:47 +02:00
2016-10-10 20:35:06 +02:00
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>
plantuml-jar-path<RET>
2015-07-13 23:09:47 +02:00
You can also download the latest version of PlantUML straight into `plantuml-jar-path`:
M-x plantuml-download-jar<RET>
2016-05-07 07:50:43 +02:00
# Features
2015-09-21 17:28:46 +02:00
- Syntax highlight
- Autocompletion
2016-10-10 20:35:06 +02:00
- Preview of buffer or region
- [EXPERIMENTAL] Use either local JAR or remote server for preview
2015-09-21 17:28:46 +02:00
2016-05-07 07:50:43 +02:00
# Enable the major mode
2015-09-21 17:28:46 +02:00
2016-10-28 06:13:24 +02:00
You can automatically enable `plantuml-mode` for files with extension `.plantuml` by adding the following to your `.emacsrc`:
2015-09-21 17:28:46 +02:00
2016-10-10 20:35:06 +02:00
;; Enable plantuml-mode for PlantUML files
(add-to-list 'auto-mode-alist '("\\.plantuml\\'" . plantuml-mode))
2015-09-21 17:28:46 +02:00
2016-10-10 20:35:06 +02:00
Of course, you can always enable manually the major mode by typing `M-x plantuml-mode` once in the desired PlantUML file buffer.
2015-09-21 17:28:46 +02:00
2016-05-07 07:50:43 +02:00
# Usage
2015-07-13 23:09:47 +02:00
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.
2015-09-21 17:28:46 +02:00
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:
2015-09-21 17:28:46 +02:00
- SVG
- PNG
2015-09-21 17:28:46 +02:00
- Unicode ASCII art
2016-10-10 20:35:06 +02:00
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.
2016-05-07 07:50:43 +02:00
## Default key bindings
2015-09-21 17:28:46 +02:00
The following shortcuts are enabled by default:
2016-10-10 20:35:06 +02:00
C-c C-c plantuml-preview: renders a PlantUML diagram from the current buffer in the best supported format
2016-03-24 22:34:50 +01:00
2016-10-10 20:35:06 +02:00
C-u C-c C-c plantuml-preview in other window
2016-03-24 22:34:50 +01:00
2016-10-10 20:35:06 +02:00
C-u C-u C-c C-c plantuml-preview in other frame
2015-07-13 23:09:47 +02:00
2016-05-07 07:50:43 +02:00
## Integration with `org-mode`
2016-10-10 20:35:06 +02:00
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:
2016-05-07 07:50:43 +02:00
```
(add-to-list
2016-10-10 20:35:06 +02:00
'org-src-lang-modes '("plantuml" . plantuml))
2016-05-07 07:50:43 +02:00
```
2016-10-10 20:35:06 +02:00
Then you can edit a `plantuml` code block with `plantuml-mode` by hitting `C-'` while inside of the code block itself:
2016-05-07 07:50:43 +02:00
```elisp
#+BEGIN_SRC plantuml
2017-05-10 22:57:49 +02:00
<hit C-c ' here to open a plantuml-mode buffer>
2016-05-07 07:50:43 +02:00
#+END_SRC
```
2016-10-10 20:35:06 +02:00
When in the `plantuml-mode` buffer you can then hit again `C-'` to return to the original `org-mode` document.
2016-05-07 07:50:43 +02:00
# 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
2019-08-19 14:10:35 +02:00
- `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`.
2016-05-07 07:50:43 +02:00
# Troubleshooting
2015-12-07 16:56:20 +01:00
## Debug messages
2015-12-07 16:56:20 +01:00
As of `v0.6.2` the following commands have been added to help resolving problems:
```
2016-10-10 20:35:06 +02:00
plantuml-enable-debug
plantuml-disable-debug
2015-12-07 16:56:20 +01:00
```
2016-10-10 20:35:06 +02:00
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).
2015-12-07 16:56:20 +01:00
## 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
2019-08-21 10:52:15 +02:00
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`)
2019-08-21 10:52:15 +02:00
- 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`
2016-05-07 07:50:43 +02:00
# Credits
2015-09-21 17:55:06 +02:00
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.
Thanks to [all the awesome contributors](https://github.com/skuro/plantuml-mode/graphs/contributors), you rock!
2015-09-21 17:55:06 +02:00
# See also
- [PlantUML](http://plantuml.com/)
- [`flycheck-plantuml`](https://github.com/alexmurray/flycheck-plantuml)
2016-05-07 07:50:43 +02:00
# License
2012-06-11 13:31:49 +02:00
2017-08-18 12:16:12 +02:00
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).