mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-25 05:48:07 -05:00
graph: Backend must have name and description.
* guix/graph.scm (<graph-backend>): Add fields "name" and "description". (%graphviz-backend): Provide values for name and description. (export-graph): Ignore name and description when matching backends. (graph-backend-name, graph-backend-description): New procedures. * tests/graph.scm (make-recording-backend): Initialize name and description fields of test graph-backend.
This commit is contained in:
parent
089f385a21
commit
51377437a1
2 changed files with 15 additions and 8 deletions
|
@ -44,6 +44,8 @@ (define-module (guix graph)
|
||||||
%graphviz-backend
|
%graphviz-backend
|
||||||
graph-backend?
|
graph-backend?
|
||||||
graph-backend
|
graph-backend
|
||||||
|
graph-backend-name
|
||||||
|
graph-backend-description
|
||||||
|
|
||||||
export-graph))
|
export-graph))
|
||||||
|
|
||||||
|
@ -140,8 +142,10 @@ (define (node-reachable-count nodes node-edges)
|
||||||
;;;
|
;;;
|
||||||
|
|
||||||
(define-record-type <graph-backend>
|
(define-record-type <graph-backend>
|
||||||
(graph-backend prologue epilogue node edge)
|
(graph-backend name description prologue epilogue node edge)
|
||||||
graph-backend?
|
graph-backend?
|
||||||
|
(name graph-backend-name)
|
||||||
|
(description graph-backend-description)
|
||||||
(prologue graph-backend-prologue)
|
(prologue graph-backend-prologue)
|
||||||
(epilogue graph-backend-epilogue)
|
(epilogue graph-backend-epilogue)
|
||||||
(node graph-backend-node)
|
(node graph-backend-node)
|
||||||
|
@ -170,7 +174,9 @@ (define (emit-edge id1 id2 port)
|
||||||
id1 id2 (pop-color id1)))
|
id1 id2 (pop-color id1)))
|
||||||
|
|
||||||
(define %graphviz-backend
|
(define %graphviz-backend
|
||||||
(graph-backend emit-prologue emit-epilogue
|
(graph-backend "graphviz"
|
||||||
|
"Generate graph in DOT format for use with Graphviz."
|
||||||
|
emit-prologue emit-epilogue
|
||||||
emit-node emit-edge))
|
emit-node emit-edge))
|
||||||
|
|
||||||
(define* (export-graph sinks port
|
(define* (export-graph sinks port
|
||||||
|
@ -181,7 +187,7 @@ (define* (export-graph sinks port
|
||||||
given BACKEND. Use NODE-TYPE to traverse the DAG. When REVERSE-EDGES? is
|
given BACKEND. Use NODE-TYPE to traverse the DAG. When REVERSE-EDGES? is
|
||||||
true, draw reverse arrows."
|
true, draw reverse arrows."
|
||||||
(match backend
|
(match backend
|
||||||
(($ <graph-backend> emit-prologue emit-epilogue emit-node emit-edge)
|
(($ <graph-backend> _ _ emit-prologue emit-epilogue emit-node emit-edge)
|
||||||
(emit-prologue (node-type-name node-type) port)
|
(emit-prologue (node-type-name node-type) port)
|
||||||
|
|
||||||
(match node-type
|
(match node-type
|
||||||
|
|
|
@ -57,7 +57,8 @@ (define (record-edge source target port)
|
||||||
(define (return)
|
(define (return)
|
||||||
(values (reverse nodes) (reverse edges)))
|
(values (reverse nodes) (reverse edges)))
|
||||||
|
|
||||||
(values (graph-backend (const #t) (const #t)
|
(values (graph-backend "test" "This is the test backend."
|
||||||
|
(const #t) (const #t)
|
||||||
record-node record-edge)
|
record-node record-edge)
|
||||||
return)))
|
return)))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue