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

Exclude Quality Control vignette from Articles dropdown. #52

Merged
merged 2 commits into from
Feb 10, 2025
Merged
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
23 changes: 22 additions & 1 deletion .github/workflows/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -98,6 +98,27 @@ jobs:
pkgdown::build_site(new_process = FALSE) # otherwise errors are not logged
shell: Rscript {0}

- name: Remove Quality Control vignette 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*<a class="dropdown-item" href=".*/qc.html">.*</a>\s*$'
PATTERN_DROPDOWN_WITH_ITEMS='(?s)<li class=\"(active )?nav-item dropdown\">.*?(?:<\/li>(*SKIP)(*FAIL)|.)dropdown-articles.*?dropdown-item.*?<\/li>'
PATTERN_DROPDOWN_WITHOUT_ITEMS='(?s)<li class=\"(active )?nav-item dropdown\">.*?(?:<\/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
Expand Down
Loading