knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  cache = FALSE
)

Register the plantuml knitr engine

The plantuml knitr engine plantuml_knit_engine() needs to be registered with knitr. The easiest is to use thew helper function plantuml_knit_engine_register in the setup code chunk. It is important to load the package plantuml before, as some options need to be set.

library(plantuml)

PlantUML Code Chunk Options

The following options are available, in addition to the standard options: - plantuml_format: the format of the resulting file. At the moment, png (the default), svg, and eps are implemented. - plantuml.path: the path at which the resulting graphs should be saved. If the directory does not exist, it will be created. - plantuml.preview: if the graph should be shown as an inline preview in the Rmarkdown document in Rstudio. This option results in generating the image twice, which may lead to a substantial increase of the processing time. The preview is always a vector preview, irrespective of the file plantuml_format

A simple chart as png

```{plantuml diagram_png, eval = TRUE, echo = FALSE, plantuml.format = "auto", plantuml.path = "graphs", plantuml.preview = TRUE} left to right direction actor "Food Critic" as fc package Restaurant { usecase "Eat Food" as UC1 usecase "Pay for Food" as UC2 usecase "Drink" as UC3 } fc --> UC1 fc --> UC2 fc --> UC3

## A simple chart as png and with code
```{plantuml diagram_png_code, eval = TRUE, echo = TRUE, plantuml.format = "png", plantuml.path = "graphs"}
left to right direction
actor "Food Critic" as fc
package Restaurant {
  usecase "Eat Food" as UC1
  usecase "Pay for Food" as UC2
  usecase "Drink" as UC3
}
fc --> UC1
fc --> UC2
fc --> UC3

A simple chart as svg with code

```{plantuml diagram_svg, eval = TRUE, plantuml.format = "svg", plantuml.path = "graphs"} robust "DNS Resolver" as DNS robust "Web Browser" as WB concise "Web User" as WU

@0 WU is Idle WB is Idle DNS is Idle

@+100 WU -> WB : URL WU is Waiting WB is Processing

@+200 WB is Waiting WB -> DNS@+50 : Resolve URL

@+100 DNS is Processing

@+300 DNS is Idle

## Now only the code
```{plantuml code, eval = FALSE, plantuml.format = "png", plantuml.path = "graphs"}
@startuml
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response

Alice -> Bob: Another authentication Request
Alice <-- Bob: Another authentication Response
@enduml


rkrug/plantuml documentation built on June 3, 2023, 6:24 a.m.