From cce80dbd0aac4f3495ce30001e0fa6f759de204c Mon Sep 17 00:00:00 2001 From: kenomersmannPC Date: Wed, 2 Oct 2024 13:37:49 +0200 Subject: [PATCH] docs: small changes + added .dicts_suggest for dictionary_sugar_inc_get --- R/dictionary_sugar.R | 9 +++++++-- man/dictionary_sugar_get.Rd | 3 ++- man/dictionary_sugar_inc_get.Rd | 3 +++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/R/dictionary_sugar.R b/R/dictionary_sugar.R index 6bef1ff4..6ddd64ae 100644 --- a/R/dictionary_sugar.R +++ b/R/dictionary_sugar.R @@ -25,15 +25,18 @@ #' @param ... (`any`)\cr #' See description. #' @param .dicts_suggest (named [`list`]) -#' Named list of [dictionaries][Dictionary] used to look up suggestions for `.key` in cases of misspelling. +#' Named list of [dictionaries][Dictionary] used to look up suggestions for `.key` if `.key` does not exist in `dict`. +#' #' @return [R6::R6Class()] -#' @export +#' #' @examples #' library(R6) #' item = R6Class("Item", public = list(x = 0)) #' d = Dictionary$new() #' d$add("key", item) #' dictionary_sugar_get(d, "key", x = 2) +#' +#' @export dictionary_sugar_get = function(dict, .key, ..., .dicts_suggest = NULL) { assert_class(dict, "Dictionary") if (missing(.key)) { @@ -148,6 +151,8 @@ fields = function(x) { #' Keys of the objects to construct - possibly with suffixes of the form `_` which will be appended to the ids. #' @param ... (any)\cr #' See description of [mlr3misc::dictionary_sugar]. +#' @param .dicts_suggest (named [`list`]) +#' Named list of [dictionaries][Dictionary] used to look up suggestions for `.key` if `.key` does not exist in `dict`. #' #' @return An element from the dictionary. #' diff --git a/man/dictionary_sugar_get.Rd b/man/dictionary_sugar_get.Rd index 4625c591..a166afa5 100644 --- a/man/dictionary_sugar_get.Rd +++ b/man/dictionary_sugar_get.Rd @@ -22,7 +22,7 @@ Key of the object to construct.} See description.} \item{.dicts_suggest}{(named \code{\link{list}}) -Named list of \link[=Dictionary]{dictionaries} used to look up suggestions for \code{.key} in cases of misspelling.} +Named list of \link[=Dictionary]{dictionaries} used to look up suggestions for \code{.key} if \code{.key} does not exist in \code{dict}.} \item{.keys}{(\code{character()})\cr Keys of the objects to construct.} @@ -56,4 +56,5 @@ item = R6Class("Item", public = list(x = 0)) d = Dictionary$new() d$add("key", item) dictionary_sugar_get(d, "key", x = 2) + } diff --git a/man/dictionary_sugar_inc_get.Rd b/man/dictionary_sugar_inc_get.Rd index 0b318527..520f49e3 100644 --- a/man/dictionary_sugar_inc_get.Rd +++ b/man/dictionary_sugar_inc_get.Rd @@ -19,6 +19,9 @@ Key of the object to construct - possibly with a suffix of the form \verb{_} \item{...}{(any)\cr See description of \link{dictionary_sugar}.} +\item{.dicts_suggest}{(named \code{\link{list}}) +Named list of \link[=Dictionary]{dictionaries} used to look up suggestions for \code{.key} if \code{.key} does not exist in \code{dict}.} + \item{.keys}{(\code{character()})\cr Keys of the objects to construct - possibly with suffixes of the form \verb{_} which will be appended to the ids.} }