From e083fbed8c1a4badd0933bdd52d69687497e46d1 Mon Sep 17 00:00:00 2001 From: Hadley Wickham Date: Wed, 4 Sep 2024 20:37:01 +0100 Subject: [PATCH] Provide `.dollarNames` method (#289) * Provide `.dollarNames` method In order to not show non-user facing methods in autocomplete * `devtools::document()` (GitHub Actions) * Update NEWS.md Co-authored-by: Davis Vaughan --------- Co-authored-by: hadley Co-authored-by: Winston Chang Co-authored-by: Davis Vaughan --- DESCRIPTION | 2 +- NAMESPACE | 1 + NEWS.md | 2 ++ R/r6_class.R | 6 ++++++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 589ec22..43c7899 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -22,4 +22,4 @@ Suggests: Config/Needs/website: tidyverse/tidytemplate, ggplot2, microbenchmark, scales Config/testthat/edition: 3 Encoding: UTF-8 -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.2 diff --git a/NAMESPACE b/NAMESPACE index b252431..b78d9e7 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,5 +1,6 @@ # Generated by roxygen2: do not edit by hand +S3method(.DollarNames,R6) S3method(as.list,R6) S3method(format,R6) S3method(format,R6ClassGenerator) diff --git a/NEWS.md b/NEWS.md index 01c085e..f047ce3 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,8 @@ R6 2.5.1.9000 ======== +* R6 methods no longer recommends `initialize` or `.__enclos_env__` in autocomplete. + * The deprecated `lock` parameter has been removed. * `R6Class()` now prints a message when a `finalize` method is public instead of private. diff --git a/R/r6_class.R b/R/r6_class.R index 5aaf8f7..e35eb2b 100644 --- a/R/r6_class.R +++ b/R/r6_class.R @@ -541,3 +541,9 @@ R6Class <- encapsulate(function(classname = NULL, public = list(), generator }) + +#' @export +.DollarNames.R6 <- function(x, pattern) { + names <- NextMethod() + names <- setdiff(names, c(".__enclos_env__", "initialize")) +}