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

id as names #354

Merged
merged 2 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Loading