How are you inserting/removing roxygen2 comments?

I insert/remove roxygen2 comments with the {roxygen2Comment} addin-package (https://github.com/csgillespie/roxygen2Comment). Because I use this a lot, I'm surprised that {roxygen2Comment} is not on CRAN.

Are you doing this differently?

FWIW Emacs ESS inserts the comments automatically if you press ENTER on a line that itself starts with roxygen comments.

If I am starting from scratch, I manually enter #' on the first line, and then RStudio automatically prepends #' to each subsequent line as I type the documentation. If I have an existing comment block that I want to convert to roxygen2 format, I find-replace # with #'. If the text isn't commented out yet, I first highlight it and commment it out with Ctrl-Shift-C. Either of the previous actions could also be accomplished using a multi-line cursor.

Lastly, the RStudio option code->Insert Roxygen Skeleton adds a roxygen template with the function arguments pre-populated.

1 Like