yihui / Rd2roxygen

Convert Rd to roxygen documentation
https://yihui.org/Rd2roxygen
32 stars 14 forks source link

Comments in Rd files? #16

Closed sje30 closed 10 years ago

sje30 commented 10 years ago

Hi, thanks for such a great package. I used it to convert some .Rd files. One problem I noted was that comments (starting with %%) in my .Rd file were just copied, as-is, to the roxygen code. This casused a problem as I had a comment in my examples section:

\examples{
stopifnot(isTRUE(all.equal.numeric(
  histbi.ab(c(0), c(-2, -2, 0, 0, 1, 1,1, 1.8,2), tmax=2, nbins=4),
  c(2,0,2,5),
  check.attributes=FALSE)))
stopifnot(identical(TRUE, all.equal.numeric(
  hist.ab(c(0), c(-2, -2, 0, 0, 1, 1,1, 1.8,  2), tmax=2, nbins=4),
  c(2,0,3,4),
  check.attributes=FALSE)))

test.hist.ab()

%% Following examples are not run since they either take a long time
%% or require an "s" structure.
\dontrun{
test.histograms.versus.r()
test.count.hist.nab()
test.count.hist.nab(s)
test.count.hist2.nab(s)
}
}

Then when R CHECK was running, it hit %% and complained. My solution for now is to remove the comment, but just thought I'd let you know.

yihui commented 10 years ago

Thanks for the note! That sounds like a problem of roxygen2, which does not interpret Rd comments correctly. Actually roxygen2 escapes all %'s in the examples, and assumes they should be treated literally. I never write comments in Rd (I guess neither does Hadley), so I did not realize this problem before.

sje30 commented 10 years ago

Thanks for the note! That sounds like a problem of roxygen2, which does not interpret Rd comments correctly. Actually roxygen2 escapes all %'s in the examples, and assumes they should be treated literately. I never write comments in Rd (I guess neither does Hadley), so I did not realize this problem before.

Okay, thanks for checking!