Skip to content

pinetr2e/ob-napkin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ob-napkin

https://melpa.org/packages/ob-napkin-badge.svg

What is this?

An Emacs library that allows Org mode to evaluate code blocks using Napkin, Python DSL for writing sequence diagrams.

Screenshot:

./screenshot.png

Installation

ob-napkin depends on napkin Python package. It can be installed as below:

$ pip install napkin

Then, the Emacs lisp package can be loaded as follows:

(with-eval-after-load 'ob
  ;; Optional for syntax highlight of napkin-puml src block.
  ;; (require 'plantuml)
  (require 'ob-napkin))

Usage

Use nakpin src block with the mandatory :file header argument. The filename extension determines the type of image and it can be any format supported by PlantUML. For example, it can be png, svg, or txt.

The first line of the source code should be def seq_diagram(c).

#+begin_src napkin :file hello.png
  def seq_diagram(c):
      user = c.object('user')
      world = c.object('world')
      with user:
          world.hello()
#+end_src

napkin-puml src block can also be use plain PlantUML text. Note that the same functionality is also supported by plantuml src block, which is available from the latest org babel package. However, napkin-puml src block uses napkin tool, which relies on the fast PlantUML server instead of jar file.

#+begin_src napkin-puml :file car.png
  class Car
  Driver - Car : drives >
#+end_src

Configuration

org-babel-napkin-plantuml-server-url can specify the server URL to use. The default is empty string, which means to use public PlantUML server. For example,

(setq org-babel-napkin-plantuml-server-url "http://localhost:8080")

Verbatim result for ASCII art output format

In order to see the result inline mainly in the terminal mode Emacs, :results verbatim header argument can be used without specifying :file. For example,

#+begin_src napkin-puml :results verbatim
  user -> world : hello
#+end_src