Skip to content

Commit 2ccaf40

Browse files
committed
same for guides
1 parent 54f5ecf commit 2ccaf40

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

R/guides-.R

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -915,8 +915,19 @@ include_layer_in_guide <- function(layer, matched) {
915915
validate_guide <- function(guide) {
916916
# if guide is specified by character, then find the corresponding guide
917917
if (is.character(guide)) {
918-
fun <- find_global(paste0("guide_", guide), env = global_env(),
919-
mode = "function")
918+
check_string(guide, allow_empty = FALSE)
919+
search_env <- list(global_env())
920+
if (isTRUE(grepl("::", guide))) {
921+
# Append prefix as namespaces to search environments
922+
prefix <- sub("::.*", "", guide)
923+
search_env <- c(search_env, list(asNamespace(prefix)))
924+
# Remove prefix from guide name
925+
guide <- sub(".*::", "", guide)
926+
}
927+
fun <- find_global(
928+
paste0("guide_", guide),
929+
env = search_env, mode = "function"
930+
)
920931
if (is.function(fun)) {
921932
guide <- fun()
922933
}

0 commit comments

Comments
 (0)