[R-pkg-devel] Format/parser for NEWS (not NEWS.Rd)?

Henrik Bengtsson henrik.bengtsson at ucsf.edu
Wed Oct 14 00:06:59 CEST 2015


On Wed, Oct 7, 2015 at 6:40 PM, boB Rudis <bob at rudis.net> wrote:
> Try looking at the source for tools:::.news_reader_default and then tools::toRd

Thank you for this.  That works - for example

> news <- tools:::.news_reader_default("NEWS")
> str(news)
Classes 'news_db' and 'data.frame':     21 obs. of  4 variables:
 $ Version : chr  "0.8.1" "0.8.1" "0.8.1" "0.8.0" ...
 $ Date    : chr  "2015-10-05" "2015-10-05" "2015-10-05" "2015-09-06" ...
 $ Category: chr  NA NA NA NA ...
 $ Text    : chr  "eager() and multicore() gained argument 'globals', where\nglo
bals=TRUE will validate that all global variables\nidentified can "| __truncated
__ "lazy(sum(x, ...), globals=TRUE) now properly passes `...`\nfrom the function
 from which the future is setup.  If not\ncalled wi"| __truncated__ "Added vigne
tte 'Futures in R: Common issues with solutions'." "plan(\"default\") resets to
the default strategy, which is\nsynchroneous eager evaluation unless option 'fut
ure_plan'\nor envir"| __truncated__ ...
 - attr(*, "bad")= logi  FALSE FALSE FALSE FALSE FALSE FALSE ...
> any(attr(news, "bad"))
[1] FALSE

This would work as way to validate NEWS.


Also, to follow up on my own original post suggesting that
tools:::news2Rd() calls deprecated functions.  From the feedback I got
on the documentation bug report
(https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=16556) and
looking at the code, the following does indeed parse and output to
NEWS.Rd:

> setwd("/path/to/MyPackage/")
> tools:::news2Rd("NEWS", out="NEWS.Rd")

which assuming NEWS is in the root of the package. If it's under
inst/, then tools:::news2Rd("inst/NEWS", out="NEWS.Rd").

However, it is important that the DESCRIPTION file is also found by
tools:::news2Rd().  In other words, tools:::news2Rd() assumes you're
running in a package director.  If you do what I tried previously and
put the NEWS file in a separate "sandbox" directory, then you get:

> tools:::news2Rd("NEWS", out="NEWS.Rd")
Error: 'readNEWS' is defunct.
See help("Defunct")

With the a very recent R-devel, you now get:

> tools:::news2Rd("NEWS", "NEWS.Rd")
Error in tools:::news2Rd("NEWS", "NEWS.Rd") : DESCRIPTION file not found

which is more informative.

Henrik

>
> On Wed, Oct 7, 2015 at 8:37 PM, Henrik Bengtsson
> <henrik.bengtsson at ucsf.edu> wrote:
>> Hi,
>>
>> I'm looking for a parser of the plain text NEWS format (not the
>> NEWS.Rd format) - ideally the same on that is used by R itself.  Does
>> anyone know which that one is / of such at tool?
>>
>> Thanks,
>>
>> Henrik
>>
>> PS. help("news") mentions tools:::news2Rd(), but that's actually
>> defunct (just reported
>> https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=16556).
>>
>> ______________________________________________
>> R-package-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-package-devel



More information about the R-package-devel mailing list