From ad61a8fe9e7c31bde07d40ac7e422b6e66662fd2 Mon Sep 17 00:00:00 2001 From: cicdguy <26552821+cicdguy@users.noreply.github.com> Date: Thu, 9 Nov 2023 10:19:41 -0600 Subject: [PATCH 1/3] Add history section and article for previous versions --- .github/workflows/common.yml | 4 +- _pkgdown.yml | 12 +++- vignettes/articles/website-versions.Rmd | 82 +++++++++++++++++++++++++ 3 files changed, 94 insertions(+), 4 deletions(-) create mode 100644 vignettes/articles/website-versions.Rmd diff --git a/.github/workflows/common.yml b/.github/workflows/common.yml index c67df158..3164365d 100644 --- a/.github/workflows/common.yml +++ b/.github/workflows/common.yml @@ -35,7 +35,7 @@ concurrency: env: R_VERSION: "4.1" - + jobs: get_r_version: name: Get R version @@ -91,7 +91,7 @@ jobs: # Whether to skip multiversion docs # Note that if you have multiple versions of docs, # your URL links are likely to break due to path changes - skip-multiversion-docs: false + skip-multiversion-docs: true linter: name: Lint uses: pharmaverse/admiralci/.github/workflows/lintr.yml@main diff --git a/_pkgdown.yml b/_pkgdown.yml index ad92ba98..ebb910ba 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -12,6 +12,10 @@ repo: source: https://github.com/pharmaverse/admiralophtha/blob/main/ issue: https://github.com/pharmaverse/admiralophtha/issues/ user: https://github.com/ + +development: + mode: auto + news: cran_dates: false reference: @@ -90,8 +94,8 @@ reference: navbar: structure: - left: [getstarted, reference, articles, news] - right: [search, slack, newissue, github] + left: [getstarted, reference, articles, news, versions] + right: [search, slack, history, newissue, github] components: getstarted: text: Get Started @@ -110,6 +114,10 @@ navbar: href: articles/adbcva.html - text: Creating ADVFQ href: articles/advfq.html + history: + icon: fa-history + href: articles/website-versions.html + aria-label: Previous Release Websites slack: icon: fa-slack href: https://app.slack.com/client/T028PB489D3/C02M8KN8269 diff --git a/vignettes/articles/website-versions.Rmd b/vignettes/articles/website-versions.Rmd new file mode 100644 index 00000000..fdb51e28 --- /dev/null +++ b/vignettes/articles/website-versions.Rmd @@ -0,0 +1,82 @@ +--- +title: "Previous Versions of Website" +--- + +```{r, include = FALSE} +# TO USE THIS ARTICLE, THE DESCRIPTION FILE MUST INCLUDE +# Config/Needs/website: gert +# Make sure to copy the gh-pages branch to your local git + +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>" +) +``` + +```{r setup, include=FALSE} +base_url <- + "https://pharmaverse.github.io/admiral/" # include the trailing backslash! + +# get list of all files in the `gh-pages` branch +df_all_files <- tryCatch(gert::git_ls(ref = "gh-pages"), error = function(x) FALSE) + +# if a local user (not on CI) does not have a copy of the `gh-pages` branch, exit silently +if (!isTRUE(as.logical(Sys.getenv("CI"))) && isFALSE(df_all_files)) { + knitr::knit_exit() +} +``` + +```{r include=FALSE} +# extract all folders in the root of the branch +all_folders <- + sub("/.*", "", df_all_files$path)[grepl( + x = df_all_files$path, + pattern = "/", + fixed = TRUE + )] |> + unique() + +# subset to all version folders +all_version_folders <- + all_folders[grep("^v[0-9]+|dev", x = all_folders)] |> + rev() +# more dev first if it appears +if ("dev" %in% all_version_folders) { + all_version_folders <- c("dev", all_version_folders) |> unique() +} + +# release dates of prior tags +df_tags <- gert::git_tag_list() +df_tags <- df_tags[df_tags$name %in% all_version_folders, ] +df_tags$date <- + lapply( + df_tags$commit, + FUN = function(x) { + tryCatch( + gert::git_commit_info(ref = x)$time |> as.Date() |> as.character(), + error = function(x) NA + ) + } + ) |> + unlist() +df_tags <- df_tags[!is.na(df_tags$date), ] + +lst_tag_dates <- + paste0(" (", df_tags$date, ")") |> + as.list() |> + setNames(df_tags$name) + +# string with all markdown links +str_website_links <- + lapply( + X = all_version_folders, + FUN = function(x) { + x_label <- ifelse(x %in% "dev", "Development Site", x) + paste0("[", x_label, lst_tag_dates[[x]], "](", paste0(base_url, x), ")") + } + ) |> + unlist() |> + paste(collapse = "\n\n") +``` + +`r str_website_links` From e3830b06d5ba032705c7593b516f3e1a45400386 Mon Sep 17 00:00:00 2001 From: cicdguy <26552821+cicdguy@users.noreply.github.com> Date: Thu, 9 Nov 2023 10:32:21 -0600 Subject: [PATCH 2/3] Update vignettes/articles/website-versions.Rmd --- vignettes/articles/website-versions.Rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vignettes/articles/website-versions.Rmd b/vignettes/articles/website-versions.Rmd index fdb51e28..378214e3 100644 --- a/vignettes/articles/website-versions.Rmd +++ b/vignettes/articles/website-versions.Rmd @@ -15,7 +15,7 @@ knitr::opts_chunk$set( ```{r setup, include=FALSE} base_url <- - "https://pharmaverse.github.io/admiral/" # include the trailing backslash! + "https://pharmaverse.github.io/admiralophtha/" # include the trailing backslash! # get list of all files in the `gh-pages` branch df_all_files <- tryCatch(gert::git_ls(ref = "gh-pages"), error = function(x) FALSE) From ed9f8552c89587c28f58273e2c31972c3e9b00aa Mon Sep 17 00:00:00 2001 From: cicdguy <26552821+cicdguy@users.noreply.github.com> Date: Thu, 9 Nov 2023 10:53:52 -0600 Subject: [PATCH 3/3] Remove dynamic linking functionality --- README.Rmd | 34 +--------------------------------- README.md | 3 --- vignettes/adbcva.Rmd | 31 +------------------------------ vignettes/admiralophtha.Rmd | 29 +---------------------------- vignettes/adoe.Rmd | 29 +---------------------------- vignettes/advfq.Rmd | 30 ++---------------------------- vignettes/standards.Rmd | 27 --------------------------- 7 files changed, 6 insertions(+), 177 deletions(-) diff --git a/README.Rmd b/README.Rmd index 1aa91d5c..df28bffa 100644 --- a/README.Rmd +++ b/README.Rmd @@ -4,39 +4,7 @@ output: md_document date: '2022-08-06' --- -```{r setup, include=FALSE} -knitr::opts_chunk$set(echo = TRUE) -link <- function(text, url) { - return( - paste0( - "[", text, "]", - "(", url, ")" - ) - ) -} -dyn_link <- function(text, - base_url, - relative_url = "", - # Change to TRUE when admiral adopts multiversion docs - is_multiversion = TRUE, - multiversion_default_ref = "main") { - url <- paste(base_url, relative_url, "", sep = "/") - if (is_multiversion) { - url <- paste( - base_url, - Sys.getenv("BRANCH_NAME", multiversion_default_ref), - "", - sep = "/" - ) - } - return(link(text, url)) -} -# Other variables -admiral_homepage <- "https://pharmaverse.github.io/admiral" -``` - - # Admiral Extension for Ophthalmology @@ -68,7 +36,7 @@ remotes::install_github("pharmaverse/admiralophtha", ref = "devel") ## References and Documentation -* Please refer to the `r dyn_link("{admiral} References and Documentation", admiral_homepage, "index.html#references-and-documentation")`. +* Please refer to the [the `{admiral}` References & Documentation page](https://pharmaverse.github.io/admiral/index.html#references-and-documentation). ## R Versions diff --git a/README.md b/README.md index 02c1593d..fb4f8d3a 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,4 @@ - - - # Admiral Extension for Ophthalmology diff --git a/vignettes/adbcva.Rmd b/vignettes/adbcva.Rmd index c43561cb..fb3a2da1 100644 --- a/vignettes/adbcva.Rmd +++ b/vignettes/adbcva.Rmd @@ -13,33 +13,6 @@ knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) -link <- function(text, url) { - return( - paste0( - "[", text, "]", - "(", url, ")" - ) - ) -} -dyn_link <- function(text, - base_url, - relative_url = "", - # Change to TRUE when admiral adopts multiversion docs - is_multiversion = FALSE, - multiversion_default_ref = "main") { - url <- paste(base_url, relative_url, sep = "/") - if (is_multiversion) { - url <- paste( - base_url, - Sys.getenv("BRANCH_NAME", multiversion_default_ref), - relative_url, - sep = "/" - ) - } - return(link(text, url)) -} -# Other variables -admiral_homepage <- "https://pharmaverse.github.io/admiral" library(admiraldev) ``` @@ -371,6 +344,4 @@ adbcva <- adbcva %>% ADaM | Sample Code ---- | -------------- - ADBCVA | `r dyn_link("ad_adbcva.R", "https://github.com/pharmaverse/admiralophtha/blob", "inst/templates/ad_adbcva.R", is_multiversion = TRUE)` - - + ADBCVA | [ad_adbcva.R](https://github.com/pharmaverse/admiralophtha/blob/main/inst/templates/ad_adbcva.R) diff --git a/vignettes/admiralophtha.Rmd b/vignettes/admiralophtha.Rmd index 13e052fe..a23a93f3 100644 --- a/vignettes/admiralophtha.Rmd +++ b/vignettes/admiralophtha.Rmd @@ -12,39 +12,12 @@ knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) -link <- function(text, url) { - return( - paste0( - "[", text, "]", - "(", url, ")" - ) - ) -} -dyn_link <- function(text, - base_url, - relative_url = "", - # Change to TRUE when admiral adopts multiversion docs - is_multiversion = FALSE, - multiversion_default_ref = "main") { - url <- paste(base_url, relative_url, sep = "/") - if (is_multiversion) { - url <- paste( - base_url, - Sys.getenv("BRANCH_NAME", multiversion_default_ref), - relative_url, - sep = "/" - ) - } - return(link(text, url)) -} -# Other variables -admiral_homepage <- "https://pharmaverse.github.io/admiral/cran-release" ``` # Introduction As this is a package extension, if you are new to `{admiral}` then the best place to first start -reading would be this `r dyn_link("Get Started", admiral_homepage, "articles/admiral.html")` +reading would be this [Get Started](https://pharmaverse.github.io/admiral/articles/admiral.html) guide. This extension package follows the same main idea and conventions, and re-uses many functions from `{admiral}`, so it is important to thoroughly understand these to be able to use `{admiralophtha}`. diff --git a/vignettes/adoe.Rmd b/vignettes/adoe.Rmd index 38e072b3..4a72328a 100644 --- a/vignettes/adoe.Rmd +++ b/vignettes/adoe.Rmd @@ -13,33 +13,6 @@ knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) -link <- function(text, url) { - return( - paste0( - "[", text, "]", - "(", url, ")" - ) - ) -} -dyn_link <- function(text, - base_url, - relative_url = "", - # Change to TRUE when admiral adopts multiversion docs - is_multiversion = FALSE, - multiversion_default_ref = "main") { - url <- paste(base_url, relative_url, sep = "/") - if (is_multiversion) { - url <- paste( - base_url, - Sys.getenv("BRANCH_NAME", multiversion_default_ref), - relative_url, - sep = "/" - ) - } - return(link(text, url)) -} -# Other variables -admiral_homepage <- "https://pharmaverse.github.io/admiral" library(admiraldev) ``` @@ -143,5 +116,5 @@ The user is invited to consult the article on [creating a BDS dataset from SDTM] ADaM | Sample Code ---- | -------------- -ADOE | `r dyn_link("ad_adoe.R", "https://github.com/pharmaverse/admiralophtha/blob", "inst/templates/ad_adoe.R", is_multiversion = TRUE)` +ADOE | [ad_adoe.R](https://github.com/pharmaverse/admiralophtha/blob/main/inst/templates/ad_adoe.R) diff --git a/vignettes/advfq.Rmd b/vignettes/advfq.Rmd index f60e964c..20c9cb6b 100644 --- a/vignettes/advfq.Rmd +++ b/vignettes/advfq.Rmd @@ -13,33 +13,6 @@ knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) -link <- function(text, url) { - return( - paste0( - "[", text, "]", - "(", url, ")" - ) - ) -} -dyn_link <- function(text, - base_url, - relative_url = "", - # Change to TRUE when admiral adopts multiversion docs - is_multiversion = FALSE, - multiversion_default_ref = "main") { - url <- paste(base_url, relative_url, sep = "/") - if (is_multiversion) { - url <- paste( - base_url, - Sys.getenv("BRANCH_NAME", multiversion_default_ref), - relative_url, - sep = "/" - ) - } - return(link(text, url)) -} -# Other variables -admiral_homepage <- "https://pharmaverse.github.io/admiral" ``` # Introduction @@ -241,4 +214,5 @@ advfq <- advfq %>% ADaM | Sample Code ---- | -------------- -ADVFQ | `r dyn_link("ad_advfq.R", "https://github.com/pharmaverse/admiralophtha/blob", "inst/templates/ad_advfq.R", is_multiversion = TRUE)` +ADVFQ | [ad_advfq.R](https://github.com/pharmaverse/admiralophtha/blob/main/inst/templates/ad_advfq.R) + diff --git a/vignettes/standards.Rmd b/vignettes/standards.Rmd index da2b4aff..bfaab5f8 100644 --- a/vignettes/standards.Rmd +++ b/vignettes/standards.Rmd @@ -13,33 +13,6 @@ knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) -link <- function(text, url) { - return( - paste0( - "[", text, "]", - "(", url, ")" - ) - ) -} -dyn_link <- function(text, - base_url, - relative_url = "", - # Change to TRUE when admiral adopts multiversion docs - is_multiversion = FALSE, - multiversion_default_ref = "main") { - url <- paste(base_url, relative_url, sep = "/") - if (is_multiversion) { - url <- paste( - base_url, - Sys.getenv("BRANCH_NAME", multiversion_default_ref), - relative_url, - sep = "/" - ) - } - return(link(text, url)) -} -# Other variables -admiral_homepage <- "https://pharmaverse.github.io/admiral" library(admiraldev) ```