diff --git a/DESCRIPTION b/DESCRIPTION index 197b838b..69a7fcb2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -74,5 +74,5 @@ Config/Needs/coverage: covr Config/Needs/website: pkgdown, tidyverse/tidytemplate Encoding: UTF-8 Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.1 SystemRequirements: pandoc (>= 1.14) - http://pandoc.org diff --git a/NAMESPACE b/NAMESPACE index ffa962c8..eb504ac3 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -2,13 +2,20 @@ S3method(format,learnr_available_tutorials) S3method(format,mock_exercise) +S3method(format,shiny_selector) +S3method(format,shiny_selector_list) S3method(format,tutorial_exercise) S3method(format,tutorial_question) S3method(format,tutorial_question_answer) S3method(format,tutorial_quiz) S3method(knit_print,tutorial_question) S3method(knit_print,tutorial_quiz) +S3method(mutate_tags,default) +S3method(mutate_tags,list) +S3method(mutate_tags,shiny.tag) S3method(print,learnr_available_tutorials) +S3method(print,shiny_selector) +S3method(print,shiny_selector_list) S3method(print,tutorial_exercise) S3method(print,tutorial_question) S3method(print,tutorial_question_answer) diff --git a/R/html_selector.R b/R/html_selector.R index 165229f7..c86f8f55 100644 --- a/R/html_selector.R +++ b/R/html_selector.R @@ -46,6 +46,7 @@ as_selector_list <- function(selector) { selector } +#' @export format.shiny_selector <- function(x, ...) { if (x$match_everything) { paste0("* // match everything") @@ -53,14 +54,19 @@ format.shiny_selector <- function(x, ...) { paste0(x$element, if (!is.null(x$id)) paste0("#", x$id), paste0(".", x$classes, collapse = "")) } } + +#' @export format.shiny_selector_list <- function(x, ...) { paste0(unlist(lapply(x, format, ...)), collapse = " ") } +#' @export print.shiny_selector <- function(x, ...) { cat("// css selector\n") cat(format(x, ...), "\n") } + +#' @export print.shiny_selector_list <- function(x, ...) { cat("// css selector list\n") cat(format(x, ...), "\n") diff --git a/R/mutate_tags.R b/R/mutate_tags.R index 8de83005..25b94c43 100644 --- a/R/mutate_tags.R +++ b/R/mutate_tags.R @@ -10,6 +10,7 @@ mutate_tags <- function(ele, selector, fn, ...) { UseMethod("mutate_tags", ele) } +#' @export mutate_tags.default <- function(ele, selector, fn, ...) { if (any( c( @@ -31,6 +32,7 @@ mutate_tags.default <- function(ele, selector, fn, ...) { ) } +#' @export mutate_tags.list <- function(ele, selector, fn, ...) { # set values to maintain attrs and class values ele[] <- lapply( @@ -42,6 +44,7 @@ mutate_tags.list <- function(ele, selector, fn, ...) { ele } +#' @export mutate_tags.shiny.tag <- function(ele, selector, fn, ...) { # # vectorize selector. (Currently not used, so removed) # if (inherits(selector, "character")) {