terrastruct / d2

D2 is a modern diagram scripting language that turns text to diagrams.
https://d2lang.com
Mozilla Public License 2.0
17.14k stars 422 forks source link

Partial imports do no work #2080

Closed BaronBonet closed 2 months ago

BaronBonet commented 2 months ago

First and foremost thanks to everyone working on this project! D2 has been a game changer in my documentation workflow and I've loved working with it.

Problem

In the docs there is a section on Partial imports.

I've tried copying this example exactly i.e. in the same directory make 2 files:

donut-flowchart.d2

...@imports-targeted-people.management
joe -> donuts: loves
jan -> donuts: brings

people.d2

management: {
 joe: {
   shape: person
   label: Joe Donutlover
 }
 jan: {
   shape: person
   label: Jan Donutbaker
 }
}
# Notice how these do not appear in the rendered diagram
employees: {
 toby: {
   shape: person
   label: Toby Simonton
 }
}

Then I use the cli command d2 donut-flowchart.d2 and get the following error:

err: failed to compile donut-flowchart.d2: /<path>/donut-flowchart.d2:1:1: failed to import "<path>/imports-targeted-people.d2": open /<path>/imports-targeted-people.d2: no such file or directory
make: *** [dev] Error 1

If I modify the donut-flowchart.svg file to remove the targeted imports i.e.

...@people.management
joe -> donuts: loves
jan -> donuts: brings

Then everything renders as expected. However, I'm hoping the partial imports functionally will work since it makes larger d2 projects more manageable.

image

I am using d2 version 0.6.6 on a Mac M2 Pro.

BaronBonet commented 2 months ago

As far as I can tell Model-view also doesn't work.

I signed up for D2 Studio and tried it there. I'm getting the same error as above.

image
alixander commented 2 months ago

@BaronBonet Oops this is just a documentation mistake from a refactor. Thank you for this catch, it's been fixed.