7

The following MWE fails to compile (via devtools::document()):

#' MWE
#'
#' @examples
#' format('{}') # Works
#' format('{')  # Nope
#' format('\{') # Nope
#' format('\\{')# Nope
format = function (str) {}

Regardless of which of the “Nope” lines I include, it always fails with the error

Failure in roxygen block beginning mwe.r:1
Mismatched braces …

According to my reading of the Rd documentation, this should work by escaping the brace. However, as shown above, this does not work. Am I doing something wrong or is this a bug in Roxygen?

One hint that this might be a Roxygen bug is the full error message when I use the single-escaped version (format('\{')):

Mismatched braces: "@example format('{}') # Works format('\\{') # Nope"

Note that the single backslash in the input has been doubled in the output.

Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214
  • @Josh Your (now deleted) answer makes this compile but — as you may have noticed, considering the deletion — it results in a broken Rd file that will show errors when attempting to display the help in R. So can we conclude that this is a roxygen bug? – Konrad Rudolph Oct 08 '15 at 16:47
  • 1
    It sure looks like a bug. I deleted because I realized (duh) that the extra right brace was just being used to close the `\examples{}` section – Josh O'Brien Oct 08 '15 at 16:52
  • Well, bug reported at https://github.com/klutometis/roxygen/issues/393 – Konrad Rudolph Oct 08 '15 at 16:53
  • maybe you can close the question now ? – Karl Forner Oct 16 '15 at 13:01
  • @KarlForner Actually if you look at the bug report you’ll see that even with the bug fixed (at least ostensibly), the problem persists. I’m unsure whether this is a bug or whether I’m doing something wrong. At any rate, the original question has evolved by remains essentially unanswered. – Konrad Rudolph Oct 16 '15 at 13:25

1 Answers1

1

Not sure when this was fixed but with roxygen2 version 6.0.1 this issue seems resolved.

devtools::document() on the MWE produces a valid Rd:

\examples{
format('{}') 
format('{')  
format('\\{') 
format('\\\\{')
}
GGamba
  • 13,140
  • 3
  • 38
  • 47