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

Make example runner less clever #191

Merged
merged 8 commits into from
Oct 22, 2024
Merged

Make example runner less clever #191

merged 8 commits into from
Oct 22, 2024

Conversation

richfitz
Copy link
Member

@richfitz richfitz commented Oct 22, 2024

After a short fight, I can't get the withr deferred events to behave nicely under devtools::run_examples, which is I presume a similar environment to pkgdown - which leads to the silently failing examples on the docs. I've updated this to be very simple now and not try and clean up automatically at all, which should mean that the docs now run with no problems.

@richfitz richfitz marked this pull request as ready for review October 22, 2024 09:02
Copy link
Member

@plietar plietar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use fs::dir_delete. I hate that unlink just fails silently.

It's a bit of a shame the r-lib packages don't handle this well. Might be worth raising the issue with pkgload/withr/devtools.

pkgload does a new.environment, and withr uses do.call to run on.exit in that environment. I guess no one exits that environment, and I don't even know if there's an API for doing that (didn't find anything in the rlang package). Maybe if pkgload had a do.call(return, list(), env=env) line it would work?

https://github.com/r-lib/pkgload/blob/96d1a746f12ebf0a54157ed2a256bdc32358f9f6/R/dev-example.R#L38

https://github.com/r-lib/withr/blob/82daa902b654edabdd523e09d9a3b1b7216f7cc3/R/defer.R#L108-L111

R/example.R Outdated Show resolved Hide resolved
R/cleanup.R Outdated
@@ -42,6 +42,7 @@
##'
##' @export
##' @examples
##' message(sprintf("Running in %s", format(environment())))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accidental leftover?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed, trying to find out what withr/devtools were thinking they had as their environment - turns out it was exactly what I expected them to have, but it just did not work

@richfitz richfitz merged commit c499952 into main Oct 22, 2024
10 checks passed
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

Successfully merging this pull request may close these issues.

2 participants