From 6e4e1e6e7dfa62bfeead764d556b0e625fbdd032 Mon Sep 17 00:00:00 2001 From: olivroy Date: Thu, 6 Jun 2024 14:03:12 -0400 Subject: [PATCH 01/10] use Posix line ending in pkgdown --- pkgdown.Rproj | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/pkgdown.Rproj b/pkgdown.Rproj index 8eb3054db..789a1f94b 100644 --- a/pkgdown.Rproj +++ b/pkgdown.Rproj @@ -1,23 +1,24 @@ -Version: 1.0 - -RestoreWorkspace: Default -SaveWorkspace: Default -AlwaysSaveHistory: Default - -EnableCodeIndexing: Yes -UseSpacesForTab: Yes -NumSpacesForTab: 2 -Encoding: UTF-8 - -RnwWeave: Sweave -LaTeX: pdfLaTeX - -AutoAppendNewline: Yes -StripTrailingWhitespace: Yes - -BuildType: Package -PackageUseDevtools: Yes -PackageInstallArgs: --no-multiarch --with-keep.source -PackageRoxygenize: rd,collate,namespace - -SpellingDictionary: en_AU +Version: 1.0 + +RestoreWorkspace: No +SaveWorkspace: No +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: Sweave +LaTeX: pdfLaTeX + +AutoAppendNewline: Yes +StripTrailingWhitespace: Yes +LineEndingConversion: Posix + +BuildType: Package +PackageUseDevtools: Yes +PackageInstallArgs: --no-multiarch --with-keep.source +PackageRoxygenize: rd,collate,namespace + +SpellingDictionary: en_AU From 7b4f6e91b63646a2db4538cb8fa51e6183357c5b Mon Sep 17 00:00:00 2001 From: olivroy Date: Thu, 6 Jun 2024 14:45:29 -0400 Subject: [PATCH 02/10] Use `withr::local_options(cli.num_colors = num_col, .local_envir = .frame)` in `section_init()` --- R/context.R | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/R/context.R b/R/context.R index a82ecc0b6..4a17d5237 100644 --- a/R/context.R +++ b/R/context.R @@ -4,10 +4,18 @@ section_init <- function(pkg, depth, override = list(), .frame = parent.frame()) rstudio_save_all() local_envvar_pkgdown(pkg, .frame) local_options_link(pkg, depth = depth, .frame = .frame) + local_options_console(.frame = .frame) pkg } +local_options_console <- function(.frame = parent.frame()) { + # Improves speed of init_site() with tip from r-lib/cli#607 + # Only does so if no option set + num_col <- getOption("cli.num_colors", default = cli::num_ansi_colors()) + withr::local_options(cli.num_colors = num_col, .local_envir = .frame) +} + local_options_link <- function(pkg, depth, .frame = parent.frame()) { article_index <- article_index(pkg) Rdname <- get_rdname(pkg$topics) From 2c3c0d73af993e819b9251eea09c2fab4a4439ba Mon Sep 17 00:00:00 2001 From: olivroy Date: Thu, 6 Jun 2024 14:45:48 -0400 Subject: [PATCH 03/10] Document `init_site()` usage. --- R/init.R | 8 ++++++++ man/init_site.Rd | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/R/init.R b/R/init.R index 90ddc21d3..24bdf234a 100644 --- a/R/init.R +++ b/R/init.R @@ -8,6 +8,14 @@ #' * copies CSS/JS assets and extra files, and #' * runs `build_favicons()`, if needed. #' +#' Typically, you will not need to call this function directly, as all `build_*()` +#' functions will run `init_site()` if needed. +#' +#' The only good reasons to call `init_site()` directly are the following: +#' * If you add or modify a package logo. +#' * If you add or modify `pkgdown/extra.scss`. +#' * If you modify `template.bslib` variables in `_pkgdown.yml`. +#' #' See `vignette("customise")` for the various ways you can customise the #' display of your site. #' diff --git a/man/init_site.Rd b/man/init_site.Rd index 5e0638c91..3bac595ce 100644 --- a/man/init_site.Rd +++ b/man/init_site.Rd @@ -18,6 +18,16 @@ init_site(pkg = ".") \item runs \code{build_favicons()}, if needed. } +Typically, you will not need to call this function directly, as all \verb{build_*()} +functions will run \code{init_site()} if needed. + +The only good reasons to call \code{init_site()} directly are the following: +\itemize{ +\item If you add or modify a package logo. +\item If you add or modify \code{pkgdown/extra.scss}. +\item If you modify \code{template.bslib} variables in \verb{_pkgdown.yml}. +} + See \code{vignette("customise")} for the various ways you can customise the display of your site. } From 67709ef20ce23bbd28e27b7ab89cbfebaf38465a Mon Sep 17 00:00:00 2001 From: olivroy Date: Thu, 6 Jun 2024 14:46:22 -0400 Subject: [PATCH 04/10] Only call `init_site()` when lazy = FALSE, since `build_home()` will call it anyway if necessary. --- R/build.R | 6 +++++- R/theme.R | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/R/build.R b/R/build.R index 24e17cb87..f3600027d 100644 --- a/R/build.R +++ b/R/build.R @@ -440,7 +440,11 @@ build_site_local <- function(pkg = ".", pkgdown_sitrep(pkg) - init_site(pkg) + if (!lazy) { + # Only force init_site() if `!lazy` + # if site is not initialized, it will be in build_home() + init_site(pkg) + } build_home(pkg, override = override, preview = FALSE) build_reference( diff --git a/R/theme.R b/R/theme.R index 235a3bba1..2c7bafaf8 100644 --- a/R/theme.R +++ b/R/theme.R @@ -29,8 +29,10 @@ build_bslib <- function(pkg = ".", call = caller_env()) { data_deps <- function(pkg, depth) { if (!file_exists(data_deps_path(pkg))) { + # this is unlikely to occur after #2439 and #2571 cli::cli_abort( "Run {.fn pkgdown::init_site} first.", + .internal = TRUE, call = caller_env() ) } From f61f4dcf9972d42cadf43e51a31b08fae425f5c3 Mon Sep 17 00:00:00 2001 From: olivroy Date: Thu, 6 Jun 2024 16:22:53 -0400 Subject: [PATCH 05/10] Add `local_options_console()` to `init_site()` --- R/init.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/init.R b/R/init.R index 24bdf234a..471914bdd 100644 --- a/R/init.R +++ b/R/init.R @@ -29,6 +29,7 @@ #' @inheritParams build_articles #' @export init_site <- function(pkg = ".") { + local_options_console() pkg <- as_pkgdown(pkg) if (is_non_pkgdown_site(pkg$dst_path)) { From eddc4eaf7bb6797078b71cc8f0890aff82d4d62f Mon Sep 17 00:00:00 2001 From: olivroy <52606734+olivroy@users.noreply.github.com> Date: Thu, 6 Jun 2024 17:12:18 -0400 Subject: [PATCH 06/10] Apply suggestions from code review [ci skip] Co-authored-by: Hadley Wickham --- R/context.R | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/R/context.R b/R/context.R index 4a17d5237..34b0c9404 100644 --- a/R/context.R +++ b/R/context.R @@ -9,9 +9,8 @@ section_init <- function(pkg, depth, override = list(), .frame = parent.frame()) pkg } -local_options_console <- function(.frame = parent.frame()) { - # Improves speed of init_site() with tip from r-lib/cli#607 - # Only does so if no option set +cache_cli_colours <- function(.frame = parent.frame()) { + # https://github.com/r-lib/cli/issues/607 num_col <- getOption("cli.num_colors", default = cli::num_ansi_colors()) withr::local_options(cli.num_colors = num_col, .local_envir = .frame) } From 129cdf4ea58dcb3ea025dc6e547890e96e7c2a76 Mon Sep 17 00:00:00 2001 From: olivroy Date: Thu, 6 Jun 2024 17:21:19 -0400 Subject: [PATCH 07/10] Change fn name [ci skip] --- R/context.R | 2 +- R/init.R | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/context.R b/R/context.R index 34b0c9404..4f0a42978 100644 --- a/R/context.R +++ b/R/context.R @@ -4,7 +4,7 @@ section_init <- function(pkg, depth, override = list(), .frame = parent.frame()) rstudio_save_all() local_envvar_pkgdown(pkg, .frame) local_options_link(pkg, depth = depth, .frame = .frame) - local_options_console(.frame = .frame) + cache_cli_colours(.frame = .frame) pkg } diff --git a/R/init.R b/R/init.R index 471914bdd..59f50dea9 100644 --- a/R/init.R +++ b/R/init.R @@ -29,7 +29,7 @@ #' @inheritParams build_articles #' @export init_site <- function(pkg = ".") { - local_options_console() + cache_cli_colours() pkg <- as_pkgdown(pkg) if (is_non_pkgdown_site(pkg$dst_path)) { From 6a91b9150079a5c95f90a48575935154a5f9770b Mon Sep 17 00:00:00 2001 From: olivroy Date: Fri, 7 Jun 2024 12:16:09 -0400 Subject: [PATCH 08/10] pass override --- R/build.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/build.R b/R/build.R index a25cd65c8..4870f6dfc 100644 --- a/R/build.R +++ b/R/build.R @@ -433,7 +433,7 @@ build_site_local <- function(pkg = ".", if (!lazy) { # Only force init_site() if `!lazy` # if site is not initialized, it will be in build_home() - init_site(pkg) + init_site(pkg, override) } build_home(pkg, override = override, preview = FALSE) From d75e451455bfbe2a8f718a5a4b108274f9ecf2f6 Mon Sep 17 00:00:00 2001 From: olivroy Date: Fri, 7 Jun 2024 12:28:25 -0400 Subject: [PATCH 09/10] try to revert changes to rproj --- pkgdown.Rproj | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkgdown.Rproj b/pkgdown.Rproj index 789a1f94b..b87b59541 100644 --- a/pkgdown.Rproj +++ b/pkgdown.Rproj @@ -1,7 +1,7 @@ Version: 1.0 -RestoreWorkspace: No -SaveWorkspace: No +RestoreWorkspace: Default +SaveWorkspace: Default AlwaysSaveHistory: Default EnableCodeIndexing: Yes @@ -14,7 +14,6 @@ LaTeX: pdfLaTeX AutoAppendNewline: Yes StripTrailingWhitespace: Yes -LineEndingConversion: Posix BuildType: Package PackageUseDevtools: Yes From 11eca7a5406b8e759f21caba4de7ddaa8dc3c1d1 Mon Sep 17 00:00:00 2001 From: olivroy Date: Fri, 7 Jun 2024 13:24:02 -0400 Subject: [PATCH 10/10] Try committing from my mac [skip ci] --- pkgdown.Rproj | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/pkgdown.Rproj b/pkgdown.Rproj index b87b59541..1a7bd8269 100644 --- a/pkgdown.Rproj +++ b/pkgdown.Rproj @@ -1,23 +1,24 @@ -Version: 1.0 - -RestoreWorkspace: Default -SaveWorkspace: Default -AlwaysSaveHistory: Default - -EnableCodeIndexing: Yes -UseSpacesForTab: Yes -NumSpacesForTab: 2 -Encoding: UTF-8 - -RnwWeave: Sweave -LaTeX: pdfLaTeX - -AutoAppendNewline: Yes -StripTrailingWhitespace: Yes - -BuildType: Package -PackageUseDevtools: Yes -PackageInstallArgs: --no-multiarch --with-keep.source -PackageRoxygenize: rd,collate,namespace - -SpellingDictionary: en_AU +Version: 1.0 + +RestoreWorkspace: Default +SaveWorkspace: Default +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: Sweave +LaTeX: pdfLaTeX + +AutoAppendNewline: Yes +StripTrailingWhitespace: Yes +LineEndingConversion: Posix + +BuildType: Package +PackageUseDevtools: Yes +PackageInstallArgs: --no-multiarch --with-keep.source +PackageRoxygenize: rd,collate,namespace + +SpellingDictionary: en_AU