EDIT: Using only the functions exported in NAMESPACE
, and assuming they do not have an @export
statement somewhere in their Roxygen block, we can do a hacky parse of all the export
ed functions:
NAMESPACE <- readLines("NAMESPACE")
exported_fns <- grep( "^export\\(", NAMESPACE, value=TRUE )
exported_fn_names <- gsub( "export\\((.*)\\)", "\\1", exported_fns )
fn_match_re <- paste("^", exported_fn_names, " ?<- ?", sep="")
for( file in list.files("./R", full.names=TRUE) ) {
doc <- readLines( file )
for( i in seq_along(doc) ) {
if( any( sapply( fn_match_re, function(x) {
length( grep( x, doc[i] ) ) > 0
} ) ) ) {
doc[i] <- paste( "##' @export", doc[i], sep="\n" )
}
}
writeLines( doc, file )
}