| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/engine.R |
| 3 |
\name{engine_output} |
| 4 |
\alias{engine_output} |
| 5 |
\title{An output wrapper for language engine output} |
| 6 |
\usage{ |
| 7 |
engine_output(options, code, out, extra = NULL) |
| 8 |
} |
| 9 |
\arguments{ |
| 10 |
\item{options}{A list of chunk options. Usually this is just the object |
| 11 |
\code{options} passed to the engine function; see |
| 12 |
\code{\link{knit_engines}}.} |
| 13 |
|
| 14 |
\item{code}{Source code of the chunk, to which the output hook \code{source} |
| 15 |
is applied, unless the chunk option \code{echo} is \code{FALSE}.} |
| 16 |
|
| 17 |
\item{out}{Text output from the engine, to which the hook \code{output} is |
| 18 |
applied, unless the chunk option \code{results} is \code{'hide'}} |
| 19 |
|
| 20 |
\item{extra}{Any additional text output that you want to include.} |
| 21 |
} |
| 22 |
\value{ |
| 23 |
A character string generated from the source code and output using |
| 24 |
the appropriate output hooks. |
| 25 |
} |
| 26 |
\description{ |
| 27 |
If you have designed a language engine, you may call this function in the end |
| 28 |
to format and return the text output from your engine. |
| 29 |
} |
| 30 |
\details{ |
| 31 |
For expert users, an advanced usage of this function is |
| 32 |
\code{engine_output(options, out = LIST)} where \code{LIST} is a list that |
| 33 |
has the same structure as the output of \code{evaluate::evaluate()}. In this |
| 34 |
case, the arguments \code{code} and \code{extra} are ignored, and the list is |
| 35 |
passed to \code{knitr::sew()} to return a character vector of final output. |
| 36 |
} |
| 37 |
\examples{ |
| 38 |
library(knitr) |
| 39 |
engine_output(opts_chunk$merge(list(engine = "Rscript")), |
| 40 |
code = "1 + 1", out = "[1] 2") |
| 41 |
engine_output(opts_chunk$merge(list(echo = FALSE, engine = "Rscript")), |
| 42 |
code = "1 + 1", out = "[1] 2") |
| 43 |
|
| 44 |
# expert use only |
| 45 |
engine_output(opts_chunk$merge(list(engine = "python")), |
| 46 |
out = list(structure(list(src = "1 + 1"), class = "source"), |
| 47 |
"2")) |
| 48 |
} |