Skip to content

Commit

Permalink
New release
Browse files Browse the repository at this point in the history
  • Loading branch information
skuro committed Aug 3, 2019
2 parents b3cfafb + 56bb653 commit 648feb5
Show file tree
Hide file tree
Showing 8 changed files with 278 additions and 118 deletions.
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#
# Programs used in the make goals
#
export CASK ?= cask
export CASK ?= cask
export EMACS ?= emacs

#
# General configuration
#
export CASK_DIR ?= `${CASK} package-directory`
export BATCH = --batch -q -l .emacs/init.el
export CASK_DIR ?= `${CASK} package-directory`
export BATCH = --batch -q -l .emacs/init.el
export COVERALLS_REPO_TOKEN = 61YFD7RG1RRJTs0kEuj1aZX7VBgUPiMNO

all: version test

Expand Down
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ You can also download the latest version of PlantUML straight into `plantuml-jar
- Syntax highlight
- Autocompletion
- Preview of buffer or region
- [EXPERIMENTAL] Use either local JAR or remote server for preview

# Enable the major mode

Expand Down Expand Up @@ -88,6 +89,27 @@ Then you can edit a `plantuml` code block with `plantuml-mode` by hitting `C-'`

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

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`.
Expand Down
Empty file modified bin/download-plantuml.sh
100644 → 100755
Empty file.
312 changes: 207 additions & 105 deletions plantuml-mode.el

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions test/plantuml-config-test.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
;;; 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))

(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
4 changes: 2 additions & 2 deletions test/plantuml-mode-custom-jar-location-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
(should (equal `("-Djava.awt.headless=true" "-jar"
,(expand-file-name "~/.plantuml/plantuml.jar")
"-charset" "UTF-8")
(plantuml-render-command)))
(plantuml-jar-render-command)))

(setq-local plantuml-jar-path "/path/with spaces/plantuml.jar")
(should (equal `("-Djava.awt.headless=true" "-jar" "/path/with spaces/plantuml.jar" "-charset" "UTF-8")
(plantuml-render-command))))
(plantuml-jar-render-command))))

(provide 'plantuml-mode-custom-jar-location-test)

Expand Down
11 changes: 7 additions & 4 deletions test/plantuml-preview-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,19 @@

;;; Code:

(defun assert-preview (puml output &optional format)
(defun assert-preview (puml output &optional format mode)
(if format
(setq plantuml-output-type format)
(setq plantuml-output-type "utxt"))
(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-utxt-test ()
(ert-deftest preview-txt-test ()
(setq-local plantuml-jar-path plantuml-test-jar-path)
(assert-preview "a-b.puml" "a-b.txt"))

Expand Down
8 changes: 4 additions & 4 deletions test/test-helper.el
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ 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-local plantuml-jar-path plantuml-test-jar-path)
(plantuml-init-once)
(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-local indent-tabs-mode nil)
(setq-local tab-width 2)
(setq indent-tabs-mode nil)
(setq tab-width 2)

(indent-region (point-min) (point-max))
(should (equal (buffer-string) after))))
Expand Down

0 comments on commit 648feb5

Please sign in to comment.