使用Clojure封裝了Graphviz的使用。眼下主要實現了UML的繪製ruby
以命令模式的UML爲例,演示cdraw的使用markdown
cdraw是對Graphviz的簡單封裝。請先安裝Graphvizui
[com.ivaneye/cdraw "0.2.0"]
(ns uml.core (:require [cdraw.uml :refer :all]))
(defclass Client)
(defclass Inboker)
(defclass Receiver {:m ["Action()"]})
(defclass Command {:m ["Execute()"]})
(defclass ConcreteCommand {:f ["state"] :m ["Execute()"]})
(defrelation Client :u Receiver)
(defrelation ConcreteCommand :u Receiver {:t "reveiver"})
(defrelation Client :d ConcreteCommand)
(defrelation ConcreteCommand :e Command)
(defrelation Invoker :p Command)
關聯 :u
依賴 :d
聚合 :p
組合 :c
繼承 :e
實現 :i
(label ConcreteCommand "receive-\\>Action()")
(defsub "Sub Command" Command ConcreteCommand)
(watch (to-file "/t.dot") "/t.png")
(ns uml.core (:require [cdraw.uml :refer :all]))
(defclass Client)
(defclass Invoker)
(defclass Receiver {:m ["Action()"]})
(defclass Command {:m ["Execute()"]})
(defclass ConcreteCommand {:f ["state"] :m ["Execute()"]})
(defrelation Client :u Receiver)
(defrelation ConcreteCommand :u Receiver {:t "reveiver"})
(defrelation Client :d ConcreteCommand)
(defrelation ConcreteCommand :e Command)
(defrelation Invoker :p Command)
(label ConcreteCommand "receive-\\>Action()")
(defsub "Sub Command" Command ConcreteCommand)
(watch (to-file "/t.dot") "/t.png")