Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #19 +/- ##
==========================================
- Coverage 99.57% 99.40% -0.18%
==========================================
Files 9 9
Lines 936 1000 +64
==========================================
+ Hits 932 994 +62
- Misses 4 6 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Examples to run manually: |
| #' Validated with [match.arg()] so it can be abbreviated. | ||
| #' When `metadata = NULL` (the default), the value is taken from the | ||
| #' `gridify.export.metadata` global option (see [options()]), falling back to | ||
| #' `"none"` if unset. This makes it possible to enable the feature globally | ||
| #' for a project via | ||
| #' `options(gridify.export.metadata = "sidecar")`. |
There was a problem hiding this comment.
| #' Validated with [match.arg()] so it can be abbreviated. | |
| #' When `metadata = NULL` (the default), the value is taken from the | |
| #' `gridify.export.metadata` global option (see [options()]), falling back to | |
| #' `"none"` if unset. This makes it possible to enable the feature globally | |
| #' for a project via | |
| #' `options(gridify.export.metadata = "sidecar")`. | |
| #' It is possible to enable the feature globally for a project via | |
| #' `options(gridify.export.metadata = "sidecar")`. |
| }) | ||
| setGeneric( | ||
| "export_to", | ||
| function(x, to, device = NULL, metadata = NULL, ...) { |
There was a problem hiding this comment.
The documentation says this is "none" by default and to use "none" when you don't want to export the metadata
| function(x, to, device = NULL, metadata = NULL, ...) { | |
| function(x, to, device = NULL, metadata = "none", ...) { |
Or it should be NULL by default and docs need updating
| return(FALSE) | ||
| } | ||
| if (is.list(payload) && is.null(names(payload))) { | ||
| return(any(vapply(payload, has_metadata_payload, logical(1)))) |
There was a problem hiding this comment.
Is this the best way to manage the situation? payload is one of NULL, an empty list or its a non-empty list so I'm not sure what the vapply is doing
| user_args <- list(...) | ||
| payload <- if (metadata == "none") NULL else gridify_metadata(x) | ||
| sidecar_json <- if (metadata == "sidecar" && has_metadata_payload(payload)) { | ||
| gridify_to_json(metadata_sidecar_payload(payload)) |
There was a problem hiding this comment.
These functions gridify_to_json and metadata_sidecar_payload are always used together and are quite small, it might be worth merging them together. I also think it would be easier to debug in the future as you wouldn't have to check both functions
Add
metadataargument toexport_to()with JSON sidecar supportIntroduces an opt-in
metadataargument toexport_to()that recordsset_cell()text values alongside exported files.What's new
export_to()gains ametadataargument ("none"/"sidecar"). Passing"sidecar"writes a<file>.jsonsidecar next to the output — a flat JSON object for single-page exports, or a JSON array (one entry per page) for multi-page PDFs.gridify.export.metadataglobal option allows project-wide defaults (e.g. in.Rprofile).gridify_metadata(),gridify_to_json(),write_metadata_sidecar(),resolve_export_metadata().jsonliteadded asSuggests(notImports) — only required whenmetadata = "sidecar"is used; a clearrequireNamespaceguard provides an install prompt otherwise.Tests & docs
simple_examples,multi_page_examples) and NEWS.md updated.