Skip to content

Commit ea8d583

Browse files
committed
feat: unifying documentation
1 parent 668af66 commit ea8d583

22 files changed

+104
-243
lines changed

R/roxygen2_templates.R

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# nocov start
2+
roxygen_decorators_param <- function(module_name) {
3+
paste(
4+
sep = " ",
5+
lifecycle::badge("experimental"),
6+
" (`list` of `teal_transform_module`, named `list` of `teal_transform_module` or",
7+
"`NULL`) optional, if not `NULL`, decorator for tables or plots included in the module.",
8+
"When a named list of `teal_transform_module`, the decorators are applied to the",
9+
"respective output objects.\n\n",
10+
"Otherwise, the decorators are applied to all objects, which is equivalent as using the name `default`.\n\n",
11+
sprintf("See section \"Decorating `%s`\"", module_name),
12+
"below for more details."
13+
)
14+
}
15+
16+
roxygen_ggplot2_args_param <- function(...) {
17+
paste(
18+
sep = " ",
19+
"(`ggplot2_args`) optional, object created by [`teal.widgets::ggplot2_args()`]",
20+
"with settings for all the plots or named list of `ggplot2_args` objects for plot-specific settings.",
21+
"The argument is merged with options variable `teal.ggplot2_args` and default module setup.\n\n",
22+
sprintf(
23+
"List names should match the following: `c(\"default\", %s)`.\n\n",
24+
paste("\"", unlist(rlang::list2(...)), "\"", collapse = ", ", sep = "")
25+
),
26+
"For more details see the vignette: `vignette(\"custom-ggplot2-arguments\", package = \"teal.widgets\")`."
27+
)
28+
}
29+
30+
# nocov end

R/tm_a_pca.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
#' It controls the font size for plot titles, axis labels, and legends.
1414
#' - If vector of `length == 1` then the font sizes will have a fixed size.
1515
#' - while vector of `value`, `min`, and `max` allows dynamic adjustment.
16-
#' @templateVar ggnames "Elbow plot", "Circle plot", "Biplot", "Eigenvector plot"
17-
#' @template ggplot2_args_multi
16+
#' @param ggplot2_args `r roxygen_ggplot2_args_param("Elbow plot", "Circle plot", "Biplot", "Eigenvector plot")`
17+
#' @param decorators `r roxygen_decorators_param("tm_a_pca")`
1818
#'
1919
#' @inherit shared_params return
2020
#'

R/tm_a_regression.R

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
#' It takes the form of `c(value, min, max)` and it is passed to the `value_min_max`
3838
#' argument in `teal.widgets::optionalSliderInputValMinMax`.
3939
#'
40-
#' @templateVar ggnames `r regression_names`
41-
#' @template ggplot2_args_multi
40+
#' @param ggplot2_args `r roxygen_ggplot2_args_param(regression_names)`
41+
#' @param decorators `r roxygen_decorators_param("tm_a_regression")`
4242
#'
4343
#' @inherit shared_params return
4444
#'
@@ -1035,7 +1035,10 @@ srv_a_regression <- function(id,
10351035
})
10361036
}
10371037

