@@ -220,7 +220,7 @@ generate_r_functions <- function(funs, package = "cpp11", use_package = FALSE) {
220220 package_call <- glue :: glue(' , PACKAGE = "{package}"' )
221221 package_names <- glue :: glue_data(funs , ' "_{package}_{name}"' )
222222 } else {
223- package_names <- glue :: glue_data(funs , ' `_{package}_{name}`' )
223+ package_names <- glue :: glue_data(funs , " `_{package}_{name}`" )
224224 package_call <- " "
225225 }
226226
@@ -229,22 +229,26 @@ generate_r_functions <- function(funs, package = "cpp11", use_package = FALSE) {
229229 funs $ params <- vcapply(funs $ list_params , function (x ) if (nzchar(x )) paste0(" , " , x ) else x )
230230 is_void <- funs $ return_type == " void"
231231 funs $ calls <- ifelse(is_void ,
232- glue :: glue_data(funs , ' invisible(.Call({package_names}{params}{package_call}))' ),
233- glue :: glue_data(funs , ' .Call({package_names}{params}{package_call})' )
232+ glue :: glue_data(funs , " invisible(.Call({package_names}{params}{package_call}))" ),
233+ glue :: glue_data(funs , " .Call({package_names}{params}{package_call})" )
234234 )
235235
236236 # Parse and associate Roxygen comments
237237 funs $ roxygen_comment <- mapply(function (file , line ) {
238- comments <- extract_roxygen_comments(file )
239- matched_comment <- " "
240- for (comment in comments ) {
241- # Check if the comment directly precedes the function without gaps
242- if (line == comment $ line + 1 ) {
243- matched_comment <- comment $ text
244- break
238+ if (file.exists(file )) {
239+ comments <- extract_roxygen_comments(file )
240+ matched_comment <- " "
241+ for (comment in comments ) {
242+ # Check if the comment directly precedes the function without gaps
243+ if (line == comment $ line + 1 ) {
244+ matched_comment <- comment $ text
245+ break
246+ }
245247 }
248+ matched_comment
249+ } else {
250+ " "
246251 }
247- matched_comment
248252 }, funs $ file , funs $ line , SIMPLIFY = TRUE )
249253
250254 # Generate R functions with or without Roxygen comments
@@ -254,9 +258,8 @@ generate_r_functions <- function(funs, package = "cpp11", use_package = FALSE) {
254258 } else {
255259 glue :: glue(" {name} <- function({list_params}) {{\n {calls}\n }}" )
256260 }
257- }, funs $ name , funs $ list_params , funs $ calls , funs $ roxygen_comment , SIMPLIFY = FALSE )
261+ }, funs $ name , funs $ list_params , funs $ calls , funs $ roxygen_comment , SIMPLIFY = TRUE )
258262
259- out <- as.character(out )
260263 out <- glue :: trim(out )
261264 out <- glue :: glue_collapse(out , sep = " \n\n " )
262265 unclass(out )
0 commit comments