File tree Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Original file line number Diff line number Diff line change 68
68
# ' }
69
69
guides <- function (... ) {
70
70
args <- list2(... )
71
- if (length( args ) > 0 ) {
72
- if (is.list (args [[ 1 ]]) && ! is.guide( args [[ 1 ]])) args <- args [[ 1 ]]
73
- args <- rename_aes( args )
71
+ # If there are no guides do nothing
72
+ if (length (args ) == 0 ) {
73
+ return ( NULL )
74
74
}
75
75
76
+ if (is.list(args [[1 ]]) && ! inherits(args [[1 ]], " guide" )) args <- args [[1 ]]
77
+ args <- rename_aes(args )
78
+
76
79
idx_false <- vapply(args , isFALSE , FUN.VALUE = logical (1L ))
77
80
if (isTRUE(any(idx_false ))) {
78
81
deprecate_warn0(" 3.3.4" , " guides(`<scale>` = 'cannot be `FALSE`. Use \" none\" instead')" )
@@ -84,11 +87,6 @@ guides <- function(...) {
84
87
return (guides_list(guides = args ))
85
88
}
86
89
87
- # If there are no guides, do nothing
88
- if (length(args ) == 0 ) {
89
- return (NULL )
90
- }
91
-
92
90
# Raise warning about unnamed guides
93
91
nms <- names(args )
94
92
if (is.null(nms )) {
Original file line number Diff line number Diff line change @@ -577,12 +577,16 @@ test_that("old S3 guides can be implemented", {
577
577
578
578
withr :: local_environment(my_env )
579
579
580
+ my_guides <- guides(x = guide_circle())
581
+ expect_length(my_guides $ guides , 1 )
582
+ expect_s3_class(my_guides $ guides [[1 ]], " guide" )
583
+
580
584
expect_snapshot_warning(
581
585
expect_doppelganger(
582
586
" old S3 guide drawing a circle" ,
583
587
ggplot(mtcars , aes(disp , mpg )) +
584
588
geom_point() +
585
- guides( x = " circle " )
589
+ my_guides
586
590
)
587
591
)
588
592
})
You can’t perform that action at this time.
0 commit comments