vignettes/mermaid.Rmd
mermaid.RmdThe knit_targets_mermaid() function provides a powerful
way to visualize your targets
pipeline as an interactive Mermaid diagram. This
vignette demonstrates how to use it in R Markdown or Quarto, including
zooming, panning, and rich tooltips with markdown support.
library(yourpackagename)
# Basic pipeline
knit_targets_mermaid(targets_only = TRUE)This will render a vertical (top-to-bottom) Mermaid diagram of your pipeline, with zoom and pan enabled.
You can pass arguments to both targets::tar_mermaid()
and targets::tar_manifest() via .... For
example, to use a custom pipeline script:
knit_targets_mermaid(script = "my_targets.R", targets_only = TRUE)If you add a description to your targets, it will appear
as a tooltip when you hover over the node. Descriptions are parsed as
markdown (if the markdown package is installed) and
rendered as HTML, so you can use formatting, links, and more:
# In your _targets.R
list(
tar_target(x, 1 + 1, description = "**Bold** _italic_ [link](https://r-project.org)"),
tar_target(y, x * 2, description = "`y` is double x.\n- Bullet 1\n- Bullet 2")
)Below is an example of a rendered diagram with tooltips:
Hover over the nodes to see the markdown-formatted tooltips. You can zoom and pan the diagram with your mouse.
The function injects custom CSS and JS for zooming, panning, and
tooltips. You can further customize the appearance by editing
inst/assets/mermaid-zoom.css and
inst/assets/mermaid-zoom.js in your package.
markdown
package is installed.knit_targets_mermaid() makes it easy to create
beautiful, interactive, and informative pipeline diagrams for your R
projects. Use markdown in your target descriptions for rich tooltips,
and enjoy seamless navigation with zoom and pan.