f11da0d6a058

Add `:shape` arg to `digraph.dot:draw`
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Wed, 08 Feb 2023 21:39:46 -0500
parents 4518e61a96c6
children 91b9b04d6914
branches/tags (none)
files docs/04-reference-dot.markdown docs/05-changelog.markdown src/dot.lisp

Changes

--- a/docs/04-reference-dot.markdown	Mon Apr 05 22:03:42 2021 -0400
+++ b/docs/04-reference-dot.markdown	Wed Feb 08 21:39:46 2023 -0500
@@ -9,7 +9,7 @@
 
 ### `DRAW` (function)
 
-    (DRAW DIGRAPH &KEY (FILENAME digraph.png) (FORMAT :PNG))
+    (DRAW DIGRAPH &KEY (FILENAME digraph.png) (FORMAT :PNG) (SHAPE :CIRCLE))
 
 Draw `digraph` with cl-dot.
 
--- a/docs/05-changelog.markdown	Mon Apr 05 22:03:42 2021 -0400
+++ b/docs/05-changelog.markdown	Wed Feb 08 21:39:46 2023 -0500
@@ -5,6 +5,11 @@
 
 [TOC]
 
+v1.5.0
+------
+
+Added `shape` argument to `digraph.dot:draw` to change the shape of the nodes.
+
 v1.4.0
 ------
 
--- a/src/dot.lisp	Mon Apr 05 22:03:42 2021 -0400
+++ b/src/dot.lisp	Wed Feb 08 21:39:46 2023 -0500
@@ -19,19 +19,21 @@
 
 
 (defparameter *current-digraph* nil)
+(defparameter *shape* nil)
 
 
 (defmethod cl-dot:graph-object-node ((graph (eql 'digraph)) (vertex t))
   (make-instance 'cl-dot:node
-    :attributes `(:label ,(format nil "~A" vertex) :shape :circle)))
+    :attributes `(:label ,(format nil "~A" vertex) :shape ,*shape*)))
 
 (defmethod cl-dot:graph-object-points-to ((graph (eql 'digraph)) (vertex t))
   (successors *current-digraph* vertex))
 
 
-(defun draw (digraph &key (filename "digraph.png") (format :png))
+(defun draw (digraph &key (filename "digraph.png") (format :png) (shape :circle))
   "Draw `digraph` with cl-dot."
-  (let ((*current-digraph* digraph))
+  (let ((*current-digraph* digraph)
+        (*shape* shape))
     (cl-dot:dot-graph
       (cl-dot:generate-graph-from-roots 'digraph (find-dot-roots digraph))
       filename