Skip to content

Commit 2f553eb

Browse files
authored
Merge branch 'main' into 333_deprecate_datanames@main
Signed-off-by: André Veríssimo <[email protected]>
2 parents faa843b + 622cb09 commit 2f553eb

File tree

5 files changed

+6
-123
lines changed

5 files changed

+6
-123
lines changed

NAMESPACE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export(get_env)
1818
export(get_var)
1919
export(get_warnings)
2020
export(join)
21-
export(new_qenv)
2221
export(qenv)
2322
exportClasses(qenv)
2423
exportMethods(show)

NEWS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
### Breaking Change
1212

13-
* `qenv` objects should now be created with `qenv()` rather than `new_qenv()`. The new constructor always creates an empty object. `new_qenv` is now deprecated.
13+
* `qenv` objects should now be created with `qenv()` rather than `new_qenv()` (which has been removed). The new constructor always creates an empty object.
1414

1515
### Miscellaneous
1616

R/qenv-constructor.R

Lines changed: 2 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -10,38 +10,11 @@
1010
#' `qenv()` instantiates a `qenv` with an empty environment.
1111
#' Any changes must be made by evaluating code in it with `eval_code` or `within`, thereby ensuring reproducibility.
1212
#'
13-
#'
14-
#' `new_qenv()` (`r badge("deprecated")` and not recommended)
15-
#' can instantiate a `qenv` object with data in the environment and code registered.
16-
#'
17-
#' @section Extracting objects from `qenv`:
18-
#'
19-
#' Extracting an object from the `qenv` by name can be done using the following methods:
20-
#'
21-
#' - `x[[name]]`
22-
#' - `x$name`
23-
#' - `get(name, envir = x)`
24-
#'
25-
#' note: `get_var(name)` was superseded by the native \R methods above.
26-
#'
27-
#' To list all objects in the environment, use `ls(x)` (which doesn't show
28-
#' objects that have a dot prefix with default arguments) or `names(x)` (shows all objects).
29-
#'
30-
#' @section Environment:
31-
#'
32-
#' The `qenv` object behaves like an environment that is locked and one can use
33-
#' some of the `base` functions dedicated to the `environment`. List of supported
34-
#' functions includes:
35-
#' `names()`, `ls()`, `get()`, `exists()`, `parent.env()`, `lapply`, `sapply`
36-
#' `vapply`, `local`, `as.environment()`, `is.environment()`, `as.list()`, ...
37-
#' We don't recommend using any function outside of the `teal.code` exports and these
38-
#' mentioned above.
39-
#'
40-
#'
4113
#' @name qenv
4214
#'
43-
#' @return `qenv` and `new_qenv` return a `qenv` object.
15+
#' @return Returns a `qenv` object.
4416
#'
17+
#' @seealso [`base::within()`], [`get_var()`], [`get_env()`], [`get_warnings()`], [`join()`], [`concat()`]
4518
#' @examples
4619
#' # create empty qenv
4720
#' qenv()
@@ -50,72 +23,3 @@
5023
qenv <- function() {
5124
methods::new("qenv")
5225
}
53-
54-
#' @param code `r badge("deprecated")`
55-
#' (`character(1)` or `language`) code to evaluate. Accepts and stores comments also.
56-
#' @param env `r badge("deprecated")` (`environment`)
57-
#' Environment being a result of the `code` evaluation.
58-
#'
59-
#' @examples
60-
#' # create qenv with data and code (deprecated)
61-
#' new_qenv(env = list2env(list(a = 1)), code = quote(a <- 1))
62-
#' new_qenv(env = list2env(list(a = 1)), code = parse(text = "a <- 1", keep.source = TRUE))
63-
#' new_qenv(env = list2env(list(a = 1)), code = "a <- 1")
64-
#'
65-
#' @rdname qenv
66-
#' @aliases new_qenv,environment,expression-method
67-
#' @aliases new_qenv,environment,character-method
68-
#' @aliases new_qenv,environment,language-method
69-
#' @aliases new_qenv,environment,missing-method
70-
#' @aliases new_qenv,missing,missing-method
71-
#'
72-
#' @seealso [`base::within()`], [`get_var()`], [`get_env()`], [`get_warnings()`], [`join()`], [`concat()`]
73-
#'
74-
#' @export
75-
setGeneric("new_qenv", function(env = new.env(parent = parent.env(.GlobalEnv)), code = character()) {
76-
lifecycle::deprecate_warn(when = " 0.5.0", what = "new_qenv()", with = "qenv()", always = TRUE)
77-
standardGeneric("new_qenv")
78-
})
79-
80-
setMethod(
81-
"new_qenv",
82-
signature = c(env = "environment", code = "expression"),
83-
function(env, code) {
84-
new_qenv(env, paste(lang2calls(code), collapse = "\n"))
85-
}
86-
)
87-
88-
setMethod(
89-
"new_qenv",
90-
signature = c(env = "environment", code = "character"),
91-
function(env, code) {
92-
new_env <- rlang::env_clone(env, parent = parent.env(.GlobalEnv))
93-
lockEnvironment(new_env, bindings = TRUE)
94-
if (length(code) > 0) code <- paste(code, collapse = "\n")
95-
id <- sample.int(.Machine$integer.max, size = length(code))
96-
methods::new(
97-
"qenv",
98-
.xData = new_env,
99-
code = code,
100-
warnings = rep("", length(code)),
101-
messages = rep("", length(code)),
102-
id = id
103-
)
104-
}
105-
)
106-
107-
setMethod(
108-
"new_qenv",
109-
signature = c(env = "environment", code = "language"),
110-
function(env, code) {
111-
new_qenv(env = env, code = paste(lang2calls(code), collapse = "\n"))
112-
}
113-
)
114-
115-
setMethod(
116-
"new_qenv",
117-
signature = c(code = "missing", env = "missing"),
118-
function(env, code) {
119-
new_qenv(env = env, code = code)
120-
}
121-
)

_pkgdown.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ reference:
3434
- get_var
3535
- get_warnings
3636
- join
37-
- new_qenv
3837
- qenv
3938
- show,qenv-method
4039
- within.qenv

man/qenv.Rd

Lines changed: 3 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)