Skip to content

Commit

Permalink
Build API docs using jsdoc-to-markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
mdaines committed Sep 9, 2023
1 parent 435e7e5 commit 8107c2b
Show file tree
Hide file tree
Showing 6 changed files with 1,124 additions and 5 deletions.
3 changes: 3 additions & 0 deletions packages/viz/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@ lib/module.mjs lib/module.wasm: src/module/Dockerfile src/module/viz.c src/modul
@test -f lib/module.mjs && touch lib/module.mjs
@test -f lib/module.wasm && touch lib/module.wasm

README.md: README.hbs src/*.mjs
yarn --silent jsdoc2md --configure ./jsdoc2md.json --template README.hbs --files src/*.mjs --no-gfm --heading-depth 3 --example-lang js > README.md

clean:
rm -f lib/module.mjs lib/module.wasm lib/encoded.mjs lib/metadata.mjs lib/viz-standalone.js lib/viz-standalone.mjs
37 changes: 37 additions & 0 deletions packages/viz/README.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Viz.js

This project builds [Graphviz](http://www.graphviz.org) with [Emscripten](https://emscripten.org) and provides a simple wrapper for using it on the web.

## Install

Viz.js is published on NPM as `@viz-js/viz`.

## Usage

Call `instance()`, which returns a `Promise` that resolves to a new `Viz` instance. Then call any of the instance's `render` methods to render a graph. A graph can be written in [the DOT language](https://www.graphviz.org/doc/info/lang.html) or as a plain JavaScript object. The `renderSVGElement()` method is convenient for displaying a graph in a webpage. The instance can be reused for multiple `render` calls.

```js
<script type="module">
import { instance } from "@viz-js/viz";
instance().then(function(viz) {
// DOT string
document.body.appendChild(viz.renderSVGElement("digraph { a -> b }"));
// Graph object
document.body.appendChild(viz.renderSVGElement({
edges: [
{ tail: "a", head: "b" }
]
}));
});
</script>
```

See the examples directory for more.

## API

{{>main}}
Loading

0 comments on commit 8107c2b

Please sign in to comment.