Skip to content

Commit 9ae0cb7

Browse files
committed
All constructors have ... as argument.
1 parent fda521e commit 9ae0cb7

File tree

9 files changed

+72
-33
lines changed

9 files changed

+72
-33
lines changed

R/all-classes.R

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ class_derive <- S7::new_S3_class("derive")
207207
#' @param complete A boolean value stating whether a theme is complete.
208208
#' @param validate A boolean value stating whether a theme should still be
209209
#' validated.
210+
#' @param ... Reserved for future expansion.
210211
#'
211212
#' @keywords internal
212213
#' @export
@@ -216,7 +217,7 @@ class_theme <- S7::new_class(
216217
complete = S7::class_logical,
217218
validate = S7::class_logical
218219
),
219-
constructor = function(elements, complete, validate) {
220+
constructor = function(elements, complete, validate, ...) {
220221
S7::new_object(
221222
elements,
222223
complete = complete,
@@ -234,6 +235,7 @@ class_theme <- S7::new_class(
234235
#' class is to use the [`labs()`] function.
235236
#'
236237
#' @param labels A named list.
238+
#' @param ... Reserved for future expansion.
237239
#'
238240
#' @details
239241
#' All members of `labels` are expected to be named and unique.
@@ -243,7 +245,9 @@ class_theme <- S7::new_class(
243245
#' @export
244246
class_labels <- S7::new_class(
245247
"labels", parent = class_S3_gg,
246-
constructor = function(labels) S7::new_object(labels),
248+
constructor = function(labels, ...) {
249+
S7::new_object(labels)
250+
},
247251
validator = function(self) {
248252
if (!is.list(self)) {
249253
return("labels must be a list.")
@@ -270,12 +274,13 @@ class_labels <- S7::new_class(
270274
#'
271275
#' @param x A list of quosures and constants.
272276
#' @param env An environment for symbols that are not quosures or constants.
277+
#' @param ... Reserved for future expansion.
273278
#'
274279
#' @keywords internal
275280
#' @export
276281
class_mapping <- S7::new_class(
277282
"mapping", parent = class_S3_gg,
278-
constructor = function(x, env = globalenv()) {
283+
constructor = function(x, env = globalenv(), ...) {
279284
check_object(x, is.list, "a {.cls list}")
280285
x <- lapply(x, new_aesthetic, env = env)
281286
x <- S7::new_object(x)
@@ -306,6 +311,7 @@ class_mapping <- S7::new_class(
306311
#' @param meta A list for additional metadata. This will be deprecated in the
307312
#' future.
308313
#' @param plot_env An environment.
314+
#' @param ... Reserved for future expansion.
309315
#'
310316
#' @keywords internal
311317
#' @export
@@ -325,12 +331,21 @@ class_ggplot <- S7::new_class(
325331
meta = S7::class_list,
326332
plot_env = S7::class_environment
327333
),
328-
constructor = function(data = waiver(), layers = list(), scales = NULL,
329-
guides = NULL, mapping = aes(), theme = NULL,
330-
coordinates = coord_cartesian(default = TRUE),
331-
facet = facet_null(), layout = NULL,
332-
labels = labs(), meta = list(),
333-
plot_env = parent.frame()) {
334+
constructor = function(
335+
data = waiver(),
336+
layers = list(),
337+
scales = NULL,
338+
guides = NULL,
339+
mapping = aes(),
340+
theme = NULL,
341+
coordinates = coord_cartesian(default = TRUE),
342+
facet = facet_null(),
343+
layout = NULL,
344+
labels = labs(),
345+
meta = list(),
346+
plot_env = parent.frame(),
347+
...
348+
) {
334349
S7::new_object(
335350
S7::S7_object(),
336351
data = data,
@@ -362,6 +377,7 @@ class_ggplot <- S7::new_class(
362377
#' @param data A list of plain data frames; one for each layer.
363378
#' @param layout A Layout ggproto object.
364379
#' @param plot A completed ggplot class object.
380+
#' @param ... Reserved for future expansion.
365381
#'
366382
#' @keywords internal
367383
#' @export
@@ -372,15 +388,17 @@ class_ggplot_built <- S7::new_class(
372388
layout = class_layout,
373389
plot = class_ggplot
374390
),
375-
constructor = function(data = NULL, layout = NULL, plot = NULL) {
391+
constructor = function(data = NULL, layout = NULL, plot = NULL, ...) {
376392
if (is.null(data) || is.null(layout) || is.null(plot)) {
377393
cli::cli_abort(
378394
"The {.cls ggplot_built} class should be constructed by {.fn ggplot_build}."
379395
)
380396
}
381397
S7::new_object(
382398
S7::S7_object(),
383-
data = data, layout = layout, plot = plot
399+
data = data,
400+
layout = layout,
401+
plot = plot
384402
)
385403
}
386404
)

R/margins.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#' @export
88
margin <- S7::new_class(
99
"margin", parent = S7::new_S3_class(c("simpleUnit", "unit", "unit_v2")),
10-
constructor = function(t = 0, r = 0, b = 0, l = 0, unit = "pt") {
10+
constructor = function(t = 0, r = 0, b = 0, l = 0, unit = "pt", ...) {
1111
lens <- c(length(t), length(r), length(b), length(l))
1212
if (any(lens != 1)) {
1313
incorrect <- c("t", "r", "b", "l")[lens != 1]
@@ -41,7 +41,7 @@ margin_part <- function(t = NA, r = NA, b = NA, l = NA, unit = "pt") {
4141
#' @rdname element
4242
#' @export
4343
margin_auto <- function(t = 0, r = t, b = t, l = r, unit = "pt") {
44-
margin(t = t, r = r, b = b, l = l, unit)
44+
margin(t = t, r = r, b = b, l = l, unit = unit)
4545
}
4646

4747
as_margin <- function(x, x_arg = caller_arg(x), call = caller_env()) {

R/theme-elements.R

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
#' a blank element among its parents will cause this element to be blank as
3434
#' well. If `FALSE` any blank parent element will be ignored when
3535
#' calculating final element state.
36+
#' @param ... Reserved for future expansion.
37+
#'
3638
#' @return An object of class `element`, `rel`, or `margin`.
3739
#' @details
3840
#' The `element_polygon()` and `element_point()` functions are not rendered
@@ -137,7 +139,7 @@ element_rect <- S7::new_class(
137139
"inherit.blank")],
138140
constructor = function(fill = NULL, colour = NULL, linewidth = NULL,
139141
linetype = NULL, color = NULL, linejoin = NULL,
140-
inherit.blank = FALSE, size = deprecated()){
142+
inherit.blank = FALSE, size = deprecated(), ...){
141143
if (lifecycle::is_present(size)) {
142144
deprecate_warn0("3.4.0", "element_rect(size)", "element_rect(linewidth)")
143145
linewidth <- size
@@ -171,7 +173,7 @@ element_line <- S7::new_class(
171173
constructor = function(colour = NULL, linewidth = NULL, linetype = NULL,
172174
lineend = NULL, color = NULL, linejoin = NULL,
173175
arrow = NULL, arrow.fill = NULL,
174-
inherit.blank = FALSE, size = deprecated()) {
176+
inherit.blank = FALSE, size = deprecated(), ...) {
175177
if (lifecycle::is_present(size)) {
176178
deprecate_warn0("3.4.0", "element_line(size)", "element_line(linewidth)")
177179
linewidth <- size
@@ -225,7 +227,7 @@ element_text <- S7::new_class(
225227
constructor = function(family = NULL, face = NULL, colour = NULL,
226228
size = NULL, hjust = NULL, vjust = NULL, angle = NULL,
227229
lineheight = NULL, color = NULL, margin = NULL,
228-
debug = NULL, inherit.blank = FALSE) {
230+
debug = NULL, inherit.blank = FALSE, ...) {
229231
n <- max(
230232
length(family), length(face), length(colour), length(size),
231233
length(hjust), length(vjust), length(angle), length(lineheight)
@@ -269,7 +271,7 @@ element_polygon <- S7::new_class(
269271
)],
270272
constructor = function(fill = NULL, colour = NULL, linewidth = NULL,
271273
linetype = NULL, color = NULL, linejoin = NULL,
272-
inherit.blank = FALSE) {
274+
inherit.blank = FALSE, ...) {
273275
colour <- color %||% colour
274276
S7::new_object(
275277
S7::S7_object(),
@@ -290,7 +292,7 @@ element_point <- S7::new_class(
290292
c("linewidth" = "stroke")
291293
),
292294
constructor = function(colour = NULL, shape = NULL, size = NULL, fill = NULL,
293-
stroke = NULL, color = NULL, inherit.blank = FALSE) {
295+
stroke = NULL, color = NULL, inherit.blank = FALSE, ...) {
294296
S7::new_object(
295297
S7::S7_object(),
296298
colour = color %||% colour, fill = fill, shape = shape, size = size,
@@ -327,8 +329,8 @@ element_geom <- S7::new_class(
327329
linetype = NULL, bordertype = NULL,
328330
family = NULL, fontsize = NULL,
329331
pointsize = NULL, pointshape = NULL,
330-
colour = NULL, color = NULL, fill = NULL) {
331-
332+
colour = NULL, color = NULL, fill = NULL,
333+
...) {
332334
if (!is.null(fontsize)) {
333335
fontsize <- fontsize / .pt
334336
}

man/class_ggplot.Rd

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

man/class_ggplot_built.Rd

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/class_labels.Rd

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

man/class_mapping.Rd

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/class_theme.Rd

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/element.Rd

Lines changed: 15 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)