Skip to content

Commit cc7d2a9

Browse files
Merge branch 'main' into 112_documentation_derivation_error_in_safety_specsxlsx
2 parents e51e3d5 + 086d732 commit cc7d2a9

33 files changed

+3200
-173
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Before you submit your pull request, take a look at the following checklist. Man
1010
- [ ] **Impact on Examples:** If your updates impact any examples, review locally for warnings or errors in the impacted example pages.
1111
- [ ] **Merge Conflicts:** Developers should address any merge conflicts and merge upon successful review.
1212
- [ ] **New Packages:** If new packages were used, ensure they are included in the `DESCRIPTION` file's `Imports` section.
13+
- [ ] **Landing Pages:** If new packages were added or removed, update the package tables in the [main landing page](../index.qmd) and the relevant section landing page(s) (`sdtm/index.qmd`, `adam/index.qmd`, `tlg/index.qmd`).
1314
- [ ] **Updated Examples:** If you added or updated an example, ensure it runs on the latest CRAN release versions of all packages used.
1415
- [ ] **Testing Instructions:** Provide instructions on how to test the code if necessary.
1516

17+
By default, a temporary website with the content of the PR is created. To avoid this add `[skip website]` to the title of the PR.

.github/workflows/docs.yaml

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ on:
2626
jobs:
2727
build-deploy:
2828
name: Build & Deploy Website
29+
if: "github.event_name != 'pull_request' || !contains(github.event.pull_request.title, '[skip website]')"
2930
runs-on: ubuntu-latest
3031
steps:
3132
- name: Check out repository
@@ -40,6 +41,9 @@ jobs:
4041
- name: Set up Quarto
4142
uses: quarto-dev/quarto-actions/setup@v2
4243

44+
- name: Install Jupyter
45+
run: python3 -m pip install jupyter
46+
4347
- name: Setup R
4448
uses: r-lib/actions/setup-r@v2
4549

@@ -51,32 +55,30 @@ jobs:
5155
with:
5256
to: html
5357

54-
# temporary!
55-
# remove this step if closed (& relleased): https://github.com/quarto-ext/shinylive/issues/59
56-
- name: Remove large WebR assets 🧹
57-
run: |
58-
packages_path <- sprintf("./_site/site_libs/quarto-contrib/shinylive-%s/shinylive/webr/packages", shinylive::assets_version())
59-
60-
# remove the dirs with size > 100 MB
61-
for (x in list.dirs(packages_path)) {
62-
x_files <- file.info(list.files(x, full.names = TRUE))
63-
if (any(x_files$size > 100 * 1024^2)) {
64-
print(x)
65-
print(x_files)
66-
unlink(x, recursive = TRUE)
67-
}
68-
}
69-
70-
# refresh the `metadata.rds` file
71-
metadata_path <- file.path(packages_path, "metadata.rds")
72-
metadata <- readRDS(metadata_path)
73-
new_metadata <- metadata[intersect(names(metadata), list.dirs(packages_path, full.names = FALSE))]
74-
saveRDS(new_metadata, metadata_path)
75-
shell: Rscript {0}
76-
7758
- name: Publish docs
59+
# runs when main branch is updated, or when a PR is merged into main
7860
if: github.ref == 'refs/heads/main'
7961
uses: peaceiris/actions-gh-pages@v3
8062
with:
8163
github_token: ${{ secrets.GITHUB_TOKEN }}
8264
publish_dir: ./_site
65+
66+
- name: Publish PR docs in a subdirectory
67+
# runs when a PR is opened or updated, but not when merged into main
68+
if: github.event_name == 'pull_request' && github.base_ref == 'main'
69+
uses: peaceiris/actions-gh-pages@v4
70+
with:
71+
github_token: ${{ secrets.GITHUB_TOKEN }}
72+
publish_dir: ./_site
73+
destination_dir: ${{ github.head_ref }}
74+
75+
- name: Create comment
76+
# runs when a PR is opened or updated, but not when merged into main
77+
if: github.event_name == 'pull_request' && github.base_ref == 'main'
78+
uses: marocchino/sticky-pull-request-comment@v2
79+
with:
80+
header: "Documentation Website"
81+
message: |
82+
The website is available at https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/${{ github.head_ref }}.
83+
env:
84+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/link_check.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ jobs:
2121
Rscript -e 'install.packages("fs")'
2222
shell: bash
2323