1038-
regression_names <- paste0(
1039-
'"Response vs Regressor", "Residuals vs Fitted", ',
1040-
'"Scale-Location", "Cook\'s distance", "Residuals vs Leverage"", "Cook\'s dist vs Leverage"'
1038+
regression_names <- c(
1039+
"Response vs Regressor",
1040+
"Residuals vs Fitted",
1041+
"Scale-Location", "Cook's distance",
1042+
"Residuals vs Leverage",
1043+
"Cook's dist vs Leverage"
10411044
)

R/tm_g_association.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
#' @param distribution_theme,association_theme (`character`) optional, `ggplot2` themes to be used by default.
2121
#' Default to `"gray"`.
2222
#'
23-
#' @templateVar ggnames "Bivariate1", "Bivariate2"
24-
#' @template ggplot2_args_multi
23+
#' @param ggplot2_args `r roxygen_ggplot2_args_param("Bivariate1", "Bivariate2")`
24+
#' @param decorators `r roxygen_decorators_param("tm_")`
2525
#'
2626
#' @inherit shared_params return
2727
#'

R/tm_g_distribution.R

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
#' and `max`.
2323
#' Defaults to `c(30L, 1L, 100L)`.
2424
#'
25-
#' @templateVar ggnames "Histogram", "QQplot"
26-
#' @template ggplot2_args_multi
25+
#' @param ggplot2_args `r roxygen_ggplot2_args_param("Histogram", "QQplot")`
26+
#' @param decorators `r roxygen_decorators_param("tm_g_distribution")`
2727
#'
2828
#' @inherit shared_params return
2929
#'
@@ -34,17 +34,19 @@
3434
#' - `test_table` (`data.frame`)
3535
#' - `summary_table` (`data.frame`)
3636
#'
37-
#' The `decorators` can be specific for the `histogram` and `decorators` outputs
38-
#' within the module, which can be specified by using a named list.
37+
#' Decorators can be applied to all outputs or only to specific objects using a
38+
#' named list of `teal_transform_module` objects.
39+
#' The `"default"` name is reserved for decorators that are applied to all outputs.
3940
#' See code snippet below:
4041
#'
4142
#' ```
4243
#' tm_g_distribution(
4344
#' ..., # arguments for module
4445
#' decorators = list(
45-
#' default = list(teal_transform_module(...)), # applied to outputs of both `histogram` and `qq`
46-
#' histogram = list(teal_transform_module(...)), # applied to outputs of `histogram`
47-
#' qq = list(teal_transform_module(...)) # applied to outputs of `qq`
46+
#' default = list(teal_transform_module(...)), # applied to all outputs
47+
#' plot = list(teal_transform_module(...)), # applied only to plot output (histogram plot)
48+
#' test_table = list(teal_transform_module(...)) # applied only to test_table
49+
#' summary_table = list(teal_transform_module(...)) # applied only to summary_table
4850
#' )
4951
#' )
5052
#' ```

R/tm_missing_data.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
#' ignored.
1313
#' @param ggtheme (`character`) optional, specifies the default `ggplot2` theme for plots. Defaults to `classic`.
1414
#'
15-
#' @templateVar ggnames "Summary Obs", "Summary Patients", "Combinations Main", "Combinations Hist", "By Subject"
16-
#' @template ggplot2_args_multi
15+
#' @param ggplot2_args `r roxygen_ggplot2_args_param(missing_data_names)`
16+
#' @param decorators `r roxygen_decorators_param("tm_missing_data")`
1717
#'
1818
#' @inherit shared_params return
1919
#'
@@ -1393,3 +1393,7 @@ srv_missing_data <- function(id,
13931393
###
13941394
})
13951395
}
1396+
1397+
missing_data_names <- c(
1398+
"Summary Obs", "Summary Patients", "Combinations Main", "Combinations Hist", "By Subject"
1399+
)

R/tm_outliers.R

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@
1111
#' Specifies variable(s) to be analyzed for outliers.
1212
#' @param categorical_var (`data_extract_spec` or `list` of multiple `data_extract_spec`) optional,
1313
#' specifies the categorical variable(s) to split the selected outlier variables on.
14-
#'
15-
#' @templateVar ggnames "Boxplot","Density Plot","Cumulative Distribution Plot"
16-
#' @template ggplot2_args_multi
14+
#' @param decorators `r roxygen_decorators_param("tm_outliers")`
15+
#' @param ggplot2_args `r roxygen_ggplot2_args_param("Boxplot", "Density Plot", "Cumulative Distribution Plot")`
1716
#'
1817
#' @inherit shared_params return
1918
#'

R/utils.R

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,6 @@
2525
#' with text placed before the output to put the output into context. For example a title.
2626
#' @param post_output (`shiny.tag`) optional, text or UI element to be displayed after the module's output,
2727
#' adding context or further instructions. Elements like `shiny::helpText()` are useful.
28-
#' @param decorators `r lifecycle::badge("experimental")`
29-
#' (`list` of `teal_transform_module`,
30-
#' named `list` of `teal_transform_module` or
31-
#' `NULL`) optional,
32-
#' if not `NULL`, decorator for tables or plots included in the module.
33-
#' When a named list of `teal_transform_module`, the decorators are applied to the
34-
#' outputs of the corresponding view of the module.
35-
#' Otherwise, the decorators are applied to all outputs in all views equally, which is the same
36-
#' as using the name `default`.
37-
#'
38-
#' A module can have different views with different outputs, such as a tab with
39-
#' a table and another with a plot.
40-
#' See section "Decorating `tm_<module_name>`" below for more details.
41-
#'
4228
#' @param alpha (`integer(1)` or `integer(3)`) optional, specifies point opacity.
4329
#' - When the length of `alpha` is one: the plot points will have a fixed opacity.
4430
#' - When the length of `alpha` is three: the plot points opacity are dynamically adjusted based on

man-roxygen/ggplot2_args_multi.R

Lines changed: 0 additions & 7 deletions
This file was deleted.

man/shared_params.Rd

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

0 commit comments

Comments
 (0)