emicklei / dot

Go package for writing descriptions using the Graphviz DOT and Mermaid language
MIT License
282 stars 19 forks source link

GraphTypeOptions override each other #38

Closed kiambogo closed 7 months ago

kiambogo commented 7 months ago

Expectation:

d := dot.NewGraph(dot.Directed, dot.Strict)

should return the following DOT:

strict digraph  {
    ...
}

Reality:

d := dot.NewGraph(dot.Directed, dot.Strict)

returns the following DOT:

strict  {
    ...
}

This appears to be because the GraphTypeOption  only works with a single option, and will overwrite itself if multiple are passed in (in the above example, strict is the last argument so is the resulting graph option used).

func (o GraphTypeOption) Apply(g *Graph) {
    g.graphType = o.Name
}
emicklei commented 7 months ago

thank you for reporting this issue. I will check the DOT rules about this and fix it accordingly.

emicklei commented 7 months ago

indeed, the strict is optional:

[ strict ] (graph | digraph)