From 7b662216521e3945aa3dbb2f99e64fe88f51f02e Mon Sep 17 00:00:00 2001 From: hadley Date: Fri, 22 Jan 2016 09:16:09 -0600 Subject: [PATCH] Add check for build-ignored NEWS.md. Fixes #1042 --- NEWS.md | 10 ++++++++-- R/check-devtools.r | 41 +++++++++++++++++++++++++++++++++++++---- man/release_checks.Rd | 3 +-- 3 files changed, 46 insertions(+), 8 deletions(-) diff --git a/NEWS.md b/NEWS.md index af01907a9..bb3d2f6b8 100644 --- a/NEWS.md +++ b/NEWS.md @@ -53,8 +53,6 @@ * `check_dev_versions()` checks only package dependencies (#983). -* `check_vignette_titles()` added to flag vignettes entitled "Vignette Title" (#960, @jennybc). - * `check_man()` replaces `check_doc()` (since most other functions are named after the corresponding directory). `check_doc()` will hang around as an alias for the forseeable future (#958). @@ -71,6 +69,14 @@ reloading packages which define S3 methods on generics from base or other packages (#1001, @jimhester). +* `release_checks()` gains two new checks: + + * `check_vignette_titles()` checks that your vignette titles aren't the + default "Vignette Title" (#960, @jennybc). + + * `check_news_md()` checks that `NEWS.md` isn't in your `.Rbuildignore` + (since it's now supported by CRAN, #1042). + * `revdep_check()`: * More verbose about which package is installed (#926, @krlmlr) diff --git a/R/check-devtools.r b/R/check-devtools.r index 72f6e7846..c77029687 100644 --- a/R/check-devtools.r +++ b/R/check-devtools.r @@ -4,8 +4,7 @@ #' automatically by \code{\link{release}()}. #' #' @param pkg package description, can be path or package name. See -#' \code{\link{as.package}} for more information. If the \code{DESCRIPTION} -#' file does not exist, it is created using \code{\link{create_description}}. +#' \code{\link{as.package}} for more information. #' @keywords internal #' @export release_checks <- function(pkg = ".", built_path = NULL) { @@ -15,6 +14,7 @@ release_checks <- function(pkg = ".", built_path = NULL) { check_version(pkg) check_dev_versions(pkg) check_vignette_titles(pkg) + check_news_md(pkg) } check_dev_versions <- function(pkg = ".") { @@ -71,8 +71,7 @@ check_vignette_titles <- function(pkg = ".") { vigns <- tools::pkgVignettes(dir = pkg$path) if (length(vigns$docs) == 0) return() - message("Checking vignette titles... ", - appendLF = FALSE) + message("Checking vignette titles... ", appendLF = FALSE) has_Vignette_Title <- function(v, n) { h <- readLines(v, n = n) any(grepl("Vignette Title", h)) @@ -95,3 +94,37 @@ check_vignette_titles <- function(pkg = ".") { return(invisible(FALSE)) } + +check_news_md <- function(pkg) { + pkg <- as.package(pkg) + + news_path <- file.path(pkg$path, "NEWS.md") + if (!file.exists(news_path)) + return() + + message("Checking that NEWS.md is not ignored... ", appendLF = FALSE) + + ignore_path <- file.path(pkg$path, ".Rbuildignore") + if (!file.exists(ignore_path)) { + ignore_lines <- character() + } else { + ignore_lines <- readLines(ignore_path) + } + + has_news <- grepl("NEWS\\.md", ignore_lines, fixed = TRUE) | + grepl("NEWS.md", ignore_lines, fixed = TRUE) + + if (!any(has_news)) { + message("OK") + return(invisible(TRUE)) + } + + message( + "WARNING", + "\n NEWS.md is in .Rbuildignore. It is now supported by CRAN ", + "\n so can be included in the package." + ) + + return(invisible(FALSE)) + +} diff --git a/man/release_checks.Rd b/man/release_checks.Rd index 456ba1796..b0ebc5bf8 100644 --- a/man/release_checks.Rd +++ b/man/release_checks.Rd @@ -8,8 +8,7 @@ release_checks(pkg = ".", built_path = NULL) } \arguments{ \item{pkg}{package description, can be path or package name. See -\code{\link{as.package}} for more information. If the \code{DESCRIPTION} -file does not exist, it is created using \code{\link{create_description}}.} +\code{\link{as.package}} for more information.} } \description{ This function performs additional checks prior to release. It is called