-
Notifications
You must be signed in to change notification settings - Fork 446
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
d2ir: Implement lazy globs and triple glob #1552
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
failed to compile: /Users/alexanderwang/dev/d2-docs/static/bespoke-d2/triple-glob.d2:1:11: fill must be style.fill
***.style.fill: yellow
**.shape: circle
*.style.multiple: true
x: {
y
}
layers: {
next: {
a
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think globs need to be overridable. currently a
is yellow with this script, but it should be red.
**.style.fill: yellow
**.style.fill: red
a
If a parent board has a triple glob, it should also be overrideable by globs in the current board, e.g.
***.style.fill: yellow
layers: {
hi: {
**.style.fill: red
# should be red, but it's yellow right now
a
}
}
Certainly was the intent, not sure how that's happening. |
fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(*** -> ***)[*].label: hi
a -> b
layers: {
hi: {
(*** -> ***)[*].label: bye
scenarios: {
b: {
# This label is "hi", but it should be "bye"
a -> b
}
}
}
}
nope using d2graph.BoardKeywords so I'm very confused by that too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you think about this one?
(*** -> ***)[*].label: hi
# This is "hey" right now but should be "hi"?
a -> b
(*** -> ***)[*].label: hey
interpretation 1: i've defined the first glob and expect all connections to lazily apply it until it's overridden, so the current behavior is broken.
interpretation 2: globs are global. i've defined two globs of the same pattern, so the last one should win, no matter what order of statements come in between/around them, so the current behavior is correct.
i'm leaning to interpretation 1. i.e. Globs should apply backwards unless an identical pattern already has lazily applied to it.
I think number 2 is the right behavior as it's implemented now. Last one to apply always wins as that's consistent with the rest of the language. Otherwise you can't override/unset globs which isn't good. Especially if you're importing a d2 file you don't control. Why are you leaning towards 1? Under what kind of scenario do you see this coming up where 1 is preferable? |
But you did override it with the second one? |
In this case the final glob isn't being applied backwards. It's being applied normally. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦🏼 another good catch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First one fixed, working on this next one. |
Also btw #1552 (review) was because of And I think this next one isn't related to globs but that |
nah i just tried this and it's the same issue *.style.opacity: 0.1
*: {
&label: x
style.opacity: 1
}
x: x |
Same issue there, |
Fixed. |
On query globs, filtering without the edge index overfilters as we only match one of the edge instead all of them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it easy to get globs working for imports? right now this doesn't work but i definitely see the utility
rules.d2
*.style.fill: red
index.d2
...@rules
x
Right now no unfortunately. Would require changing how imports work to merge ASTs together instead of IRs. |
i think that can be another use case of |
can we encode globs into the IR? i think imports should continue just dealing with IRs, globs just need to be in there |
Perhaps, I'm not sure of a good way to do it right now. |
303058d
to
1d9f0aa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This finishes up the globs implementation!
See tests for what I mean by lazy globs and what the triple glob does.