Skip to content

Commit fbb365f

Browse files
committed
workaround for roxygen comments in cpp chunks
1 parent f717713 commit fbb365f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

vignettes/cpp11.Rmd

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ knitr::opts_chunk$set(
1616
comment = "#>",
1717
eval = as.logical(Sys.getenv("CPP11_EVAL", "false"))
1818
)
19+
knitr::knit_hooks$set(strip_roxygen = function(before, options, envir) {
20+
if (before) {
21+
code <- options$code
22+
code <- gsub("/\\* roxygen start.*?roxygen end \\*/", "", code, perl = TRUE)
23+
options$code <- code
24+
options
25+
}
26+
})
1927
library(cpp11)
2028
```
2129

@@ -354,7 +362,7 @@ This is easy to do in RMarkdown by using `{cpp11}` instead of `{r}` at the begin
354362
It is possible to use `roxygen2` to document your C++ functions. Here is an
355363
example of how to do this:
356364

357-
```{cpp11, eval = FALSE}
365+
```{cpp11, strip_roxygen = TRUE}
358366
/* roxygen start
359367
@title Mean of a numeric vector
360368
@param x A numeric vector

0 commit comments

Comments
 (0)