#' @title Call devtools::document on an S3 Object
#'
#' @description This function downloads a package from AWS S3 to a temporary
#' directory, expands it, and calls devtools::document on it. This has the
#' effect of temporarily installing it.
#' @param object Character string with the object key, or an object of class
#' "s3_object". In most cases, if 'object' is specified as the
#' latter, 'bucket' can be omitted because the bucket name will
#' be extracted from "Bucket" slot in 'object'.
#' @param bucket Character string with the name of the bucket, or an object of
#' class "s3_bucket".
#' @param force_redoc if the package is already loaded, should it be reloaded?
#' @param dest_dir location where the downloaded package will be temporarily
#' stored.
#' @importFrom aws.s3 save_object
#' @importFrom devtools document
aws_document <- function(object, bucket, force_redoc = FALSE,
dest_dir = tempdir()) {
create
object_name <- basename(object)
save_object(object, bucket, file = file.path(dest_dir, object_name))
if (endsWith(basename(object), ".zip")) {
} else if ( any(
endsWith( object_name, c(".tar.gz", ".tgz", ".tar.bz2", ".tar.xv") ) ) ) {
uc <- untar(file.path(dest_dir, object_name), compressed = TRUE,
list = TRUE, exdir = dest_dir)
untar(file.path(dest_dir, object_name), compressed = TRUE,
list = FALSE, exdir = dest_dir)
local_dir <- dirname(uc)
local_dir <- local_dir[which.min(nchar(local_dir))]
document(file.path(dest_dir, local_dir))
invisible(TRUE)
} else {
stop("Unknown compression.")
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.