Closed dvg-p4 closed 3 months ago
It's not clear to me what you're advocating for. Hiding the blocks completely? I'm guess not sure what you mean by "turned off".
Current:
Proposed:
I’d recommend using a different technique like @exampleIf
I’d recommend using a different technique like
@exampleIf
@exampleIf FALSE
actually removes the ## Not run:
from the R/Rstudio docs, but still leaves the if (FALSE)
in pkgdown
and @exampleIf 1 == 0
yields if (FALSE) { # 1 == 0
You should use a real condition that evaluates to TRUE
when pkgdown is running.
What would that be?
Presumably you have some idea of when connect()
will succeed. You might find https://r-pkgs.org/man.html#sec-man-examples-dependencies-conditional-execution helpful.
In short, it won't ever, because the functions in our class require a live connection to an actual database, for which we don't want to put credentials in our package examples.
I guess I'm confused as to why pkgdown wants to add this whole if (FALSE)
in the first place. The point is to render examples on a webpage; the code isn't going to magically run itself (right?) -- and if someone manually copy-pastes the example code into an R terminal, the if (FALSE)
won't stop them cause they can just not copy that part.
@hadley Am I misunderstanding something about how these example blocks work, is pkgdown actually evaluating the code when it generates the site?
Yes, pkgdown runs all the examples.
We use
\dontrun{...}
in all of our examples, which require database connections or otherwise should not be automatically run when building our package docs. In R or Rstudio, these unfortunately render as## Not run:
...## End(Not run)
, which at least renders in an easily-ignorable gray. However, pkgdown renders the tags asif (FALSE) {...}
, which I think clutters up the page to very little benefit and looks kind of ugly. So, it would be nice if this could be turned off.