Applies makeOxygen function to all functions/dataframes in supplied file(s)

makeOxyFile(input = NULL, overwrite = FALSE, verbose = interactive(), ...)

Arguments

input

character, vector of path(s) to one or more .R files, a path to directory containing .R files, Default: NULL

overwrite

logical, If TRUE overwrites file(s), FALSE writes "Oxy"- prefixed files in the same directory, Default: FALSE

verbose

logical, If TRUE will print output to console and open edited files in the editor viewer, Default: interactive()

...

additional parameters passed to makeOxygen

Value

Nothing. Writes files with roxygen2 comments as a side effect

Details

If an object cannot be found it will be sourced into a temporary environment. If the file already contains roxygen2 comments they will be deleted to avoid duplication. Some functions may require attaching additional packages. For instance, if functions were defined with purrr's compose or partial functions, omission of purr:: in definitions will require library(purrr) before proceeding with makeOxyFile.

See also

Examples

# copy dummy package to tempdir file.copy(system.file('pkg',package = 'sinew'),tempdir(),recursive = TRUE)
#> [1] TRUE
pkg_dir <- file.path(tempdir(),'pkg') pkg_dir_R <- file.path(pkg_dir,'R') # update namespaces in package functions pretty_namespace(pkg_dir_R, overwrite = TRUE)
#> #> functions changed in '/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T//RtmpsuvloD/pkg/R/yy.R': #> #> ✔: found, : not found, (): instances, ☒: user intervention #> #> ✔ utils::head (1) #> ✔ stats::runif (1) #> #> #> functions changed in '/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T//RtmpsuvloD/pkg/R/zz.R': #> #> ✔: found, : not found, (): instances, ☒: user intervention #> #> ✔ utils::head (1) #> ✔ stats::runif (1) #>
# test on one R file # this will create a new R file called 'oxy-yy.R' in the same directory makeOxyFile(file.path(pkg_dir_R,'yy.R'))
#> #' @title FUNCTION_TITLE #> #' @description FUNCTION_DESCRIPTION #> #' @param a PARAM_DESCRIPTION, Default: 4 #> #' @return OUTPUT_DESCRIPTION #> #' @details DETAILS #> #' @examples #> #' \dontrun{ #> #' if(interactive()){ #> #' #EXAMPLE1 #> #' } #> #' } #> #' @seealso #> #' \code{\link[utils]{head}} #> #' \code{\link[stats]{Uniform}} #> #' @author Jonathan Sidi #> #' @importFrom utils head #> #' @importFrom stats runif
# Remove the file unlink(file.path(pkg_dir_R,'oxy-yy.R')) # Test on all R files in directory and overwrite the contents makeOxyFile(pkg_dir_R, overwrite = TRUE)
#> #' @title FUNCTION_TITLE #> #' @description FUNCTION_DESCRIPTION #> #' @param a PARAM_DESCRIPTION, Default: 4 #> #' @return OUTPUT_DESCRIPTION #> #' @details DETAILS #> #' @examples #> #' \dontrun{ #> #' if(interactive()){ #> #' #EXAMPLE1 #> #' } #> #' } #> #' @seealso #> #' \code{\link[utils]{head}} #> #' \code{\link[stats]{Uniform}} #> #' @author Jonathan Sidi #> #' @importFrom utils head #> #' @importFrom stats runif #> #' @title FUNCTION_TITLE #> #' @description FUNCTION_DESCRIPTION #> #' @param v PARAM_DESCRIPTION, Default: 10 #> #' @param a PARAM_DESCRIPTION, Default: 8 #> #' @return OUTPUT_DESCRIPTION #> #' @details DETAILS #> #' @examples #> #' \dontrun{ #> #' if(interactive()){ #> #' #EXAMPLE1 #> #' } #> #' } #> #' @seealso #> #' \code{\link[utils]{head}} #> #' \code{\link[stats]{Uniform}} #> #' @author Jonathan Sidi #> #' @importFrom utils head #> #' @importFrom stats runif
# Remove Skeleton rmOxygen(file.path(pkg_dir_R,'yy.R')) rmOxygen(file.path(pkg_dir_R,'zz.R')) # adds more fields to defaults, passes "cut" to make_import sinew_opts$append(list(add_fields=c("concept", "describeIn"))) makeOxyFile(file.path(pkg_dir_R,'yy.R'), cut = 5)
#> #' @title FUNCTION_TITLE #> #' @description FUNCTION_DESCRIPTION #> #' @param a PARAM_DESCRIPTION, Default: 4 #> #' @return OUTPUT_DESCRIPTION #> #' @details DETAILS #> #' @examples #> #' \dontrun{ #> #' if(interactive()){ #> #' #EXAMPLE1 #> #' } #> #' } #> #' @seealso #> #' \code{\link[utils]{head}} #> #' \code{\link[stats]{Uniform}} #> #' @author Jonathan Sidi #> #' @concept CONCEPT_TERM_1 [CONCEPT_TERM_2] #> #' @describeIn FUNCTION_NAME DESCRIPTION #> #' @importFrom utils head #> #' @importFrom stats runif
# cleanup unlink(pkg_dir, recursive = TRUE, force = TRUE) sinew_opts$restore()