roxygen_remove_extra_brace: Fix 'tools::parse_Rd()' output

Description Usage Examples

View source: R/roxygen-examples-parse.R

Description

Since tools::parse_Rd() treats braces in quotes as literal braces when determining brace symmetry, a brace might be added in error to the parsed data (at the end). We'll remove one at the time, check if output is parsable until no braces are left. If we end up with no braces left, we signal a parsing error, otherwise, we return the initial (not parsable input due to dont sequence) with the trailing braces removed.

Usage

1

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
styler:::parse_roxygen(
  c(
    "#' @examples",
    "#' x <- '{'",
    "#' \\dontrun{",
    "#' fu(x = 3)",
    "#' }"
  )
)
styler:::parse_roxygen(
  c(
    "#' @examples",
    "#' x <- '{'",
    "#' \\dontrun{",
    "#' c('{', \"'{{{\" ,\"[\")",
    "#' }"
  )
)

styler documentation built on Sept. 23, 2021, 5:07 p.m.