Skip to content

Run as_gt() examples conditionally #338

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Feb 15, 2024
Merged

Run as_gt() examples conditionally #338

merged 1 commit into from
Feb 15, 2024

Conversation

nanxstats
Copy link
Collaborator

Fixes #334

I used @examplesIf to only run the as_gt() examples when it is either in interactive mode OR not rendered by pkgdown.

#' @examplesIf interactive() && !identical(Sys.getenv("IN_PKGDOWN"), "true")

This will make the examples section in the pkgdown site not showing the 7,000 lines of raw HTML.


I did not choose to capture the tables as images and create an "example output" section to link them (what gtsummary does) because:

  • gt outputs is not the main theme of this package so it's less important to show what the output looks like.
  • Since we have 11 tables here, the saved PNG files will bloat up the bundled package size by at least 1 Mb.
  • One needs to regenerate the images using a script if the examples are updated. As people tend to forget about things outside of the standard workflow, it could become easily out of sync or a maintenance burden.

Copy link
Collaborator

@LittleBeannie LittleBeannie left a comment

Choose a reason for hiding this comment

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

Thanks, @nanxstats !

@LittleBeannie LittleBeannie merged commit 69ad566 into main Feb 15, 2024
@LittleBeannie LittleBeannie deleted the as-gt-examples branch February 15, 2024 14:10
@jdblischak jdblischak mentioned this pull request Feb 19, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reasonable as_gt() code example output
2 participants