24-
- name: Switch .qmd to .md
25-
run: Rscript R/switch.R
26-
shell: bash
27-
2824
- name: Link Checker
2925
uses: lycheeverse/lychee-action@v1.8.0
3026
with:
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Remove PR website
2+
3+
on:
4+
workflow_call:
5+
secrets:
6+
GITHUB_PAT:
7+
required: false
8+
description: GitHub API access token, which might be needed for downstream ops or rendering.
9+
pull_request:
10+
types:
11+
- closed
12+
branches:
13+
- main
14+
15+
permissions:
16+
contents: write
17+
18+
jobs:
19+
delete-subfolder:
20+
runs-on: ubuntu-latest
21+
env:
22+
BRANCH: ${{ github.event.pull_request.head.ref }}
23+
steps:
24+
- name: Checkout repository (default branch)
25+
uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 0
28+
persist-credentials: true
29+
30+
- name: Ensure gh-pages exists and check it out
31+
run: |
32+
set -euo pipefail
33+
if git ls-remote --heads origin gh-pages | grep -q 'refs/heads/gh-pages'; then
34+
git fetch origin gh-pages:gh-pages
35+
git checkout gh-pages
36+
else
37+
echo "gh-pages branch not found. Nothing to do."
38+
exit 0
39+
fi
40+
shell: bash
41+
42+
- name: Remove subfolder named after merged branch (if present)
43+
run: |
44+
set -euo pipefail
45+
SUBDIR="${BRANCH}"
46+
echo "SUBDIR: ${SUBDIR}"
47+
if [ -z "$SUBDIR" ]; then
48+
echo "Branch name empty. Nothing to do."
49+
exit 0
50+
fi
51+
52+
if [ -d "$SUBDIR" ]; then
53+
git rm -r --ignore-unmatch -- "$SUBDIR"
54+
if [ -n "$(git status --porcelain)" ]; then
55+
git config user.name "github-actions[bot]"
56+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
57+
git commit -m "ci: remove gh-pages subfolder for merged branch ${BRANCH}"
58+
git push origin gh-pages
59+
else
60+
echo "No changes to commit after removal."
61+
fi
62+
else
63+
echo "Subfolder '$SUBDIR' does not exist on gh-pages. Nothing to do."
64+
fi
65+
shell: bash

DESCRIPTION

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Authors@R:
1616
person("Aksel", "Thomsen", , "oath@novonordisk.com", role = "aut"),
1717
person("Shiyu", "Chen", , "shiyu.chen@atorusresearch.com", role = "aut"),
1818
person("Rammprasad", "Ganapathy", , "rammprasad.ganapathy@gene.com", role = "aut")
19+
person("Alanah", "Jonas", , "alanah.x.jonas@gsk.com", role = "aut"),
1920
Description: This is not a package, but we just use this file to declare
2021
the dependencies of the site.
2122
URL: https://github.com/pharmaverse/examples
@@ -26,6 +27,7 @@ Imports:
2627
cards,
2728
dplyr,
2829
filters,
30+
forcats,
2931
gtsummary,
3032
lubridate,
3133
labelled,
@@ -38,7 +40,6 @@ Imports:
3840
pharmaverseadam,
3941
pkglite,
4042
reactable,
41-
reactablefmtr,
4243
rtables,
4344
rtables.officer,
4445
rlistings,
@@ -50,6 +51,7 @@ Imports:
5051
teal.modules.clinical,
5152
teal.modules.general,
5253
tern,
54+
tfrmt,
5355
tidyr,
5456
xportr,
5557
logr,
@@ -58,6 +60,8 @@ Imports:
5860
Suggests:
5961
knitr,
6062
rmarkdown
63+
Remotes:
64+
shinylive=posit-dev/r-shinylive
6165
Encoding: UTF-8
6266
Language: en-US
6367

