Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skipping the "is not a valid attribute" for custom attributes #52

Open
frranck opened this issue Jun 7, 2019 · 11 comments
Open

Skipping the "is not a valid attribute" for custom attributes #52

frranck opened this issue Jun 7, 2019 · 11 comments

Comments

@frranck
Copy link

frranck commented Jun 7, 2019

Hello Walter, thanks for the lib.
Would there be a way to skip the "is not a valid attribute" for attributes name not in your list?
Cheers

@awalterschulze
Copy link
Owner

Could you explain your use case?

I think the attr check doesn't happen during parsing

graphAst, _ := gographviz.ParseString(`digraph G {}`)

So you could reuse the parsing library and then create your own more lenient graph

if err := gographviz.Analyse(graphAst, graph); err != nil {

@frranck
Copy link
Author

frranck commented Jun 11, 2019

I want to use your library to load some state machines, for this I need some extra node attributes like "initial state". Dot isn't complaining on unknown attributes so it's compatible with graphviz tools, but the Analyze function is throwing an error...

@frranck
Copy link
Author

frranck commented Jun 17, 2019

@awalterschulze Would that be possible to add a function like
func AddExtraAttr(k string) {
validAttrs[k] = Attr(k)
}
so I could patch the validAttrs map? or maybe setting validAttrs global ?

@awalterschulze
Copy link
Owner

I think this is where we first added the error check for attributes.

https://github.com/awalterschulze/gographviz/pull/25/files#diff-f88c16358abbd541327ed0fb84d3bc1b

@awalterschulze
Copy link
Owner

awalterschulze commented Jun 19, 2019

I don't like adding globals here.

We would need to inject it and make a new Analyse function that takes extra valid attrs or turns of valid attr checking.

Maybe this is something to experiment with on a fork, to see how much code it would be?

@fsaintjacques
Copy link

I would be interested in this, I'll take a stab at it.

@sinkingpoint
Copy link

@fsaintjacques did you get anywhere with this?

@fsaintjacques
Copy link

@sinkingpoint I ended up implementing my own gographviz.Interface since I needed other stuff.

@sinkingpoint
Copy link

Ah fair. I ended up doing the same, although it does seem like overkill

@akrentsel
Copy link

I'd quite like this as well. If nobody else grabs it, I may take a stab at it.

@sinkingpoint
Copy link

Mine is at https://github.com/sinkingpoint/kiora/blob/main/cmd/kiora/config/graph.go if you want something to work off of. I don't really have the bandwidth to support it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants