Skip to content

Use pkgdown selective HTML for dev/release docs#1060

Open
seabbs-bot wants to merge 3 commits intomainfrom
issue-810-pkgdown-selective-html
Open

Use pkgdown selective HTML for dev/release docs#1060
seabbs-bot wants to merge 3 commits intomainfrom
issue-810-pkgdown-selective-html

Conversation

@seabbs-bot
Copy link
Collaborator

Summary

  • Replace R code that detects package version at knit time with pkgdown's built-in selective HTML feature
  • Uses .pkgdown-devel and .pkgdown-release CSS classes to show appropriate documentation links based on whether pkgdown is building the dev or release site
  • This is cleaner and more reliable as it doesn't depend on the package version installed when knitting the README

Changes

The previous approach used R code in a setup chunk to detect if the installed version was a dev version:

version <- packageVersion("scoringutils")
devel <- length(unclass(package_version(version))[[1]]) > 3

This has been replaced with pkgdown's selective HTML:

::: {.pkgdown-devel}
***Note***: [*This documentation*](https://epiforecasts.io/scoringutils/dev/)...
:::

::: {.pkgdown-release}
***Note***: [*This documentation*](https://epiforecasts.io/scoringutils/)...
:::

References

This was opened by a bot. Please ping @seabbs for any questions.

Replace R code that detects package version at knit time with pkgdown's built-in selective HTML feature. This uses .pkgdown-devel and .pkgdown-release CSS classes to show appropriate documentation links based on whether pkgdown is building the dev or release site.

This approach is cleaner and more reliable as it doesn't depend on the package version installed when knitting the README.

Closes #810
Instead of embedding selective HTML directly in README (which shows on GitHub), generate pkgdown/index.md at build time by prepending the version note header to README.md.

This keeps README.md clean for GitHub while giving pkgdown the version-aware home page.
Use sed to insert the header content after the badges section rather than prepending it to the entire file.
@seabbs-bot seabbs-bot force-pushed the issue-810-pkgdown-selective-html branch from 247ebae to cfc5804 Compare January 30, 2026 10:59
@codecov
Copy link

codecov bot commented Jan 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.83%. Comparing base (6c5a5c4) to head (cfc5804).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1060   +/-   ##
=======================================
  Coverage   97.83%   97.83%           
=======================================
  Files          35       35           
  Lines        1845     1845           
=======================================
  Hits         1805     1805           
  Misses         40       40           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@seabbs seabbs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good and I think is correct. Calling for another review as this is just me and @seabbs-bot

@seabbs seabbs requested review from nikosbosse and sbfnk January 30, 2026 15:44
Copy link
Collaborator

@nikosbosse nikosbosse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, the sed injection is quite clever. Nice!

@nikosbosse
Copy link
Collaborator

It does remove the reference in the Github Readme though, right? Not sure how much we mind. Maybe slightly?
The alternatives I see would be:

  • leaving things as is
  • creating a dedicated static pkgdown/index.md file which then would need updating every time we change the Readme.md file

@seabbs
Copy link
Contributor

seabbs commented Feb 2, 2026

Yes that was intentional. I don't think it is really clear why you would want that in the github docs? It seems like the path should be to get everyone into the html docs and then go from there. If you do think that is useful then it is quite easy to have it stay in the readme by injecting it at build time when we render the readme from Rmd to md.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clean up readme by using pkgdown to render dev version docs

3 participants