Skip to content

Commit 921dc19

Browse files
authored
Merge pull request #64 from r-lib/f-43-deprecate
- `thisfile()` and related functions are soft-deprecated, now available in the whereami package (#43).
2 parents 2caf667 + 297a26d commit 921dc19

20 files changed

+66
-68
lines changed

DESCRIPTION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Imports:
2020
backports
2121
Suggests:
2222
knitr,
23+
lifecycle,
2324
mockr,
2425
rmarkdown,
2526
testthat,

NAMESPACE

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
# Generated by roxygen2: do not edit by hand
22

33
S3method("|",root_criterion)
4-
S3method(as.root_criterion,default)
54
S3method(as_root_criterion,character)
65
S3method(as_root_criterion,default)
76
S3method(as_root_criterion,root_criterion)
87
S3method(format,root_criterion)
98
S3method(print,root_criterion)
109
S3method(str,root_criteria)
11-
export(as.root_criterion)
1210
export(as_root_criterion)
1311
export(criteria)
1412
export(find_package_root_file)
@@ -23,7 +21,6 @@ export(has_basename)
2321
export(has_dir)
2422
export(has_file)
2523
export(has_file_pattern)
26-
export(is.root_criterion)
2724
export(is_drake_project)
2825
export(is_git_root)
2926
export(is_projectile_project)

R/criterion.R

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -116,27 +116,12 @@ is_root_criterion <- function(x) {
116116
inherits(x, "root_criterion")
117117
}
118118

119-
#' @rdname deprecated
120-
#' @inheritParams is_root_criterion
121-
#' @export
122-
is.root_criterion <- function(x) {
123-
.Deprecated("is_root_criterion")
124-
is_root_criterion(x)
125-
}
126-
127119
#' @rdname root_criterion
128120
#' @export
129121
as_root_criterion <- function(x) UseMethod("as_root_criterion", x)
130122

131-
#' @rdname deprecated
132-
#' @export
133-
as.root_criterion <- function(x) {
134-
.Deprecated("as_root_criterion")
135-
UseMethod("as.root_criterion", x)
136-
}
137-
138123
#' @details
139-
#' The `as.root_criterion()` function accepts objects of class
124+
#' The `as_root_criterion()` function accepts objects of class
140125
#' `root_criterion`, and character values; the latter will be
141126
#' converted to criteria using `has_file`.
142127
#'
@@ -155,11 +140,6 @@ as_root_criterion.default <- function(x) {
155140
stop("Cannot coerce ", x, " to type root_criterion.", call. = FALSE)
156141
}
157142

158-
#' @export
159-
as.root_criterion.default <- function(x) {
160-
as_root_criterion(x)
161-
}
162-
163143
#' @export
164144
format.root_criterion <- function(x, ...) {
165145
if (length(x$desc) > 1) {

R/deprecated.R

Lines changed: 0 additions & 11 deletions
This file was deleted.

R/rprojroot-package.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#' @details
22
#' See the "Value" section in [root_criterion()] for documentation
3-
#' of root criterion objects, and [criteria()] for useful predefined
3+
#' of root criterion objects, and [criteria] for useful predefined
44
#' root criteria.
55
#'
66
#' @examples
@@ -11,5 +11,4 @@
1111
#' root_fun("NAMESPACE")
1212
#' }
1313
#' @import backports
14-
#' @api
1514
"_PACKAGE"

R/thisfile.R

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
#' @title Determines the path of the currently running script
2-
#' @description \R does not store nor export the path of the currently running
1+
#' Determines the path of the currently running script
2+
#'
3+
#' @description
4+
#' `r lifecycle::badge("soft-deprecated")`
5+
#'
6+
#' \R does not store nor export the path of the currently running
37
#' script. This is an attempt to circumvent this limitation by applying
48
#' heuristics (such as call stack and argument inspection) that work in many
59
#' cases.
@@ -12,17 +16,29 @@
1216
#' or run with `Rscript` or using the `--file` parameter to the
1317
#' `R` executable. For code run with `Rscript`, the exact value
1418
#' of the parameter passed to `Rscript` is returned.
19+
#'
20+
#' @section Life cycle:
21+
#'
22+
#' These functions are now available in the \pkg{whereami} package.
23+
#'
1524
#' @return The path of the currently running script, NULL if it cannot be
1625
#' determined.
1726
#' @seealso [base::source()], [utils::Rscript()], [base::getwd()]
1827
#' @references [https://stackoverflow.com/q/1815606/946850]()
1928
#' @author Kirill Müller, Hadley Wickham, Michael R. Head
29+
#' @keywords internal
2030
#' @examples
2131
#' \dontrun{
2232
#' thisfile()
2333
#' }
2434
#' @export
2535
thisfile <- function() {
36+
lifecycle::deprecate_soft(
37+
"2.0.0",
38+
"rprojroot::thisfile()",
39+
"whereami::thisfile()"
40+
)
41+
2642
if (!is.null(res <- thisfile_source())) {
2743
res
2844
} else if (!is.null(res <- thisfile_r())) {
@@ -39,6 +55,12 @@ thisfile <- function() {
3955
#' @rdname thisfile
4056
#' @export
4157
thisfile_source <- function() {
58+
lifecycle::deprecate_soft(
59+
"2.0.0",
60+
"rprojroot::thisfile_source()",
61+
"whereami::thisfile_source()"
62+
)
63+
4264
for (i in -(1:sys.nframe())) {
4365
if (identical(args(sys.function(i)), args(base::source))) {
4466
return(normalizePath(sys.frame(i)$ofile))
@@ -52,6 +74,12 @@ thisfile_source <- function() {
5274
#' @importFrom utils tail
5375
#' @export
5476
thisfile_r <- function() {
77+
lifecycle::deprecate_soft(
78+
"2.0.0",
79+
"rprojroot::thisfile_r()",
80+
"whereami::thisfile_r()"
81+
)
82+
5583
cmd_args <- commandArgs(trailingOnly = FALSE)
5684
if (!grepl("^R(?:|term)(?:|[.]exe)$", basename(cmd_args[[1L]]), ignore.case = TRUE)) {
5785
return(NULL)
@@ -77,6 +105,12 @@ thisfile_r <- function() {
77105
#' @importFrom utils tail
78106
#' @export
79107
thisfile_rscript <- function() {
108+
lifecycle::deprecate_soft(
109+
"2.0.0",
110+
"rprojroot::thisfile_rscript()",
111+
"whereami::thisfile_rscript()"
112+
)
113+
80114
cmd_args <- commandArgs(trailingOnly = FALSE)
81115
if (!grepl("^R(?:term|script)(?:|[.]exe)$", basename(cmd_args[[1L]]), ignore.case = TRUE)) {
82116
return(NULL)
@@ -100,6 +134,12 @@ thisfile_rscript <- function() {
100134
#' @rdname thisfile
101135
#' @export
102136
thisfile_knit <- function() {
137+
lifecycle::deprecate_soft(
138+
"2.0.0",
139+
"rprojroot::thisfile_knit()",
140+
"whereami::thisfile_knit()"
141+
)
142+
103143
if (requireNamespace("knitr")) {
104144
return(knitr::current_input(dir = TRUE))
105145
}

man/deprecated.Rd

Lines changed: 0 additions & 26 deletions
This file was deleted.

man/figures/lifecycle-archived.svg

Lines changed: 1 addition & 0 deletions
Loading

man/figures/lifecycle-defunct.svg

Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)