Skip to content

Commit

Permalink
workaround for roxygen comments in cpp chunks
Browse files Browse the repository at this point in the history
  • Loading branch information
pachadotdev committed Jan 5, 2025
1 parent f717713 commit fbb365f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion vignettes/cpp11.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ knitr::opts_chunk$set(
comment = "#>",
eval = as.logical(Sys.getenv("CPP11_EVAL", "false"))
)
knitr::knit_hooks$set(strip_roxygen = function(before, options, envir) {
if (before) {
code <- options$code
code <- gsub("/\\* roxygen start.*?roxygen end \\*/", "", code, perl = TRUE)
options$code <- code
options
}
})
library(cpp11)
```

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

```{cpp11, eval = FALSE}
```{cpp11, strip_roxygen = TRUE}
/* roxygen start
@title Mean of a numeric vector
@param x A numeric vector
Expand Down

0 comments on commit fbb365f

Please sign in to comment.