/
covrpage.R
51 lines (44 loc) · 1.42 KB
/
covrpage.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#' @title Render covrpage
#' @description Render the template of the covrpage in the package directory.
#' @param path path to package
#' @param preview boolean, to open the output in viewer, Default: TRUE
#' @param auto_push boolean, push to remote repo on exit, Default: FALSE
#' @param update_badge boolean, locate badge in README and update with
#' testthat results, Default: TRUE
#' @param vignette boolean, if TRUE then the covrpage README will be copied
#' as a vignette of the package, Default: FALSE
#' @seealso
#' \code{\link[rmarkdown]{render}}
#' @rdname covrpage
#' @family invoke
#' @export
#' @importFrom rmarkdown render
#' @importFrom git2r repository add commit push
#' @importFrom utils tail
covrpage <- function(path = getwd(), preview = TRUE, auto_push = FALSE, update_badge = TRUE, vignette = FALSE) {
testdir <- file.path(path, "tests")
thiswd <- getwd()
on.exit({
covrpage_cleanup(
preview = preview,
auto_push = auto_push,
update_badge = update_badge,
vignette = vignette
)
setwd(thiswd)
}, add = TRUE)
check_for_pkgs(path)
check_for_tests(testdir)
setwd(path)
file.copy(
system.file("covrpage.Rmd", package = "covrpage"),
"tests/_covrpage.Rmd"
)
rmarkdown::render(
input = "tests/_covrpage.Rmd",
output_file = "README.md",
output_dir = "tests",
output_format = "github_document",
output_options = list(toc = TRUE, toc_depth = 3)
)
}