#' Create review templates.
#'
#' Creates skeleton review files:
#' \itemize{
#' \item `index.Rmd`: `html_notebook` to perform and record review in
#' \item `README.md`: prepopulated README for review repo.
#' }
#' `index.Rmd` will be automatically added to `.Rbuildignore`.
#' The resulting templates are populated with default
#' YAML frontmatter and R fenced code chunks (`Rmd`).
#'
#' @param pkg_data package metadata generated by pkgreview_getdata()
#' @param template character string, one of `review` or `editor`.
#' @param destdir where to save the template
#'
#' @export
# @importFrom usethis getFromNamespace check_installed
# @importFrom usethis getFromNamespace render_template
pkgreview_index_rmd <- function(pkg_data,
template = c("review", "editor"),
destdir) { # nolint: function_argument_linter
template <- match.arg(template)
usethis::with_project(destdir, {
usethis::use_template(
sprintf("%s-index", template),
"index.Rmd",
data = pkg_data,
ignore = FALSE,
open = FALSE,
package = "pkgreviewr"
)
})
invisible(TRUE)
}
#' @export
#' @rdname pkgreview_index_rmd
pkgreview_readme_md <- function(pkg_data, destdir) {
usethis::local_project(destdir)
usethis::use_template(
"review-README",
"README.md",
data = pkg_data,
ignore = FALSE,
open = FALSE,
package = "pkgreviewr"
)
}
#' Create software review/editor response template
#'
#' Clone an up to date copy of the specified ropensci software
#' review/editor response template.
#' @param template character string, one of `review` or `editor`.
#' @param destdir where to save the template
#'
#' @return writes a `{template}.md` checklist template file in `destdir`.
#' @export
#'
#' @examples
#' \dontrun{
#' use_onboarding_tmpl(template = "editor")
#' }
use_onboarding_tmpl <- function(template = c("review", "editor"), destdir) { # nolint: function_argument_linter
template <- match.arg(template)
tmpl_txt <- gh::gh("/repos/:owner/:repo/contents/:path",
owner = "ropensci",
repo = "dev_guide",
path = sprintf("templates/%s.md", template) # nolint: nonportable_path_litner
)
curl::curl_download(
tmpl_txt[["download_url"]],
fs::path(destdir, fs::path_ext_set(template, ".md"))
)
}
#' @export
#' @rdname pkgreview_index_rmd
pkgreview_request <- function(pkg_data, destdir) {
pkg_data <- c(
pkg_data,
editor = try_whoami()[["name"]]
)
usethis::local_project(destdir)
usethis::use_template(
"request",
"request.Rmd",
data = pkg_data,
ignore = FALSE,
open = FALSE,
package = "pkgreviewr"
)
}
#' Render request email body
#'
#' Launches an interactive input browser tab to complete required parameters:
#' - `reviewer_first_name`: reviewers first name
#' - `banter`: character string of custom greeting message
#' - `JOSS`: logical, whether review includes submission to JOSS
#' @return renders `request.Rmd` using parameters provided.
#' @export
#'
#' @examples
#' \dontrun{
#' render_request()
#' }
render_request <- function() {
rmarkdown::render(usethis::proj_path("request.Rmd"),
params = "ask"
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.