Skip to content
wesleyelPublic

About

Draw data-structure diagrams in Typst from a compact text DSL (Rust/WASM plugin)

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

dsviz

CI build status Typst Universe package version Minimum Typst version Plugin written in Rust and compiled to WASM MIT license

English · 中文

Draw data-structure and computer-systems diagrams in Typst from a few lines of text. The style is plain and traditional: square corners and thin black lines, with restrained color. A grayscale palette keeps every figure clear in black-and-white printing.

Labels are typeset by Typst itself, so diagrams align with any font and match your document.

Overview of all 22 diagram kinds: trees, B-trees, lists, arrays, stacks, ring buffers, matrices, tables, graphs, adjacency structures, bit fields, pipeline charts, Gantt charts, sequence diagrams, waveforms and block diagrams

Usage

#import "@preview/dsviz:0.2.2": ds

// Every ```ds block becomes a diagram.
#show raw.where(lang: "ds"): ds

```ds
bintree thread=in
A
  B
    _
    D
  C
```

The first line names the kind and its options; the rest describes the structure. You can also call the function directly:

#ds(width: 5cm, spacing: 1.2)[```
wave grid=on bits=1 0 1
CLK: c c c
Data: 10 01 10
```]

Palettes

Diagrams use color by default. Pass palette: "gray" for black-and-white printing, per diagram or for a whole document:

#show raw.where(lang: "ds"): ds.with(palette: "gray")

The same red-black tree, digraph and array in the gray and color palettes

Kinds
Trees tree forest bintree rbtree btree bplus
Linear list array stack ring matrix table
Graphs graph digraph orthlist multilist
Systems fields pipeline gantt ladder wave block

Full syntax and ds parameters: docs/syntax.md.

Gallery

Huffman-style binary tree with 0/1 edge labels, a red-black tree with NIL leaves, a decision tree, a forest and a B+ tree

Linked lists, an adjacency list, sorting passes, a stack, a circular queue and a KMP next table

Undirected and directed graphs, an adjacency matrix, an orthogonal list and an adjacency multilist

Sources are in examples/.

Development

Requires Rust with the wasm32-unknown-unknown target.

make wasm    # build the plugin into src/dsviz.wasm
make test    # unit tests, gallery and examples
make images  # regenerate docs/images/

Release notes: CHANGELOG.md. License: MIT.

About

Draw data-structure diagrams in Typst from a compact text DSL (Rust/WASM plugin)

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages