# From srr/R/pkg-skeleon.R make_pkg_path <- function (base_dir = tempdir (), pkg_name = "demo") { d <- file.path (base_dir, pkg_name) if (!file.exists (d)) { dir.create (d, recursive = TRUE) } return (d) } write_desc <- function (d, pkg_name) { desc <- c ( paste0 ("Package: ", pkg_name), "Title: What the Package Does (One Line, Title Case)", "Version: 0.0.1", "Authors@R: ", " person(given = \"First\",", " family = \"Last\",", " role = c(\"aut\", \"cre\"),", " email = \"first.last@example.com\")", "Description: What the package does (one paragraph).", "Suggests:", " testthat", "License: GPL-3", "Encoding: UTF-8" ) fp <- file.path (d, "DESCRIPTION") if (!file.exists (fp)) { writeLines (desc, con = fp) } } write_r_fn <- function (d, pkg_name) { rfile <- c ( "#' test_fn", "#'", "#' A test funtion", "#'", "#' @export", "test_fn <- function() {", " message(\"This function does nothing\")", "}" ) dr <- file.path (d, "R") if (!file.exists (dr)) { dir.create (dr) } fp <- file.path (dr, "test.R") if (!file.exists (fp)) { writeLines (rfile, con = fp) } rfile <- c ( "#' @keywords internal", "\"_PACKAGE\"", "", paste0 ( "# The following block is used by ", "usethis to automatically manage" ), "# roxygen namespace tags. Modify with care!", "## usethis namespace: start", "## usethis namespace: end", "NULL" ) fp <- file.path (dr, paste0 (pkg_name, "-package.R")) if (!file.exists (fp)) { writeLines (rfile, con = fp) } } write_readme <- function (d, pkg_name) { # nolint start --- lines > 80 characters rfile <- c ( paste0 ("# ", pkg_name), "", "", "[](https://badge-link)", "", "", "This `README.Rmd` file is here to demonstrate some stuff.", "", "``` r", " x <- 1", "```", "", "And it includes a HTML table", "", "
| ", " | ", "