diff --git a/DESCRIPTION b/DESCRIPTION index 1ae5d3a..b33e80c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -20,8 +20,8 @@ Suggests: rstudioapi, tinytex (>= 0.30), mime, - markdown, - knitr, + markdown (>= 1.5), + knitr (>= 1.42), htmltools, remotes, pak, diff --git a/NEWS.md b/NEWS.md index 41ed877..f841ae6 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,8 @@ - Added a function `is_arm64()` to test the CPU type (thanks, @AlbanSagouis, #72). +- Started deprecating `xfun::isFALSE()` in favor of `base::isFALSE()` for R >= 3.5.0 (thanks, @mmaechler, #66); `isFALSE()` will eventually be removed from **xfun** when we do not need to support R < 3.5.0. + # CHANGES IN xfun VERSION 0.36 - Added a new argument `resolve_symlink` to `normalize_path()` to get the absolute paths of symlinks without resolving them (with `resolve_symlink = FALSE`). diff --git a/R/packages.R b/R/packages.R index 38ef2ef..17770b6 100644 --- a/R/packages.R +++ b/R/packages.R @@ -47,7 +47,7 @@ pkg_attach = function( suppressPackageStartupMessages(base::library(...)) } for (i in c(...)) { - if (!isFALSE(install) && !loadable(i)) pkg_install(i, install) + if (!base::isFALSE(install) && !loadable(i)) pkg_install(i, install) library(i, character.only = TRUE) } } @@ -60,7 +60,7 @@ pkg_load = function(..., error = TRUE, install = FALSE) { if (n == 0) return(invisible(res)) for (i in seq_len(n)) { res[i] = loadable(p <- pkg[i]) - if (!isFALSE(install) && !res[i]) { + if (!base::isFALSE(install) && !res[i]) { pkg_install(p, install); res[i] = loadable(p) } } diff --git a/R/paths.R b/R/paths.R index 4ded25a..7f7d2f9 100644 --- a/R/paths.R +++ b/R/paths.R @@ -123,7 +123,7 @@ existing_files = function(x, first = FALSE, error = TRUE) { x = x[file_exists(x)] if (!first) return(x) x = head(x, 1) - if (length(x) != 1 && !isFALSE(error)) { + if (length(x) != 1 && !base::isFALSE(error)) { if (isTRUE(error)) error = 'None of the specified files exist.' stop(error, call. = FALSE) } diff --git a/R/session.R b/R/session.R index 8ae7c90..7f12f8d 100644 --- a/R/session.R +++ b/R/session.R @@ -106,7 +106,7 @@ do_once = function(task, option, hint = c( 'If you never want to see this message,', sprintf('you may set options(%s = FALSE) in your .Rprofile.', option) )) { - if (isFALSE(getOption(option))) return(invisible()) + if (base::isFALSE(getOption(option))) return(invisible()) task hint = paste(hint, collapse = ' ') if (hint != '') message(hint) diff --git a/R/utils.R b/R/utils.R index 168b139..d4acb06 100644 --- a/R/utils.R +++ b/R/utils.R @@ -90,17 +90,31 @@ in_dir = function(dir, expr) { expr } -#' Test if an object is identical to \code{FALSE} +#' Test if an object is \code{FALSE} #' -#' A simple abbreviation of \code{identical(x, FALSE)}. +#' For R versions lower than 3.5.0, this function is a simple abbreviation of +#' \code{identical(x, FALSE)}. For higher R versions, this function calls +#' \code{base::isFALSE()}. #' @param x An R object. +#' @note This function will be deprecated in the future. We recommend that you +#' use \code{base::\link[base]{isFALSE}()} instead. If you have to support R +#' versions lower than 3.5.0, you may use \code{identical(x, FALSE)}, but +#' please note that it is not equivalent to \code{base::isFALSE()}. #' @export -#' @examples +#' @keywords internal +#' @examplesIf getRversion() < '3.5.0' #' library(xfun) #' isFALSE(TRUE) # false #' isFALSE(FALSE) # true #' isFALSE(c(FALSE, FALSE)) # false -isFALSE = function(x) identical(x, FALSE) +isFALSE = function(x) { + if (!('isFALSE' %in% ls(baseenv()))) return(identical(x, FALSE)) + do_once((if (is_R_CMD_check()) stop else warning)( + 'The function xfun::isFALSE() will be deprecated in the future. Please ', + 'consider using base::isFALSE(x) or identical(x, FALSE) instead.' + ), 'xfun.isFALSE.message', '') + base::isFALSE(x) +} #' Parse R code and do not keep the source #' diff --git a/man/isFALSE.Rd b/man/isFALSE.Rd index a9074fe..d2395d3 100644 --- a/man/isFALSE.Rd +++ b/man/isFALSE.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/utils.R \name{isFALSE} \alias{isFALSE} -\title{Test if an object is identical to \code{FALSE}} +\title{Test if an object is \code{FALSE}} \usage{ isFALSE(x) } @@ -10,11 +10,21 @@ isFALSE(x) \item{x}{An R object.} } \description{ -A simple abbreviation of \code{identical(x, FALSE)}. +For R versions lower than 3.5.0, this function is a simple abbreviation of +\code{identical(x, FALSE)}. For higher R versions, this function calls +\code{base::isFALSE()}. } -\examples{ +\note{ +This function will be deprecated in the future. We recommend that you + use \code{base::\link[base]{isFALSE}()} instead. If you have to support R + versions lower than 3.5.0, you may use \code{identical(x, FALSE)}, but + please note that it is not equivalent to \code{base::isFALSE()}. +} +\examples{\dontshow{if (getRversion() < '3.5.0') (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} library(xfun) isFALSE(TRUE) # false isFALSE(FALSE) # true isFALSE(c(FALSE, FALSE)) # false +\dontshow{\}) # examplesIf} } +\keyword{internal}