klutometis/roxygen — pull request #54 by briandk (2011-11-03 05:18:11+00:00)
Title: Selectively wrap description text

## Background

The current version of `cat.description()` rewrites some fields of a user's `DESCRIPTION`. If a user formatted, say, the "Author" field like this:

```
Author: Alan Turing ,
Alonzo Church ,
Charles Babbage ,
Ada Lovelace ,
Grace Murray Hopper
```

`cat.description()` will forcibly rewrite that as:

```
Author: Alan Turing , Alonzo Church
, Charles Babbage
, Ada Lovelace
, Grace Murray Hopper

```

The user has no choice in the final formatting because `cat.description()` paves over their original text. (See Issue #39 for a fuller description.)

## My Solution

I've introduced three new functions

- `WrapFieldIfNecessary()` handles the highest-level logic for determining whether a field should be wrapped or left as-is. This function *calls*
- `MockFormattedText()` which tries to re-expand text back out to simulate the user's original formatting intent, *and*
- `LeftPadFourSpaces()`, a thin wrapper around `paste()` I wrote primarily for testing purposes

`WrapFieldIfNecessary()` will largely respect a user's original formatting *unless*:

- A line in the field is longer than the pre-specifield `wrap.threshold`, OR
- The field passed in is one of the following:

Suggests:
Depends:
Extends:
Imports:
Collate:

In all, I tried to make my additions as seamless as possible. But, as per [our discussion][2] I've changed the default wrap-width to 80 characters.

## Testing

I've written tests for all three functions I'm submitting, and I also created a fake `DESCRIPTION` file for testing purposes. Please provide feedback if my tests are flawed, insufficient, or incomplete.

## Formatting and Style

I've tried to adhere to [Google's R Style Guide][1] as much as possible. Please let me know if you have any style/formatting concerns.

[1]: http://google-styleguide.googlecode.com/svn/trunk/google-r-style.html
[2]: https://github.com/klutometis/roxygen/issues/39#issuecomment-2512639