Skip to content

Commit

Permalink
Use desc package to avoid mangling DESCRIPTION
Browse files Browse the repository at this point in the history
Fixes #430
  • Loading branch information
hadley committed Aug 29, 2016
1 parent ab7b218 commit 39a824c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
11 changes: 6 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,26 @@ Authors@R: c(
person("Manuel", "Eugster", role = c("aut", "cph")),
person("RStudio", role = "cph")
)
Depends:
Depends:
R (>= 3.0.2)
Imports:
Imports:
stringr (>= 0.5),
stringi,
brew,
digest,
methods,
Rcpp (>= 0.11.0),
R6
Suggests:
R6,
desc
Suggests:
testthat (>= 0.8.0),
knitr,
devtools,
rmarkdown,
covr
VignetteBuilder: knitr
LinkingTo: Rcpp
Collate:
Collate:
'RcppExports.R'
'RdTopic.R'
'alias.R'
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# roxygen2 5.0.1.9000

* Changes to DESCRIPTION (i.e. `Collate:` and `RoxygenNote`) now use
the desc package. This will minimise spurious changes (#430).

* `@family` see also are added in the same order they appear, not
alphabetically (#315).

Expand Down
13 changes: 6 additions & 7 deletions R/roclet-collate.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,18 @@ register_tags(
#' }
#' @export
update_collate <- function(base_path) {
collate <- generate_collate(file.path(base_path, "R"))
if (is.null(collate)) return()
new <- generate_collate(file.path(base_path, "R"))
if (is.null(new)) return()

desc_path <- file.path(base_path, "DESCRIPTION")
old <- read.description(desc_path)

new <- old
new$Collate <- paste0("'", collate, "'", collapse = "\n")
old <- desc::desc_get_collate(file = desc_path)

if (!identical(old, new)) {
cat('Updating collate directive in ', desc_path, "\n")
write.description(new, desc_path)
desc::desc_set_collate(new, file = desc_path)
}

invisible()
}

generate_collate <- function(base_path) {
Expand Down
7 changes: 3 additions & 4 deletions R/safety.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,12 @@ made_by <- function(comment) {

update_roxygen_version <- function(base_path) {
desc_path <- file.path(base_path, "DESCRIPTION")
old <- read.description(desc_path)

new <- old
new$RoxygenNote <- as.character(utils::packageVersion("roxygen2"))
new <- as.character(utils::packageVersion("roxygen2"))
old <- desc::desc_get("RoxygenNote", file = desc_path)[[1]]

if (!identical(old, new)) {
cat('Updating roxygen version in ', desc_path, "\n")
write.description(new, desc_path)
desc::desc_set(RoxygenNote = new, file = desc_path)
}
}

0 comments on commit 39a824c

Please sign in to comment.