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

Cleaning the docs/reference folder from the files that may be generated by the examples of the documentation #1097

Closed
choisy opened this issue Jul 30, 2019 · 4 comments

Comments

@choisy
Copy link

choisy commented Jul 30, 2019

In this minimalist repexpkgdown R package, there is one function, hello(), and the example of its documentation creates a file on disk. A consequence of this is that, when using the pkgdown package to generate a website for the repexpkgdown package, the file created by the example of the hello()function is created in the docs/reference folder, which we would like to avoid. Is there a way to automatically avoid this?
Thanks for help.

@choisy choisy changed the title Cleaning the docs/reference folder from the files that my be generated by the examples of the docu Cleaning the docs/reference folder from the files that may be generated by the examples of the documentation Jul 30, 2019
@jayhesselberth
Copy link
Collaborator

You can prevent the example from running with \dontrun:

#' @examples
#' \dontrun{
#' write.csv(mtcars, "mtcars.csv")
#' }

@choisy
Copy link
Author

choisy commented Jul 31, 2019

Yes, we thought of that too, but \dontrun is not a satisfying solution for us as we would like the examples to be run when we look at the documentation of the functions. What we are doing now is that we have a wrapper around the pkgdown::build_site() function that cleans the docs/reference folder after the site is built. We were thinking that adding such a cleaning functionality directly to the pkgdown::build_site() function would be something you may consider.

@hadley
Copy link
Member

hadley commented Aug 8, 2019

You won't be able to get a package on CRAN if it writes to the working directory; I think that suggests this isn't pkgdown's problem to handle.

(Thanks for the minimal reprex package!!)

@hadley hadley closed this as completed Aug 8, 2019
@choisy
Copy link
Author

choisy commented Aug 9, 2019

Ah? Thanks for the info about CRAN!
(and thanks for pkgdown too!)

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

3 participants