Skip to content

Commit

Permalink
id as names (#354)
Browse files Browse the repository at this point in the history
  • Loading branch information
gogonzo authored Nov 14, 2024
1 parent bf89a7d commit 3660261
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
15 changes: 4 additions & 11 deletions R/teal_data-class.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,7 @@ setOldClass("join_keys")
#' proven to yield contents of `@.xData`.
#' Used internally. See [`verify()`] for more details.
#'
#' @section Code:
#'
#' Each code element is a character representing one call. Each element has possible attributes:
#' - `warnings` (`character`) the warnings output when evaluating the code element
#' - `messages` (`character`) the messages output when evaluating the code element
#' - `id (`integer`) random identifier of the code element to make sure uniqueness when joining
#' - `dependency` (`character`) names of objects that appear in this call and gets affected by this call,
#' separated by `<-` (objects on LHS of `<-` are affected by this line, and objects on RHS are affecting this line)
#' @inheritSection teal.code::`qenv-class` Code
#'
#' @import teal.code
#' @keywords internal
Expand Down Expand Up @@ -107,17 +100,17 @@ code2list <- function(code) {

parsed_code <- parse(text = code, keep.source = TRUE)

if (length(parsed_code)) {
code_list <- if (length(parsed_code)) {
lapply(split_code(code), function(current_code) {
attr(current_code, "id") <- sample.int(.Machine$integer.max, 1)
parsed_code <- parse(text = current_code, keep.source = TRUE)
attr(current_code, "dependency") <- extract_dependency(parsed_code)
current_code
})
} else {
# empty code like "", or just comments
attr(code, "id") <- sample.int(.Machine$integer.max, size = 1)
attr(code, "dependency") <- extract_dependency(parsed_code) # in case comment contains @linksto tag
list(code)
}
names(code_list) <- sample.int(.Machine$integer.max, length(code_list))
code_list
}
12 changes: 7 additions & 5 deletions man/teal_data-class.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3660261

Please sign in to comment.