]> git.donarmstrong.com Git - lilypond.git/blob - ly/graphviz.ly
65b6538ec6e96fb477b0855378c5f1c10f16fcdf
[lilypond.git] / ly / graphviz.ly
1 \version "2.11.15"
2
3 #(define last-grob-action '())
4
5 #(define sym-blacklist
6   '(cause font))
7
8 #(define sym-whitelist
9   '(control-points))
10
11 #(define file-line-blacklist
12   '())
13
14 #(define file-line-whitelist
15   '())
16
17 #(define graph (make-graph "graph.dot"))
18
19 % an event is relevant if
20 % (it is on some whitelist or all whitelists are empty)
21 % and
22 % (it isn't on any blacklist)
23
24 #(define (relevant? grob file line prop)
25   (let ((file-line `(,file . ,line)))
26    (and
27     (or
28      (= 0 (length file-line-whitelist) (length sym-whitelist))
29      (memq prop sym-whitelist)
30      (member file-line file-line-whitelist))
31     (and
32      (not (memq prop sym-blacklist))
33      (not (member file-line file-line-blacklist))))))
34
35 #(define (grob-mod grob file line func prop val)
36   (let* ((prev (assv grob last-grob-action))
37          (val-str0 (format "~a" val))
38          (val-str (string-take val-str0 (min 50 (string-length val-str0))))
39          (label (format "~a\\n~a:~a\\n~a <- ~a" grob file line prop val-str))
40          (node-id (make-node graph label file)))
41    (if (relevant? grob file line prop)
42     (begin
43      (if (pair? prev)
44       (add-edge graph (cdr prev) node-id))
45      (set! last-grob-action (assv-set! last-grob-action grob node-id))))))
46
47 #(define (grob-create grob file line func)
48   (let* ((label (format "~a\\n~a:~a" grob file line))
49          (node-id (make-node graph label file)))
50    (set! last-grob-action (assv-set! last-grob-action grob node-num))))
51
52 #(ly:set-grob-modification-callback grob-mod)
53 #(ly:set-grob-creation-callback grob-create)