Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

335 remove aliases from package index #569

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions R/remove_aliases.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#' 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 succeeded, 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("<a href=\"%s\\.html\">", name), index_contents),
grep(sprintf("<a href=\".*\\.html\">%s</a></td>", 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)
}
5 changes: 0 additions & 5 deletions R/teal_slice.R
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,13 @@ teal_slice <- function(dataname,

#' @rdname teal_slice
#' @export
#' @keywords internal
#'
is.teal_slice <- function(x) { # nolint
inherits(x, "teal_slice")
}

#' @rdname teal_slice
#' @export
#' @keywords internal
#'
as.teal_slice <- function(x) { # nolint
checkmate::assert_list(x, names = "named")
Expand All @@ -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)), "...")
Expand All @@ -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)
Expand 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, ...))
Expand Down
7 changes: 0 additions & 7 deletions R/teal_slices.R
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ teal_slices <- function(...,

#' @rdname teal_slices
#' @export
#' @keywords internal
#'
is.teal_slices <- function(x) { # nolint
inherits(x, "teal_slices")
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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(...)
Expand All @@ -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)
Expand 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")
Expand Down
2 changes: 2 additions & 0 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
13 changes: 7 additions & 6 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
18 changes: 18 additions & 0 deletions man/remove_aliases.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/teal_slice.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/teal_slices.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading