From f4ea5e5b0038f4f1ac864e247d7bb9578d6e43b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?zxBIB=20Lech=C3=B3n=2CMiguel=20=28MED=20BDS=29=20EXTERNAL?= Date: Fri, 7 Feb 2025 18:27:37 +0100 Subject: [PATCH] Exclude Quality Control vignette from Articles dropdown. --- .github/workflows/pkgdown.yml | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pkgdown.yml b/.github/workflows/pkgdown.yml index e35d848..31fdd13 100644 --- a/.github/workflows/pkgdown.yml +++ b/.github/workflows/pkgdown.yml @@ -81,7 +81,7 @@ jobs: name: val_results path: inst/validation/results - - name: Build site 🔧 + - name: Build site run: | # Pay the hadley tax: https://github.com/r-lib/roxygen2/issues/905 desc <- read.dcf("DESCRIPTION") @@ -98,6 +98,27 @@ jobs: pkgdown::build_site(new_process = FALSE) # otherwise errors are not logged shell: Rscript {0} + - name: Remove Quality Control vignete from Articles dropdown + run: | + # This removal is highly dependent on the pkgdown template, but we've tried to make the regexp patterns + # fairly restrictive to prevent deletions from happening if the template changes. If that were to happen, + # the QC vignette would reappear under Articles, which is annoying, but not the end of the world. + + # For reference, see https://regex101.com/ and https://stackoverflow.com/a/56927135 + PATTERN_QC_ITEM='^\s*.*\s*$' + PATTERN_DROPDOWN_WITH_ITEMS='(?s)
  • .*?(?:<\/li>(*SKIP)(*FAIL)|.)dropdown-articles.*?dropdown-item.*?<\/li>' + PATTERN_DROPDOWN_WITHOUT_ITEMS='(?s)
  • .*?(?:<\/li>(*SKIP)(*FAIL)|.)dropdown-articles.*?<\/li>' + + readarray -t FILES < <(find docs -name "*.html" -print0 | xargs -0 grep -l "$PATTERN_QC_ITEM") + for f in "${FILES[@]}"; do + sed -i "\#$PATTERN_QC_ITEM#d" "$f" + grep -Pzoq "$PATTERN_DROPDOWN_WITH_ITEMS" "$f" + if [ $? -ne 0 ]; then + perl -0 -i -p -e "s/$PATTERN_DROPDOWN_WITHOUT_ITEMS//gs" "$f" + fi + done + shell: bash + - name: Check URLs 🌐 run: | lychee . --format markdown --verbose --no-progress --exclude "https://boehringer-ingelheim.github.io*" >> $GITHUB_STEP_SUMMARY