devtools::load_all()
docker_spec_fetch <- function(dest) {
vcapply(swagger_spec_versions(), docker_spec_fetch1, dest)
}
docker_spec_fetch1 <- function(version, dest) {
url <- sprintf("https://docs.docker.com/engine/api/v%s/swagger.yaml", version)
dest_file <- file.path(dest, sprintf("v%s.yaml", version))
download_file(url, dest_file)
clean_file(dest_file)
bzip_file(dest_file)
}
clean_file <- function(path) {
x <- readLines(path, encoding = "UTF-8")
x <- gsub("’", "'", x)
x <- gsub("└", "*", x)
x <- gsub("“", "'", x)
x <- gsub("”", "'", x)
x <- gsub("=", "=", x)
if (length(suppressMessages(tools::showNonASCII(x))) > 0) {
stop("did not clean all non-ascii")
}
writeLines(x, path)
}
bzip_file <- function(path) {
dest <- paste0(path, ".bz2")
dat <- read_binary(path)
con <- bzfile(dest, "wb", compression = 9L)
on.exit(close(con))
writeBin(dat, con)
dest
}
docker_spec_fetch("inst/spec")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.