Skip to content

Figure examples no longer render if example checks that the active graphics device isn't pdf() #2874

@trevorld

Description

@trevorld
  • I have some examples that make sure to not run if the active graphics device is pdf() in order to avoid triggering _R_CHECK_MBCS_CONVERSION_FAILURE_ issues with CRAN's R CMD check.

  • Previously these examples would show up in my {pkgdown} websites since it seems that previously {pkgdown} would record examples using ragg::agg_png():

    • e.g. in this line of highlight_examples() the device option is hardcoded to ragg::agg_png() with the intention that this device will be used to record the examples:
      device = function(...) ragg::agg_png(..., bg = bg),
  • However these examples no longer show up in my {pkgdown} websites since it seems that now examples are de facto now actually being recorded using pdf(NULL):

    • Looking at the code it seems this is because upstream in {evaluate} they changed the code to no longer use the device set by the device option but to instead to always use pdf(NULL):
  • This issue is similar to Record example plots with device requested in figures field instead of ragg::agg_png() #2299 in that there is a "problem" because the graphics device being used to record the example is a different device from the one being used to render the example and there are cases where one may want to skip the recording graphics device but not skip the rendering graphics device.

  • I did notice that the development version of {ragg} recently added the agg_record() graphics device which doesn't create any files and seems optimized for recording figure examples and (after release) I speculate it may be a better choice for recording examples than pdf(NULL): r-lib/ragg@de052f5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions