From d985e30b252c416a1710654fe2619da96467ffdf Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Tue, 19 Mar 2024 08:45:07 +0100 Subject: [PATCH] add minimal ci --- .github/workflows/test.yml | 28 +++++++++++ CHANGELOG.md | 4 ++ tests/example.qmd | 87 +++++++++++++++++++++++++++++++++ example.qmd => tests/global.qmd | 0 tests/interactive.qmd | 19 +++++++ tests/minimum.qmd | 9 ++++ 6 files changed, 147 insertions(+) create mode 100644 .github/workflows/test.yml create mode 100644 tests/example.qmd rename example.qmd => tests/global.qmd (100%) create mode 100644 tests/interactive.qmd create mode 100644 tests/minimum.qmd diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..136bf44 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,28 @@ +name: Test D2 Quarto Extension + +on: [push] + +jobs: + test_extension: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Quarto + uses: quarto-dev/quarto-actions/setup@v2 + + - name: Install D2 + run: curl -fsSL https://d2lang.com/install.sh | sh -s -- + + - name: Render Quarto document + run: | + cp -r _extensions tests + for file in $(find tests -name "*.qmd"); do + quarto render $file + done + + - name: Upload PDF artifact + uses: actions/upload-artifact@v4 + with: + name: rendered-output + path: tests diff --git a/CHANGELOG.md b/CHANGELOG.md index 4103a28..4a3d410 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # quarto-d2 development +## NEW FUNCTIONALITY + +* Added minimal CI testing using GitHub actions. + ## BUG FIXES * Added tala to the list of layouts (#9, thanks @tosaddler!). diff --git a/tests/example.qmd b/tests/example.qmd new file mode 100644 index 0000000..83c3933 --- /dev/null +++ b/tests/example.qmd @@ -0,0 +1,87 @@ +--- +title: D2 Extension For Quarto +format: gfm +filters: + - d2 +d2: + layout: "elk" +--- + +This [Quarto](https://quarto.org) extension allows you to render [D2](https://d2lang.com) diagrams directly within your markdown documents. + +Main features: + +- Render [D2](https://d2lang.com) diagrams directly within your [Quarto](https://quarto.org) markdown documents. +- Control the appearance and layout of your diagrams using global settings or code block attributes. +- Tune the width and height of the resulting figures using the "width" and "height" arguments. + +This extension was inspired by [`ram02z/d2-filter`](https://github.com/ram02z/d2-filter). + +## Installation + +### Prerequisites + +Ensure that you have [D2](https://d2lang.com/tour/install) installed on your system. + +### Install + +Run the following command to add this extension to your current project: + +``` bash +quarto add data-intuitive/quarto-d2 +``` + +This will install the extension under the `_extensions` subdirectory. +If you're using version control, you will want to check in this directory. + + + +## Example + + +```{.d2 width="50%" echo="true"} +logs: { + shape: page + style.multiple: true +} +user: User {shape: person} +network: Network { + tower: Cell Tower { + satellites: { + shape: stored_data + style.multiple: true + } + + satellites -> transmitter + satellites -> transmitter + satellites -> transmitter + transmitter + } + processor: Data Processor { + storage: Storage { + shape: cylinder + style.multiple: true + } + } + portal: Online Portal { + UI + } + + tower.transmitter -> processor: phone logs +} +server: API Server + +user -> network.tower: Make call +network.processor -> server +network.processor -> server +network.processor -> server + +server -> logs +server -> logs +server -> logs: persist + +server -> network.portal.UI: display +user -> network.portal.UI: access { + style.stroke-dash: 3 +} +``` diff --git a/example.qmd b/tests/global.qmd similarity index 100% rename from example.qmd rename to tests/global.qmd diff --git a/tests/interactive.qmd b/tests/interactive.qmd new file mode 100644 index 0000000..ec7a916 --- /dev/null +++ b/tests/interactive.qmd @@ -0,0 +1,19 @@ +--- +title: "D2 Example" +format: html +filters: + - d2 +d2: + format: svg + embed_mode: raw +--- + +```{.d2 width="40%"} +x { + link: "https://quarto.org" +} +y { + tooltip: "This is a tooltip" +} +x -> y -> z +``` diff --git a/tests/minimum.qmd b/tests/minimum.qmd new file mode 100644 index 0000000..2b692e9 --- /dev/null +++ b/tests/minimum.qmd @@ -0,0 +1,9 @@ +--- +title: "D2 Example" +filters: + - d2 +--- + +```{.d2} +x -> y +```