File: generate_vctrs.R

package info (click to toggle)
r-cran-rsample 1.1.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,872 kB
  • sloc: sh: 13; makefile: 2
file content (20 lines) | stat: -rw-r--r-- 618 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# This file generates helpers for compatibility with vctrs
# and is not a part of the rsample package proper

devtools::load_all()
read_utf8 <- function(x) base::readLines(x, encoding = "UTF-8", warn = FALSE)

template <- read_utf8("inst/vctrs_template.R")

for (name in names(rset_subclasses)) {
  generated_template <- whisker::whisker.render(template)
  generated_template <- c(
    "# This file was generated, do not edit by hand",
    "# Please edit inst/generate_vctrs.R instead",
    generated_template
  )
  writeLines(
    generated_template,
    file.path("R", paste0("zzz-compat-vctrs-", name, ".R"))
  )
}