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

Create hard parameters for graphviz attributes? #352

Open
2br-2b opened this issue Jun 2, 2024 · 3 comments
Open

Create hard parameters for graphviz attributes? #352

2br-2b opened this issue Jun 2, 2024 · 3 comments

Comments

@2br-2b
Copy link

2br-2b commented Jun 2, 2024

When creating a Graphviz graph, there isn't any documentation for the parameters built into the system, which means there's no intellisense and no way to see what parameters exist or what their valid values are.

The currently best way for a beginner is to go to the official documentation for graphviz (for example, https://graphviz.org/docs/edges/) to see the possible values and set them there, but it would be easier to have built-in enums. For example, here's how I am creating my edges:

class ArrowStyle(Enum):
    FORWARD = "forward"
    BACKWARD = "back"
    BOTH = "both"
    NONE = "none"

class JwEdge(pydot.Edge):
    def __init__(self, source_id: str, destination_id: str, arrow_direction: ArrowStyle = ArrowStyle.NONE):
        super().__init__(
            src=source_id,
            dst=destination_id,
            dir=arrow_direction.value,
            )

On one hand, this makes it easier for me to create edges; on the other hand, I don't know how static Graphiz's api is, so having an attribute there that might not be supported for a specific version could lead to other issues.

Related to #130

@lkk7
Copy link
Member

lkk7 commented Jun 3, 2024

Yeah, that's a difficult thing to solve.
I also like Intellisense and typing wherever possible, but keeping up with all the attributes, possible values, and types is an unrealistic effort for me now.
And as you said, there's the problem of having different versions of Graphviz (even though it's probably very stable now, you never know what's going to happen or what weird version someone will use).

@ferdnyc
Copy link
Member

ferdnyc commented Jun 12, 2024

And as you said, there's the problem of having different versions of Graphviz (even though it's probably very stable now, you never know what's going to happen or what weird version someone will use).

This isn't just a theoretical concern, either. There are extant cases where graphviz takes undocumented or conflictingly-documented values for certain attributes, which create a real difficulty for PyDot to handle sensibly.

@ferdnyc
Copy link
Member

ferdnyc commented Jun 12, 2024

The other tricky thing here is, if this were to be implemented, the corresponding getters and setters would really need to be defined using the enums as their output/input types (respectively). Whereas, currently, all of those methods are generated from lists of names (and, of course, therefore generated untyped) at class definition time.

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

3 participants