Skip to content

Commit

Permalink
.add_pkgdown()
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentarelbundock committed Apr 7, 2024
1 parent 96f563a commit b8386c7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions R/setup_docs.R
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ setup_docs <- function(tool, path = ".", overwrite = FALSE) {
.add_rbuildignore("^docs$", path = path)
.add_rbuildignore("^altdoc$", path = path)
.add_gitignore("altdoc/freeze.rds", path = path)
.add_pkgdown(path = path)
if (tool == "quarto_website") {
.add_rbuildignore("^_quarto$", path = path)
.add_gitignore("_quarto/*", path = path)
Expand Down
20 changes: 20 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,26 @@
}


.add_pkgdown <- function(path = ".") {
if (!isTRUE(.dir_is_package(path))) {
stop(".add_pkgdown() must be run from the root of a package.", call. = FALSE)
}
url <- desc::desc_get_urls()
fn <- fs::path_join(c(path, "altdoc/pkgdown.yml"))
if (!fs::file_exists(fn) && length(url) > 0) {
url <- url[1]
vig <- fs::path_join(c(url, "vignettes"))
man <- fs::path_join(c(url, "man"))
content <- c(
"urls:",
paste(" reference:", man),
paste(" article:", vig),
"")
cli::cli_alert_info("Adding altdoc/pkgdown.yml file.")
writeLines(content, fn)
}
}


.add_rbuildignore <- function(x = "^docs$", path = ".") {
if (!isTRUE(.dir_is_package(path))) {
Expand Down

0 comments on commit b8386c7

Please sign in to comment.