-
Notifications
You must be signed in to change notification settings - Fork 0
Add multi-version pkgdown documentation with version dropdown menu #173
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
Open
Copilot
wants to merge
10
commits into
main
Choose a base branch
from
copilot/copy-pkgdown-setup
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a4fad2e
Initial plan
Copilot a972bef
Add multi-version pkgdown workflow with version dropdown support
Copilot 98b8f04
Fix workflow syntax and configuration for multi-version docs
Copilot 4148222
Add NEWS entry for multi-version pkgdown setup
Copilot 02c6187
Add comprehensive documentation for multi-version pkgdown setup
Copilot 4eea04a
Fix security vulnerability: update actions to latest v4 versions
Copilot b016f79
Add docs workflow file to path triggers
Copilot c4ca44d
Remove path filters from docs workflow to ensure it always runs
Copilot cf0c771
Restore path filters and allow draft PRs to run workflow
Copilot 989119c
Fix workflow conditions and add conditional devel parameter
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,153 @@ | ||
| # Multi-Version Documentation Setup | ||
|
|
||
| This repository uses multi-version pkgdown documentation with a version dropdown menu, based on the [insightsengineering/tern](https://github.com/insightsengineering/tern) setup. | ||
|
|
||
| ## Features | ||
|
|
||
| ### Version Dropdown Menu | ||
| Users can switch between different versions of the documentation using a dropdown menu in the navbar: | ||
| - **main**: Development version (latest commits on main branch) | ||
| - **latest-tag**: Most recent release version | ||
| - **v*.*.*** Version-tagged releases (e.g., v1.0.0, v1.1.0) | ||
|
|
||
| ### Default Landing Page | ||
| The default page at https://ucd-serg.github.io/serodynamics/ shows the **latest-tag** (most recent release) documentation. | ||
|
|
||
| ### PR Previews | ||
| Pull requests automatically generate preview documentation at: | ||
| - `https://ucd-serg.github.io/serodynamics/preview/pr<number>/` | ||
| - Preview link is posted as a comment on the PR | ||
| - Previews are automatically cleaned up when PRs are closed | ||
|
|
||
| ## How It Works | ||
|
|
||
| ### Workflow: `.github/workflows/docs.yaml` | ||
|
|
||
| The workflow has four jobs: | ||
|
|
||
| 1. **docs**: Builds the pkgdown site | ||
| - Runs on: PRs, pushes to main, version tags | ||
| - Deploys to version-specific directories on gh-pages | ||
|
|
||
| 2. **multi-version-docs**: Creates version dropdown | ||
| - Runs on: pushes to main, workflow_dispatch | ||
| - Uses `insightsengineering/r-pkgdown-multiversion@v3` | ||
| - Generates navigation between versions | ||
|
|
||
| 3. **upload-release-assets**: Upload pkgdown.zip | ||
| - Runs on: version tags only | ||
| - Uploads documentation to GitHub Releases | ||
|
|
||
| 4. **cleanup-pr-preview**: Clean up PR previews | ||
| - Runs on: PR close events | ||
| - Removes preview directories from gh-pages | ||
|
|
||
| ### Configuration | ||
|
|
||
| #### `pkgdown/_pkgdown.yml` | ||
| ```yaml | ||
| template: | ||
| bootstrap: 5 # Required for multi-version action | ||
|
|
||
| url: https://ucd-serg.github.io/serodynamics/ # Required | ||
| ``` | ||
|
|
||
| #### `DESCRIPTION` | ||
| ``` | ||
| URL: https://github.com/UCD-SERG/serodynamics, | ||
| https://ucd-serg.github.io/serodynamics/ | ||
| ``` | ||
|
|
||
| ### Version Filtering | ||
|
|
||
| Versions shown in the dropdown are controlled by: | ||
|
|
||
| **refs-order**: `"main latest-tag"` | ||
| - Determines the order of versions in the dropdown | ||
|
|
||
| **branches-or-tags-to-list**: `'^main$|^latest-tag$|^v([0-9]+\\.)?([0-9]+\\.)?([0-9]+)$'` | ||
| - Regex pattern matching versions to include | ||
| - Matches: `main`, `latest-tag`, and semver tags like `v1.0.0` | ||
|
|
||
| ## Creating a New Version | ||
|
|
||
| To create a new versioned documentation: | ||
|
|
||
| 1. **Tag a release**: | ||
| ```bash | ||
| git tag v1.0.0 | ||
| git push origin v1.0.0 | ||
| ``` | ||
|
|
||
| 2. **Workflow runs automatically**: | ||
| - Builds pkgdown site for v1.0.0 | ||
| - Deploys to `gh-pages/v1.0.0/` | ||
| - Updates version dropdown to include v1.0.0 | ||
| - Uploads pkgdown.zip to the GitHub release | ||
|
|
||
| 3. **Version appears in dropdown**: | ||
| - Users can now select v1.0.0 from the versions menu | ||
| - If it's the latest tag, it becomes the default landing page | ||
|
|
||
| ## Triggering Builds | ||
|
|
||
| ### Automatic Triggers | ||
| - **PR opened/updated**: Builds preview documentation | ||
| - **Push to main**: Rebuilds main version docs | ||
| - **Version tag pushed**: Builds new version docs | ||
| - **PR closed**: Cleans up preview | ||
|
|
||
| ### Manual Trigger | ||
| Use the Actions tab to manually trigger the workflow via `workflow_dispatch`. | ||
|
|
||
| ### Path Filtering | ||
| The workflow only runs when these files change: | ||
| - `inst/templates/**` | ||
| - `pkgdown/**` | ||
| - `_pkgdown.*` | ||
| - `DESCRIPTION` | ||
| - `**.md`, `**.Rmd` | ||
| - `man/**` | ||
| - `LICENSE.*` | ||
| - `NAMESPACE` | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ### Workflow requires approval | ||
| First-time workflows using external actions need manual approval: | ||
| 1. Go to repository Actions tab | ||
| 2. Find the workflow run | ||
| 3. Click "Approve and run" | ||
| 4. Subsequent runs will execute automatically | ||
|
|
||
| ### Version not appearing in dropdown | ||
| Check that: | ||
| 1. Documentation was successfully built for that version | ||
| 2. Version name matches the regex pattern | ||
| 3. Version is listed in `refs-order` or matches `branches-or-tags-to-list` | ||
|
|
||
| ### Default landing page not updating | ||
| Ensure: | ||
| 1. `default-landing-page: "latest-tag"` is set in workflow | ||
| 2. Latest tag has documentation built | ||
| 3. Multi-version-docs job completed successfully | ||
|
|
||
| ## Comparison to Original Setup | ||
|
|
||
| ### Before (pkgdown.yaml) | ||
| - Single version (main branch only) | ||
| - PR previews only | ||
| - No version switching | ||
|
|
||
| ### After (docs.yaml) | ||
| - Multiple versions (main + all releases) | ||
| - Version dropdown menu | ||
| - PR previews maintained | ||
| - Default to latest release | ||
| - Version-specific documentation URLs | ||
|
|
||
| ## Resources | ||
|
|
||
| - [insightsengineering/r-pkgdown-multiversion](https://github.com/insightsengineering/r-pkgdown-multiversion) | ||
| - [insightsengineering/tern](https://github.com/insightsengineering/tern) (reference implementation) | ||
| - [pkgdown documentation](https://pkgdown.r-lib.org/) | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation states that the workflow has path filtering, but the actual workflow file (docs.yaml) does not have any path filters in its trigger configuration. Lines 104-112 in this documentation file should be removed as they are inaccurate. The PR description correctly mentions "No path filtering: Workflow runs on all PR and push events for reliable execution", which aligns with the actual workflow implementation.