R/switch.R

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,57 @@
1-
#' fixes link-check problem
2-
#' Finds whether any files use the string: "(.mailto:" for linking email adresses
3-
#' then just replaces with: "(mailto:" as is markdown standard
1+
#' Fixes link-check problem
2+
#' - Finds files that use the string "(.mailto:" and corrects to "(mailto:"
3+
#' - Updates links to `.qmd` files to point to `.md` files.
44
#'
55
#' @param file_list vector of filenames
66
#'
7-
#' @return messages only. side effect is: changes files.
7+
#' @return messages. Side effect: modifies files.
88
modify_files <- function(file_list) {
9-
# Create an empty vector to store the file names that contain the string
9+
# Create an empty vector to store file names that need modifications
1010
matching_files <- c()
1111

12-
# Iterate over each file in the directory
12+
# Iterate over each file to check for issues
1313
for (file in file_list) {
1414
# Read the contents of the file
1515
file_contents <- readLines(file)
1616

17-
# Check if the file contains the string "(.mailto:"
18-
if (any(grepl("\\(\\.mailto:", file_contents))) {
17+
# Check if the file contains the string "(.mailto:" OR references to `.qmd` files
18+
if (any(grepl("\\(\\.mailto:", file_contents)) || any(grepl("\\.qmd\\)", file_contents))) {
1919
# Add the file name to the vector
2020
matching_files <- c(matching_files, file)
2121
}
2222
}
2323

24-
# Iterate over the matching files
24+
# Iterate over the matching files to apply fixes
2525
for (file in matching_files) {
2626
# Read the contents of the file
2727
file_contents <- readLines(file)
2828

29-
# Remove the "." from each line that contains the string
29+
# Fix email links
3030
modified_contents <- gsub("\\(\\.mailto:", "(mailto:", file_contents)
3131

32+
# Update links to `.qmd` files to point to `.md` files
33+
# Matches patterns like `[text](filename.qmd)` and replaces `.qmd` with `.md`
34+
modified_contents <- gsub("\\.qmd\\)", ".md)", modified_contents)
35+
3236
# Write the modified contents back to the file
3337
writeLines(modified_contents, file)
3438

35-
# Print a message indicating the modification has been made
39+
# Print a message indicating what modifications have been made
3640
message("Modified file:", file, "\n")
3741
}
3842

39-
# Print the list of matching files
43+
# Print a list of matching files that were modified
4044
message("Matching files:", matching_files, "\n")
4145
}
4246

43-
# get all qmd files
47+
# Get all `.qmd` files
4448
all_qmd <- list.files(full.names = FALSE, all.files = FALSE, pattern = ".qmd$", recursive = TRUE)
4549

46-
# modify if needed the link to email problem for link checker
50+
# Modify files to fix email links and update `.qmd` references
4751
modify_files(all_qmd)
48-
# get filenames ending with .md
52+
53+
# Generate a list of `.md` filenames that will replace `.qmd` files
4954
all_md <- gsub(".qmd$", ".md", all_qmd)
50-
# rename all files
55+
56+
# Rename all `.qmd` files to `.md`
5157
file.rename(all_qmd, all_md)

_extensions/quarto-ext/shinylive/shinylive.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,13 @@ return {
458458
el.attr.classes = pandoc.List()
459459
el.attr.classes:insert("shinylive-r")
460460
end
461+
462+
el.text =
463+
"#| '!! shinylive warning !!': |\n"..
464+
"#| shinylive does not work in self-contained HTML documents.\n" ..
465+
"#| Please set `embed-resources: false` in your metadata.\n" ..
466+
el.text
467+
461468
return el
462469
end
463470
}

_quarto.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,17 @@ filters:
6565

6666
format:
6767
html:
68+
include-in-header:
69+
text: |
70+
<script type="text/javascript">
71+
function googleTranslateElementInit() {
72+
new google.translate.TranslateElement({pageLanguage: 'en', includedLanguages: 'zh-CN,fr,es,ja,hi'}, 'google_translate_element');
73+
}
74+
</script>
75+
<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
76+
include-before-body:
77+
text: |
78+
<div id="google_translate_element"></div>
6879
search: true
6980
theme:
7081
light:

adam/adae.qmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "ADAE"
3-
order: 7
3+
order: 3
44
---
55

66
```{r setup script, include=FALSE, purl=FALSE}

0 commit comments

Comments
 (0)