Skip to content

Commit

Permalink
Set width argument of wrapString() call to 75 for usage section
Browse files Browse the repository at this point in the history
At present, it's set to 80. Given that a further 5 space indent is
added to the Usage section in the process of compiling rendered help
files from Rd files, this means that the section can have width up to
85. This causes unattractive/distracting wrap around of some lines in
textual help output (i.e. that got by doing `help(.,
help_type="text")`) in devices whose default viewing window is 80
characters wide.

Not sure that my proposed solution is optimal, but it involves few
enough lines of code that it should be easy to review.
  • Loading branch information
JoshOBrien committed Jun 29, 2018
1 parent de9e1c9 commit 385c490
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion R/rd.R
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ topic_add_keyword <- function(topic, block) {
# Prefer explicit \code{@@usage} to a \code{@@formals} list.
topic_add_usage <- function(topic, block) {
if (is.null(block$usage)) {
usage <- wrap_string(object_usage(attr(block, "object")))
usage <- wrap_string(object_usage(attr(block, "object")), width = 75L)
} else if (block$usage == "NULL") {
usage <- NULL
} else {
Expand Down
6 changes: 3 additions & 3 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,10 @@ read.description <- function(file) {
}


wrap_string <- function(x) UseMethod("wrap_string")
wrap_string <- function(x, ...) UseMethod("wrap_string")
wrap_string.NULL <- function(x) return(x)
wrap_string.default <- function(x) {
y <- wrapString(x)
wrap_string.default <- function(x, width = 80L) {
y <- wrapString(x, width = as.integer(width))
y <- gsub("\u{A0}", " ", y, useBytes = TRUE)
Encoding(y) <- "UTF-8"
class(y) <- class(x)
Expand Down

0 comments on commit 385c490

Please sign in to comment.