Skip to content

Commit 6632574

Browse files
committed
remove build_ggplot() in favour of ggplot_build()
1 parent 0f7d790 commit 6632574

File tree

3 files changed

+12
-29
lines changed

3 files changed

+12
-29
lines changed

NAMESPACE

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ S3method(fortify,tbl_df)
5959
S3method(ggplot,"function")
6060
S3method(ggplot,default)
6161
S3method(ggplot_add,default)
62-
S3method(ggplot_build,default)
6362
S3method(ggplot_gtable,default)
6463
S3method(grid.draw,absoluteGrob)
6564
S3method(grobHeight,absoluteGrob)
@@ -292,7 +291,6 @@ export(autoplot)
292291
export(benchplot)
293292
export(binned_scale)
294293
export(borders)
295-
export(build_ggplot)
296294
export(calc_element)
297295
export(check_device)
298296
export(class_ggplot)

R/plot-build.R

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,19 @@
2525
#' The `r link_book("build step section", "internals#sec-ggplotbuild")`
2626
#' @keywords internal
2727
#' @export
28-
build_ggplot <- S7::new_generic("build_ggplot", "plot", fun = function(plot, ...) {
28+
ggplot_build <- function(plot, ...) {
2929
env <- try_prop(plot, "plot_env")
3030
if (!is.null(env)) {
3131
attach_plot_env(env)
3232
}
33-
S7::S7_dispatch()
34-
})
33+
UseMethod("ggplot_build")
34+
}
3535

36-
S7::method(build_ggplot, class_ggplot_built) <- function(plot, ...) {
36+
S7::method(ggplot_build, class_ggplot_built) <- function(plot, ...) {
3737
plot # This is a no-op
3838
}
3939

40-
S7::method(build_ggplot, class_ggplot) <- function(plot, ...) {
40+
S7::method(ggplot_build, class_ggplot) <- function(plot, ...) {
4141
plot <- plot_clone(plot)
4242
if (length(plot@layers) == 0) {
4343
plot <- plot + geom_blank()
@@ -136,29 +136,17 @@ S7::method(build_ggplot, class_ggplot) <- function(plot, ...) {
136136
build
137137
}
138138

139-
# TODO: the S3 generic should be phased out once S7 is adopted more widely
140-
#' @rdname build_ggplot
141-
#' @export
142-
ggplot_build <- function(plot, ...) {
143-
UseMethod("ggplot_build")
144-
}
145-
146-
#' @export
147-
ggplot_build.default <- function(plot, ...) {
148-
build_ggplot(plot)
149-
}
150-
151139
#' @export
152-
#' @rdname build_ggplot
140+
#' @rdname ggplot_build
153141
get_layer_data <- function(plot = get_last_plot(), i = 1L) {
154142
ggplot_build(plot)@data[[i]]
155143
}
156144
#' @export
157-
#' @rdname build_ggplot
145+
#' @rdname ggplot_build
158146
layer_data <- get_layer_data
159147

160148
#' @export
161-
#' @rdname build_ggplot
149+
#' @rdname ggplot_build
162150
get_panel_scales <- function(plot = get_last_plot(), i = 1L, j = 1L) {
163151
b <- ggplot_build(plot)
164152

@@ -172,19 +160,19 @@ get_panel_scales <- function(plot = get_last_plot(), i = 1L, j = 1L) {
172160
}
173161

174162
#' @export
175-
#' @rdname build_ggplot
163+
#' @rdname ggplot_build
176164
layer_scales <- get_panel_scales
177165

178166
#' @export
179-
#' @rdname build_ggplot
167+
#' @rdname ggplot_build
180168
get_layer_grob <- function(plot = get_last_plot(), i = 1L) {
181169
b <- ggplot_build(plot)
182170

183171
b@plot@layers[[i]]$draw_geom(b@data[[i]], b@layout)
184172
}
185173

186174
#' @export
187-
#' @rdname build_ggplot
175+
#' @rdname ggplot_build
188176
layer_grob <- get_layer_grob
189177

190178
#' Build a plot with all the usual bits and pieces.

man/build_ggplot.Rd renamed to man/ggplot_build.Rd

Lines changed: 1 addition & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)