yihui / formatR

Format R Code Automatically
https://yihui.org/formatr/
255 stars 52 forks source link

apparent difficulty with inline comments in argument list #15

Closed davharris closed 12 years ago

davharris commented 12 years ago

Hi, this looks like a fantastic piece of software. I'm trying it out on a script that has a few functions with the following general structure:

myfun <- function(
    a, #a comment
    b #another comment
){
    a + b
}

I saved that minimal example to my desktop and ran the following line:

tidy.source("~/Desktop/test.R")

Which results in the following error:

Error in base::parse(text = block.text) : <text>:2:6: unexpected SPECIAL
1: myfun <- function (
2: a ,  %InLiNe_IdEnTiFiEr%
        ^

My best guess is that it doesn't like comments appearing among the function's arguments, but I don't know for sure that this is the issue or if it's something you'd be interested in fixing.

Hope this is useful feedback.

Thanks again,

Dave

yihui commented 12 years ago

Not all inline comments can be retained correctly, and this has been explained in the last section in the wiki: https://github.com/yihui/formatR/wiki

BTW, it seems you want to document function arguments, and roxygen2 may be a better way to go.

davharris commented 12 years ago

Thanks.