Skip to content

Commit

Permalink
add minimal ci
Browse files Browse the repository at this point in the history
  • Loading branch information
rcannood committed Mar 19, 2024
1 parent 8bfd075 commit 423a190
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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
87 changes: 87 additions & 0 deletions tests/example.qmd
Original file line number Diff line number Diff line change
@@ -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
}
```
File renamed without changes.
19 changes: 19 additions & 0 deletions tests/interactive.qmd
Original file line number Diff line number Diff line change
@@ -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
```
9 changes: 9 additions & 0 deletions tests/minimum.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: "D2 Example"
filters:
- d2
---

```{.d2}
x -> y
```

0 comments on commit 423a190

Please sign in to comment.