Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide option to disable internet connections #774

Merged
merged 2 commits into from Jul 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS.md
@@ -1,5 +1,8 @@
# pkgdown 1.1.0.9000

* Users with limited internet connectivity can explicitly disable pkgdown CRAN checks
by setting `options(pkgdown.internet = FALSE)` prior to running `build_site()`.

* `build_reference_index()`: Selectors that do not match topics now generate a warning.
If none of the specified selectors have a match, no topics are selected (#728).

Expand Down
4 changes: 4 additions & 0 deletions R/build-home-index.R
Expand Up @@ -101,6 +101,10 @@ sidebar_section <- function(heading, bullets, class = make_slug(heading)) {
}

repo_link <- memoise(function(pkg) {
if (!has_internet()) {
return(NULL)
}

cran_url <- paste0("https://cloud.r-project.org/package=", pkg)

if (!httr::http_error(cran_url)) {
Expand Down
4 changes: 4 additions & 0 deletions R/build-home.R
Expand Up @@ -81,6 +81,10 @@
#' This section is automatically populated if the first paragraph of the
#' homepage consists solely of status badges as linked images.
#'
#' @section Internet:
#' Users with limited internet connectivity can disable CRAN checks by setting
#' `options(pkgdown.internet = FALSE)`.
#'
#' @inheritParams build_articles
#' @export
build_home <- function(pkg = ".",
Expand Down
4 changes: 4 additions & 0 deletions R/build-news.R
Expand Up @@ -209,6 +209,10 @@ is_dev <- function(version) {
}

pkg_timeline <- function(package) {
if (!has_internet()) {
return(NULL)
}

url <- paste0("http://crandb.r-pkg.org/", package, "/all")

resp <- httr::GET(url)
Expand Down
4 changes: 4 additions & 0 deletions R/utils.r
Expand Up @@ -112,3 +112,7 @@ print.print_yaml <- function(x, ...) {
skip_if_no_pandoc <- function() {
testthat::skip_if_not(rmarkdown::pandoc_available("1.12.3"))
}

has_internet <- function() {
return(getOption("pkgdown.internet", default = TRUE))
}
6 changes: 6 additions & 0 deletions man/build_home.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions tests/testthat/test-utils.R
Expand Up @@ -19,3 +19,9 @@ test_that("find_reexport_source_from_imports", {
"R6"
)
})

test_that("pkgdown.internet can be set and read", {
options(pkgdown.internet = FALSE)
expect_false(has_internet())
})