Autoappend namespace to functions in script by searchpath order
pretty_namespace(
con = NULL,
text = NULL,
ask = TRUE,
askenv = new.env(),
force = NULL,
ignore = NULL,
overwrite = FALSE,
sos = FALSE
)
character, path to file or directory that contains script, Default: NULL
character, vector that contains script, Default: NULL
boolean, If TRUE then a menu
will be created for the use to
choose between competing namespaces for a function, Default: TRUE
environment, environment that stores names of functions to force in ask, Default: new.env()
list, named list of functions to force over the internal search (seee details), Default: NULL
list, named list of functions to ignore (seee details), Default: NULL
boolean, overwrite original file, Default: FALSE
boolean, apply sos search for uninstalled libraries, Default: FALSE
character
Searches for functions in the loadedNamespace
, help.search
and then findFn
.
If force is not NULL but a named list eg list(stats=c('rnorm','runif'),utils = 'head')
,
then the value pairs will be used in place of what was found using the search path.
If ignore is not NULL but a named list eg list(stats=c('rnorm','runif'),utils = 'head')
,
then if the functions are found they will not have a namespace attached to them.
If you want to toggle off the summary console printing you can set it globally via
sinew_opts$set(pretty_print=FALSE)
.
txt <- '#some comment
yy <- function(a=4){
head(runif(10),a)
# a comment
}
zz <- function(v=10,a=8){
head(runif(v),a)
}'
pretty_namespace(text=txt)
#>
#> functions changed in 'text object':
#>
#> ✔: found, ✖: not found, (): instances, ☒: user intervention
#>
#> ✔ utils::head (2)
#> ✔ stats::runif (2)
#>
#> #some comment
#> yy <- function(a=4){
#> utils::head(stats::runif(10),a)
#> # a comment
#> }
#>
#> zz <- function(v=10,a=8){
#> utils::head(stats::runif(v),a)
#> }