Last active
November 16, 2017 09:14
-
-
Save apg/7d3eda32a2925d8270f2dabef2b968fd to your computer and use it in GitHub Desktop.
Using the functions in graphviz.rkt, we now can do the things in enables.scrbl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@(require "graphviz.rkt") | |
@(require scriblib/figure) | |
@graphviz-figure["foo-bar" "Overview of Foo Bar"]{ | |
digraph G { | |
foo -> bar | |
bar -> baz | |
baz -> quux | |
quux -> foo | |
} | |
} | |
As @figure-ref["foo-bar"] clearly shows, the cycle of foo bar is complete. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket/base | |
(require racket/file | |
racket/path | |
racket/system | |
scribble/base) | |
(require scriblib/figure) | |
(provide graphviz-figure | |
graphviz-dot) | |
;; @graphviz-dot["output"]{ ... } | |
(define (graphviz-dot #:dir [dir "."] name . lines) | |
(define tmpfile (make-temporary-file "dot~a.dot")) | |
(with-output-to-file tmpfile | |
(lambda () (for-each displayln lines)) | |
#:exists 'append) | |
(define type (if (path-get-extension name) | |
(subbytes (path-get-extension name) 1) | |
#"png")) | |
(system (format "dot -T~a -o ~a ~a" | |
type (build-path dir name) tmpfile)) | |
(build-path dir name)) | |
(define (graphviz-figure tag caption | |
#:type [type "svg"] #:dir [dir "."] | |
. src) | |
(define filename (string-append tag "." type)) | |
(figure tag | |
(elem caption) | |
(image (keyword-apply graphviz-dot | |
'(#:dir) (list dir) | |
(cons filename src))))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@figure["foo-bar" @elem{Overview of the Foo Bar}]{@image[@graphviz-dot["./build/foo-bar.svg"]{ | |
digraph G { | |
graph [fontsize=10] | |
center = true | |
packMode = "graph" | |
machine -> kafka | |
kafka -> splunk | |
kafka -> user | |
} | |
}]} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment