Skip to content

Commit b23a73a

Browse files
committed
feat: export ptype_config
1 parent 1119312 commit b23a73a

19 files changed

+213
-30
lines changed

DESCRIPTION

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ Description: A canonicalized way to R package configuration striving for
99
License: AGPL (>= 3)
1010
URL: https://gitlab.com/rpkg.dev/funky
1111
BugReports: https://gitlab.com/rpkg.dev/funky/-/issues
12+
Depends:
13+
R (>= 3.5)
1214
Imports:
1315
checkmate (>= 2.3.2),
1416
cli (>= 3.6.4),

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export(config_val)
66
export(config_val_default)
77
export(has_config_val)
88
export(print_config)
9+
export(ptype_config)
910
importFrom(magrittr,"%!>%")
1011
importFrom(magrittr,"%$%")
1112
importFrom(magrittr,"%<>%")

R/funky.gen.R

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ has_config_val <- function(key,
178178
#'
179179
#' @inheritParams config_val
180180
#'
181-
#' @return `r pkgsnip::param_lbl("tibble_cols", cols = colnames(ptype_funky_config))`
181+
#' @return `r pkgsnip::param_lbl("tibble_cols", cols = colnames(ptype_config))`
182182
#' @family pkg_config_data
183183
#' @export
184184
#'
@@ -205,7 +205,7 @@ config <- function(pkg = utils::packageName(env = parent.frame())) {
205205

206206
# ensure/complement df structure
207207
funky_config |>
208-
vctrs::tib_cast(to = ptype_funky_config) |>
208+
vctrs::tib_cast(to = ptype_config) |>
209209
tidyr::replace_na(replace = list(require = TRUE))
210210
}
211211

@@ -292,6 +292,18 @@ print_config <- function(pkg = utils::packageName(env = parent.frame()),
292292
pal::pipe_table()
293293
}
294294

295+
#' Package configuration data prototype
296+
#'
297+
#' An empty funky configuration data [tibble][tibble::tbl_df]. E.g. useful to start from when defining funky configuration data via [tibble::add_row()] calls.
298+
#'
299+
#' @format `r pkgsnip::return_lbl("tibble_cols", cols = colnames(ptype_config))`
300+
#' @family pkg_config_data
301+
#' @export
302+
#'
303+
#' @examples
304+
#' funky::ptype_config
305+
"ptype_config"
306+
295307
utils::globalVariables(names = c(".",
296308
# tidyselect fns
297309
"any_of",
@@ -337,9 +349,3 @@ opt_name <- function(key,
337349
paste(pkg, key,
338350
sep = ".")
339351
}
340-
341-
ptype_funky_config <- tibble::tibble(key = character(),
342-
default_value = list(),
343-
default_value_dynamic = character(),
344-
require = logical(),
345-
description = character())

R/sysdata.rda

240 Bytes
Binary file not shown.

Rmd/funky.Rmd

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ has_config_val <- function(key,
213213
#'
214214
#' @inheritParams config_val
215215
#'
216-
#' @return `r pkgsnip::param_lbl("tibble_cols", cols = colnames(ptype_funky_config))`
216+
#' @return `r pkgsnip::param_lbl("tibble_cols", cols = colnames(ptype_config))`
217217
#' @family pkg_config_data
218218
#' @export
219219
#'
@@ -240,7 +240,7 @@ config <- function(pkg = utils::packageName(env = parent.frame())) {
240240
241241
# ensure/complement df structure
242242
funky_config |>
243-
vctrs::tib_cast(to = ptype_funky_config) |>
243+
vctrs::tib_cast(to = ptype_config) |>
244244
tidyr::replace_na(replace = list(require = TRUE))
245245
}
246246
```
@@ -340,6 +340,22 @@ print_config <- function(pkg = utils::packageName(env = parent.frame()),
340340
}
341341
```
342342

343+
### `ptype_config`
344+
345+
```{r}
346+
#' Package configuration data prototype
347+
#'
348+
#' An empty funky configuration data [tibble][tibble::tbl_df]. E.g. useful to start from when defining funky configuration data via [tibble::add_row()] calls.
349+
#'
350+
#' @format `r pkgsnip::return_lbl("tibble_cols", cols = colnames(ptype_config))`
351+
#' @family pkg_config_data
352+
#' @export
353+
#'
354+
#' @examples
355+
#' funky::ptype_config
356+
"ptype_config"
357+
```
358+
343359
# INTERNAL
344360

345361
## Avoid `R CMD check` NOTES about undefined global objects
@@ -403,15 +419,3 @@ opt_name <- function(key,
403419
sep = ".")
404420
}
405421
```
406-
407-
## Constants
408-
409-
### `ptype_funky_config`
410-
411-
```{r}
412-
ptype_funky_config <- tibble::tibble(key = character(),
413-
default_value = list(),
414-
default_value_dynamic = character(),
415-
require = logical(),
416-
description = character())
417-
```

Rmd/sysdata.nopurl.Rmd

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
editor_options:
3+
chunk_output_type: console
4+
---
5+
6+
# NOTES
7+
8+
- This file is *not* included in the [source package](https://r-pkgs.org/structure.html#sec-source-package) because of the [`.nopurl` suffix in its
9+
filename](https://pkgpurl.rpkg.dev/reference/purl_rmd.html#-rmd-files-excluded-from-purling).
10+
11+
- The chunks below have to be manually executed in order to regenerate the package data.
12+
13+
- Although the datasets below are saved as ["internal data" in `R/sysdata.rda`](https://r-pkgs.org/data.html#sec-data-sysdata), they can still be exported and
14+
documented (by documenting the dataset's quoted name in the main `.Rmd` source file – which only works when the dataset is also `@export`ed), something [not
15+
explicitly mentioned](https://coolbutuseless.github.io/2018/12/10/r-packages-internal-and-external-data/) in the book [R
16+
Packages](https://r-pkgs.org/data.html#sec-data-data). To do so, you first need to manually add the `export()` directive in the NAMESPACE file since
17+
roxygen2 won't add it automatically.
18+
19+
# Define data
20+
21+
## `ptype_funky_config`
22+
23+
```{r}
24+
ptype_config <- tibble::tibble(key = character(),
25+
default_value = list(),
26+
default_value_dynamic = character(),
27+
require = logical(),
28+
description = character())
29+
```
30+
31+
# Write data
32+
33+
Save all the small data objects as a single internal file `R/sysdata.rda`. Note that when documenting them, they must be explicitly `@export`ed to be available
34+
to package users.
35+
36+
```{r}
37+
usethis::use_data(ptype_config,
38+
internal = TRUE,
39+
overwrite = TRUE,
40+
compress = "xz",
41+
version = 3L)
42+
```

docs/dev/pkgdown.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ pandoc: 3.6.3
22
pkgdown: 2.1.1.9000
33
pkgdown_sha: 87287f602d5889b3ee3ccd82a6c686f6e5874732
44
articles: {}
5-
last_built: 2025-03-05T01:15Z
5+
last_built: 2025-03-05T20:45Z
66
urls:
77
reference: https://funky.rpkg.dev/reference
88
article: https://funky.rpkg.dev/articles

docs/dev/reference/augment_config.html

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

docs/dev/reference/config.html

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

docs/dev/reference/index.html

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

0 commit comments

Comments
 (0)