Skip to contents

Render a .textSection object as a temporary HTML report to check whether the section text and code can be rendered successfully.

Usage

testSection(x, object, view)

Arguments

x

A .textSection object, usually created with reportSection().

object

An optional camReport object created by camData(). The default is NULL.

view

A logical value (default TRUE) specifying whether the rendered temporary HTML file is opened after rendering.

Value

Invisibly returns the path to the rendered temporary HTML file.

Details

This function is mainly used to test custom report sections before they are added to a full camReport report. It checks whether the section text, R Markdown chunk settings, required packages, and R code can be rendered successfully.

The object argument is only needed when the R code in the section refers to a camReport object.

Examples

tx <- reportSection(
  name = "introduction",
  title = "Introduction",
  parent = NULL,
  txt = "This is an introduction section.",
  code = {
    plot(1:10)
  }
)

# Render the section without opening a browser
test_file <- testSection(
  tx,
  view = FALSE
)

file.exists(test_file)
#> [1] TRUE

# Remove the generated HTML file
unlink(test_file)