Skip to content

Commit

Permalink
Improve find_pkgdown_url()
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroen committed Jan 6, 2025
1 parent b599553 commit 372be44
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions R/buildtools.R
Original file line number Diff line number Diff line change
Expand Up @@ -1041,11 +1041,19 @@ normalize_description <- function(path){
write.dcf(x, path, keep.white='Authors@R')
}

# Mimic downlit:::remote_metadata_slow but skip r-universe urls
find_pkgdown_url <- function(package){
tryCatch({
yaml <- downlit:::remote_metadata(package)
if(length(yaml$pkgdown) && length(yaml$pandoc)){
dirname(as.character(yaml$urls$reference))
}
}, error = function(...){})
urls <- downlit:::package_urls(package)
urls <- grep('r-universe.dev', urls, value = TRUE, invert = TRUE)
for(x in urls){
try({
req <- curl::curl_fetch_memory(paste0(x, '/pkgdown.yml'))
if(req$status == 200){
yaml <- yaml:::yaml.load(rawToChar(req$content))
if(length(yaml$pkgdown)){
return(yaml)
}
}
}, silent = TRUE)
}
}

0 comments on commit 372be44

Please sign in to comment.