简体   繁体   中英

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
#' }

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM