terrastruct / d2

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

Feature request: absolute import support #1397

Open bo-ku-ra opened 1 year ago

bo-ku-ra commented 1 year ago

when importing d2-file that define 'style' and 'classes', absolute path is better than relative path.

move "cccc.d2" "./bar/cccc.d2"

├─d2 │ │ bokura-config.d2 │ │ │ └─foo │  │ aaaaa.d2 (classes{ ...@../bokura-config.classes }) │  │ bbbbb.d2 (classes{ ...@../bokura-config.classes }) │  │ (ccccc.d2) <-OK │  │ │  └─bar │   ccccc.d2 (classes{ ...@../bokura-config.classes }) <- NG (../../ <-OK)

bo-ku-ra commented 1 year ago

i may want to put 'bokura-config.d2' on a network drive when i share it with my colleagues.

bo-ku-ra commented 1 year ago

doesn't it work on v0.6.0?

alixander commented 1 year ago

unfortunately not, didn't get to it

tylerhartwig commented 4 days ago

Just wanted to add a comment and say this is something I'd really appreciate from D2 as well, for similar reasons as the classes and style imports.

I'd also like to organize pieces of my diagrams in separate files, and then import them into the relevant diagram to avoid redundancies. Absolute imports would make this much easier and avoid the need to update relative paths if I were to change my directory structure

alixander commented 2 days ago

This will be in the next release, thank you all for patience