[Rd] Accessing Package NEWS (NEWS.Rd)

Paul Roebuck paul_roebuck at comcast.net
Sat Feb 19 04:12:24 CET 2011


Okay. So, after having spent quite some time never really tracking down
why my package NEWS files were unacceptable to readNEWS(), I
noticed that there was recent (to me anyway) development that allowed
the NEWS to be done as an Rd file. Sweet! A more standard format...

I converted a NEWS file in one of my unreleased packages to Rd format.
checkNEWS() gave it a thumbs up.

But then it went south. Tried the following after installation:

> checkNEWS("myapp/trunk/MyApp/inst/NEWS.Rd")
[1] TRUE
> news(package="MyApp")

Nothing.

Debugging news() itself left me wondering. The first thing checked
for was 'inst/NEWS.Rd' - once I install the package, that would never
exist though, right? Should tools:::.build_news_db() instead use:

    nfile <- file.path(dir, c("NEWS.Rd", file.path("inst", "NEWS.Rd")))

On the slim chance it should, I modified the path to my
source folder's copy and continued debugging into 
tools:::.build_news_db_from_package_NEWS_Rd().


debug: ind <- grepl(re_v, nms, ignore.case = TRUE)
Browse[2]> 
debug: if (!all(ind)) warning("Cannot extract version info from the following section titles:\n", 
Browse[2]> ind
[1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
Browse[2]> 
debug: NULL
Browse[2]> 
debug: .make_news_db(cbind(ifelse(ind, sub(re_v, "\\1", nms), NA_character_), 
    ifelse(grepl(re_d, nms), sub(re_d, "\\1", nms), NA_character_), 
    db[, 2L], sub("\n*$", "", db[, 3L])), logical(nrow(db)), 
    "news_db_from_Rd")
Browse[2]> 
debugging in: .make_news_db(cbind(ifelse(ind, sub(re_v, "\\1", nms), NA_character_), 
    ifelse(grepl(re_d, nms), sub(re_d, "\\1", nms), NA_character_), 
    db[, 2L], sub("\n*$", "", db[, 3L])), logical(nrow(db)), 
    "news_db_from_Rd")
debug: {
    out <- data.frame(x, row.names = NULL, stringsAsFactors = FALSE)
    colnames(out) <- c("Version", "Date", "Category", "Text")
    if (!is.null(bad)) 
        attr(out, "bad") <- bad
    class(out) <- unique(c(classes, "news_db", "data.frame"))
    out
}
Browse[3]> 
debug: out <- data.frame(x, row.names = NULL, stringsAsFactors = FALSE)
Browse[3]> 
debug: colnames(out) <- c("Version", "Date", "Category", "Text")
Browse[3]> 
debug: if (!is.null(bad)) attr(out, "bad") <- bad
Browse[3]> 
debug: attr(out, "bad") <- bad
Browse[3]> 
debug: class(out) <- unique(c(classes, "news_db", "data.frame"))
Browse[3]> 
debug: out
Browse[3]> 
exiting from: .make_news_db(cbind(ifelse(ind, sub(re_v, "\\1", nms), NA_character_), 
    ifelse(grepl(re_d, nms), sub(re_d, "\\1", nms), NA_character_), 
    db[, 2L], sub("\n*$", "", db[, 3L])), logical(nrow(db)), 
    "news_db_from_Rd")
exiting from: tools:::.build_news_db_from_package_NEWS_Rd(newsfile)
Error: invalid version specification CHANGES IN VERSION 1.0.0CHANGES IN VERSION 1.0.1CHANGES IN VERSION 2.0.0


Well, so it didn't like my version numbers. But is the regexp check correct?

Browse[2]> .standard_regexps()$valid_package_version
[1] "([[:digit:]]+[.-]){1,}[[:digit:]]+"

Would appear as though packages with only major.minor comparisons would
pass. Or did I miss something...


----
P.S. Another thing I didn't see specified was whether this was an acceptable format
in current Rd format:

\section{CHANGES IN VERSION 2.0.0}{

Trying to get original TEXT files to be read by readNEWS(), the sections had to
read "CHANGES IN R VERSION nnn". Using Rd format, checkNEWS() seemed
to allow optionally using a package name instead (of 'R'). As it also allowed using
nothing, i went with that. What's the intended canonical format?



More information about the R-devel mailing list