Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
#' }
like image 678
DeanAttali Avatar asked May 25 '15 08:05

DeanAttali


1 Answers

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.

like image 192
Backlin Avatar answered Nov 17 '22 23:11

Backlin