You could pre-process your R files with the brew package, e.g.
File 'foo-tmp.r'
##' a function that doesn't do much
##'
##' @title foo
##' @param x
##' @param y
##' @param z
##' @return error message
##' @author Baptiste
##' @examples
##' dontrun{
#<%= cat(paste0("##'", getSrcref(foo), "\n")) %> ##' }
foo <- function(x, y, z){
rnorm(10) == 1
# inline comment
.NotYetImplemented()
" other stuff"
return(FALSE)
}
Then process the file to generate foo.r
source("foo-tmp.r") # to know what the function is
brew("foo-tmp.r", "foo.r")
with resulting output:
##' a function that doesn't do much
##'
##' @title foo
##' @param x
##' @param y
##' @param z
##' @return error message
##' @author Baptiste
##' @examples
##' dontrun{
###'function(x, y, z){
##' rnorm(10) == 1
##' # inline comment
##' .NotYetImplemented()
##' " other stuff"
##' return(FALSE)
##' }
##' }
foo <- function(x, y, z){
rnorm(10) == 1
.NotYetImplemented()
" other stuff"
return(FALSE)
}