-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocumentPackage.R
More file actions
66 lines (50 loc) · 2.12 KB
/
Copy pathdocumentPackage.R
File metadata and controls
66 lines (50 loc) · 2.12 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
{
rm(list = ls())
options(error = NULL)
# Set path and specify package name
package_name <- "LinkOrgs"
setwd(sprintf("~/Documents/%s-software", package_name))
# Version number (should match DESCRIPTION)
versionNumber <- "0.01"
# Package path
package_path <- sprintf("~/Documents/%s-software/%s", package_name, package_name)
# Add data list if package has data
tools::add_datalist(package_path, force = TRUE, small.size = 1L)
# Build vignettes
devtools::build_vignettes(package_path)
# Generate documentation from roxygen comments
devtools::document(package_path)
# Remove old PDF manual
try(file.remove(sprintf("%s/../%s.pdf", package_path, package_name)), silent = TRUE)
# Create new PDF manual
system(sprintf("R CMD Rd2pdf %s", package_path))
# Manual commands for reference:
# R CMD build --resave-data ~/Documents/LinkOrgs-software/LinkOrgs
# R CMD check --as-cran ~/Documents/LinkOrgs_0.01.tar.gz
install.packages("~/Documents/LinkOrgs-software/LinkOrgs", repos = NULL, type = "source", force = FALSE) # install from local
# devtools::install_github("cjerzak/LinkOrgs-software/LinkOrgs") # install from github
# Run tests (stop on failure)
test_results <- devtools::test(package_path)
if (any(as.data.frame(test_results)$failed > 0)) {
stop("Tests failed! Stopping build process.")
}
cat("\n✓ All tests passed!\n\n")
# Show object sizes in environment (for debugging memory usage)
log(sort(sapply(ls(), function(l_) { object.size(eval(parse(text = l_))) })))
# Check package to ensure it meets CRAN standards
devtools::check(package_path)
# Build tar.gz
system(paste(
shQuote(file.path(R.home("bin"), "R")),
"CMD build --resave-data",
shQuote(package_path)
))
# Check as CRAN
system(paste(
shQuote(file.path(R.home("bin"), "R")),
"CMD check --as-cran",
shQuote(paste0(package_name, "_", versionNumber, ".tar.gz"))
))
install.packages("~/Documents/LinkOrgs-software/LinkOrgs", repos = NULL, type = "source", force = FALSE) # install from local
# devtools::install_github("cjerzak/LinkOrgs-software/LinkOrgs") # install from github
}