From Kurt.Hornik at wu.ac.at  Mon Feb 21 15:26:23 2011
From: Kurt.Hornik at wu.ac.at (Kurt Hornik)
Date: Mon, 21 Feb 2011 15:26:23 +0100
Subject: [Rd] Accessing Package NEWS (NEWS.Rd)
In-Reply-To: <0806D6AB-89F2-476A-BBBA-7A82F5A90983@comcast.net>
References: <0806D6AB-89F2-476A-BBBA-7A82F5A90983@comcast.net>
Message-ID: <19810.30223.616666.563347@fangorn.hornik.net>

>>>>> Paul Roebuck writes:

> 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:

All of this works much better for r-devel: in particular, this makes
clear that checkNEWS is for old-style (pre 2.12.0) R NEWS files ...

Best
-k

>> 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?

> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] Accessing Package NEWS (NEWS.Rd)
Kurt Hornik