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

Examples in the documentation are wrapped in ´if(FALSE){}, use @examplesIf` instead #700

Open
PietrH opened this issue Jan 26, 2024 · 0 comments

Comments

@PietrH
Copy link
Contributor

PietrH commented Jan 26, 2024

When referring to the documentation I noticed @examples were wrapped in if(FALSE){}, probably so they don't run while package building or on CRAN because they would take too long or require credentials.

Isn't it better to instead use:

  • if(interactive()){}: only run when session is interactive
  • \dontrun{} (but we'd still need one example per function for CRAN)
  • @examplesIf interactive(), doesn't show the if clause in the rendered documentation, and I believe is allowed by CRAN

I prefer this last solution, and this is similar as to how {googledrive} does it:
https://github.com/tidyverse/googledrive/blob/ed574d9eb3308619fc3e735251bfd42e6cfdb8e2/R/drive_read.R#L25

I believe interactive() is a suitable condition to running the examples, this would allow users to use example() as well.

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

No branches or pull requests

1 participant