R/show-news.R

Defines functions show_news

Documented in show_news

#' Show package news
#'
#' @template devtools
#' @param latest if `TRUE`, only show the news for the most recent
#'   version.
#' @param ... other arguments passed on to `news`
#' @export
show_news <- function(pkg = ".", latest = TRUE, ...) {
  pkg <- as.package(pkg)
  news_path <- path(pkg$path, "NEWS")

  if (!file_exists(news_path)) {
    cli::cli_abort("No NEWS found")
  }

  check_dots_used(action = getOption("devtools.ellipsis_action", rlang::warn))

  out <- utils::news(..., db = ("tools" %:::% ".news_reader_default")(news_path))
  if (latest) {
    ver <- numeric_version(out$Version)
    recent <- ver == max(ver)
    structure(out[recent, ],
      class = class(out),
      bad = attr(out, "bad")[recent]
    )
  } else {
    out
  }
}

Try the devtools package in your browser

Any scripts or data that you put into this service are public.

devtools documentation built on Oct. 12, 2022, 1:06 a.m.