Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove NEWS functionality #12

Open
wants to merge 6 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
CHANGES IN VERSION 1.68.0
-------------------------

NEW FEATURES

o getPackageNEWS and printNEWS are deprecated from biocViews.
See help('biocViews-deprecated') for more details.

CHANGES IN VERSION 1.67.0
-------------------------

Expand Down
109 changes: 17 additions & 92 deletions R/getPackageNEWS.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,20 @@
## collate package NEWS files using starting version number in
## prevRepos, and membership in currRepos as references. Package
## source tree rooted at srcDir, possibiblly as tarred files

utils::globalVariables("Version")
# repo: bioc data/experiment workflows
getPackageNEWS <- function(prevRepos="3.6",
currRepos="3.7",
repo=c("bioc", "data/experiment", "workflows"),
srcdir=NULL){

.Deprecated(
"getPackagesNEWS", "ReleaseLaunch",
c(
"'getPackageNEWS' is deprecated.\n",
"Use 'ReleaseLaunch::getPackagesNEWS' instead.\n",
"See help(\"biocViews-deprecated\")"
)
)
repo <- match.arg(repo)
URL_BASE <- "http://master.bioconductor.org/packages/"
VIEWS <- "%s%s/%s/VIEWS"
Expand Down Expand Up @@ -73,99 +80,17 @@ getPackageNEWS <- function(prevRepos="3.6",

}


## based on tools:::.build_news_db()
getNEWSFromFile <- function (dir, destfile, format = NULL, reader = NULL,
output=c("md", "text"))
{
mdIfy <- function(txt)
{
lines <- strsplit(txt, "\n")
segs <- lines[[1]]
segs <- sub("^ o +", "- ", segs)
segs <- sub("^\t", " ", segs)
return(paste(segs, collapse="\n"))
}

newsRdFile <- file.path(dir, "NEWS.Rd") ## should never be found
newsRdFile2 <- file.path(dir, "inst", "NEWS.Rd")

if (!file_test("-f", newsRdFile) && !file_test("-f", newsRdFile2)) {


newsMdFile <- file.path(dir, "NEWS.md")
newsMdFile2 <- file.path(dir, "inst", "NEWS.md")

if (!file_test("-f", newsMdFile) && !file_test("-f", newsMdFile2)) {


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


if (!file_test("-f", nfile) && !file_test("-f", nfile2))
return(invisible())

nfile <- ifelse(file_test("-f", nfile), nfile, nfile2)

if (!is.null(format))
.NotYetUsed("format", FALSE)
if (!is.null(reader))
.NotYetUsed("reader", FALSE)

file <- file(destfile, "w+")
on.exit(close(file))
news <- paste(readLines(nfile), collapse="\n")
if ("md" == output)
news = mdIfy(news)
cat(news, file=file)
return(invisible())
}

newsMdFile <- ifelse(file_test("-f", newsMdFile), newsMdFile,
newsMdFile2)
file <- file(destfile, "w+")
on.exit(close(file))
db <- tools:::.build_news_db_from_package_NEWS_md(newsMdFile)
news <- NULL
try(news <- capture.output(print(db)))
if (is.null(news))
{
message(sprintf("Error building news database for %s/%s",
dir, destfile))
return(invisible())
}
news <- paste(news, collapse="\n")
if ("md" == output)
news <- mdIfy(news)
cat(news, file=file)
return(invisible())
}

newsRdFile <- ifelse(file_test("-f", newsRdFile), newsRdFile, newsRdFile2)

file <- file(destfile, "w+")
on.exit(close(file))
db <- tools:::.build_news_db_from_package_NEWS_Rd(newsRdFile)
news <- NULL
try(news <- capture.output(print(db)))
if (is.null(news))
{
message(sprintf("Error building news database for %s/%s",
dir, destfile))
return(invisible())
}
news <- paste(news, collapse="\n")
if ("md" == output)
news <- mdIfy(news)
cat(news, file=file)
return(invisible())
}


printNEWS <- function(dbs, destfile, overwrite=FALSE, width=68,
output=c("md", "text"), relativeLink=FALSE, ...)
{
.Deprecated(
"printNEWS", "ReleaseLaunch",
c(
"'printNEWS' is deprecated.\n",
"Use 'ReleaseLaunch::printNEWS' instead.\n",
"See help(\"biocViews-deprecated\")"
)
)
output <- match.arg(output)
dbs <- lapply(dbs, function(db) {
db[["Text"]] <- sapply(db[["Text"]], function(elt) {
Expand Down
88 changes: 88 additions & 0 deletions R/repository.R
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,94 @@ extractReadmes <- function(reposRoot, srcContrib, destDir) {
extractTopLevelFiles(reposRoot, srcContrib, destDir, "README")
}

## based on tools:::.build_news_db()
getNEWSFromFile <- function (dir, destfile, format = NULL, reader = NULL,
output=c("md", "text"))
{
mdIfy <- function(txt)
{
lines <- strsplit(txt, "\n")
segs <- lines[[1]]
segs <- sub("^ o +", "- ", segs)
segs <- sub("^\t", " ", segs)
return(paste(segs, collapse="\n"))
}

newsRdFile <- file.path(dir, "NEWS.Rd") ## should never be found
newsRdFile2 <- file.path(dir, "inst", "NEWS.Rd")

if (!file_test("-f", newsRdFile) && !file_test("-f", newsRdFile2)) {


newsMdFile <- file.path(dir, "NEWS.md")
newsMdFile2 <- file.path(dir, "inst", "NEWS.md")

if (!file_test("-f", newsMdFile) && !file_test("-f", newsMdFile2)) {


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


if (!file_test("-f", nfile) && !file_test("-f", nfile2))
return(invisible())

nfile <- ifelse(file_test("-f", nfile), nfile, nfile2)

if (!is.null(format))
.NotYetUsed("format", FALSE)
if (!is.null(reader))
.NotYetUsed("reader", FALSE)

file <- file(destfile, "w+")
on.exit(close(file))
news <- paste(readLines(nfile), collapse="\n")
if ("md" == output)
news = mdIfy(news)
cat(news, file=file)
return(invisible())
}

newsMdFile <- ifelse(file_test("-f", newsMdFile), newsMdFile,
newsMdFile2)
file <- file(destfile, "w+")
on.exit(close(file))
db <- tools:::.build_news_db_from_package_NEWS_md(newsMdFile)
news <- NULL
try(news <- capture.output(print(db)))
if (is.null(news))
{
message(sprintf("Error building news database for %s/%s",
dir, destfile))
return(invisible())
}
news <- paste(news, collapse="\n")
if ("md" == output)
news <- mdIfy(news)
cat(news, file=file)
return(invisible())
}

newsRdFile <- ifelse(file_test("-f", newsRdFile), newsRdFile, newsRdFile2)

file <- file(destfile, "w+")
on.exit(close(file))
db <- tools:::.build_news_db_from_package_NEWS_Rd(newsRdFile)
news <- NULL
try(news <- capture.output(print(db)))
if (is.null(news))
{
message(sprintf("Error building news database for %s/%s",
dir, destfile))
return(invisible())
}
news <- paste(news, collapse="\n")
if ("md" == output)
news <- mdIfy(news)
cat(news, file=file)
return(invisible())
}

extractNEWS <- function(reposRoot, srcContrib, destDir) {

if (missing(destDir))
Expand Down
40 changes: 23 additions & 17 deletions man/getPackageNEWS.Rd → man/biocViews-deprecated.Rd
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
\name{getPackageNEWS}
\name{biocViews-deprecated}

\alias{getPackageNEWS}
\alias{printNEWS}
\title{
Retrieve and print package NEWS
}
\description{
\alias{biocViews-deprecated}

These functions visit two Bioconductor releases, identifying
packages that are present in the \sQuote{current} repository and have
NEWS since the base version of the same package in the
\sQuote{previous} release. All NEWS is reported for packages only
in the current repository.
\title{Deprecated NEWS functions in biocViews}

\description{
Functions working with a package's NEWS file have been moved out of the
package. These include \code{getPackageNEWS}, and \code{printNEWS}.
Please see the \code{ReleaseLaunch} package.
}

\usage{
getPackageNEWS(prevRepos="3.6",
currRepos="3.7",
repo=c("bioc", "data/experiment", "workflows"),
srcdir = NULL)
printNEWS(dbs, destfile, overwrite = FALSE, width = 68,
output=c("md", "text"), relativeLink=FALSE, ...)
getPackageNEWS(
prevRepos="3.6",
currRepos="3.7",
repo=c("bioc", "data/experiment", "workflows"),
srcdir = NULL
)
printNEWS(
dbs, destfile, overwrite = FALSE, width = 68, output=c("md", "text"),
relativeLink=FALSE, ...
)
}

\arguments{
Expand Down Expand Up @@ -53,8 +57,8 @@ printNEWS(dbs, destfile, overwrite = FALSE, width = 68,
'https//bioconductor.org'. default: FALSE is full url.}

\item{...}{additional arguments, unused.}

}

\value{
A list of \code{news_db} files, as returned by \code{utils::news},
for each package for which relevant NEWS is available.
Expand All @@ -63,4 +67,6 @@ printNEWS(dbs, destfile, overwrite = FALSE, width = 68,
Martin Morgan \url{[email protected]} and Lori Shepherd
}

\seealso{\url{https://github.com/Bioconductor/ReleaseLaunch}}

\keyword{manip}% __ONLY ONE__ keyword per line