roxygen2 makes it easy to generate documentation for R packages. Code in this repo just transforms function documentation part of Google R style to roxygen2 format.
Input (part of file):
fun <- function(x, y) {
# Add together two numbers
#
# Args:
# x: A number
# y: A number
#
# Returns:
# The sum of x and y
x+y
}
Output:
#' Add together two numbers
#' @export
#'
#' @param x: A number
#' @param y: A number
#'
#' @return The sum of x and y
fun <- function(x, y) {
x+y
}
git clone https://github.com/jukujala/r-google-style-to-roxygen2.git
cd r-google-style-to-roxygen2/
./run_transform_comments.sh -i my_file.r
# prints to stdout
Feel free to report bugs to my email given at github page. Tell also if there is a better way to do the transformation, the current state machine logic feels too complicated.
This is just something I quickly wrote, so do not expect it to work well ;)