-
Notifications
You must be signed in to change notification settings - Fork 230
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
Dynamic examples #798
Comments
Do you think this strategy is still viable now that CRAN is requiring that most (all?) documentation files have executable examples? |
I think so, yes. I think the most common case is that a package is needed to run the example. This package is probably suggested, so it is installed for the check, and a proper example is generated dynamically. Even if the example does not work for a CRAN check, we'll dynamically generate a placeholder instead, and this might also work as an "example" for the automatic checks. The human review is a tossup, I guess. But usually there is no human review for package updates, so in practice I think we are fine, even if CRAN is not enthusiastic about the dynamic examples. My only worry is that the package must be installed for |
Instead of adding a roxygen2 dependency, maybe roxygen2 could add a helper file à la |
Yeah, that's an option. Roxygen does not generate files in |
There is a proof of concept here: https://github.com/gaborcsardi/dynex The main problem is that this still generates an
|
The installation warning seems to be a similar bug to https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17479, I reported it at https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17623#c0 |
The current practice of writing conditional examples, i.e. examples that need a certain package to be installed, a certain platform, etc., is not ideal, because we need to include the boilerplate code that checks for the suitable conditions in the body of the example itself.
With an
R CMD check
issue fixed recently (wch/r-source@1501a3e), we are able to generate the\examples
block dynamically, at install time, or potentially even at runtime.We need to produce the following Rd:
stage
will need to berender
in some cases, e.g. when checking for the presence of a package, that has to happen at run time.This also means that roxygen2 will be a dependency of these packages. Alternatively it will generate some code that the package author needs to put in the package. Neither are very good solutions...
The API in roxygen could be something like this:
and if
ps::ps_is_supported()
isTRUE
, thenroxygen2::dynamic_example()
will generate the normal\examples
block with<R code>
. Otherwise it would generate this:We'll still need
ps::ps_is_supported()
at install time or render time.ps::ps_is_supported()
should just return the comments to be inserted into the docs for a negative answer, andTRUE
otherwise?The text was updated successfully, but these errors were encountered: