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

Remove usage of metaprogramming in device helpers #267

Merged
merged 2 commits into from
Jul 31, 2024
Merged

Conversation

lionel-
Copy link
Member

@lionel- lionel- commented Jul 30, 2024

To fix the R-devel warning. It seems more robust not to inline programmatically the arguments in generated functions so I've now hardcoded the implementations. For simplicity arguments are passed via ... and the documentation now contains a list of links to wrapped functions so the relevant signatures can be browsed by following the links.

Does this seem reasonable enough @hadley ?

I was also expecting these notes to disappear following this change:

  pdf_dev: no visible binding for global variable ‘grDevices’
  pdf_dev: no visible binding for global variable ‘pdf’
  pdf_dev: no visible binding for global variable ‘dev.cur’
  png_dev: no visible binding for global variable ‘grDevices’
  png_dev: no visible binding for global variable ‘png’
  png_dev: no visible binding for global variable ‘dev.cur’

Somehow they're still there.

@hadley
Copy link
Member

hadley commented Jul 30, 2024

All the weird variable binding errors are caused by on_load(:: <- base::::)

Copy link
Member

@hadley hadley left a comment

Choose a reason for hiding this comment

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

This seems like a cleaner approach to me.

R/devices.R Outdated

pdf_dev <- function(filename, ...) {
grDevices::pdf(file = filename, ...)
grDevices::dev.cur()
Copy link
Member

Choose a reason for hiding this comment

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

I'd be tempted to move the dev.cur() in to the local_* functions. Then you could remove all the shims except for those necessary to standardise the argument names.

Copy link
Member Author

@lionel- lionel- Jul 30, 2024

Choose a reason for hiding this comment

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

Good idea. How does this now look? I've also abstracted device closing in a defer_dev_close() helper.

Copy link
Member

Choose a reason for hiding this comment

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

Looks great!

@lionel- lionel- merged commit afd84aa into main Jul 31, 2024
11 checks passed
@lionel- lionel- deleted the bugfix/pdf-doc branch July 31, 2024 07:20
@lionel-
Copy link
Member Author

lionel- commented Jul 31, 2024

All the weird variable binding errors are caused by on_load(:: <- base::::)

oh no :-(

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