diff --git a/ci/render.sh b/ci/render.sh index 6bd58a9..5e43d91 100755 --- a/ci/render.sh +++ b/ci/render.sh @@ -26,6 +26,8 @@ _bespoke() { sh_c d2 ./static/bespoke-d2/wcc.d2 ./static/img/generated/wcc.pptx sh_c d2 ./static/bespoke-d2/imports-nested.d2 ./static/img/generated/imports-nested.pdf + + sh_c d2 ./static/bespoke-d2/triple-glob.d2 ./static/img/generated/triple-glob.pdf } main() { diff --git a/docs/tour/globs.md b/docs/tour/globs.md index 14436e1..3f29fa7 100644 --- a/docs/tour/globs.md +++ b/docs/tour/globs.md @@ -1,12 +1,5 @@ # Globs -:::caution Alpha -Globs are an alpha feature in 0.6.0. It is likely to change in behavior in followup minor -releases. In particular, the current plan is for globs to be lazy evaluated, so that it -can be used to set defaults, as opposed to the current implementation where it is -evaluated as it appears. -::: - :::note Etymology > The glob command, short for global, originates in the earliest versions of Bell Labs' Unix... to expand wildcard characters in unquoted arguments ... @@ -29,6 +22,26 @@ iphone 12 mini
+## Globs apply backwards and forwards + +In the following example, the instructions are as follows: +1. Create a shape `a`. +2. Apply a glob rule. This immediately applies to existing shapes, i.e., `a`. +3. Create a shape `b`. Existing glob rules are re-evaluated, and applied if they meet the + criteria. This does, so it applies to `b`. +4. Same with `c`. + +```d2 +a + +* -> y + +b +c +``` + +
+ ## Globs are case insensitive ```d2 @@ -194,7 +207,7 @@ catapult: {
:::info -We are working on adding more filters. +We are working on adding more filters, as well as the "not-filter", `!&`. ::: ## Nested globs @@ -225,3 +238,34 @@ conversation 2: { ```
+ +## Global globs + +Triple globs apply globally to the whole diagram. The difference between a double glob and +a triple glob is that a triple glob will apply to nested `layers` (see the section on +[composition](/tour/composition) for more on `layers`), as well as persist across imports. + +```d2 +***.style.fill: yellow +**.shape: circle +*.style.multiple: true + +x: { + y +} + +layers: { + next: { + a + } +} +``` + + + +:::info Imports +If you import a file, the globs declared inside it are usually not carried over. Triple +globs are the exception -- since they are global, importing a file with triple glob will +carry that glob as well. +::: diff --git a/static/bespoke-d2/triple-glob.d2 b/static/bespoke-d2/triple-glob.d2 new file mode 100644 index 0000000..50d7304 --- /dev/null +++ b/static/bespoke-d2/triple-glob.d2 @@ -0,0 +1,13 @@ +***.style.fill: yellow +**.shape: circle +*.style.multiple: true + +x: { + y +} + +layers: { + next: { + a + } +} diff --git a/static/d2/globs-lazy.d2 b/static/d2/globs-lazy.d2 new file mode 100644 index 0000000..a9591f8 --- /dev/null +++ b/static/d2/globs-lazy.d2 @@ -0,0 +1,6 @@ +a + +* -> y + +b +c diff --git a/static/img/generated/cat.pdf b/static/img/generated/cat.pdf index 1fc1a00..7d5a67a 100644 Binary files a/static/img/generated/cat.pdf and b/static/img/generated/cat.pdf differ diff --git a/static/img/generated/cult.pptx b/static/img/generated/cult.pptx index a66c281..efae1f8 100644 Binary files a/static/img/generated/cult.pptx and b/static/img/generated/cult.pptx differ diff --git a/static/img/generated/globs-lazy.svg2 b/static/img/generated/globs-lazy.svg2 new file mode 100644 index 0000000..3e92727 --- /dev/null +++ b/static/img/generated/globs-lazy.svg2 @@ -0,0 +1,170 @@ +aybc + + + + + + diff --git a/static/img/generated/imports-nested.pdf b/static/img/generated/imports-nested.pdf index 199ca53..1fe5274 100644 Binary files a/static/img/generated/imports-nested.pdf and b/static/img/generated/imports-nested.pdf differ diff --git a/static/img/generated/lotr.pdf b/static/img/generated/lotr.pdf index 46d2c9e..a2e5637 100644 Binary files a/static/img/generated/lotr.pdf and b/static/img/generated/lotr.pdf differ diff --git a/static/img/generated/tiktok.pdf b/static/img/generated/tiktok.pdf index 223b6b5..41085d2 100644 Binary files a/static/img/generated/tiktok.pdf and b/static/img/generated/tiktok.pdf differ diff --git a/static/img/generated/triple-glob.pdf b/static/img/generated/triple-glob.pdf new file mode 100644 index 0000000..e0aef48 Binary files /dev/null and b/static/img/generated/triple-glob.pdf differ diff --git a/static/img/generated/vars-config.svg2 b/static/img/generated/vars-config.svg2 index 656d51d..8678be1 100644 --- a/static/img/generated/vars-config.svg2 +++ b/static/img/generated/vars-config.svg2 @@ -1,9 +1,9 @@ - + .d2-359220359 .fill-N1{fill:#0A0F25;} + .d2-359220359 .fill-N2{fill:#676C7E;} + .d2-359220359 .fill-N3{fill:#9499AB;} + .d2-359220359 .fill-N4{fill:#CFD2DD;} + .d2-359220359 .fill-N5{fill:#DEE1EB;} + .d2-359220359 .fill-N6{fill:#EEF1F8;} + .d2-359220359 .fill-N7{fill:#FFFFFF;} + .d2-359220359 .fill-B1{fill:#000536;} + .d2-359220359 .fill-B2{fill:#0F66B7;} + .d2-359220359 .fill-B3{fill:#4393DD;} + .d2-359220359 .fill-B4{fill:#87BFF3;} + .d2-359220359 .fill-B5{fill:#BCDDFB;} + .d2-359220359 .fill-B6{fill:#E5F3FF;} + .d2-359220359 .fill-AA2{fill:#076F6F;} + .d2-359220359 .fill-AA4{fill:#77DEDE;} + .d2-359220359 .fill-AA5{fill:#C3F8F8;} + .d2-359220359 .fill-AB4{fill:#C1A2F3;} + .d2-359220359 .fill-AB5{fill:#DACEFB;} + .d2-359220359 .stroke-N1{stroke:#0A0F25;} + .d2-359220359 .stroke-N2{stroke:#676C7E;} + .d2-359220359 .stroke-N3{stroke:#9499AB;} + .d2-359220359 .stroke-N4{stroke:#CFD2DD;} + .d2-359220359 .stroke-N5{stroke:#DEE1EB;} + .d2-359220359 .stroke-N6{stroke:#EEF1F8;} + .d2-359220359 .stroke-N7{stroke:#FFFFFF;} + .d2-359220359 .stroke-B1{stroke:#000536;} + .d2-359220359 .stroke-B2{stroke:#0F66B7;} + .d2-359220359 .stroke-B3{stroke:#4393DD;} + .d2-359220359 .stroke-B4{stroke:#87BFF3;} + .d2-359220359 .stroke-B5{stroke:#BCDDFB;} + .d2-359220359 .stroke-B6{stroke:#E5F3FF;} + .d2-359220359 .stroke-AA2{stroke:#076F6F;} + .d2-359220359 .stroke-AA4{stroke:#77DEDE;} + .d2-359220359 .stroke-AA5{stroke:#C3F8F8;} + .d2-359220359 .stroke-AB4{stroke:#C1A2F3;} + .d2-359220359 .stroke-AB5{stroke:#DACEFB;} + .d2-359220359 .background-color-N1{background-color:#0A0F25;} + .d2-359220359 .background-color-N2{background-color:#676C7E;} + .d2-359220359 .background-color-N3{background-color:#9499AB;} + .d2-359220359 .background-color-N4{background-color:#CFD2DD;} + .d2-359220359 .background-color-N5{background-color:#DEE1EB;} + .d2-359220359 .background-color-N6{background-color:#EEF1F8;} + .d2-359220359 .background-color-N7{background-color:#FFFFFF;} + .d2-359220359 .background-color-B1{background-color:#000536;} + .d2-359220359 .background-color-B2{background-color:#0F66B7;} + .d2-359220359 .background-color-B3{background-color:#4393DD;} + .d2-359220359 .background-color-B4{background-color:#87BFF3;} + .d2-359220359 .background-color-B5{background-color:#BCDDFB;} + .d2-359220359 .background-color-B6{background-color:#E5F3FF;} + .d2-359220359 .background-color-AA2{background-color:#076F6F;} + .d2-359220359 .background-color-AA4{background-color:#77DEDE;} + .d2-359220359 .background-color-AA5{background-color:#C3F8F8;} + .d2-359220359 .background-color-AB4{background-color:#C1A2F3;} + .d2-359220359 .background-color-AB5{background-color:#DACEFB;} + .d2-359220359 .color-N1{color:#0A0F25;} + .d2-359220359 .color-N2{color:#676C7E;} + .d2-359220359 .color-N3{color:#9499AB;} + .d2-359220359 .color-N4{color:#CFD2DD;} + .d2-359220359 .color-N5{color:#DEE1EB;} + .d2-359220359 .color-N6{color:#EEF1F8;} + .d2-359220359 .color-N7{color:#FFFFFF;} + .d2-359220359 .color-B1{color:#000536;} + .d2-359220359 .color-B2{color:#0F66B7;} + .d2-359220359 .color-B3{color:#4393DD;} + .d2-359220359 .color-B4{color:#87BFF3;} + .d2-359220359 .color-B5{color:#BCDDFB;} + .d2-359220359 .color-B6{color:#E5F3FF;} + .d2-359220359 .color-AA2{color:#076F6F;} + .d2-359220359 .color-AA4{color:#77DEDE;} + .d2-359220359 .color-AA5{color:#C3F8F8;} + .d2-359220359 .color-AB4{color:#C1A2F3;} + .d2-359220359 .color-AB5{color:#DACEFB;}.appendix text.text{fill:#0A0F25}.md{--color-fg-default:#0A0F25;--color-fg-muted:#676C7E;--color-fg-subtle:#9499AB;--color-canvas-default:#FFFFFF;--color-canvas-subtle:#EEF1F8;--color-border-default:#000536;--color-border-muted:#0F66B7;--color-neutral-muted:#EEF1F8;--color-accent-fg:#0F66B7;--color-accent-emphasis:#0F66B7;--color-attention-subtle:#676C7E;--color-danger-fg:red;}.sketch-overlay-B1{fill:url(#streaks-darker);mix-blend-mode:lighten}.sketch-overlay-B2{fill:url(#streaks-dark);mix-blend-mode:overlay}.sketch-overlay-B3{fill:url(#streaks-dark);mix-blend-mode:overlay}.sketch-overlay-B4{fill:url(#streaks-normal);mix-blend-mode:color-burn}.sketch-overlay-B5{fill:url(#streaks-normal);mix-blend-mode:color-burn}.sketch-overlay-B6{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-AA2{fill:url(#streaks-dark);mix-blend-mode:overlay}.sketch-overlay-AA4{fill:url(#streaks-normal);mix-blend-mode:color-burn}.sketch-overlay-AA5{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-AB4{fill:url(#streaks-normal);mix-blend-mode:color-burn}.sketch-overlay-AB5{fill:url(#streaks-normal);mix-blend-mode:color-burn}.sketch-overlay-N1{fill:url(#streaks-darker);mix-blend-mode:lighten}.sketch-overlay-N2{fill:url(#streaks-dark);mix-blend-mode:overlay}.sketch-overlay-N3{fill:url(#streaks-normal);mix-blend-mode:color-burn}.sketch-overlay-N4{fill:url(#streaks-normal);mix-blend-mode:color-burn}.sketch-overlay-N5{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-N6{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-N7{fill:url(#streaks-bright);mix-blend-mode:darken}.light-code{display: block}.dark-code{display: none}@media screen and (prefers-color-scheme:dark){ + .d2-359220359 .fill-N1{fill:#CDD6F4;} + .d2-359220359 .fill-N2{fill:#BAC2DE;} + .d2-359220359 .fill-N3{fill:#A6ADC8;} + .d2-359220359 .fill-N4{fill:#585B70;} + .d2-359220359 .fill-N5{fill:#45475A;} + .d2-359220359 .fill-N6{fill:#313244;} + .d2-359220359 .fill-N7{fill:#1E1E2E;} + .d2-359220359 .fill-B1{fill:#CBA6f7;} + .d2-359220359 .fill-B2{fill:#CBA6f7;} + .d2-359220359 .fill-B3{fill:#6C7086;} + .d2-359220359 .fill-B4{fill:#585B70;} + .d2-359220359 .fill-B5{fill:#45475A;} + .d2-359220359 .fill-B6{fill:#313244;} + .d2-359220359 .fill-AA2{fill:#f38BA8;} + .d2-359220359 .fill-AA4{fill:#45475A;} + .d2-359220359 .fill-AA5{fill:#313244;} + .d2-359220359 .fill-AB4{fill:#45475A;} + .d2-359220359 .fill-AB5{fill:#313244;} + .d2-359220359 .stroke-N1{stroke:#CDD6F4;} + .d2-359220359 .stroke-N2{stroke:#BAC2DE;} + .d2-359220359 .stroke-N3{stroke:#A6ADC8;} + .d2-359220359 .stroke-N4{stroke:#585B70;} + .d2-359220359 .stroke-N5{stroke:#45475A;} + .d2-359220359 .stroke-N6{stroke:#313244;} + .d2-359220359 .stroke-N7{stroke:#1E1E2E;} + .d2-359220359 .stroke-B1{stroke:#CBA6f7;} + .d2-359220359 .stroke-B2{stroke:#CBA6f7;} + .d2-359220359 .stroke-B3{stroke:#6C7086;} + .d2-359220359 .stroke-B4{stroke:#585B70;} + .d2-359220359 .stroke-B5{stroke:#45475A;} + .d2-359220359 .stroke-B6{stroke:#313244;} + .d2-359220359 .stroke-AA2{stroke:#f38BA8;} + .d2-359220359 .stroke-AA4{stroke:#45475A;} + .d2-359220359 .stroke-AA5{stroke:#313244;} + .d2-359220359 .stroke-AB4{stroke:#45475A;} + .d2-359220359 .stroke-AB5{stroke:#313244;} + .d2-359220359 .background-color-N1{background-color:#CDD6F4;} + .d2-359220359 .background-color-N2{background-color:#BAC2DE;} + .d2-359220359 .background-color-N3{background-color:#A6ADC8;} + .d2-359220359 .background-color-N4{background-color:#585B70;} + .d2-359220359 .background-color-N5{background-color:#45475A;} + .d2-359220359 .background-color-N6{background-color:#313244;} + .d2-359220359 .background-color-N7{background-color:#1E1E2E;} + .d2-359220359 .background-color-B1{background-color:#CBA6f7;} + .d2-359220359 .background-color-B2{background-color:#CBA6f7;} + .d2-359220359 .background-color-B3{background-color:#6C7086;} + .d2-359220359 .background-color-B4{background-color:#585B70;} + .d2-359220359 .background-color-B5{background-color:#45475A;} + .d2-359220359 .background-color-B6{background-color:#313244;} + .d2-359220359 .background-color-AA2{background-color:#f38BA8;} + .d2-359220359 .background-color-AA4{background-color:#45475A;} + .d2-359220359 .background-color-AA5{background-color:#313244;} + .d2-359220359 .background-color-AB4{background-color:#45475A;} + .d2-359220359 .background-color-AB5{background-color:#313244;} + .d2-359220359 .color-N1{color:#CDD6F4;} + .d2-359220359 .color-N2{color:#BAC2DE;} + .d2-359220359 .color-N3{color:#A6ADC8;} + .d2-359220359 .color-N4{color:#585B70;} + .d2-359220359 .color-N5{color:#45475A;} + .d2-359220359 .color-N6{color:#313244;} + .d2-359220359 .color-N7{color:#1E1E2E;} + .d2-359220359 .color-B1{color:#CBA6f7;} + .d2-359220359 .color-B2{color:#CBA6f7;} + .d2-359220359 .color-B3{color:#6C7086;} + .d2-359220359 .color-B4{color:#585B70;} + .d2-359220359 .color-B5{color:#45475A;} + .d2-359220359 .color-B6{color:#313244;} + .d2-359220359 .color-AA2{color:#f38BA8;} + .d2-359220359 .color-AA4{color:#45475A;} + .d2-359220359 .color-AA5{color:#313244;} + .d2-359220359 .color-AB4{color:#45475A;} + .d2-359220359 .color-AB5{color:#313244;}.appendix text.text{fill:#CDD6F4}.md{--color-fg-default:#CDD6F4;--color-fg-muted:#BAC2DE;--color-fg-subtle:#A6ADC8;--color-canvas-default:#1E1E2E;--color-canvas-subtle:#313244;--color-border-default:#CBA6f7;--color-border-muted:#CBA6f7;--color-neutral-muted:#313244;--color-accent-fg:#CBA6f7;--color-accent-emphasis:#CBA6f7;--color-attention-subtle:#BAC2DE;--color-danger-fg:red;}.sketch-overlay-B1{fill:url(#streaks-normal);mix-blend-mode:color-burn}.sketch-overlay-B2{fill:url(#streaks-normal);mix-blend-mode:color-burn}.sketch-overlay-B3{fill:url(#streaks-dark);mix-blend-mode:overlay}.sketch-overlay-B4{fill:url(#streaks-dark);mix-blend-mode:overlay}.sketch-overlay-B5{fill:url(#streaks-darker);mix-blend-mode:lighten}.sketch-overlay-B6{fill:url(#streaks-darker);mix-blend-mode:lighten}.sketch-overlay-AA2{fill:url(#streaks-normal);mix-blend-mode:color-burn}.sketch-overlay-AA4{fill:url(#streaks-darker);mix-blend-mode:lighten}.sketch-overlay-AA5{fill:url(#streaks-darker);mix-blend-mode:lighten}.sketch-overlay-AB4{fill:url(#streaks-darker);mix-blend-mode:lighten}.sketch-overlay-AB5{fill:url(#streaks-darker);mix-blend-mode:lighten}.sketch-overlay-N1{fill:url(#streaks-normal);mix-blend-mode:color-burn}.sketch-overlay-N2{fill:url(#streaks-normal);mix-blend-mode:color-burn}.sketch-overlay-N3{fill:url(#streaks-normal);mix-blend-mode:color-burn}.sketch-overlay-N4{fill:url(#streaks-dark);mix-blend-mode:overlay}.sketch-overlay-N5{fill:url(#streaks-darker);mix-blend-mode:lighten}.sketch-overlay-N6{fill:url(#streaks-darker);mix-blend-mode:lighten}.sketch-overlay-N7{fill:url(#streaks-darker);mix-blend-mode:lighten}.light-code{display: none}.dark-code{display: block}}]]> @@ -169,8 +169,8 @@ -xy - - - +xy + + + diff --git a/static/img/generated/wcc.pptx b/static/img/generated/wcc.pptx index 24764c8..2912c10 100644 Binary files a/static/img/generated/wcc.pptx and b/static/img/generated/wcc.pptx differ