rules_graphviz
rules_graphviz is a Bazel ruleset published to the tomato-bazel registry.
| Latest | 0.2.0 |
|---|---|
| Versions | 2 |
| Category | Bazel rules |
| Maintainers | Matt Marshall |
| Registry | https://registry.tbzl.dev/modules/rules_graphviz/ |
| Source | github.com/tomato-bazel/rules_graphviz |
bazel_dep(name = "rules_graphviz", version = "0.2.0")
View source & releases on GitHub ↗
Bazel rules for rendering Graphviz diagrams — hermetically.
The default toolchain runs @hpcc-js/wasm-graphviz
(Graphviz compiled to WebAssembly, WASM inlined into one JS file) under a
hermetic bun runtime (via rules_bun). No host dot
required, cross-platform wherever bun runs.
Install (MODULE.bazel)
bazel_dep(name = "rules_graphviz", version = "0.2.0")
.bazelrc (fastverk registry):
common --registry=https://raw.githubusercontent.com/fastverk/bazel-registry/main/
common --registry=https://bcr.bazel.build/
Use
load("@rules_graphviz//graphviz:defs.bzl", "dot_diagram", "dot_corpus", "dot_pdf", "svg_pdf")
dot_diagram(name = "graph", src = "graph.dot") # dot -> svg
dot_diagram(name = "g2", src = "graph.dot", engine = "neato") # any layout engine
dot_diagram(name = "g3", src = "graph.dot", output_format = "json") # structured output
dot_corpus(name = "all", srcs = glob(["*.dot"])) # fan-out
dot_pdf(name = "graph_pdf", src = "graph.dot", engine = "twopi") # dot -> vector PDF
svg_pdf(name = "logo_pdf", src = "logo.svg") # any SVG -> vector PDF
- engines:
dot neato fdp sfdp twopi circo osage patchwork - formats:
svg dot canon xdot json json0 plain plain-ext gv
Vector PDF (dot_pdf / svg_pdf)
dot_pdf and svg_pdf emit vector PDF — useful for LaTeX (\includegraphics
in tectonic/pdflatex), which embeds PDF but not SVG. They render to SVG with the
WASM engine, then convert SVG → PDF with a vendored, self-contained bun bundle
(graphviz/svg2pdf.bundle.js: pdfkit + svg-to-pdfkit, headless — no browser, no
cairo, no host dot). So PDF stays as hermetic as the rest of the toolchain. The
PDF page is sized to the SVG’s viewBox. See graphviz/NOTICE.svg2pdf for the
bundled packages and how to regenerate the bundle.
Scope
The WASM toolchain covers every layout engine + the structured output formats.
Vector PDF is available via dot_pdf / svg_pdf (SVG → PDF under bun, above).
The native standalone tools (gvpr, gvpack, tred, unflatten, …) and raster
output (png, which needs cairo) are not in the WASM build. Register an
alternate toolchain for @rules_graphviz//graphviz:toolchain_type if you need them.
License
Apache-2.0. Vendors @hpcc-js/wasm-graphviz (Apache-2.0); see graphviz/NOTICE.
Usage#
Real usage, taken from the module’s examples/.
examples/BUILD.bazel
load("@rules_graphviz//graphviz:defs.bzl", "dot_corpus", "dot_diagram", "dot_pdf", "svg_pdf")
package(default_visibility = ["//visibility:public"])
# Default engine (dot) -> svg.
dot_diagram(
name = "sample_svg",
src = "sample.dot",
)
# A different layout engine, hermetically (no host graphviz).
dot_diagram(
name = "sample_neato",
src = "sample.dot",
engine = "neato",
)
# Structured output.
dot_diagram(
name = "sample_json",
src = "sample.dot",
output_format = "json",
)
dot_corpus(
name = "all",
srcs = ["sample.dot"],
)
# Vector PDF straight from .dot (dot -> svg -> pdf), hermetic — no host tools.
dot_pdf(
name = "sample_pdf",
src = "sample.dot",
)
# Or convert an existing SVG (here, the dot_diagram output above) to PDF.
svg_pdf(
name = "sample_svg_pdf",
src = ":sample_svg",
)Conformance#
2 findings across 1 invariant. 8 contested atoms. See how gating works or the full report.
| version | toolchain |
|---|---|
0.2.0 | //graphviz:graphviz_toolchain_def |
0.2.0 | @bun//:bun_toolchain_def |
Contested atoms
Third-party modules where this module resolves a different version than others do. Not a violation of anything this module did — it is the actionable form of a registry-level convergence finding, and the sentence a maintainer can act on.
| Atom | Resolved here | Elsewhere |
|---|---|---|
apple_support | 1.24.2 | 2.2.0 ×1 |
bazel_skylib | 1.8.2 | 1.9.0 ×2 |
nlohmann_json | 3.6.1 | 3.12.0.bcr.1 ×1 |
protobuf | 33.4 | 34.0.bcr.1 ×2 |
rules_jvm_external | 6.7 | 6.8 ×4 |
rules_python | 1.7.0 | 2.0.1 ×1 |
rules_swift | 3.1.2 | 3.6.1 ×1 |
upb | 0.0.0-20220923-a547704 | 0.0.0-20230516-61a97ef ×1 |
Dependencies#
Depends on
Used by (1 in the registry)
Versions#
2 published versions, newest first. Each resolves to an immutable, integrity-checked archive.
| Version | Integrity (sha256) | Source archive |
|---|---|---|
0.2.0 latest | Uyw4Ny9HwpITcXQd… | tag archive ↗ |
0.1.0 | /0oJj9wFI0HWduEW… | tag archive ↗ |
Changelog#
0.2.0 (unreleased)
Added
- Vector PDF output via
dot_pdf(dot → svg → pdf) andsvg_pdf(any svg → pdf), for embedding graphviz output in LaTeX (tectonic/pdflatex), which takes PDF but not SVG. Conversion is hermetic: a vendored, self-contained bun bundle (graphviz/svg2pdf.bundle.js, built fromgraphviz/svg2pdf.mjs— pdfkit + svg-to-pdfkit, headless, no browser/cairo/hostdot). The bundle rides on the toolchain via the newsvg2pdffield ongraphviz_toolchain. Seegraphviz/NOTICE.svg2pdffor the bundled packages and the rebundle command.
Notes
- The WASM graphviz toolchain still emits SVG/structured formats; PDF goes through the bun converter. Raster PNG remains out of scope (needs cairo).
Publishing this version (registry entry)
bazel_dep(name = "rules_graphviz", version = "0.2.0") resolves from the fastverk
registry once tagged + published. Consumers can build against a local checkout in
the meantime with a local_path_override (see e.g. the spec repo). To publish:
## 1. commit the 0.2.0 changes, then tag + push
git tag v0.2.0 && git push origin v0.2.0
## 2. compute the archive integrity from the published tag tarball
URL=https://github.com/fastverk/rules_graphviz/archive/refs/tags/v0.2.0.tar.gz
curl -sL "$URL" | openssl dgst -sha256 -binary | openssl base64 -A # -> sha256-...
## 3. add the registry entry under bazel-registry/modules/rules_graphviz/0.2.0/
## - MODULE.bazel : copy of this repo's MODULE.bazel
## - source.json : { "url": "$URL", "integrity": "sha256-...",
## "strip_prefix": "rules_graphviz-0.2.0" }
## and append "0.2.0" to modules/rules_graphviz/metadata.json versions,
## then drop the local_path_override in consuming repos.
0.1.0
- Initial release:
dot_diagram/dot_corpusrendering.dot/.gvto SVG and structured formats via a hermetic WASM graphviz toolchain (bun runtime).