DeanAttali
DeanAttali

Reputation: 26323

Possible to use newline inside roxygen2 code block?

I'm wondering if it's possible to insert newlines inside code blocks in roxygen2 when documenting a function?

If I have something inside \code{}, roxygen2 collapses all newlines into single spaces by default. I tried inserting \cr inside to enforce a line break, and I get the desired behaviour, but then I get a WARNING when I "R CMD CHECK". Is there a way to do this?

Example:

#' \code{
#'   multiple
#'   lines
#' }

Upvotes: 13

Views: 2478

Answers (1)

Backlin
Backlin

Reputation: 14852

Use \preformatted instead of \code. \code is for inline code (works like `` on SO) and \preformatted is for verbatim blocks (like indentation on SO).

#' \preformatted{
#'   multiple
#'   lines
#' }

Note that the initial line break, just after {, will also be part of the code block, so you might want to consider removing it.

Upvotes: 22

Related Questions