Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

roxygen2 generates documentation that doesn't pass CHECK on R-devel(?) #125

Closed
cboettig opened this issue May 22, 2013 · 2 comments
Closed

roxygen2 generates documentation that doesn't pass CHECK on R-devel(?) #125

cboettig opened this issue May 22, 2013 · 2 comments

Comments

@cboettig
Copy link

@cboettig cboettig commented May 22, 2013

In my function declarations and roxygen2 comments, I have hard-wrapped all lines to less than 80 characters. Roxygen2 appears to be expanding my function definitions to violate this, causing R-devel to complain about my over 90 character length lines.

For instance, I declare my function in my .R file with hard-wrapped arguments,

bib_format <- function(ordering = 
                       c("authors", "year", "title", "journal",
                         "volume", "number", "pages", "doi", "url"),
                       authors, year, title, journal, volume, 
                       number, pages, doi, uri, collapse=" "){

but the .Rd files build by devtools give me things like this:

\usage{
  bib_format(ordering = c("authors", "year", "title", "journal", "volume", "number", "pages", "doi", "url"),
    authors, year, title, journal, volume, number, pages,
    doi, uri, collapse = " ")
}
@hadley
Copy link
Member

@hadley hadley commented Nov 8, 2013

This is a bit tricky to fix because currently we're generating the usage from the function formals, not from the source code. It might be possible to use a srcref to get to the original function, but you'd still need to do some munging since in your example you probably wouldn't want such extreme indenting in the usage statement.

@yihui
Copy link
Contributor

@yihui yihui commented Nov 10, 2013

Currently I use formatR to try to reformat the usage and examples with a series of attempts using width = 90, 89, ..., 40. The dirty hack is at https://github.com/yihui/Rd2roxygen/blob/master/R/build.R

> x = c("  bib_format(ordering = c(\"authors\", \"year\", \"title\", \"journal\", \"volume\", \"number\", \"pages\", \"doi\", \"url\"),", 
"    authors, year, title, journal, volume, number, pages,", 
"    doi, uri, collapse = \" \")")

> formatR::tidy.source(text=x)
bib_format(ordering = c("authors", "year", "title", "journal", "volume", "number", 
    "pages", "doi", "url"), authors, year, title, journal, volume, number, pages, 
    doi, uri, collapse = " ") 

> cat(Rd2roxygen:::tidy.code(x))
bib_format(ordering = c("authors", "year", "title", "journal", "volume", "number", 
    "pages", "doi", "url"), authors, year, title, journal, volume, number, pages, 
    doi, uri, collapse = " ")

When I have got some time, I will see if I can plug formatR into roxygen2 as an optional feature to reformat code in usage and examples. The current implementation in Rd2roxygen is mostly for my personal use.

@hadley hadley closed this in 5be2e3e Nov 12, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants