mirror of
https://github.com/msberends/AMR.git
synced 2026-03-19 15:42:27 +01:00
Add {.topic} markup for non-function help page references
Replace {.code ?AMR-options} and backtick-style ?AMR-options / ?AMR-deprecated
references with proper {.topic AMR-options} / {.topic AMR-deprecated} cli markup
in count.R, interpretive_rules.R, proportion.R, and zz_deprecated.R.
Add {.topic} fallback handler to format_message() in aa_helper_functions.R:
plain-text environments render {.topic foo} as ?foo, and the [text](topic)
link form extracts just the display text (same pattern as {.help}).
Also convert remaining backtick function/arg references in proportion.R to
{.help [{.fun ...}](AMR::...)}, {.arg}, and {.code} markup for consistency.
Note: zzz.R intentionally keeps the backtick form since its startup message
goes through packageStartupMessage() which bypasses our cli infrastructure.
https://claude.ai/code/session_01XHWLohiSTdZvCutwD7ag2b
This commit is contained in:
@@ -465,6 +465,11 @@ cli_to_plain <- function(msg, envir = parent.frame()) {
|
|||||||
m <- regmatches(c, regexec("^\\[(.*)\\]\\([^)]*\\)$", c, perl = TRUE))[[1L]]
|
m <- regmatches(c, regexec("^\\[(.*)\\]\\([^)]*\\)$", c, perl = TRUE))[[1L]]
|
||||||
if (length(m) >= 2L) m[2L] else paste0("`", resolve(c), "`")
|
if (length(m) >= 2L) m[2L] else paste0("`", resolve(c), "`")
|
||||||
})
|
})
|
||||||
|
msg <- apply_sub(msg, "\\{\\.topic ([^}]+)\\}", function(c) {
|
||||||
|
# Handle [display text](topic) markdown link format: extract just the display text
|
||||||
|
m <- regmatches(c, regexec("^\\[(.*)\\]\\([^)]*\\)$", c, perl = TRUE))[[1L]]
|
||||||
|
if (length(m) >= 2L) m[2L] else paste0("?", resolve(c))
|
||||||
|
})
|
||||||
msg <- apply_sub(msg, "\\{\\.url (\\{[^}]+\\}|[^}]+)\\}", function(c) resolve(c))
|
msg <- apply_sub(msg, "\\{\\.url (\\{[^}]+\\}|[^}]+)\\}", function(c) resolve(c))
|
||||||
msg <- apply_sub(msg, "\\{\\.href ([^}]+)\\}", function(c) strsplit(resolve(c), " ", fixed = TRUE)[[1L]][1L])
|
msg <- apply_sub(msg, "\\{\\.href ([^}]+)\\}", function(c) strsplit(resolve(c), " ", fixed = TRUE)[[1L]][1L])
|
||||||
|
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ count_resistant <- function(...,
|
|||||||
# other arguments for meet_criteria are handled by sir_calc()
|
# other arguments for meet_criteria are handled by sir_calc()
|
||||||
meet_criteria(guideline, allow_class = "character", is_in = c("EUCAST", "CLSI"), has_length = 1)
|
meet_criteria(guideline, allow_class = "character", is_in = c("EUCAST", "CLSI"), has_length = 1)
|
||||||
if (is.null(getOption("AMR_guideline")) && missing(guideline) && message_not_thrown_before("count_resistant", "eucast_default", entire_session = TRUE)) {
|
if (is.null(getOption("AMR_guideline")) && missing(guideline) && message_not_thrown_before("count_resistant", "eucast_default", entire_session = TRUE)) {
|
||||||
message_("{.help [{.fun count_resistant}](AMR::count_resistant)} assumes the EUCAST guideline and thus considers the 'I' category susceptible. Set the {.arg guideline} argument or the {.code AMR_guideline} option to either \"CLSI\" or \"EUCAST\", see {.code ?AMR-options}.")
|
message_("{.help [{.fun count_resistant}](AMR::count_resistant)} assumes the EUCAST guideline and thus considers the 'I' category susceptible. Set the {.arg guideline} argument or the {.code AMR_guideline} option to either \"CLSI\" or \"EUCAST\", see {.topic AMR-options}.")
|
||||||
message_("This message will be shown once per session.")
|
message_("This message will be shown once per session.")
|
||||||
}
|
}
|
||||||
tryCatch(
|
tryCatch(
|
||||||
@@ -152,7 +152,7 @@ count_susceptible <- function(...,
|
|||||||
# other arguments for meet_criteria are handled by sir_calc()
|
# other arguments for meet_criteria are handled by sir_calc()
|
||||||
meet_criteria(guideline, allow_class = "character", is_in = c("EUCAST", "CLSI"), has_length = 1)
|
meet_criteria(guideline, allow_class = "character", is_in = c("EUCAST", "CLSI"), has_length = 1)
|
||||||
if (is.null(getOption("AMR_guideline")) && missing(guideline) && message_not_thrown_before("count_susceptible", "eucast_default", entire_session = TRUE)) {
|
if (is.null(getOption("AMR_guideline")) && missing(guideline) && message_not_thrown_before("count_susceptible", "eucast_default", entire_session = TRUE)) {
|
||||||
message_("{.help [{.fun count_susceptible}](AMR::count_susceptible)} assumes the EUCAST guideline and thus considers the 'I' category susceptible. Set the {.arg guideline} argument or the {.code AMR_guideline} option to either \"CLSI\" or \"EUCAST\", see {.code ?AMR-options}.")
|
message_("{.help [{.fun count_susceptible}](AMR::count_susceptible)} assumes the EUCAST guideline and thus considers the 'I' category susceptible. Set the {.arg guideline} argument or the {.code AMR_guideline} option to either \"CLSI\" or \"EUCAST\", see {.topic AMR-options}.")
|
||||||
message_("This message will be shown once per session.")
|
message_("This message will be shown once per session.")
|
||||||
}
|
}
|
||||||
tryCatch(
|
tryCatch(
|
||||||
|
|||||||
@@ -1097,7 +1097,7 @@ eucast_rules <- function(x,
|
|||||||
rules = getOption("AMR_interpretive_rules", default = c("breakpoints", "expected_phenotypes")),
|
rules = getOption("AMR_interpretive_rules", default = c("breakpoints", "expected_phenotypes")),
|
||||||
...) {
|
...) {
|
||||||
if (!is.null(getOption("AMR_eucastrules", default = NULL))) {
|
if (!is.null(getOption("AMR_eucastrules", default = NULL))) {
|
||||||
warning_("The global option {.code AMR_eucastrules} that you have set is now invalid was ignored - set {.code AMR_interpretive_rules} instead. See {.code ?AMR-options}.")
|
warning_("The global option {.code AMR_eucastrules} that you have set is now invalid was ignored - set {.code AMR_interpretive_rules} instead. See {.topic AMR-options}.")
|
||||||
}
|
}
|
||||||
interpretive_rules(x = x, col_mo = col_mo, info = info, rules = rules, guideline = "EUCAST", ...)
|
interpretive_rules(x = x, col_mo = col_mo, info = info, rules = rules, guideline = "EUCAST", ...)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ resistance <- function(...,
|
|||||||
# other arguments for meet_criteria are handled by sir_calc()
|
# other arguments for meet_criteria are handled by sir_calc()
|
||||||
meet_criteria(guideline, allow_class = "character", is_in = c("EUCAST", "CLSI"), has_length = 1)
|
meet_criteria(guideline, allow_class = "character", is_in = c("EUCAST", "CLSI"), has_length = 1)
|
||||||
if (is.null(getOption("AMR_guideline")) && missing(guideline) && message_not_thrown_before("resistance", "eucast_default", entire_session = TRUE)) {
|
if (is.null(getOption("AMR_guideline")) && missing(guideline) && message_not_thrown_before("resistance", "eucast_default", entire_session = TRUE)) {
|
||||||
message_("`resistance()` assumes the EUCAST guideline and thus considers the 'I' category susceptible. Set the `guideline` argument or the `AMR_guideline` option to either \"CLSI\" or \"EUCAST\", see `?AMR-options`.")
|
message_("{.help [{.fun resistance}](AMR::resistance)} assumes the EUCAST guideline and thus considers the 'I' category susceptible. Set the {.arg guideline} argument or the {.code AMR_guideline} option to either \"CLSI\" or \"EUCAST\", see {.topic AMR-options}.")
|
||||||
message_("This message will be shown once per session.")
|
message_("This message will be shown once per session.")
|
||||||
}
|
}
|
||||||
tryCatch(
|
tryCatch(
|
||||||
@@ -266,7 +266,7 @@ susceptibility <- function(...,
|
|||||||
# other arguments for meet_criteria are handled by sir_calc()
|
# other arguments for meet_criteria are handled by sir_calc()
|
||||||
meet_criteria(guideline, allow_class = "character", is_in = c("EUCAST", "CLSI"), has_length = 1)
|
meet_criteria(guideline, allow_class = "character", is_in = c("EUCAST", "CLSI"), has_length = 1)
|
||||||
if (is.null(getOption("AMR_guideline")) && missing(guideline) && message_not_thrown_before("susceptibility", "eucast_default", entire_session = TRUE)) {
|
if (is.null(getOption("AMR_guideline")) && missing(guideline) && message_not_thrown_before("susceptibility", "eucast_default", entire_session = TRUE)) {
|
||||||
message_("`susceptibility()` assumes the EUCAST guideline and thus considers the 'I' category susceptible. Set the `guideline` argument or the `AMR_guideline` option to either \"CLSI\" or \"EUCAST\", see `?AMR-options`.")
|
message_("{.help [{.fun susceptibility}](AMR::susceptibility)} assumes the EUCAST guideline and thus considers the 'I' category susceptible. Set the {.arg guideline} argument or the {.code AMR_guideline} option to either \"CLSI\" or \"EUCAST\", see {.topic AMR-options}.")
|
||||||
message_("This message will be shown once per session.")
|
message_("This message will be shown once per session.")
|
||||||
}
|
}
|
||||||
tryCatch(
|
tryCatch(
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ deprecation_warning <- function(old = NULL, new = NULL, fn = NULL, extra_msg = N
|
|||||||
". The old name will be removed in future version, so please update your code.",
|
". The old name will be removed in future version, so please update your code.",
|
||||||
ifelse(type == "argument",
|
ifelse(type == "argument",
|
||||||
". While the old argument still works, it will be removed in a future version, so please update your code.",
|
". While the old argument still works, it will be removed in a future version, so please update your code.",
|
||||||
" and will be removed in a future version, see `?AMR-deprecated`."
|
" and will be removed in a future version, see {.topic AMR-deprecated}."
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
ifelse(!is.null(extra_msg),
|
ifelse(!is.null(extra_msg),
|
||||||
|
|||||||
Reference in New Issue
Block a user