|
1 |
| -# S3 classes -------------------------------------------------------------- |
| 1 | +# Docs ------------------------------------------------------------- |
2 | 2 |
|
3 |
| -# Meta classes: |
4 |
| -# TODO: These should be replaced once R 4.3.0 is the minimum version as `+` |
5 |
| -# dispatch should work as intended. |
6 |
| -class_gg <- S7::new_class("gg", abstract = TRUE) |
7 |
| -class_S3_gg <- S7::new_S3_class("gg") |
| 3 | +#' Class definitions |
| 4 | +#' |
| 5 | +#' The S7 object oriented programming system requires class definitions. |
| 6 | +#' Here, we provide definitions of classes that are home to ggplot2. |
| 7 | +#' |
| 8 | +#' @section S7 classes: |
| 9 | +#' |
| 10 | +#' A general advice the S7 package gives is to name class definition objects |
| 11 | +#' the same as the class name, which then becomes the constructor for the class. |
| 12 | +#' The classes listed below deviate from that advice for historical reasons, |
| 13 | +#' because some constructors like `ggplot()` are also S3 generics with methods. |
| 14 | +#' The have the `class_`-prefix to indicate their role. |
| 15 | +#' |
| 16 | +#' * [`class_ggplot`] is an S7 class used for objects generated by [ggplot()]. |
| 17 | +#' * [`class_ggplot_built`] is an S7 class used for objects generated by |
| 18 | +#' [ggplot_build()]. |
| 19 | +#' * [`class_mapping`] is an S7 class used for objects generated by [aes()]. |
| 20 | +#' * [`class_theme`] is an S7 class used for objects generated by [theme()]. |
| 21 | +#' * [`class_labels`] is an S7 class used for objects generated by [labs()]. |
| 22 | +#' |
| 23 | +#' @section Theme elements: |
| 24 | +#' |
| 25 | +#' The theme elements follow the advice of the S7 package that the class names |
| 26 | +#' are also the class definitions and constructors. |
| 27 | +#' |
| 28 | +#' * [`element`] is an abstract S7 class used to invoke similar behaviour among |
| 29 | +#' theme element objects. |
| 30 | +#' * [`element_blank`] is an S7 class for not drawing theme elements. |
| 31 | +#' * [`element_rect`] is an S7 class for drawing rectangles. |
| 32 | +#' * [`element_line`] is an S7 class for drawing lines. |
| 33 | +#' * [`element_text`] is an S7 class for rendering text. |
| 34 | +#' * [`element_polygon`] is an S7 class for drawing polygons. |
| 35 | +#' * [`element_point`] is an S7 class for drawing points. |
| 36 | +#' * [`element_geom`] is an S7 class holding geom defaults. |
| 37 | +#' * [`margin`] is an S7 class for declaring margins. |
| 38 | +#' |
| 39 | +#' @section ggproto classes: |
| 40 | +#' |
| 41 | +#' The ggproto classes are S3 classes of the type environment that form the |
| 42 | +#' backbone of most systems in ggplot2 and are in particular crucial to the |
| 43 | +#' extension system. |
| 44 | +#' |
| 45 | +#' @section S3 classes: |
| 46 | +#' |
| 47 | +#' Some simple classes remain S3. |
| 48 | +#' |
| 49 | +#' @name class_definitions |
| 50 | +NULL |
| 51 | + |
| 52 | +#' @rdname class_definitions |
| 53 | +#' @section S7 classes: |
| 54 | +#' * `class_gg` is an abstract S7 class to used invoke similar behaviour among |
| 55 | +#' ggplot objects. |
| 56 | +#' @export |
| 57 | +#' @format NULL |
| 58 | +#' @usage NULL |
| 59 | +class_gg <- S7::new_class("gg", abstract = TRUE) |
| 60 | + |
| 61 | +# ggproto classes --------------------------------------------------------- |
8 | 62 |
|
9 |
| -# Proper S3 classes we need awareness for |
| 63 | +#' @rdname class_definitions |
| 64 | +#' @section ggproto classes: |
| 65 | +#' * `class_ggproto` is an S3 class used for the objects generated by |
| 66 | +#' [ggproto()] which are of the type environment. |
| 67 | +#' @export |
| 68 | +#' @format NULL |
| 69 | +#' @usage NULL |
10 | 70 | class_ggproto <- S7::new_S3_class("ggproto")
|
11 |
| -class_gtable <- S7::new_S3_class("gtable") |
12 | 71 |
|
13 |
| -# The important ggproto classes that we treat as S3 classes in S7 even though |
14 |
| -# they are their own thing. |
15 |
| -class_scale <- S7::new_S3_class("Scale") |
| 72 | +# We don't own this class, so we don't export or describe it |
| 73 | +class_gtable <- S7::new_S3_class("gtable") |
| 74 | + |
| 75 | +#' @rdname class_definitions |
| 76 | +#' @section ggproto classes: |
| 77 | +#' * `class_scale` is a subclass of `class_ggproto` and is more described in |
| 78 | +#' the [Scale] documentation. |
| 79 | +#' @export |
| 80 | +#' @format NULL |
| 81 | +#' @usage NULL |
| 82 | +class_scale <- S7::new_S3_class("Scale") |
| 83 | + |
| 84 | +#' @rdname class_definitions |
| 85 | +#' @section ggproto classes: |
| 86 | +#' * `class_guides` is a subclass of `class_ggproto` and is considered an |
| 87 | +#' internal class. |
| 88 | +#' @export |
| 89 | +#' @format NULL |
| 90 | +#' @usage NULL |
16 | 91 | class_guides <- S7::new_S3_class("Guides")
|
| 92 | + |
| 93 | +#' @rdname class_definitions |
| 94 | +#' @section ggproto classes: |
| 95 | +#' * `class_guide` is a subclass of `class_ggproto` and is more described in the |
| 96 | +#' [Guide] documentation. |
| 97 | +#' @export |
| 98 | +#' @format NULL |
| 99 | +#' @usage NULL |
17 | 100 | class_guide <- S7::new_S3_class("Guide")
|
| 101 | + |
| 102 | +#' @rdname class_definitions |
| 103 | +#' @section ggproto classes: |
| 104 | +#' * `class_coord` is a subclass of `class_ggproto` and is more described in the |
| 105 | +#' [Coord] documentation. |
| 106 | +#' @export |
| 107 | +#' @format NULL |
| 108 | +#' @usage NULL |
18 | 109 | class_coord <- S7::new_S3_class("Coord")
|
| 110 | + |
| 111 | + |
| 112 | +#' @rdname class_definitions |
| 113 | +#' @section ggproto classes: |
| 114 | +#' * `class_facet` is a subclass of `class_ggproto` and is more described in the |
| 115 | +#' [Facet] documentation. |
| 116 | +#' @export |
| 117 | +#' @format NULL |
| 118 | +#' @usage NULL |
19 | 119 | class_facet <- S7::new_S3_class("Facet")
|
| 120 | + |
| 121 | +#' @rdname class_definitions |
| 122 | +#' @section ggproto classes: |
| 123 | +#' * `class_layer` is a subclass of `class_ggproto` and is used for the objects |
| 124 | +#' generated by [layer()]. The class itself is considered internal and is |
| 125 | +#' described in more detail in the [Layer] documentation. |
| 126 | +#' @export |
| 127 | +#' @format NULL |
| 128 | +#' @usage NULL |
20 | 129 | class_layer <- S7::new_S3_class("Layer")
|
| 130 | + |
| 131 | +#' @rdname class_definitions |
| 132 | +#' @section ggproto classes: |
| 133 | +#' * `class_layout` is a subclass of `class_ggproto` and is considered an |
| 134 | +#' internal class. It is described in more detail in the [Layout] |
| 135 | +#' documentation. |
| 136 | +#' @export |
| 137 | +#' @format NULL |
| 138 | +#' @usage NULL |
21 | 139 | class_layout <- S7::new_S3_class("Layout")
|
| 140 | + |
| 141 | +#' @rdname class_definitions |
| 142 | +#' @section ggproto classes: |
| 143 | +#' * `class_scales_list` is a subclass of `class_ggproto` and is considered an |
| 144 | +#' internal class. |
| 145 | +#' @export |
| 146 | +#' @format NULL |
| 147 | +#' @usage NULL |
22 | 148 | class_scales_list <- S7::new_S3_class("ScalesList")
|
23 | 149 |
|
| 150 | +# S3 classes -------------------------------------------------------------- |
| 151 | + |
| 152 | +#' @rdname class_definitions |
| 153 | +#' @section S3 classes: |
| 154 | +#' * `r lifecycle::badge("superseded")` `class_S3_gg` is a temporary S3 class |
| 155 | +#' until R 4.3.0 is the minimum supported version. It is exported and |
| 156 | +#' listed here for completeness, but its use is heavily discouraged. It |
| 157 | +#' is superseded by `class_gg`. |
| 158 | +#' @export |
| 159 | +#' @format NULL |
| 160 | +#' @usage NULL |
| 161 | +class_S3_gg <- S7::new_S3_class("gg") |
| 162 | + |
24 | 163 | # User facing classes -----------------------------------------------------
|
25 | 164 |
|
26 | 165 | ## Theme -------------------------------------------------------------------
|
|
0 commit comments