Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9923e41
commit 40501eb
Showing
29 changed files
with
469 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#' addPareArticle | ||
#' | ||
#' Writes an Rmd-file to `./vignettes/articles/PaReReport.Rmd`. The relative | ||
#' path is dictated by the specified path in the \link[PaRe]{Repository} object. | ||
#' | ||
#' @param repo (\link[PaRe]{Repository}) | ||
#' Repository object. | ||
#' | ||
#' @return `NULL` | ||
#' Writes Rmd-file to ./vignettes/articles/PaReReport.Rmd | ||
#' | ||
#' @export | ||
#' | ||
#' @examples | ||
#' fetchedRepo <- tryCatch( | ||
#' { | ||
#' # Set dir to clone repository to. | ||
#' tempDir <- tempdir() | ||
#' pathToRepo <- file.path(tempDir, "glue") | ||
#' | ||
#' # Clone repo | ||
#' git2r::clone( | ||
#' url = "https://github.com/darwin-eu/IncidencePrevalence.git", | ||
#' local_path = pathToRepo | ||
#' ) | ||
#' | ||
#' # Create instance of Repository object. | ||
#' repo <- PaRe::Repository$new(path = pathToRepo) | ||
#' | ||
#' # Set fetchedRepo to TRUE if all goes well. | ||
#' TRUE | ||
#' }, | ||
#' error = function(e) { | ||
#' # Set fetchedRepo to FALSE if an error is encountered. | ||
#' FALSE | ||
#' }, | ||
#' warning = function(w) { | ||
#' # Set fetchedRepo to FALSE if a warning is encountered. | ||
#' FALSE | ||
#' } | ||
#' ) | ||
#' | ||
#' if (fetchedRepo) { | ||
#' # Run makeReport on the Repository object. | ||
#' addPaReArticle(repo) | ||
#' } | ||
addPareArticle <- function(repo) { | ||
injected <- readLines( | ||
con = system.file(package = "PaRe", "rmd", "ReportInjectable.Rmd") | ||
) %>% | ||
gsub( | ||
pattern = "#!P_TITLE", | ||
replacement = glue::glue("{repo$getName()} [{repo$getDescription()$get_version()}]") | ||
) %>% | ||
gsub( | ||
pattern = "#!P_PATH", | ||
replacement = repo$getPath() | ||
) | ||
|
||
dir.create(file.path(repo$getPath(), "vignettes", "articles")) | ||
|
||
writeLines( | ||
text = injected, | ||
con = file.path( | ||
repo$getPath(), "vignettes", "articles", "PareReport.Rmd" | ||
) | ||
) | ||
return(invisible(NULL)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.