d2-docs icon indicating copy to clipboard operation
d2-docs copied to clipboard

distinguish that imports are not includes

Open alixander opened this issue 1 year ago • 7 comments

Screen Shot 2023-06-13 at 10 18 35 AM

alixander avatar Jun 13 '23 17:06 alixander

but maybe we should add an @includes

alixander avatar Jun 13 '23 17:06 alixander

this works:

z
layers: {
  y: {
    _.z.style.opacity: 0.1
  }
}

but if you split out y into its own file, it wouldn't. this could be a use case for includes

alixander avatar Jun 13 '23 17:06 alixander

Yea perhaps it should and this should be considered a bug.

nhooyr avatar Jun 13 '23 21:06 nhooyr

@nhooyr i don't think so. they're different things.

y.d2

a -> b: hi
(a -> b)[0].style.opacity: 0.1

x.d2

a -> b: hello

...@import y
// vs
/// @includes y

alixander avatar Jun 14 '23 16:06 alixander

I don't follow. Why couldn't we just make imports have the same behaviour the same as includes? Why have another way to add a file? The idea after all is you can move any code anywhere into a new file and it'll just work.

nhooyr avatar Jun 15 '23 16:06 nhooyr

@nhooyr In my example, if you "import y", it imports an opacity 0.1 connection. if you "includes y", it imports a connection but makes the existing connection 0.1 opacity.

So they're two different things. And I can see both being useful.

alixander avatar Jun 15 '23 18:06 alixander

maybe @includes can also take in non-d2 files!

e.g. someone wants to embed a code snippet or markdown that's in its own file.

although we don't have syntax to specify language tag and value separately. maybe we should

alixander avatar Jun 30 '23 16:06 alixander