graph/encoding: provide attribute handling out of the box

This commit is contained in:
Dan Kortschak
2021-05-27 07:18:04 +09:30
parent c8613b2ab9
commit 97f387b38f
4 changed files with 175 additions and 19 deletions

View File

@@ -321,10 +321,6 @@ type graphAttributer struct {
edge encoding.Attributer
}
type attributer []encoding.Attribute
func (a attributer) Attributes() []encoding.Attribute { return a }
func (g graphAttributer) DOTAttributers() (graph, node, edge encoding.Attributer) {
return g.graph, g.node, g.edge
}
@@ -1192,8 +1188,8 @@ var encodeTests = []struct {
{from: 2, to: 4}: {},
{from: 3, to: 4}: {{Key: "color", Value: "red"}},
}),
graph: attributer{{Key: "rankdir", Value: `"LR"`}},
node: attributer{{Key: "fontsize", Value: "16"}, {Key: "shape", Value: "ellipse"}},
graph: &encoding.Attributes{{Key: "rankdir", Value: `"LR"`}},
node: &encoding.Attributes{{Key: "fontsize", Value: "16"}, {Key: "shape", Value: "ellipse"}},
edge: nil,
},