Skip to content

Commit

Permalink
Merge pull request #284 from krlmlr/no-wrap-authors-r
Browse files Browse the repository at this point in the history
don't wrap Authors@R field in the DESCRIPTION file
  • Loading branch information
hadley committed Sep 29, 2014
2 parents 009ae8b + 6557e6a commit dd2af6d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Expand Up @@ -4,6 +4,8 @@
ordering between `devtools::document()` and `devtools::check()` this
was the cause of that.

* Don't wrap `Authors@R` field in `DESCRIPTION` (@krlmlr, 284).

# roxygen2 4.0.2

* If you don't use `@exports` or other namespace directives, your namespace
Expand Down
11 changes: 9 additions & 2 deletions R/description.R
Expand Up @@ -16,15 +16,22 @@ write.description <- function(desc, file = "") {
# Print the field-value pair to a given file or standard out.
cat.description <- function(field, value, file='') {
comma_sep <- any(field %in% c("Suggests", "Depends", "Extends", "Imports"))
individual_lines <- field %in% c("Collate")

if (comma_sep) {
value <- strsplit(value, ",\\s+")[[1]]
value <- gsub("^\\s+|\\s+$", "", value)
value_string <- paste(" ", value, collapse = ",\n", sep = "")
out <- paste(field, ":\n", value_string, sep = "")
} else {
width <- if (individual_lines) 0 else 80
width <- 80
if (field %in% c("Collate")) {
# Individual lines
width <- 0
} else if (field %in% c("Authors@R")) {
# No wrapping
width <- Inf
}

out <- wrap_field_if_necessary(field, value, wrap.threshold = width)
}

Expand Down
10 changes: 8 additions & 2 deletions tests/testthat/test-wrapFieldIfNecessary.R
Expand Up @@ -55,5 +55,11 @@ test_that("DESCRIPTION fields DO NOT get wrapped if no line exceeds the wrapping
}
)



test_that("Infinity threshold turns off wrapping", {
poem <- paste(sample(letters, 1000, TRUE), collapse = "")
expect_equal(
wrap_field_if_necessary("LongPoem", poem, wrap.threshold = Inf),
paste("LongPoem:", poem)
)
}
)

0 comments on commit dd2af6d

Please sign in to comment.