R/tasks_mermaid.R
knit_targets_mermaid.RdThis function generates a mermaid diagram from a targets pipeline, modifies the direction from left-to-right (LR) to top-to-bottom (TB), and returns it as knitr asis output for embedding in R Markdown or Quarto documents.
knit_targets_mermaid(...)A character string formatted for knitr asis output containing the mermaid diagram with interactive tooltips.
The diagram includes a config block (see the top of the output) that sets node and rank spacing for improved layout. The function also injects custom CSS and JS for zooming, panning, and interactive tooltips.
If a target in the pipeline has a `description` field in the manifest, it will be shown as a tooltip when hovering 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 other markdown features in your tooltips.
# In an R Markdown code chunk:
if (FALSE) { # \dontrun{
knit_targets_mermaid(targets_only = TRUE)
# You can use markdown in target descriptions:
# tar_target(x, 1, description = "**Bold** [link](https://r-project.org)")
} # }