Skip to content

feature: use_RdTemplate #1617

@mikeroswell

Description

@mikeroswell

Starting a new package, I wanted to use templates for parameters used in multiple functions. I forgot how this was supposed to work with the @template syntax (what the directory needed to be, whether the templates were .R or .Rd, etc.) and was hoping usethis would do things for me. I wrote the below quickly to remind future me, but i think it would be a nice feature of usethis. I'll create a PR now as well, though I'm sure your team will write a better function if you add this functionality.

#' Create a template for package documentation
#'
#' @param templateName Character, name of template and file
#'
#' @return This function creates a `.R` file in the directory "man-roxygen". If
#' that directory does not already exist in your package, it will create it.
#' The function opens the new (blank) file in your editor.
#'
#' @seealso \code{\link{file.edit}}
#' @export
#'
#' @examples
use_RdTemplate <- function(templateName){
  if(!dir.exists("man-roxygen")){
    dir.create("man-roxygen")
  }
  pth <- paste0("man-roxygen/", templateName, ".R")
  file.create(pth)
  file.edit(pth)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions