rgbif icon indicating copy to clipboard operation
rgbif copied to clipboard

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

Open PietrH opened this issue 1 year ago • 0 comments

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.

PietrH avatar Jan 26 '24 14:01 PietrH