Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add minimal ci #10

Merged
merged 2 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# quarto-d2 development

## NEW FUNCTIONALITY

* Added minimal CI testing using GitHub actions (#10).

## BUG FIXES

* Added tala to the list of layouts (#9, thanks @tosaddler!).
Expand Down
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
```