diff --git a/NEWS.md b/NEWS.md index de66ef26a..df3731f2e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -48,6 +48,7 @@ * New internal `cli_to_plain()` converts `cli` markup to plain text for non-cli path * All internal call sites updated to `cli` glue syntax * CI dev-version and old-tinytest workflows now only run on `main` branch pushes +* Single-quoted literal values in messaging calls replaced with `{.val}`, `{.cls}`, `{.field}`, or `{.code}` markup throughout # AMR 3.0.1 diff --git a/R/ab_from_text.R b/R/ab_from_text.R index 2d6087fd8..c9705f1ae 100755 --- a/R/ab_from_text.R +++ b/R/ab_from_text.R @@ -212,7 +212,7 @@ ab_from_text <- function(text, } }) } else { - stop_("{.arg type} must be either 'drug', 'dose' or 'administration'") + stop_("{.arg type} must be either {.val drug}, {.val dose} or {.val administration}") } # collapse text if needed diff --git a/R/av_from_text.R b/R/av_from_text.R index e1ca7592d..d07dc81bb 100755 --- a/R/av_from_text.R +++ b/R/av_from_text.R @@ -168,7 +168,7 @@ av_from_text <- function(text, } }) } else { - stop_("{.arg type} must be either 'drug', 'dose' or 'administration'") + stop_("{.arg type} must be either {.val drug}, {.val dose} or {.val administration}") } # collapse text if needed diff --git a/R/mo_source.R b/R/mo_source.R index 2e7cfb4ef..e68bb3f09 100755 --- a/R/mo_source.R +++ b/R/mo_source.R @@ -289,7 +289,7 @@ check_validity_mo_source <- function(x, refer_to_name = "`reference_df`", stop_o } if (!"mo" %in% colnames(x)) { if (stop_on_error == TRUE) { - stop_(refer_to_name, " must contain a column 'mo'", call = FALSE) + stop_(refer_to_name, " must contain a column {.field mo}", call = FALSE) } else { return(FALSE) } diff --git a/R/sir.R b/R/sir.R index b3d71e61c..ea8aac961 100755 --- a/R/sir.R +++ b/R/sir.R @@ -985,7 +985,7 @@ as.sir.data.frame <- function(x, } else if (!is.sir(x.bak[, ab, drop = TRUE])) { show_message <- TRUE if (isTRUE(info)) { - message_("Assigning class 'sir' to already clean column '", font_bold(ab), "' (", + message_("Assigning class {.cls sir} to already clean column '", font_bold(ab), "' (", ifelse(ab_coerced != toupper(ab), paste0(ab_coerced, ", "), ""), ab_name(ab_coerced, tolower = TRUE, language = NULL, info = info), ")... ", appendLF = FALSE, @@ -1276,7 +1276,7 @@ as_sir_method <- function(method_short, mo_var_found <- "" } if (is.null(mo)) { - stop_("No information was supplied about the microorganisms (missing argument {.arg mo} and no column of class 'mo' found). See {.help [{.fun as.sir}](AMR::as.sir)}.\n\n", + stop_("No information was supplied about the microorganisms (missing argument {.arg mo} and no column of class {.cls mo} found). See {.help [{.fun as.sir}](AMR::as.sir)}.\n\n", "To transform certain columns with e.g. mutate(), use ", highlight_code("data %>% mutate(across(..., as.sir, mo = x))"), ", where x is your column with microorganisms.\n", "To transform all ", method_long, " in a data set, use ", highlight_code("data %>% as.sir()"), " or ", highlight_code(paste0("data %>% mutate_if(is.", method_short, ", as.sir)")), ".", call = FALSE @@ -1988,7 +1988,7 @@ sir_interpretation_history <- function(clean = FALSE) { #' @noRd print.sir_log <- function(x, ...) { if (NROW(x) == 0) { - message_("No results to print. First run {.help [{.fun as.sir}](AMR::as.sir)} on MIC values or disk diffusion zones (or on a {.cls data.frame} containing any of these) to print a 'logbook' data set here.") + message_("No results to print. First run {.help [{.fun as.sir}](AMR::as.sir)} on MIC values or disk diffusion zones (or on a {.cls data.frame} containing any of these) to print a {.val logbook} data set here.") return(invisible(NULL)) } class(x) <- class(x)[class(x) != "sir_log"] @@ -2227,10 +2227,10 @@ check_reference_data <- function(reference_data, .call_depth) { class_sir <- vapply(FUN.VALUE = character(1), AMR::clinical_breakpoints, function(x) paste0("<", class(x), ">", collapse = " and ")) class_ref <- vapply(FUN.VALUE = character(1), reference_data, function(x) paste0("<", class(x), ">", collapse = " and ")) if (!all(names(class_sir) == names(class_ref))) { - stop_("{.arg reference_data} must have the same column names as the 'clinical_breakpoints' data set.", call = .call_depth) + stop_("{.arg reference_data} must have the same column names as the {.code clinical_breakpoints} data set.", call = .call_depth) } if (!all(class_sir == class_ref)) { - stop_("{.arg reference_data} must be the same structure as the 'clinical_breakpoints' data set. Column '", names(class_ref[class_sir != class_ref][1]), "' is of class ", class_ref[class_sir != class_ref][1], ", but should be of class ", class_sir[class_sir != class_ref][1], ".", call = .call_depth) + stop_("{.arg reference_data} must be the same structure as the {.code clinical_breakpoints} data set. Column '", names(class_ref[class_sir != class_ref][1]), "' is of class ", class_ref[class_sir != class_ref][1], ", but should be of class ", class_sir[class_sir != class_ref][1], ".", call = .call_depth) } } } diff --git a/R/sir_calc.R b/R/sir_calc.R index 5fcb8ba51..6378a2dd4 100755 --- a/R/sir_calc.R +++ b/R/sir_calc.R @@ -144,7 +144,7 @@ sir_calc <- function(..., FUN = min ) if ("SDD" %in% ab_result && "SDD" %in% y && message_not_thrown_before("sir_calc", only_count, ab_result, entire_session = TRUE)) { - message_("Note that `", ifelse(only_count, "count", "proportion"), "_", ifelse("S" %in% ab_result, "S", ""), "I", ifelse("R" %in% ab_result, "R", ""), "()` will also include dose-dependent susceptibility, 'SDD'. This note will be shown once for this session.", as_note = FALSE) + message_("Note that `", ifelse(only_count, "count", "proportion"), "_", ifelse("S" %in% ab_result, "S", ""), "I", ifelse("R" %in% ab_result, "R", ""), "()` will also include dose-dependent susceptibility, {.val SDD}. This note will be shown once for this session.", as_note = FALSE) } numerator <- sum(!is.na(y) & y %in% as.double(ab_result), na.rm = TRUE) denominator <- sum(vapply(FUN.VALUE = logical(1), x_transposed, function(y) !(anyNA(y)))) @@ -152,7 +152,7 @@ sir_calc <- function(..., # may contain NAs in any column other_values <- setdiff(c(NA, denominator_vals), ab_result) if ("SDD" %in% ab_result && "SDD" %in% unlist(x_transposed) && message_not_thrown_before("sir_calc", only_count, ab_result, entire_session = TRUE)) { - message_("Note that `", ifelse(only_count, "count", "proportion"), "_", ifelse("S" %in% ab_result, "S", ""), "I", ifelse("R" %in% ab_result, "R", ""), "()` will also include dose-dependent susceptibility, 'SDD'. This note will be shown once for this session.", as_note = FALSE) + message_("Note that `", ifelse(only_count, "count", "proportion"), "_", ifelse("S" %in% ab_result, "S", ""), "I", ifelse("R" %in% ab_result, "R", ""), "()` will also include dose-dependent susceptibility, {.val SDD}. This note will be shown once for this session.", as_note = FALSE) } numerator <- sum(vapply(FUN.VALUE = logical(1), x_transposed, function(y) any(y %in% ab_result, na.rm = TRUE))) denominator <- sum(vapply(FUN.VALUE = logical(1), x_transposed, function(y) !(all(y %in% other_values) & anyNA(y)))) @@ -164,7 +164,7 @@ sir_calc <- function(..., print_warning <- TRUE } if ("SDD" %in% ab_result && "SDD" %in% x && message_not_thrown_before("sir_calc", only_count, ab_result, entire_session = TRUE)) { - message_("Note that `", ifelse(only_count, "count", "proportion"), "_", ifelse("S" %in% ab_result, "S", ""), "I", ifelse("R" %in% ab_result, "R", ""), "()` will also include dose-dependent susceptibility, 'SDD'. This note will be shown once for this session.", as_note = FALSE) + message_("Note that `", ifelse(only_count, "count", "proportion"), "_", ifelse("S" %in% ab_result, "S", ""), "I", ifelse("R" %in% ab_result, "R", ""), "()` will also include dose-dependent susceptibility, {.val SDD}. This note will be shown once for this session.", as_note = FALSE) } numerator <- sum(x %in% ab_result, na.rm = TRUE) denominator <- sum(x %in% denominator_vals, na.rm = TRUE) @@ -172,7 +172,7 @@ sir_calc <- function(..., if (print_warning == TRUE) { if (message_not_thrown_before("sir_calc")) { - warning_("Increase speed by transforming to class 'sir' on beforehand:\n", + warning_("Increase speed by transforming to class {.cls sir} on beforehand:\n", highlight_code(" your_data %>% mutate_if(is_sir_eligible, as.sir)"), call = FALSE )