Skip to content
Open
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
24 changes: 12 additions & 12 deletions R/add_caption_alt_text.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@
#' caption, and alt_text for a figure or table not present in stockplotr.
#'
#' @inheritParams create_rda
#'
#' @param topic_label String. Figure/table label. For automated matching in
#'
#' @param topic_label String. Figure/table label. For automated matching in
#' asar-based report, it must match the label in your plot's chunk options, MINUS
#' the "fig-" or "tab-". For example, the label "custom_table1" would match up
#' the "fig-" or "tab-". For example, the label "custom_table1" would match up
#' properly with the "tbl-custom_table1" code chunk label.
#'
#'
#' @param caption String. Figure/table caption.
#'
#'
#' @param alt_text String. Figure alternative text. Unnecessary for text-based tables.
#'
#'
#' Default: ""
#'
#'
#' @param dir Path. Path to the existing captions_alt_text.csv file that will be
#' updated with the new caption and alt text.
#'
#' Default: file.path(getwd(), "captions_alt_text.csv")
#'
#' @export
#'
#'
#' @examples \dontrun{
#' add_caption_alt_text(
#' topic_label = "my_topic",
Expand All @@ -38,22 +38,22 @@ add_caption_alt_text <- function(topic_label,
alt_text = "",
dir = file.path(getwd(), "captions_alt_text.csv")) {
captions_alt_text <- utils::read.csv(dir)

if (fig_or_table == tolower("figure") & alt_text == "") {
cli::cli_alert_warning("No alt text provided for figure {topic_label}.")
cli::cli_alert_warning("Figure alt text is necessary to pass asar report accessibility checks.")
cli::cli_alert_info("Learn how to write descriptive alt text with the asar 'Increasing Report Accessibility' vignette: {.url https://nmfs-ost.github.io/asar/articles/accessibility_guide.html#alternative-text}.")
}

new_row <- data.frame(
label = topic_label,
type = fig_or_table,
caption = caption,
alt_text = alt_text
)

captions_alt_text <- rbind(captions_alt_text, new_row)

utils::write.csv(
captions_alt_text,
file = dir,
Expand Down
7 changes: 3 additions & 4 deletions R/convert_output.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,17 @@ convert_output <- function(
fleet_names = NULL,
save_dir = NULL
) {

if (is.character(file) && grepl("Report.sso", file)) {
lifecycle::deprecate_warn(
when = "2.8.0",
what = I("convert_output(file = 'Report.sso')"),
when = "2.8.0",
what = I("convert_output(file = 'Report.sso')"),
details = c(
i = "Please use the returned object from `r4ss::ss_output()`",
i = "File will be compatible until Oct. 1, 2027"
)
)
}

# check if entered save_dir exists so doesn't waste user time finding this out at the end
if (!is.null(save_dir)) {
if (!grepl(".rda", save_dir)) {
Expand Down
Loading
Loading