# devtools::install_github("hadley/requirements") # we need to copy some sources as req_dir is not exported flat_map_chr <- function(x, f, ...) { if (length(x) == 0) { character() } else { unlist(lapply(x, f, ...)) } } char_or_sym <- function(x) { if (is.character(x)) { x } else if (is.symbol(x)) { as.character(x) } else { character() } } find_pkgs_rec <- function(x) { if (is_syntactic_literal(x) || is_symbol(x)) { return(character()) } if (is_pairlist(x) || is.expression(x)) { return(flat_map_chr(as.list(x), find_pkgs_rec)) } if (is_call(x, c("::", ":::"))) { char_or_sym(x[[2]]) } else if (is_call(x, c("library", "require"))) { x <- call_standardise(x, env = baseenv()) if (isTRUE(x$character.only) || identical(x$character.only, quote(T))) { if (is.character(x$package)) { x$package } else { character() } } else { char_or_sym(x$package) } } else if (is_call(x, c("requireNamespace", "loadNamespace"))) { x <- call_standardise(x, env = baseenv()) char_or_sym(x$package) } else { flat_map_chr(as.list(x), find_pkgs_rec) } } req_dir <- function(path = ".") { files <- dir(path, recursive = TRUE, include.dirs = FALSE, full.names = TRUE) sort(unique(flat_map_chr(files, req_file))) } library(requirements)
packs = req_dir("inst/app") lices = matrix(unlist(lapply(packs, FUN = function(x)c(x, packageDescription(x, fields="License")))),ncol = 2,byrow = T) write.table(lices, file = "inst/develo/licensesList.txt", quote = F, sep = ":\t", row.names = F, col.names = F)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.