Skip to content

Commit 8d63c24

Browse files
authored
[doc] minor doc cleanup (#945)
* [docs] Fix doc entry for create_colors_xml() * [docs] minimal updates to wb_color() documentation
1 parent f84c5ae commit 8d63c24

15 files changed

+124
-31
lines changed

R/class-color.R

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#' Helper to create a color
22
#'
33
#' Creates a `wbColour` object.
4-
#' @param name A name of a color known to R
4+
#' @param name A name of a color known to R either as name or RGB/ARGB value.
55
#' @param auto A boolean.
6-
#' @param indexed An indexed color values.
7-
#' @param hex A rgb color as ARGB hex value "FF000000".
6+
#' @param indexed An indexed color value. This color has to be provided by the workbook.
7+
#' @param hex A rgb color either a ARGB hex value or RGB hex value With or without leading "#".
88
#' @param theme A zero based index referencing a value in the theme.
99
#' @param tint A tint value applied. Range from -1 (dark) to 1 (light).
10-
#' @seealso [wb_get_base_colors()]
10+
#' @seealso [wb_get_base_colors()] [grDevices::colors()]
1111
#' @return a `wbColour` object
1212
#' @export
1313
wb_color <- function(
@@ -33,7 +33,7 @@ wb_color <- function(
3333
z <- z[z != ""]
3434

3535
# wbColour for historical reasons
36-
class(z) <- c("character", "wbColour")
36+
class(z) <- c("wbColour", "character")
3737
z
3838
}
3939

R/helper-functions.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ create_hyperlink <- function(sheet, row = 1, col = 1, text = NULL, file = NULL)
8989
#' @param my.col my.col
9090
#' @noRd
9191
col2hex <- function(my.col) {
92-
rgb(t(col2rgb(my.col)), maxColorValue = 255)
92+
grDevices::rgb(t(grDevices::col2rgb(my.col)), maxColorValue = 255)
9393
}
9494

9595
# validate color --------------------------------------------------------------

R/wb_styles.R

+19-9
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ import_styles <- function(x) {
7979
#' @description
8080
#' Border styles can any of the following: "thin", "thick", "slantDashDot", "none", "mediumDashed", "mediumDashDot", "medium", "hair", "double", "dotted", "dashed", "dashedDotDot", "dashDot"
8181
#' Border colors can be created with [wb_color()]
82-
#' @seealso [wb_add_border()]
8382
#' @param diagonal_down x
8483
#' @param diagonal_up x
8584
#' @param outline x
@@ -94,6 +93,8 @@ import_styles <- function(x) {
9493
#' @param top x
9594
#' @param vertical x
9695
#' @param ... x
96+
#' @seealso [wb_add_border()]
97+
#' @family style creating functions
9798
#'
9899
#' @export
99100
create_border <- function(
@@ -168,6 +169,7 @@ create_border <- function(
168169
#' @param numFmtId an id, the list can be found in the **Details** of [create_cell_style()]
169170
#' @param formatCode a format code
170171
#' @seealso [wb_add_numfmt()]
172+
#' @family style creating functions
171173
#' @export
172174
create_numfmt <- function(numFmtId, formatCode) {
173175

@@ -202,6 +204,7 @@ create_numfmt <- function(numFmtId, formatCode) {
202204
#' @param vert_align vertical alignment
203205
#' @param ... ...
204206
#' @seealso [wb_add_font()]
207+
#' @family style creating functions
205208
#' @examples
206209
#' font <- create_font()
207210
#' # openxml has the alpha value leading
@@ -330,6 +333,7 @@ create_font <- function(
330333
#' @param fgColor hex8 color with alpha, red, green, blue only for patternFill
331334
#' @param ... ...
332335
#' @seealso [wb_add_fill()]
336+
#' @family style creating functions
333337
#'
334338
#' @export
335339
create_fill <- function(
@@ -374,7 +378,6 @@ create_fill <- function(
374378
# TODO can be further generalized with additional xf attributes and children
375379
#' Helper to create a cell style
376380
#'
377-
#' Create_cell_style with [wb_add_cell_style()]
378381
#' @param border_id dummy
379382
#' @param fill_id dummy
380383
#' @param font_id dummy
@@ -397,6 +400,8 @@ create_fill <- function(
397400
#' @param horizontal alignment can be "", "center", "right"
398401
#' @param vertical alignment can be "", "center", "right"
399402
#' @param ... reserved for additional arguments
403+
#' @seealso [wb_add_cell_style()]
404+
#' @family style creating functions
400405
#'
401406
#' @details
402407
#' | "ID" | "numFmt" |
@@ -623,7 +628,7 @@ set_cellstyle <- function(
623628
write_xf(z)
624629
}
625630

626-
#' get all styles on a sheet
631+
#' Get all styles on a sheet
627632
#'
628633
#' @param wb workbook
629634
#' @param sheet worksheet
@@ -666,7 +671,6 @@ get_cell_styles <- function(wb, sheet, cell) {
666671
#' @details
667672
#' It is possible to override border_color and border_style with \{left, right, top, bottom\}_color, \{left, right, top, bottom\}_style.
668673
#'
669-
#' @seealso [wb_add_style()]
670674
# TODO maybe font_name,font_size could be documented together.
671675
#' @param font_name A name of a font. Note the font name is not validated.
672676
#' If `font_name` is `NULL`, the workbook `base_font` is used. (Defaults to Calibri), see [wb_get_base_font()]
@@ -688,6 +692,8 @@ get_cell_styles <- function(wb, sheet, cell) {
688692
#' @param text_underline underline 1, true, single or double
689693
#' @param ... Additional arguments
690694
#' @return A dxfs style node
695+
#' @seealso [wb_add_style()] [wb_add_dxfs_style()]
696+
#' @family style creating functions
691697
#' @examples
692698
#' # do not apply anything
693699
#' style1 <- create_dxfs_style()
@@ -831,7 +837,8 @@ create_dxfs_style <- function(
831837
#' @param page_field_labels pageFieldLabels
832838
#' @param page_field_values pageFieldValues
833839
#' @param ... additional arguments
834-
#' @name tablestyle
840+
#' @name create_tablestyle
841+
#' @family style creating functions
835842
#' @export
836843
# TODO: combine both functions and simply set pivot=0 or table=0
837844
create_tablestyle <- function(
@@ -964,7 +971,7 @@ create_tablestyle <- function(
964971
)
965972
}
966973

967-
#' @rdname tablestyle
974+
#' @rdname create_tablestyle
968975
#' @export
969976
create_pivottablestyle <- function(
970977
name,
@@ -1192,13 +1199,16 @@ create_pivottablestyle <- function(
11921199
)
11931200
}
11941201

1195-
#' create custom color xml schemes
1196-
#' To be used with [wb_set_base_colors()]
1202+
#' Create custom color xml schemes
1203+
#'
1204+
#' Create custom color themes that can be used with [wb_set_base_colors()]. The color input will be checked with [wb_color()], so it must be either a color R from [grDevices::colors()] or a hex value.
1205+
#' Default values for the dark argument are: `black`, `white`, `darkblue` and `lightgray`. For the accent argument, the six inner values of [grDevices::palette()]. The link argument uses `blue` and `purple` by default for active and visited links.
11971206
#' @name create_colors_xml
11981207
#' @param name the color name
11991208
#' @param dark four colors: dark, light, brighter dark, darker light
12001209
#' @param accent six accent colors
12011210
#' @param link two link colors: link and visited link
1211+
#' @family style creating functions
12021212
#' @examples
12031213
#' colors <- create_colors_xml()
12041214
#' wb <- wb_workbook()$add_worksheet()$set_base_colors(xml = colors)
@@ -1217,7 +1227,7 @@ create_colors_xml <- function(
12171227
accent <- grDevices::palette()[2:7]
12181228

12191229
if (is.null(link))
1220-
link <- c("blue", "gray")
1230+
link <- c("blue", "purple")
12211231

12221232
if (length(dark) != 4) {
12231233
stop("dark vector must be of length 4")

man/create_border.Rd

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/create_cell_style.Rd

+14-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/create_colors_xml.Rd

+14-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/create_dxfs_style.Rd

+11-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/create_fill.Rd

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/create_font.Rd

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/create_numfmt.Rd

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/tablestyle.Rd man/create_tablestyle.Rd

+12-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/styles_on_sheet.Rd

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/wb_color.Rd

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-class-color.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ test_that("get()", {
99
exp <- c(rgb = "FF000000")
1010
expect_false(is_wbColour(exp))
1111

12-
class(exp) <- c("character", "wbColour")
12+
class(exp) <- c("wbColour", "character")
1313
got <- wb_colour("black")
1414

1515
expect_true(is_wbColour(got))

tests/testthat/test-wb_styles.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ test_that("apply styles across columns and rows", {
872872

873873
test_that("create_colors_xml() works", {
874874

875-
exp <- "<a:clrScheme name=\"Base R\"><a:dk1><a:sysClr val=\"windowText\" lastClr=\"000000\"/></a:dk1><a:lt1><a:sysClr val=\"window\" lastClr=\"FFFFFF\"/></a:lt1><a:dk2><a:srgbClr val=\"00008B\"/></a:dk2><a:lt2><a:srgbClr val=\"D3D3D3\"/></a:lt2><a:accent1><a:srgbClr val=\"DF536B\"/></a:accent1><a:accent2><a:srgbClr val=\"61D04F\"/></a:accent2><a:accent3><a:srgbClr val=\"2297E6\"/></a:accent3><a:accent4><a:srgbClr val=\"28E2E5\"/></a:accent4><a:accent5><a:srgbClr val=\"CD0BBC\"/></a:accent5><a:accent6><a:srgbClr val=\"F5C710\"/></a:accent6><a:hlink><a:srgbClr val=\"0000FF\"/></a:hlink><a:folHlink><a:srgbClr val=\"BEBEBE\"/></a:folHlink></a:clrScheme>"
875+
exp <- "<a:clrScheme name=\"Base R\"><a:dk1><a:sysClr val=\"windowText\" lastClr=\"000000\"/></a:dk1><a:lt1><a:sysClr val=\"window\" lastClr=\"FFFFFF\"/></a:lt1><a:dk2><a:srgbClr val=\"00008B\"/></a:dk2><a:lt2><a:srgbClr val=\"D3D3D3\"/></a:lt2><a:accent1><a:srgbClr val=\"DF536B\"/></a:accent1><a:accent2><a:srgbClr val=\"61D04F\"/></a:accent2><a:accent3><a:srgbClr val=\"2297E6\"/></a:accent3><a:accent4><a:srgbClr val=\"28E2E5\"/></a:accent4><a:accent5><a:srgbClr val=\"CD0BBC\"/></a:accent5><a:accent6><a:srgbClr val=\"F5C710\"/></a:accent6><a:hlink><a:srgbClr val=\"0000FF\"/></a:hlink><a:folHlink><a:srgbClr val=\"A020F0\"/></a:folHlink></a:clrScheme>"
876876
got <- create_colors_xml()
877877
expect_equal(exp, got)
878878

0 commit comments

Comments
 (0)