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

Render output in a temp directory, when in an R package #435

Merged
merged 4 commits into from
May 13, 2024

Conversation

juliasilge
Copy link
Collaborator

@juliasilge juliasilge commented May 8, 2024

This PR updates the preview behavior so by default output files go to a temporary directory when the workspace is an R package.

Copy link
Collaborator Author

@juliasilge juliasilge left a comment

Choose a reason for hiding this comment

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

In my testing, this works well for files at the top level of an R package like README and NEWS. We'll need to follow up for vignettes, because although the final file is written to the temporary directory, these kinds of files are still getting written to the directory where the vignette lives:

Screenshot 2024-05-08 at 4 19 21 PM

Comment on lines +1076 to +1082
"quarto.render.rPackageOutputDirectory": {
"order": 15,
"scope": "window",
"type": "boolean",
"default": true,
"markdownDescription": "Render output files in a temporary directory, when in an R package."
},
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is new configuration, so users can turn off this behavior if they prefer:

Screenshot 2024-05-08 at 4 08 13 PM

I want to argue that this should be true by default, because otherwise, R package developers need to add all these output files to both .gitignore and .Rbuildignore.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would recommend doing a bit of work ahead of time to make sure that this is not going to create other bugs. In an R package, will users mostly preview README.md files and vignettes? In that case, I wonder if the right behavior is to use --output-dir only in these special cases.

Like we discussed, relocating files for an .html target is unlikely to be robust because of things like CSS resource paths; in that case, we tend to recommend to use --output-dir together with embed-resources

Copy link
Contributor

Choose a reason for hiding this comment

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

With that said, this is a pain in the neck to test in an automated fashion. It might be good enough to test this by making a mock test harness over at https://github.com/quarto-dev/quarto-cli. I can help with that; I think it's prudent to do it. Because quarto-cli won't generally know the ways in which the extension calls quarto render, quarto preview etc, we have a pretty big regression risk unless we do something about it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In that case, I wonder if the right behavior is to use --output-dir only in these special cases.

I'm going to get some more feedback on this from folks, but my current belief is that there are basically no cases where you want to check in generated code such as HTML, libs, etc, for an R package.

The one exception is README.Rmd being rendered to README.md but a) none of that works for people right now because of output: github_document and b) we can encourage them to use devtools::build_readme() for this purpose. If we want to be more forward thinking, we could exclude README.Rmd and README.qmd from this treatment, rather than make a list of files to include for this treatment.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm going to get some more feedback on this from folks, but my current belief is that there are basically no cases where you want to check in generated code such as HTML, libs, etc, for an R package.

I believe that! Really my only concern is that quarto preview itself might break under common use cases in R packages, and I'd hate for us to enable something by default that doesn't work well in these scenarios.

apps/vscode/src/providers/preview/preview-util.ts Outdated Show resolved Hide resolved
@juliasilge juliasilge marked this pull request as ready for review May 8, 2024 22:22
@juliasilge juliasilge requested a review from cscheid May 8, 2024 22:22
Copy link
Contributor

@cscheid cscheid left a comment

Choose a reason for hiding this comment

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

There's a catch { } clause that I think we should be more careful about before merging, but this otherwise looks good.

@cscheid
Copy link
Contributor

cscheid commented May 9, 2024

This looks good from my end, so feel free to squash+merge it or let me know if you have no further changes to make!

@juliasilge juliasilge marked this pull request as draft May 9, 2024 21:46
@juliasilge juliasilge marked this pull request as ready for review May 13, 2024 21:26
@cscheid cscheid merged commit 83a2dda into main May 13, 2024
1 check passed
@juliasilge juliasilge deleted the r-pkg-output-dir branch October 26, 2024 20:28
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