Skip to content

Commit a9587f0

Browse files
committedFeb 13, 2020
change package name from s-dot to s-graphviz
1 parent a7b4558 commit a9587f0

12 files changed

+59
-58
lines changed
 

‎README.org

+14-14
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#+PROPERTY: literate-load no
99
* Table of Contents :noexport:TOC:
1010
- [[#introduction][Introduction]]
11-
- [[#the-s-dot-language][The S-DOT Language]]
11+
- [[#the-s-graphviz-language][The S-Graphviz Language]]
1212
- [[#exported-functions][Exported Functions]]
1313
- [[#format-graph][format-graph]]
1414
- [[#render-graph][render-graph]]
@@ -23,7 +23,7 @@ This is a S-expression presentation of [[http://www.graphviz.org/][AT&T GraphViz
2323
The original idea is from http://www.martin-loetzsch.de/S-DOT, but with a full compatiblity of original
2424
DOT syntax by following its [[https://www.graphviz.org/doc/info/lang.html][lang definition]].
2525

26-
* The S-DOT Language
26+
* The S-Graphviz Language
2727
We have a similar presentation with the original [[https://graphviz.gitlab.io/_pages/doc/info/lang.html][DOT Language]], but in a single list.
2828
#+begin_src lisp :load no
2929
(graph-type graph-id . graph-statement-list)
@@ -57,16 +57,16 @@ generated DOT file.
5757

5858
* Exported Functions
5959
This library created a new package named as ~:dot~, and it exports the following functions to
60-
convert the S-DOT expression to a file can be read as the DOT Language.
60+
convert the S-Graphviz expression to a file can be read as the DOT Language.
6161
** format-graph
6262
This function accepts a S-expression and a keyword ~:stream~.
63-
- The S-expression has the syntax of the S-DOT Language.
63+
- The S-expression has the syntax of the S-Graphviz Language.
6464
- The stream is nil by default which means it will return a string which can be read as the DOT Language.
6565
if the stream is not nil, then the target string will be written into this stream directly.
6666

6767
For example, the following lisp expression
6868
#+BEGIN_SRC lisp :load no
69-
(dot:format-graph '(:digraph nil
69+
(graphviz:format-graph '(:digraph nil
7070
(node1
7171
(:label "nice node")
7272
(:shape :box)
@@ -80,16 +80,16 @@ digraph {
8080
}
8181
#+end_src
8282
** render-graph
83-
This function is used to render a S-DOT expression to a image type,it accepts the following arguments.
83+
This function is used to render a S-Graphviz expression to a image type,it accepts the following arguments.
8484
- a ~file-name~ for the target image,it can be a string or a pathname.
8585
- a ~S-expression~ for the graph
8686
- a keyword ~format~ to indicate the image type, it is the file type of ~file-name~ by default.
8787
- a keyword ~dot-exe~ for the target dot application, it is ~dot~ by default.
8888
- a keyword ~dot-arguments~ for the additional dot arguments, it is null by default.
8989

90-
For example to render a S-DOT expression to a image file, we can run the following lisp expression.
90+
For example to render a S-Graphviz expression to a image file, we can run the following lisp expression.
9191
#+BEGIN_SRC lisp :load no
92-
(dot:render-graph "/tmp/test1.png"
92+
(graphviz:render-graph "/tmp/test1.png"
9393
'(:digraph ()
9494
(= :rankdir "LR")
9595
(:-> nil a b c)
@@ -101,18 +101,18 @@ For example to render a S-DOT expression to a image file, we can run the followi
101101
** Preparation
102102
We will store all images in this section in the subdirectory ~images~
103103
#+BEGIN_SRC lisp :load demo
104-
(defun render-dot-demo (name s-expression)
105-
(dot:render-graph
104+
(defun render-graphviz-demo (name s-expression)
105+
(graphviz:render-graph
106106
(merge-pathnames
107107
(format nil "images/~a.png" name)
108-
(asdf:component-pathname (asdf:find-system :dot)))
108+
(asdf:component-pathname (asdf:find-system :s-graphviz)))
109109
s-expression))
110110
#+END_SRC
111111

112112
** a finite state machine
113113
The original example is [[https://graphviz.gitlab.io/_pages/Gallery/directed/fsm.html][here]].
114114
#+BEGIN_SRC lisp :load demo
115-
(render-dot-demo
115+
(render-graphviz-demo
116116
"fsm"
117117
'(:digraph nil
118118
(= :rankdir "LR")
@@ -139,7 +139,7 @@ The original example is [[https://graphviz.gitlab.io/_pages/Gallery/directed/fsm
139139
** a cluster
140140
The original example is [[https://graphviz.gitlab.io/_pages/Gallery/directed/cluster.html][here]].
141141
#+BEGIN_SRC lisp :load demo
142-
(render-dot-demo
142+
(render-graphviz-demo
143143
"cluster2"
144144
'(:digraph nil
145145
(:subgraph :cluster_0
@@ -167,7 +167,7 @@ The original example is [[https://graphviz.gitlab.io/_pages/Gallery/directed/clu
167167
** add compass point value in a node id
168168
You can add a compass point value in any node id as you can in the original DOT Language, for example:
169169
#+BEGIN_SRC lisp :load demo
170-
(render-dot-demo
170+
(render-graphviz-demo
171171
"port"
172172
'(:digraph nil
173173
(:-> nil (node1 :e) (node2 :s))))

‎images/attr.dot

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This file is generated automatically by s-dot.
1+
// This file is generated automatically by S-GRAPHVIZ.
22

33
digraph {
44
compound = true;

‎images/cluster1.dot

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This file is generated automatically by s-dot.
1+
// This file is generated automatically by S-GRAPHVIZ.
22

33
digraph {
44
subgraph cluster_1{

‎images/cluster2.dot

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This file is generated automatically by s-dot.
1+
// This file is generated automatically by S-GRAPHVIZ.
22

33
digraph {
44
subgraph cluster_0{

‎images/edge1.dot

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This file is generated automatically by s-dot.
1+
// This file is generated automatically by S-GRAPHVIZ.
22

33
digraph {
44
node1 -> node2 -> node3 [arrowhead = diamond, color = "#FF0000", headlabel = "head\nlabel", label = "red edge", labelfontname = "Arial", fontname = "courier", arrowsize = 2];

‎images/fsm.dot

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This file is generated automatically by s-dot.
1+
// This file is generated automatically by S-GRAPHVIZ.
22

33
digraph {
44
rankdir = "LR";

‎images/node1.dot

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This file is generated automatically by s-dot.
1+
// This file is generated automatically by S-GRAPHVIZ.
22

33
digraph {
44
node1 [label = "nice node", shape = box, fontname = "Arial", fontcolor = "#AA0000"];

‎images/node2.dot

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This file is generated automatically by s-dot.
1+
// This file is generated automatically by S-GRAPHVIZ.
22

33
digraph {
44
node [fillcolor = "#AAFFAA", shape = circle, color = "#0000AA", style = filled, fontsize = 16];

‎images/port.dot

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This file is generated automatically by S-DOT.
1+
// This file is generated automatically by S-GRAPHVIZ.
22

33
digraph {
44
node1 : e -> node2 : s;

‎images/statements.dot

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This file is generated automatically by s-dot.
1+
// This file is generated automatically by S-GRAPHVIZ.
22

33
digraph {
44
rankdir = "LR";

‎dot.asd ‎s-graphviz.asd

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
(in-package :asdf)
33

44
(eval-when (:compile-toplevel :load-toplevel :execute)
5-
(unless (find-package :dot.system)
6-
(defpackage :dot.system
5+
(unless (find-package :s-graphviz.system)
6+
(defpackage :s-graphviz.system
77
(:use :cl :asdf))))
88

9-
(in-package :dot.system)
9+
(in-package :s-graphviz.system)
1010

11-
(asdf:defsystem dot
11+
(asdf:defsystem s-graphviz
1212
:author "Xu Jingtao <jingtaozf@gmail.com>"
1313
:version "2.0"
1414
:licence "MIT"
@@ -17,4 +17,4 @@
1717
:defsystem-depends-on ("literate-lisp")
1818
:depends-on ((:version :iterate "1.5"))
1919
:components ((:module :demo :pathname "./"
20-
:components ((:org "dot")))))
20+
:components ((:org "s-graphviz")))))

‎dot.org ‎s-graphviz.org

+31-30
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
- [[#the-encode-stream][the encode stream]]
1515
- [[#the-indent-level][the indent level]]
1616
- [[#the-default-size-for-indent-tab][the default size for indent tab]]
17-
- [[#how-to-render-a-dot-s-expression][how to render a DOT S-expression]]
17+
- [[#how-to-render-a-s-graphviz-s-expression][how to render a S-GRAPHVIZ S-expression]]
1818
- [[#graph][graph]]
1919
- [[#stmt-list][stmt-list]]
2020
- [[#stmt][stmt]]
@@ -32,17 +32,18 @@
3232
- [[#node-statement-1][node statement]]
3333

3434
* Introduction
35-
S-Dot is an S-Expression syntax for the input language of the 'Dot' graph drawing tool from the [[http://www.graphviz.org/][AT&T GraphViz]] suite.
36-
With S-Dot, you can render 'Dot' graphs from within Common Lisp.
35+
S-Graphviz is an S-Expression syntax for the input language of the 'Dot' graph drawing tool from the [[http://www.graphviz.org/][AT&T GraphViz]] suite.
36+
With S-Graphviz, you can render 'Dot' graphs from within Common Lisp.
3737
The idea of this package is from [[http://martin-loetzsch.de/S-DOT/][S-DOT]].
3838

3939
* Preparation
4040
Let's create an individual package for this module.
4141
#+BEGIN_SRC lisp
42-
(defpackage :dot
42+
(defpackage :s-graphviz
43+
(:nicknames :graphviz)
4344
(:use :common-lisp :iter)
4445
(:export :render-graph :format-graph))
45-
(in-package :dot)
46+
(in-package :s-graphviz)
4647
#+END_SRC
4748
* Language presentation
4849
We will use a lisp style to present the [[https://www.graphviz.org/doc/info/lang.html][DOT language]].
@@ -81,8 +82,8 @@ How many whitespaces will be written before printing current DOT expression.
8182
#+BEGIN_SRC lisp
8283
(defvar *indent-tab-size* 2)
8384
#+END_SRC
84-
** how to render a DOT S-expression
85-
Renders a s-DOT graph into a graphic file.
85+
** how to render a S-GRAPHVIZ S-expression
86+
Renders a s-graphviz graph into a graphic file.
8687
~file-name~ should be a pathname.
8788
If the file-name is ~/foo/bar.png~ , the DOT file ~/foo/bar.dot~ is created
8889
and then rendered.
@@ -98,17 +99,17 @@ for example svg, ps, gif, png, or jpg.
9899
:name (pathname-name file-name) :type "dot")))
99100
(with-open-file (stream dot-file-name :direction :output :if-exists :supersede
100101
:if-does-not-exist :create)
101-
(format stream "// This file is generated automatically by S-DOT.~%~%")
102+
(format stream "// This file is generated automatically by S-GRAPHVIZ.~%~%")
102103
(format-graph s-expression :stream stream))
103104
(uiop:run-program (format nil "~a -o ~a ~a~a ~a ~a"
104105
dot-exe file-name dot-output-format-switch
105106
format dot-options dot-file-name)
106107
:ignore-error-status t)))
107108
#+END_SRC
108109

109-
We will provide a helpful routine to render a DOT S-expression and open it in Emacs.
110+
We will provide a helpful routine to render a S-GRAPHVIZ S-expression and open it in Emacs.
110111
#+BEGIN_SRC lisp :load dev
111-
(defmacro render-and-open-s-dot (file-name &rest left-args)
112+
(defmacro render-and-open-s-graphviz (file-name &rest left-args)
112113
(let ((real-file-name (gensym "file-name")))
113114
`(let ((,real-file-name (namestring ,file-name)))
114115
(render-graph ,real-file-name ,@left-args)
@@ -154,10 +155,10 @@ We will provide a helpful routine to render a DOT S-expression and open it in Em
154155
a graph is established by a stmt_list.
155156
We can also apply some global configuration in a ~stmt_list~ to limit their affection scope,for example:
156157
#+BEGIN_SRC lisp :load no
157-
(render-and-open-s-dot
158+
(render-and-open-s-graphviz
158159
(merge-pathnames
159160
#p"images/statements.png"
160-
(asdf:component-pathname (asdf:find-system :dot)))
161+
(asdf:component-pathname (asdf:find-system :s-graphviz)))
161162
'(:digraph nil
162163
(= :rankdir "LR")
163164
(:-> nil a b c)
@@ -206,10 +207,10 @@ There are many different kinds of statements,let's recognize them one by one.
206207

207208
If a statement starts without a known keyword, then it's a node statement,for example
208209
#+BEGIN_SRC lisp :load no
209-
(render-and-open-s-dot
210+
(render-and-open-s-graphviz
210211
(merge-pathnames
211212
#p"images/node1.png"
212-
(asdf:component-pathname (asdf:find-system :dot)))
213+
(asdf:component-pathname (asdf:find-system :s-graphviz)))
213214
'(:digraph nil
214215
(node1 (:label "nice node") (:shape :box) (:fontname "Arial") (:fontcolor "#AA0000"))))
215216
#+END_SRC
@@ -245,10 +246,10 @@ edgeRHS : edgeop (node_id | subgraph) [ edgeRHS ]
245246
In a S-expression, it's a list that starts with an ~edgeop~ and an ~attr_list~ and
246247
the rest are a list of ~node id~, for example
247248
#+BEGIN_SRC lisp :load no
248-
(render-and-open-s-dot
249+
(render-and-open-s-graphviz
249250
(merge-pathnames
250251
#p"images/edge1.png"
251-
(asdf:component-pathname (asdf:find-system :dot)))
252+
(asdf:component-pathname (asdf:find-system :s-graphviz)))
252253
'(:digraph nil
253254
(:-> ((arrowhead :diamond)
254255
(color "#FF0000")
@@ -278,13 +279,13 @@ the rest are a list of ~node id~, for example
278279
#+begin_src bnf
279280
attr_stmt : (graph | node | edge) attr_list
280281
#+end_src
281-
In a DOT S-expression, it starts with keyword ~:graph~, ~:node~, ~:edge~ , and the rest items
282+
In a S-GRAPHVIZ S-expression, it starts with keyword ~:graph~, ~:node~, ~:edge~ , and the rest items
282283
in the list is the ~attr_list~(ref:attr-list),for example:
283284
#+begin_src lisp :load no
284-
(render-and-open-s-dot
285+
(render-and-open-s-graphviz
285286
(merge-pathnames
286287
#p"images/node2.png"
287-
(asdf:component-pathname (asdf:find-system :dot)))
288+
(asdf:component-pathname (asdf:find-system :s-graphviz)))
288289
'(:digraph nil
289290
(:node
290291
(:fillcolor "#AAFFAA")
@@ -303,12 +304,12 @@ in the list is the ~attr_list~(ref:attr-list),for example:
303304
#+END_SRC
304305
** attribute
305306
a single attribute can be applied to global environment in a statement,
306-
in a DOT S-expression, it looks like this:
307+
in a S-GRAPHVIZ S-expression, it looks like this:
307308
#+BEGIN_SRC lisp :load no
308-
(render-and-open-s-dot
309+
(render-and-open-s-graphviz
309310
(merge-pathnames
310311
#p"images/attr.png"
311-
(asdf:component-pathname (asdf:find-system :dot)))
312+
(asdf:component-pathname (asdf:find-system :s-graphviz)))
312313
'(:digraph nil
313314
(= :compound t)
314315
(node1 (:id :test)(:label :test))))
@@ -325,12 +326,12 @@ in a DOT S-expression, it looks like this:
325326
#+END_SRC
326327
** subgraph
327328
It a subgraph's name starts with "cluster", then it has a special meaning.
328-
in a DOT S-expression, it looks like this:
329+
in a S-GRAPHVIZ S-expression, it looks like this:
329330
#+BEGIN_SRC lisp :load no
330-
(render-and-open-s-dot
331+
(render-and-open-s-graphviz
331332
(merge-pathnames
332333
#p"images/cluster1.png"
333-
(asdf:component-pathname (asdf:find-system :dot)))
334+
(asdf:component-pathname (asdf:find-system :s-graphviz)))
334335
'(:digraph nil
335336
(:subgraph cluster_1
336337
(node1 (:id :test)(:label :test))
@@ -371,12 +372,12 @@ port : ':' ID [ ':' compass_pt ]
371372
| ':' compass_pt
372373
compass_pt : (n | ne | e | se | s | sw | w | nw | c | _)
373374
#+end_src
374-
In a DOT S-expression, it looks like this:
375+
In a S-GRAPHVIZ S-expression, it looks like this:
375376
#+BEGIN_SRC lisp :load no
376-
(render-and-open-s-dot
377+
(render-and-open-s-graphviz
377378
(merge-pathnames
378379
#p"images/port.png"
379-
(asdf:component-pathname (asdf:find-system :dot)))
380+
(asdf:component-pathname (asdf:find-system :s-graphviz)))
380381
'(:digraph nil
381382
(:-> nil (node1 :e) (node2 :s))))
382383
#+END_SRC
@@ -430,8 +431,8 @@ The [[https://common-lisp.net/project/fiveam/][FiveAM]] library is used to test.
430431
(unless (find-package :fiveam)
431432
#+quicklisp (ql:quickload :fiveam)
432433
#-quicklisp (asdf:load-system :fiveam)))
433-
(5am:def-suite dot-suite :description "The test suite of DOT.")
434-
(5am:in-suite dot-suite)
434+
(5am:def-suite s-graphviz-suite :description "The test suite of S-GRAPHVIZ.")
435+
(5am:in-suite s-graphviz-suite)
435436
#+END_SRC
436437
** node statement
437438
label:test-of-node-statement

0 commit comments

Comments
 (0)
Please sign in to comment.