Skip to content

Commit

Permalink
Add check for build-ignored NEWS.md.
Browse files Browse the repository at this point in the history
Fixes #1042
  • Loading branch information
hadley committed Jan 22, 2016
1 parent a5615c0 commit 7b66221
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 8 deletions.
10 changes: 8 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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)
Expand Down
41 changes: 37 additions & 4 deletions R/check-devtools.r
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 = ".") {
Expand Down Expand Up @@ -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))
Expand All @@ -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))

}
3 changes: 1 addition & 2 deletions man/release_checks.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7b66221

Please sign in to comment.