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

Add history section and article for previous versions #212

Merged
merged 3 commits into from
Nov 16, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ concurrency:

env:
R_VERSION: "4.1"

jobs:
get_r_version:
name: Get R version
Expand Down Expand Up @@ -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
Expand Down
34 changes: 1 addition & 33 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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"
```

<!-- Please do not edit the README.md file as it is auto-generated after PR merges. Only edit the README.Rmd file -->
<!-- The purpose of this is to enable dynamic links using dyn_link function above to access devel/main admiral homepage respectively -->
<!-- To test this in your feature branch use code: rmarkdown::render("README.Rmd", output_format ="md_document") -->

# Admiral Extension for Ophthalmology <img src="man/figures/logo.png" align="right" width="200" style="margin-left:50px;"/>
Expand Down Expand Up @@ -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

Expand Down
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<!-- Please do not edit the README.md file as it is auto-generated after PR merges. Only edit the README.Rmd file -->

<!-- The purpose of this is to enable dynamic links using dyn_link function above to access devel/main admiral homepage respectively -->

<!-- To test this in your feature branch use code: rmarkdown::render("README.Rmd", output_format ="md_document") -->

# Admiral Extension for Ophthalmology <img src="man/figures/logo.png" align="right" width="200" style="margin-left:50px;"/>
Expand Down
12 changes: 10 additions & 2 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
31 changes: 1 addition & 30 deletions vignettes/adbcva.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
```

Expand Down Expand Up @@ -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)
29 changes: 1 addition & 28 deletions vignettes/admiralophtha.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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}`.
Expand Down
29 changes: 1 addition & 28 deletions vignettes/adoe.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
```

Expand Down Expand Up @@ -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)

30 changes: 2 additions & 28 deletions vignettes/advfq.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

82 changes: 82 additions & 0 deletions vignettes/articles/website-versions.Rmd
Original file line number Diff line number Diff line change
@@ -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/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)

# 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`
27 changes: 0 additions & 27 deletions vignettes/standards.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
```

Expand Down
Loading