diff --git a/NAMESPACE b/NAMESPACE index f24a7fc..c5faa07 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,28 +1,14 @@ # Generated by roxygen2: do not edit by hand -export(add_code_of_conduct) -export(add_contributing) -export(add_license) -export(add_license_header) -export(add_readme) -export(add_rproj) -export(analysis_skeleton) export(bgc_colours) -export(devex_badge) export(get_data_license) export(multiplot) export(order_df) -export(roxygen_template) export(theme_soe) export(theme_soe_facet) import(extrafont) import(ggplot2) import(ggthemes) import(grid) -importFrom(git2r,clone) -importFrom(git2r,init) -importFrom(git2r,is_empty) -importFrom(git2r,repository) importFrom(rstudioapi,getActiveDocumentContext) importFrom(rstudioapi,insertText) -importFrom(utils,file.edit) diff --git a/R/add_git.R b/R/add_git.R deleted file mode 100644 index 3cc376e..0000000 --- a/R/add_git.R +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright 2015 Province of British Columbia -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and limitations under the License. - -#' Clones a remote repository -#' -#' @importFrom git2r repository clone is_empty -#' -#' @param url url of remote git repository -#' @param path path to clone into -#' -#' @return a repository object -clone_git <- function(url, path) { - remote_repo <- repository(url) - if (!is_empty(remote_repo)) { - warning("Not cloning a non-empty repository") - return(invisible(NULL)) - } else { - repo <- clone(remote_repo@path, path) - } - repo -} - -write_gitignore <- function(..., path = ".") { - gitignew <- c(...) - if (file.exists(".gitignore")) { - gitignore <- readLines(".gitignore") - gitignew <- union(gitignore, gitignew) - } - cat(gitignew, file = file.path(path, ".gitignore"), append = FALSE, sep = "\n") - invisible(TRUE) -} diff --git a/R/add_meta.R b/R/add_meta.R deleted file mode 100644 index a7ed845..0000000 --- a/R/add_meta.R +++ /dev/null @@ -1,185 +0,0 @@ -# Copyright 2015 Province of British Columbia -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and limitations under the License. - -#' Add a README.md file to the project directory -#' -#' @param path Directory path (default \code{"."}) -#' @param package Is this a package or a regular project? (Default \code{FALSE}) -#' @param CoC Should a Code of Conduct be added to the repository? -#' @export -#' @seealso \code{\link{add_contributing}}, \code{\link{add_license}}, \code{\link{add_license_header}} -#' @return NULL -add_readme <- function(path = ".", package = FALSE, CoC = TRUE) { - if (CoC == TRUE) add_code_of_conduct() - - if (package) fname <- "pkg-README.md" else fname <- "README.md" - - add_file_from_template(path, fname, outfile = "README.md") - invisible(TRUE) -} - -#' Add a CONTRIBUTING.md file to the project directory -#' -#' @param path Directory path (default \code{"."}) -#' @param package Is this a package or a regular project? (Default \code{FALSE}). -#' If \code{TRUE}, "CONTRIBUTING.md" will be added to .Rbuildignore -#' @export -#' @seealso \code{\link{add_readme}}, \code{\link{add_license}}, \code{\link{add_license_header}} -#' @return \code{TRUE} (invisibly) -add_contributing <- function(path = ".", package = FALSE) { - add_file_from_template(path, "CONTRIBUTING.md") - if (package) add_to_rbuildignore(path = path, text = "CONTRIBUTING.md") - invisible(TRUE) -} - -#' Add a CODE_OF_CONDUCT.md file to the project directory -#' -#' @param path Directory path (default \code{"."}) -#' @param package Is this a package or a regular project? (Default \code{FALSE}). -#' If \code{TRUE}, "CODE_OF_CONDUCT.md" will be added to .Rbuildignore -#' @export -#' @seealso \code{\link{add_readme}}, \code{\link{add_license}}, \code{\link{add_license_header}} -#' @return \code{TRUE} (invisibly) -add_code_of_conduct <- function(path = ".", package = FALSE) { - add_file_from_template(path, "CODE_OF_CONDUCT.md") - if (package) add_to_rbuildignore(path = path, text = "CODE_OF_CONDUCT.md") - message("* Don't forget to describe the code of conduct in your README.md/Rmd:") - message("Please note that this project is released with a ", - "[Contributor Code of Conduct](CODE_OF_CONDUCT.md). ", - "By participating in this project you agree to abide by its terms.") - invisible(TRUE) -} - -#' Add a LICENSE file (Apache 2.0) to the project directory -#' -#' @param path Directory path (default \code{"."}) -#' @param package_desc Should the license be added to the DESCRIPTION file if this is a package? -#' -#' @export -#' @seealso \code{\link{add_readme}}, \code{\link{add_contributing}}, \code{\link{add_license_header}} -#' @return NULL -add_license <- function(path = ".", package_desc = FALSE) { - add_file_from_template(path, "LICENSE") - if (package_desc) { - desc <- readLines(file.path(path, "DESCRIPTION")) - desc[grep("License:", desc)] <- "License: Apache License (== 2.0) | file LICENSE" - writeLines(desc, "DESCRIPTION") - } - invisible(TRUE) -} - -#' Add an RProject file to a directory -#' -#' @param path folder path of the project -#' @param outfile the name of the RProj file -#' @export -#' @seealso \code{\link{add_readme}}, \code{\link{add_license}}, \code{\link{add_license_header}} -#' @return NULL -add_rproj <- function(path = ".", outfile) { - add_file_from_template(path, "template.Rproj", outfile) - invisible(TRUE) -} - -#' Add a file to a directory from a template in inst/templates -#' -#' Should really only be called by other functions -#' -#' @param path Directory path (default \code{"."}) -#' @param fname the name of the template file in inst/templates -#' @param outfile name of the file to be written, if different from the name of the template file -#' @param pkg package from which to load the template -#' @keywords internal -#' @seealso \code{\link{add_readme}}, \code{\link{add_contributing}}, \code{\link{add_license}} -#' @return NULL -add_file_from_template <- function(path, fname, outfile = NULL, pkg = "envreportutils") { - - if (!dir.exists(path)) dir.create(path) - - path <- normalizePath(path, winslash = "/", mustWork = TRUE) - - if (is.null(outfile)) { - outfile <- file.path(path, fname) - } else { - outfile <- file.path(path, outfile) - } - - if (file.exists(outfile)) { - warning(paste(outfile, "already exists. Not adding a new one")) - } else { - message(paste("Adding file", outfile)) - - template_path <- system.file("templates", fname, package = pkg) - - file.copy(template_path, outfile) - } - - invisible(TRUE) -} - -#' Add the boilerplate Apache header to the top of a source code file -#' -#' @param file Path to the file -#' @param year The year the license should apply -#' @param copyright_holder Copyright holder (Default "Province of British Columbia") -#' @export -#' @seealso \code{\link{add_license}} -#' @return NULL -add_license_header <- function(file, year, copyright_holder = "Province of British Columbia") { - - file_text <- readLines(file) - - license_text <- make_license_header_text(year, copyright_holder) - - writeLines(c(license_text, file_text), file) - message("adding Apache boilerplate header to the top of ", file) - - invisible(TRUE) -} - -make_license_header_text <- function(year = NULL, copyright_holder = "Province of British Columbia") { - license_txt <- '# Copyright YYYY COPYRIGHT_HOLDER -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and limitations under the License. - -' - if (is.null(year)) year <- format(Sys.Date(), "%Y") - - license_txt <- gsub("YYYY", year, license_txt) - license_txt <- gsub("COPYRIGHT_HOLDER", copyright_holder, license_txt) - license_txt -} - -#' Add text to Rbuildignore -#' -#' @param path -#' @param text -#' -#' @return TRUE -#' @keywords internal -add_to_rbuildignore <- function(path, text) { - fpath <- file.path(path, ".Rbuildignore") - rbuildignore <- character(0) - if (file.exists(fpath)) rbuildignore <- readLines(fpath) - if (!any(grepl(text, rbuildignore))) { - rbuildignore <- c(rbuildignore, text) - writeLines(rbuildignore, fpath) - } - invisible(TRUE) -} diff --git a/R/addins.R b/R/addins.R index f038691..01d3ab3 100644 --- a/R/addins.R +++ b/R/addins.R @@ -12,20 +12,6 @@ #' @importFrom rstudioapi insertText getActiveDocumentContext -devex_badge_addin <- function() { - txt <- " -```{r echo=FALSE, results='asis'} -## Insert 'inspiration', 'exploration', or 'delivery' -envreportutils::devex_badge('') -``` -" - rstudioapi::insertText(text = txt) -} - -license_header_addin <- function() { - txt <- make_license_header_text() - rstudioapi::insertText(location = c(1,1), text = txt) -} envreportbc_footer_addin <- function() { txt <- "\nThis repository is maintained by [Environmental Reporting BC](http://www2.gov.bc.ca/gov/content?id=FF80E0B985F245CEA62808414D78C41B). Click [here](https://github.com/bcgov/EnvReportBC-RepoList) for a complete list of our repositories on GitHub." diff --git a/R/analysis_skeleton.R b/R/analysis_skeleton.R deleted file mode 100644 index b55da91..0000000 --- a/R/analysis_skeleton.R +++ /dev/null @@ -1,127 +0,0 @@ -# Copyright 2015 Province of British Columbia -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and limitations under the License. - -#' Creates the framework of a new analysis development folder -#' -#' Creates the folder structure for a new analysis. -#' -#' @importFrom git2r repository init -#' -#' @param path location to create new analysis. If \code{"."} (the default), -#' the name of the working directory will be taken as the analysis name. If -#' not \code{"."}, the last component of the given path will be used as the -#' analysis name. -#' @param git_init Create a new git repository? Logical, default \code{TRUE}. -#' @param git_clone the url of a git repo to clone. -#' @param rstudio Create an Rstudio project file? -#' @param apache Add licensing info for release under Apache 2.0? Default \code{TRUE}. -#' @param CoC Should a Code of Conduct be added to the repository? Default \code{TRUE}. -#' @param copyright_holder the name of the copyright holder (default -#' "Province of British Columbia). Only necessary if adding a license -#' -#' @details If you are cloning a repository (\code{git_clone = "path_to_repo"}), -#' you should run this function from the root of your dev folder and leave -#' \code{path = "."}, as the repository will be cloned into a new folder. If -#' you are setting up a new project (with or without git), \code{path} should -#' be \code{"."} if you are within an already created project directory, or -#' the name of the folder you want to create. -#' @export -#' -#' @examples \donttest{ -#' analysis_skeleton(path = "c:/_dev/tarballs", rstudio = TRUE) -#' } -analysis_skeleton <- function(path = ".", git_init = TRUE, git_clone = NULL, - rstudio = TRUE, apache = TRUE, CoC = TRUE, - copyright_holder = "Province of British Columbia") { - -# now <- Sys.time() -# options(error = quote(error_cleanup(now))) -# on.exit(options(error = NULL), add = TRUE) - - if (path != ".") dir.create(path, recursive = TRUE) - - npath <- normalizePath(path, winslash = "/", mustWork = TRUE) - - if (is.character(git_clone)) { - clone_git(git_clone, npath) - git_init = FALSE - } - - ## Need to check for analysis structure - Rfiles <- file.path(npath, c("01_load.R", "02_clean.R", "03_analysis.R", "04_output.R", - "internal.R", "run_all.R")) - dirs <- file.path(npath, c("out", "tmp", "data")) - - if (any(file.exists(Rfiles, dirs))) { ## file.exists is case-insensitive - #if (git) unlink(c(".git", ".gitignore", recursive = TRUE, force = TRUE) - stop("It looks as though you already have an analysis set up here!") - } - - ## Add the necessary R files and directories - message("Creating new analysis in ", npath) - lapply(Rfiles, file.create) - lapply(dirs, dir.create) - add_contributing(npath) - if (CoC) add_code_of_conduct(npath, package = FALSE) - add_readme(npath, package = FALSE) - - cat('source("01_load.R") -source("02_clean.R") -source("03_analysis.R") -source("04_output.R") - -## Make print version -mon_year <- format(Sys.Date(), "%B%Y") -outfile <- paste0("envreportbc_[indicator_name]_", mon_year, ".pdf") -rmarkdown::render("print_ver/[indicator_name].Rmd", output_file = outfile) -extrafont::embed_fonts(file.path("print_ver/", outfile)) -## You will likely want to "optimize pdf" in Acrobat to make the print version smaller.\n', - file = file.path(npath,"run_all.R")) - - if (apache) { - add_license(npath) - lapply(Rfiles, add_license_header, year = substr(Sys.Date(), 1, 4), - copyright_holder = copyright_holder) - } - - if (rstudio) { - if (!length(list.files(npath, pattern = "*.Rproj", ignore.case = TRUE))) { - add_rproj(npath, paste0(basename(npath), ".Rproj")) - } else { - warning("Rproj file already exists, so not adding a new one") - } - } - - if (git_init) { - if (file.exists(file.path(npath,".git"))) { - warning("This directory is already a git repository. Not creating a new one") - } else { - init(npath) - } - } - - if (git_init || is.character(git_clone)) { - write_gitignore(".Rproj.user", ".Rhistory", ".RData", "out/", "tmp/", - "internal.R", path = npath) - } - setwd(npath) - message("Setting working directory to ", npath) - invisible(npath) -} - -# Function to be executed on error, to clean up files that were created -# error_cleanup <- function(t) { -# info <- file.info(list.files(all.files = TRUE, include.dirs = TRUE, no.. = TRUE)) -# del_files <- rownames(info[t < info$ctime, ]) -# cat("Deleting generatedfiles:", del_files) -# unlink(del_files, recursive = TRUE, force = TRUE) -# } diff --git a/R/defunct.R b/R/defunct.R new file mode 100644 index 0000000..ceebf95 --- /dev/null +++ b/R/defunct.R @@ -0,0 +1,92 @@ +# Copyright 2017 Province of British Columbia +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and limitations under the License. + + +#' Defunct functions in envreportutils +#' +#' These functions are no longer available in this package. +#' +#' All of these functions, except roxygen_template, are available in the bcgovr +#' package available on GitHub here: https://github.com/bcgov/bcgovr +#' +#' \itemize{ +#' \item \code{\link{roxygen_template}}: This function is defunct. +#' \item \code{\link{devex_badge}}: This function is defunct. +#' \item \code{\link{analysis_skeleton}}: This function is defunct. +#' \item \code{\link{add_code_of_conduct}}: This function is defunct. +#' \item \code{\link{add_contributing}}: This function is defunct. +#' \item \code{\link{add_license}}: This function is defunct. +#' \item \code{\link{add_license_header}}: This function is defunct. +#' \item \code{\link{add_readme}}: This function is defunct. +#' \item \code{\link{add_rproj}}: This function is defunct. +#' } +#' +#' @param ... any paramters passed are ignored +#' +#' +#' @name envreportutils-deprecated +NULL + + +#' @rdname envreportutils-deprecated +roxygen_template <- function(...) { + .Defunct("the RStudio shortcut Ctrl+Alt+Shift+R") +} + +#' @rdname envreportutils-deprecated +devex_badge <- function(...) { + .Defunct("bcgovr::devex_badge") +} + +#' @rdname envreportutils-deprecated +analysis_skeleton <- function(...) { + .Defunct("bcgovr::analysis_skeleton") +} + +#' @rdname envreportutils-deprecated +add_code_of_conduct <- function(...) { + .Defunct("bcgovr::add_code_of_conduct") +} + +#' @rdname envreportutils-deprecated +add_contributing <- function(...) { + .Defunct("bcgovr::add_contributing") +} + +#' @rdname envreportutils-deprecated +add_license <- function(...) { + .Defunct("bcgovr::add_license") +} + +#' @rdname envreportutils-deprecated +add_license_header <- function(...) { + .Defunct("bcgovr::add_license_header") +} + +#' @rdname envreportutils-deprecated +add_readme <- function(...) { + .Defunct("bcgovr::add_readme") +} + +#' @rdname envreportutils-deprecated +add_rproj <- function(...) { + .Defunct("bcgovr::add_rproj") +} + + + + + + + + + diff --git a/R/devex_badge.R b/R/devex_badge.R deleted file mode 100644 index 7a01062..0000000 --- a/R/devex_badge.R +++ /dev/null @@ -1,32 +0,0 @@ -#' Add html for BC DevExchange project state badge -#' -#' @param project_state one of:'inspiration', 'exploration', or 'delivery' -#' @param cat use cat to print the result (\code{TRUE}; default) or return a character vector (\code{FALSE})? -#' -#' @return html -#' @export -devex_badge <- function(project_state, cat = TRUE) { - project_state <- tolower(project_state) - if (!project_state %in% c("inspiration", "exploration", "delivery") || - length(project_state) != 1L) { - stop("project_state should be one of 'inspiration', 'exploration', or 'delivery'") - } - html <- make_badge(state = project_state) - if (!cat) { - return(html) - } else { - cat(html) - invisible(NULL) - } -} - -make_badge <- function(state) { - title <- tools::toTitleCase(state) - state_desc <- c(inspiration = "An idea being explored and shaped. Open for discussion, but may never go anywhere.", - exploration = "Being designed and built, but in the lab. May change, disappear, or be buggy.", - delivery = "In production, but maybe in Alpha or Beta. Intended to persist and be supported.")[state] - paste0('
', state_desc, 
-         '
') -} diff --git a/R/roxygen_template.R b/R/roxygen_template.R deleted file mode 100644 index 5cd8cbd..0000000 --- a/R/roxygen_template.R +++ /dev/null @@ -1,83 +0,0 @@ -# Copyright 2015 Province of British Columbia -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and limitations under the License. - -#' Populate the boilerplate roxygen template at the top of the function. -#' -#' Inspired by Karthik Ram's RTools Sublime Text 2 plugin: -#' https://github.com/karthik/Rtools -#' @param funfile path to the .R file containing the function -#' @param func the name of the function you want to document -#' @param export Is the function exported (default \code{TRUE})? If \code{FALSE} -#' keyword 'internal' is added -#' @importFrom utils file.edit -#' @export -#' -#' @return nothing, but adds the roxygen template to the top of the file -roxygen_template <- function(funfile, func, export = TRUE) { - - stopifnot(is.character(funfile), is.character(func)) - - fun_text <- readLines(funfile, warn=FALSE) - - fundef_start <- grep(paste0(func, "\\s*(<-|=)\\s*function\\s*\\("), fun_text) - - # Check the previous few lines to make sure roxygen block doesn't already exist - check_lines <- function(n) { - from <- n - min(5, (n - 1)) - to <- n - 1 - - if (any(grepl("^#'", fun_text[from:to]))) { - stop("It appears you already have roxygen documentation for your function!") - } - } - - if (fundef_start > 1) { - check_lines(fundef_start) - } - - if (fundef_start == 1) { - above <- NULL - } else { - above <- fun_text[1:(fundef_start - 1)] - } - - the_rest <- fun_text[fundef_start:length(fun_text)] - - source(funfile, local = TRUE) - params <- names(formals(func)) - - # Put together the roxygen fields: - params <- paste0("#' @param ", params, " ") - top <- paste("#' ", - "#'", "#' ","#'", - "#' @import ", - "#' @importFrom ", - sep = "\n") - exp <- ifelse(export, "#' @export", "#' @keywords internal") - end <- paste("#' @seealso ", - "#' @return ", - "#' @examples \\dontrun{", - "#'", - "#'}", sep = "\n") - roxy <- paste(c(top, params, exp, end), sep="") - - ## Strip off leading whitespace from roxy lines: - roxy <- gsub("(^|\\n)\\s+", "\\1", roxy) - - # Write to the top of the file (without asking... should be safe, i think) - writeLines(c(above, roxy, the_rest), funfile) - - # Open the file to fill in documentation - file.edit(funfile) - - invisible(NULL) -} diff --git a/README.Rmd b/README.Rmd index 7458889..f967742 100644 --- a/README.Rmd +++ b/README.Rmd @@ -15,7 +15,7 @@ knitr::opts_chunk$set( ``` ```{r, echo=FALSE, results='asis'} -envreportutils::devex_badge("delivery") +bcgovr::devex_badge("delivery") ``` [![Travis-CI Build Status](https://travis-ci.org/bcgov/envreportutils.svg?branch=master)](https://travis-ci.org/bcgov/envreportutils) diff --git a/man/add_code_of_conduct.Rd b/man/add_code_of_conduct.Rd deleted file mode 100644 index 399e7a4..0000000 --- a/man/add_code_of_conduct.Rd +++ /dev/null @@ -1,23 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/add_meta.R -\name{add_code_of_conduct} -\alias{add_code_of_conduct} -\title{Add a CODE_OF_CONDUCT.md file to the project directory} -\usage{ -add_code_of_conduct(path = ".", package = FALSE) -} -\arguments{ -\item{path}{Directory path (default \code{"."})} - -\item{package}{Is this a package or a regular project? (Default \code{FALSE}). -If \code{TRUE}, "CODE_OF_CONDUCT.md" will be added to .Rbuildignore} -} -\value{ -\code{TRUE} (invisibly) -} -\description{ -Add a CODE_OF_CONDUCT.md file to the project directory -} -\seealso{ -\code{\link{add_readme}}, \code{\link{add_license}}, \code{\link{add_license_header}} -} diff --git a/man/add_contributing.Rd b/man/add_contributing.Rd deleted file mode 100644 index 3844a5d..0000000 --- a/man/add_contributing.Rd +++ /dev/null @@ -1,23 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/add_meta.R -\name{add_contributing} -\alias{add_contributing} -\title{Add a CONTRIBUTING.md file to the project directory} -\usage{ -add_contributing(path = ".", package = FALSE) -} -\arguments{ -\item{path}{Directory path (default \code{"."})} - -\item{package}{Is this a package or a regular project? (Default \code{FALSE}). -If \code{TRUE}, "CONTRIBUTING.md" will be added to .Rbuildignore} -} -\value{ -\code{TRUE} (invisibly) -} -\description{ -Add a CONTRIBUTING.md file to the project directory -} -\seealso{ -\code{\link{add_readme}}, \code{\link{add_license}}, \code{\link{add_license_header}} -} diff --git a/man/add_file_from_template.Rd b/man/add_file_from_template.Rd deleted file mode 100644 index 2b9d448..0000000 --- a/man/add_file_from_template.Rd +++ /dev/null @@ -1,24 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/add_meta.R -\name{add_file_from_template} -\alias{add_file_from_template} -\title{Add a file to a directory from a template in inst/templates} -\usage{ -add_file_from_template(path, fname, outfile = NULL, pkg = "envreportutils") -} -\arguments{ -\item{path}{Directory path (default \code{"."})} - -\item{fname}{the name of the template file in inst/templates} - -\item{outfile}{name of the file to be written, if different from the name of the template file} - -\item{pkg}{package from which to load the template} -} -\description{ -Should really only be called by other functions -} -\seealso{ -\code{\link{add_readme}}, \code{\link{add_contributing}}, \code{\link{add_license}} -} -\keyword{internal} diff --git a/man/add_license.Rd b/man/add_license.Rd deleted file mode 100644 index 409ae03..0000000 --- a/man/add_license.Rd +++ /dev/null @@ -1,19 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/add_meta.R -\name{add_license} -\alias{add_license} -\title{Add a LICENSE file (Apache 2.0) to the project directory} -\usage{ -add_license(path = ".", package_desc = FALSE) -} -\arguments{ -\item{path}{Directory path (default \code{"."})} - -\item{package_desc}{Should the license be added to the DESCRIPTION file if this is a package?} -} -\description{ -Add a LICENSE file (Apache 2.0) to the project directory -} -\seealso{ -\code{\link{add_readme}}, \code{\link{add_contributing}}, \code{\link{add_license_header}} -} diff --git a/man/add_license_header.Rd b/man/add_license_header.Rd deleted file mode 100644 index 3d5373e..0000000 --- a/man/add_license_header.Rd +++ /dev/null @@ -1,22 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/add_meta.R -\name{add_license_header} -\alias{add_license_header} -\title{Add the boilerplate Apache header to the top of a source code file} -\usage{ -add_license_header(file, year, - copyright_holder = "Province of British Columbia") -} -\arguments{ -\item{file}{Path to the file} - -\item{year}{The year the license should apply} - -\item{copyright_holder}{Copyright holder (Default "Province of British Columbia")} -} -\description{ -Add the boilerplate Apache header to the top of a source code file -} -\seealso{ -\code{\link{add_license}} -} diff --git a/man/add_readme.Rd b/man/add_readme.Rd deleted file mode 100644 index d0027de..0000000 --- a/man/add_readme.Rd +++ /dev/null @@ -1,21 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/add_meta.R -\name{add_readme} -\alias{add_readme} -\title{Add a README.md file to the project directory} -\usage{ -add_readme(path = ".", package = FALSE, CoC = TRUE) -} -\arguments{ -\item{path}{Directory path (default \code{"."})} - -\item{package}{Is this a package or a regular project? (Default \code{FALSE})} - -\item{CoC}{Should a Code of Conduct be added to the repository?} -} -\description{ -Add a README.md file to the project directory -} -\seealso{ -\code{\link{add_contributing}}, \code{\link{add_license}}, \code{\link{add_license_header}} -} diff --git a/man/add_rproj.Rd b/man/add_rproj.Rd deleted file mode 100644 index 5886f73..0000000 --- a/man/add_rproj.Rd +++ /dev/null @@ -1,19 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/add_meta.R -\name{add_rproj} -\alias{add_rproj} -\title{Add an RProject file to a directory} -\usage{ -add_rproj(path = ".", outfile) -} -\arguments{ -\item{path}{folder path of the project} - -\item{outfile}{the name of the RProj file} -} -\description{ -Add an RProject file to a directory -} -\seealso{ -\code{\link{add_readme}}, \code{\link{add_license}}, \code{\link{add_license_header}} -} diff --git a/man/add_to_rbuildignore.Rd b/man/add_to_rbuildignore.Rd deleted file mode 100644 index 96d46e8..0000000 --- a/man/add_to_rbuildignore.Rd +++ /dev/null @@ -1,20 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/add_meta.R -\name{add_to_rbuildignore} -\alias{add_to_rbuildignore} -\title{Add text to Rbuildignore} -\usage{ -add_to_rbuildignore(path, text) -} -\arguments{ -\item{path}{} - -\item{text}{} -} -\value{ -TRUE -} -\description{ -Add text to Rbuildignore -} -\keyword{internal} diff --git a/man/analysis_skeleton.Rd b/man/analysis_skeleton.Rd deleted file mode 100644 index 685e659..0000000 --- a/man/analysis_skeleton.Rd +++ /dev/null @@ -1,45 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/analysis_skeleton.R -\name{analysis_skeleton} -\alias{analysis_skeleton} -\title{Creates the framework of a new analysis development folder} -\usage{ -analysis_skeleton(path = ".", git_init = TRUE, git_clone = NULL, - rstudio = TRUE, apache = TRUE, CoC = TRUE, - copyright_holder = "Province of British Columbia") -} -\arguments{ -\item{path}{location to create new analysis. If \code{"."} (the default), -the name of the working directory will be taken as the analysis name. If -not \code{"."}, the last component of the given path will be used as the -analysis name.} - -\item{git_init}{Create a new git repository? Logical, default \code{TRUE}.} - -\item{git_clone}{the url of a git repo to clone.} - -\item{rstudio}{Create an Rstudio project file?} - -\item{apache}{Add licensing info for release under Apache 2.0? Default \code{TRUE}.} - -\item{CoC}{Should a Code of Conduct be added to the repository? Default \code{TRUE}.} - -\item{copyright_holder}{the name of the copyright holder (default -"Province of British Columbia). Only necessary if adding a license} -} -\description{ -Creates the folder structure for a new analysis. -} -\details{ -If you are cloning a repository (\code{git_clone = "path_to_repo"}), - you should run this function from the root of your dev folder and leave - \code{path = "."}, as the repository will be cloned into a new folder. If - you are setting up a new project (with or without git), \code{path} should - be \code{"."} if you are within an already created project directory, or - the name of the folder you want to create. -} -\examples{ -\donttest{ - analysis_skeleton(path = "c:/_dev/tarballs", rstudio = TRUE) -} -} diff --git a/man/clone_git.Rd b/man/clone_git.Rd deleted file mode 100644 index 58932a0..0000000 --- a/man/clone_git.Rd +++ /dev/null @@ -1,19 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/add_git.R -\name{clone_git} -\alias{clone_git} -\title{Clones a remote repository} -\usage{ -clone_git(url, path) -} -\arguments{ -\item{url}{url of remote git repository} - -\item{path}{path to clone into} -} -\value{ -a repository object -} -\description{ -Clones a remote repository -} diff --git a/man/devex_badge.Rd b/man/devex_badge.Rd deleted file mode 100644 index a6ef980..0000000 --- a/man/devex_badge.Rd +++ /dev/null @@ -1,19 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/devex_badge.R -\name{devex_badge} -\alias{devex_badge} -\title{Add html for BC DevExchange project state badge} -\usage{ -devex_badge(project_state, cat = TRUE) -} -\arguments{ -\item{project_state}{one of:'inspiration', 'exploration', or 'delivery'} - -\item{cat}{use cat to print the result (\code{TRUE}; default) or return a character vector (\code{FALSE})?} -} -\value{ -html -} -\description{ -Add html for BC DevExchange project state badge -} diff --git a/man/envreportutils-deprecated.Rd b/man/envreportutils-deprecated.Rd new file mode 100644 index 0000000..d3ae9f5 --- /dev/null +++ b/man/envreportutils-deprecated.Rd @@ -0,0 +1,55 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/defunct.R +\name{envreportutils-deprecated} +\alias{envreportutils-deprecated} +\alias{roxygen_template} +\alias{devex_badge} +\alias{analysis_skeleton} +\alias{add_code_of_conduct} +\alias{add_contributing} +\alias{add_license} +\alias{add_license_header} +\alias{add_readme} +\alias{add_rproj} +\title{Defunct functions in envreportutils} +\usage{ +roxygen_template(...) + +devex_badge(...) + +analysis_skeleton(...) + +add_code_of_conduct(...) + +add_contributing(...) + +add_license(...) + +add_license_header(...) + +add_readme(...) + +add_rproj(...) +} +\arguments{ +\item{...}{any paramters passed are ignored} +} +\description{ +These functions are no longer available in this package. +} +\details{ +All of these functions, except roxygen_template, are available in the bcgovr +package available on GitHub here: https://github.com/bcgov/bcgovr + +\itemize{ + \item \code{\link{roxygen_template}}: This function is defunct. + \item \code{\link{devex_badge}}: This function is defunct. + \item \code{\link{analysis_skeleton}}: This function is defunct. + \item \code{\link{add_code_of_conduct}}: This function is defunct. + \item \code{\link{add_contributing}}: This function is defunct. + \item \code{\link{add_license}}: This function is defunct. + \item \code{\link{add_license_header}}: This function is defunct. + \item \code{\link{add_readme}}: This function is defunct. + \item \code{\link{add_rproj}}: This function is defunct. +} +} diff --git a/man/roxygen_template.Rd b/man/roxygen_template.Rd deleted file mode 100644 index ede8312..0000000 --- a/man/roxygen_template.Rd +++ /dev/null @@ -1,23 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/roxygen_template.R -\name{roxygen_template} -\alias{roxygen_template} -\title{Populate the boilerplate roxygen template at the top of the function.} -\usage{ -roxygen_template(funfile, func, export = TRUE) -} -\arguments{ -\item{funfile}{path to the .R file containing the function} - -\item{func}{the name of the function you want to document} - -\item{export}{Is the function exported (default \code{TRUE})? If \code{FALSE} -keyword 'internal' is added} -} -\value{ -nothing, but adds the roxygen template to the top of the file -} -\description{ -Inspired by Karthik Ram's RTools Sublime Text 2 plugin: -https://github.com/karthik/Rtools -} diff --git a/tests/testthat.R b/tests/testthat.R index 1daa7cd..4ec21f9 100644 --- a/tests/testthat.R +++ b/tests/testthat.R @@ -1,5 +1,4 @@ library(testthat) library(envreportutils) -library(git2r) test_check("envreportutils") diff --git a/tests/testthat/test-analysis_skeleton.R b/tests/testthat/test-analysis_skeleton.R deleted file mode 100644 index f4ff4b3..0000000 --- a/tests/testthat/test-analysis_skeleton.R +++ /dev/null @@ -1,119 +0,0 @@ -context("analysis_skeleton") -options(warn = 2) -expected_files <- c(".git", "data", "out", "tmp", - ".gitignore", "01_load.R", "02_clean.R", "03_analysis.R", - "04_output.R", "CONTRIBUTING.md", "CODE_OF_CONDUCT.md", - "internal.R", "LICENSE", "README.md", "run_all.R") - -name_incrementer <- function(name) { - i <- 0 - function() { - i <<- i + 1 - paste0(name, i) - } -} - -increment_foo <- name_incrementer("foo") - -test_that("analysis_skeleton works with dot path and git_init", { - base_dir <- increment_foo() - dir <- tempdir() - dir.create(file.path(dir, base_dir)) - setwd(file.path(dir, base_dir)) - ret <- analysis_skeleton() - skip_on_travis() - expect_equal(normalizePath(ret, winslash = "/"), - normalizePath(".", winslash = "/")) - files <- list.files(all.files = TRUE, full.names = TRUE, include.dirs = TRUE, no.. = TRUE) - skip_on_travis() - expect_equal(sort(normalizePath(files, winslash = "/")), - sort(normalizePath( - file.path(".", c(expected_files, paste0(base_dir, ".Rproj"))), - winslash = "/"))) -}) - -test_that("analysis_skeleton works with relative path and git init", { - base_dir <- increment_foo() - dir <- tempdir() - setwd(dir) - ret <- analysis_skeleton(base_dir, git_init = TRUE) - skip_on_travis() - expect_equal(normalizePath(ret, winslash = "/"), - normalizePath(file.path(dir, base_dir), winslash = "/")) - files <- list.files(file.path(dir, base_dir), all.files = TRUE, - full.names = TRUE, include.dirs = TRUE, no.. = TRUE) - skip_on_travis() - expect_equal(sort(normalizePath(files, winslash = "/")), - sort(normalizePath( - file.path(dir, base_dir, c(expected_files, paste0(base_dir, ".Rproj"))), - winslash = "/"))) -}) - -test_that("analysis_skeleton works with absolute path and git init", { - base_dir <- increment_foo() - dir <- file.path(tempdir(), base_dir) - ret <- analysis_skeleton(dir, git_init = TRUE) - skip_on_travis() - expect_equal(normalizePath(ret), normalizePath(dir)) - files <- list.files(dir, all.files = TRUE, full.names = TRUE, - include.dirs = TRUE, no.. = TRUE) - skip_on_travis() - expect_equal(sort(normalizePath(files)), - sort(normalizePath(file.path(dir, - c(expected_files, paste0(base_dir, ".Rproj")))))) -}) - -bare_repo_path <- file.path(tempdir(), "bare_test_repo.git") -dir.create(bare_repo_path, recursive = TRUE) -bare_repo <- init(bare_repo_path, bare = TRUE) - -test_that("analysis_skeleton works with dot path and git clone", { - base_dir <- increment_foo() - dir <- tempdir() - dir.create(file.path(dir, base_dir)) - setwd(file.path(dir, base_dir)) - ret <- analysis_skeleton(git_clone = bare_repo) - skip_on_travis() - expect_equal(normalizePath(ret), normalizePath(".")) - files <- list.files(all.files = TRUE, full.names = TRUE, - include.dirs = TRUE, no.. = TRUE) - skip_on_travis() - expect_equal(sort(normalizePath(files)), - sort(normalizePath(file.path(".", - c(expected_files, paste0(base_dir, ".Rproj")))))) -}) - -test_that("analysis_skeleton works with relative path and git clone", { - base_dir <- increment_foo() - dir <- tempdir() - setwd(dir) - ret <- analysis_skeleton(base_dir, git_clone = bare_repo) - skip_on_travis() - expect_equal(normalizePath(ret, winslash = "/"), - normalizePath(file.path(dir, base_dir), winslash = "/")) - files <- list.files(file.path(dir, base_dir), all.files = TRUE, - full.names = TRUE, include.dirs = TRUE, no.. = TRUE) - skip_on_travis() - expect_equal(sort(normalizePath(files, winslash = "/")), - sort(normalizePath( - file.path(dir, base_dir, c(expected_files, paste0(base_dir, ".Rproj"))), - winslash = "/"))) -}) - -test_that("analysis_skeleton works with absolute path and git clone", { - base_dir <- increment_foo() - dir <- file.path(tempdir(), base_dir) - ret <- analysis_skeleton(dir, git_clone = bare_repo) - skip_on_travis() - expect_equal(normalizePath(ret, winslash = "/"), - normalizePath(dir, winslash = "/")) - files <- list.files(dir, all.files = TRUE, full.names = TRUE, - include.dirs = TRUE, no.. = TRUE) - skip_on_travis() - expect_equal(sort(normalizePath(files, winslash = "/")), - sort(normalizePath( - file.path(dir, c(expected_files, paste0(base_dir, ".Rproj"))), - winslash = "/"))) -}) - -unlink(bare_repo_path, recursive = TRUE, force = TRUE)