From bd5feac80cee3ccd3676ec5e80f856ae40618d2e Mon Sep 17 00:00:00 2001 From: Aleksander Chlebowski Date: Wed, 6 Mar 2024 16:45:30 +0100 Subject: [PATCH 1/6] add function remove_aliases --- R/remove_aliases.R | 37 +++++++++++++++++++++++++++++++++++++ man/remove_aliases.Rd | 18 ++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 R/remove_aliases.R create mode 100644 man/remove_aliases.Rd diff --git a/R/remove_aliases.R b/R/remove_aliases.R new file mode 100644 index 000000000..2fbdfb033 --- /dev/null +++ b/R/remove_aliases.R @@ -0,0 +1,37 @@ + +#' Remove aliases from package index. +#' +#' Removes entries from package index page that list aliases of topics given in `names`. +#' +#' @param names (`character`) names of objects for which to remove aliases +#' +#' @return Invisible `TRUE` if operation succeded, invisible `FALSE` otherwise. +#' +#' @keywords internal +#' +remove_aliases <- function(names) { + checkmate::assert_character(names) + + index_file <- system.file("html", "00Index.html", package = "teal.slice") + + if (identical(index_file, "") || !isTRUE(utils::file_test("-w", index_file))) return(invisible(FALSE)) + + index_contents <- readLines(index_file) + + indices <- as.list( + lapply(names, function(name) { + intersect( + grep(sprintf("", name), index_contents), + grep(sprintf("%s", name), index_contents, invert = TRUE) + ) + }) + ) + + ind <- Reduce(union, indices) + if (identical(ind, integer(0L))) return(invisible(TRUE)) + ind <- c(ind, ind + 1L) + index_contents <- index_contents[-ind] + + writeLines(index_contents, index_file) + invisible(TRUE) +} diff --git a/man/remove_aliases.Rd b/man/remove_aliases.Rd new file mode 100644 index 000000000..3c4d7440f --- /dev/null +++ b/man/remove_aliases.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/remove_aliases.R +\name{remove_aliases} +\alias{remove_aliases} +\title{Remove aliases from package index.} +\usage{ +remove_aliases(names) +} +\arguments{ +\item{names}{(\code{character}) names of objects for which to remove aliases} +} +\value{ +Invisible \code{TRUE} if operation succeded, invisible \code{FALSE} otherwise. +} +\description{ +Removes entries from package index page that list aliases of topics given in \code{names}. +} +\keyword{internal} From c6b5623b9d7a4155f97c6d10d9c0aec5cd964a6f Mon Sep 17 00:00:00 2001 From: Aleksander Chlebowski Date: Wed, 6 Mar 2024 16:45:49 +0100 Subject: [PATCH 2/6] add remove_aliases to loading hook --- R/zzz.R | 2 ++ 1 file changed, 2 insertions(+) diff --git a/R/zzz.R b/R/zzz.R index 6fcd671db..21743d729 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -8,6 +8,8 @@ # Set up the teal logger instance teal.logger::register_logger("teal.slice") + remove_aliases(c("teal_slice", "teal_slices", "filter_state_api")) + invisible() } From f151906fe2dbb30e49bf479a95aa62313378a9d9 Mon Sep 17 00:00:00 2001 From: Aleksander Chlebowski Date: Wed, 6 Mar 2024 16:46:20 +0100 Subject: [PATCH 3/6] remove keywords internal --- R/teal_slice.R | 5 ----- R/teal_slices.R | 7 ------- man/teal_slice.Rd | 1 - man/teal_slices.Rd | 1 - 4 files changed, 14 deletions(-) diff --git a/R/teal_slice.R b/R/teal_slice.R index 1c65284eb..b9867c632 100644 --- a/R/teal_slice.R +++ b/R/teal_slice.R @@ -174,7 +174,6 @@ teal_slice <- function(dataname, #' @rdname teal_slice #' @export -#' @keywords internal #' is.teal_slice <- function(x) { # nolint inherits(x, "teal_slice") @@ -182,7 +181,6 @@ is.teal_slice <- function(x) { # nolint #' @rdname teal_slice #' @export -#' @keywords internal #' as.teal_slice <- function(x) { # nolint checkmate::assert_list(x, names = "named") @@ -191,7 +189,6 @@ as.teal_slice <- function(x) { # nolint #' @rdname teal_slice #' @export -#' @keywords internal #' as.list.teal_slice <- function(x, ...) { formal_args <- setdiff(names(formals(teal_slice)), "...") @@ -211,7 +208,6 @@ as.list.teal_slice <- function(x, ...) { #' @rdname teal_slice #' @export -#' @keywords internal #' format.teal_slice <- function(x, show_all = FALSE, trim_lines = TRUE, ...) { checkmate::assert_flag(show_all) @@ -225,7 +221,6 @@ format.teal_slice <- function(x, show_all = FALSE, trim_lines = TRUE, ...) { #' @rdname teal_slice #' @export -#' @keywords internal #' print.teal_slice <- function(x, ...) { cat(format(x, ...)) diff --git a/R/teal_slices.R b/R/teal_slices.R index 7fb9161c0..505fae7b7 100644 --- a/R/teal_slices.R +++ b/R/teal_slices.R @@ -129,7 +129,6 @@ teal_slices <- function(..., #' @rdname teal_slices #' @export -#' @keywords internal #' is.teal_slices <- function(x) { # nolint inherits(x, "teal_slices") @@ -138,7 +137,6 @@ is.teal_slices <- function(x) { # nolint #' @rdname teal_slices #' @export -#' @keywords internal #' as.teal_slices <- function(x) { # nolint checkmate::assert_list(x) @@ -152,7 +150,6 @@ as.teal_slices <- function(x) { # nolint #' @rdname teal_slices #' @export -#' @keywords internal #' as.list.teal_slices <- function(x, recursive = FALSE, ...) { # nolint ans <- unclass(x) @@ -163,7 +160,6 @@ as.list.teal_slices <- function(x, recursive = FALSE, ...) { # nolint #' @rdname teal_slices #' @export -#' @keywords internal #' `[.teal_slices` <- function(x, i) { if (missing(i)) i <- seq_along(x) @@ -187,7 +183,6 @@ as.list.teal_slices <- function(x, recursive = FALSE, ...) { # nolint #' @rdname teal_slices #' @export -#' @keywords internal #' c.teal_slices <- function(...) { x <- list(...) @@ -211,7 +206,6 @@ c.teal_slices <- function(...) { #' @param show_all (`logical(1)`) whether to display non-null elements of constituent `teal_slice` objects #' @param trim_lines (`logical(1)`) whether to trim lines #' @export -#' @keywords internal #' format.teal_slices <- function(x, show_all = FALSE, trim_lines = TRUE, ...) { checkmate::assert_flag(show_all) @@ -230,7 +224,6 @@ format.teal_slices <- function(x, show_all = FALSE, trim_lines = TRUE, ...) { #' @rdname teal_slices #' @export -#' @keywords internal #' print.teal_slices <- function(x, ...) { cat(format(x, ...), "\n") diff --git a/man/teal_slice.Rd b/man/teal_slice.Rd index 36fcb0196..7dcefefe8 100644 --- a/man/teal_slice.Rd +++ b/man/teal_slice.Rd @@ -171,4 +171,3 @@ print(x1, show_all = TRUE, trim_lines = FALSE) \seealso{ \code{\link{teal_slices}} } -\keyword{internal} diff --git a/man/teal_slices.Rd b/man/teal_slices.Rd index 0e931d40b..017d8b7f0 100644 --- a/man/teal_slices.Rd +++ b/man/teal_slices.Rd @@ -137,4 +137,3 @@ print(all_filters, trim_lines = FALSE) \item \code{\link[teal:slices_store]{teal::slices_store}} for robust utilities for saving and loading \code{teal_slices} in \code{JSON} format } } -\keyword{internal} From b50af8315693e9288beed670f68d6a9a2027764d Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 6 Mar 2024 16:10:16 +0000 Subject: [PATCH 4/6] [skip style] [skip vbump] Restyle files --- R/remove_aliases.R | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/R/remove_aliases.R b/R/remove_aliases.R index 2fbdfb033..0552af0f0 100644 --- a/R/remove_aliases.R +++ b/R/remove_aliases.R @@ -1,4 +1,3 @@ - #' Remove aliases from package index. #' #' Removes entries from package index page that list aliases of topics given in `names`. @@ -14,7 +13,9 @@ remove_aliases <- function(names) { index_file <- system.file("html", "00Index.html", package = "teal.slice") - if (identical(index_file, "") || !isTRUE(utils::file_test("-w", index_file))) return(invisible(FALSE)) + if (identical(index_file, "") || !isTRUE(utils::file_test("-w", index_file))) { + return(invisible(FALSE)) + } index_contents <- readLines(index_file) @@ -28,7 +29,9 @@ remove_aliases <- function(names) { ) ind <- Reduce(union, indices) - if (identical(ind, integer(0L))) return(invisible(TRUE)) + if (identical(ind, integer(0L))) { + return(invisible(TRUE)) + } ind <- c(ind, ind + 1L) index_contents <- index_contents[-ind] From 94c7b7980bf8dfe0c73321c5b96bf5e27d711ce6 Mon Sep 17 00:00:00 2001 From: Aleksander Chlebowski Date: Thu, 7 Mar 2024 14:07:51 +0100 Subject: [PATCH 5/6] hide some functions in pkgdown reference --- _pkgdown.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/_pkgdown.yml b/_pkgdown.yml index 5dd0529d2..25d97fdac 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -24,14 +24,15 @@ reference: - title: "`teal` filter-panel API" desc: "Functions used initialize filter-panel and to modify its states." contents: - - init_filtered_data - - set_filter_state - - get_filter_state - - get_filter_expr - - remove_filter_state - - clear_filter_states - teal_slice - teal_slices + - init_filtered_data + - get_filter_expr + - title: "internal" + contents: + - ends_with("_filter_state") + - ends_with(".teal_slice") + - ends_with(".teal_slices") - title: "For developers" subtitle: "R6 Classes" desc: "Abstract and concrete classes used to build teal functionality." From bc81ccbeeb5b2d01300360842ceb3ef7cccce064 Mon Sep 17 00:00:00 2001 From: Aleksander Chlebowski Date: Thu, 7 Mar 2024 14:16:58 +0100 Subject: [PATCH 6/6] spelling --- R/remove_aliases.R | 2 +- man/remove_aliases.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/remove_aliases.R b/R/remove_aliases.R index 0552af0f0..6bb252c19 100644 --- a/R/remove_aliases.R +++ b/R/remove_aliases.R @@ -4,7 +4,7 @@ #' #' @param names (`character`) names of objects for which to remove aliases #' -#' @return Invisible `TRUE` if operation succeded, invisible `FALSE` otherwise. +#' @return Invisible `TRUE` if operation succeeded, invisible `FALSE` otherwise. #' #' @keywords internal #' diff --git a/man/remove_aliases.Rd b/man/remove_aliases.Rd index 3c4d7440f..241aca3d6 100644 --- a/man/remove_aliases.Rd +++ b/man/remove_aliases.Rd @@ -10,7 +10,7 @@ remove_aliases(names) \item{names}{(\code{character}) names of objects for which to remove aliases} } \value{ -Invisible \code{TRUE} if operation succeded, invisible \code{FALSE} otherwise. +Invisible \code{TRUE} if operation succeeded, invisible \code{FALSE} otherwise. } \description{ Removes entries from package index page that list aliases of topics given in \code{names}.