diff --git a/DESCRIPTION b/DESCRIPTION index 4903a4e2b..365eaab96 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -11,17 +11,18 @@ 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, @@ -29,7 +30,7 @@ Suggests: covr VignetteBuilder: knitr LinkingTo: Rcpp -Collate: +Collate: 'RcppExports.R' 'RdTopic.R' 'alias.R' diff --git a/NEWS.md b/NEWS.md index 70ff4c254..4ba51d3e6 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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). diff --git a/R/roclet-collate.R b/R/roclet-collate.R index 3f0f665ba..55e9dec6f 100644 --- a/R/roclet-collate.R +++ b/R/roclet-collate.R @@ -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) { diff --git a/R/safety.R b/R/safety.R index ec6e69ba6..1390497b2 100644 --- a/R/safety.R +++ b/R/safety.R @@ -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) } }