-
Notifications
You must be signed in to change notification settings - Fork 235
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
Use the C++ roxygen parser #295
Comments
What needs to be done here? |
The C++ parser introduced two main entry points, E.g. lines <- "#' @param foo A parameter.\n#' @param bar Another parameter.\n"
roxygen2:::parse.preref(lines)
roxygen2:::preparse_block(lines) Comparing output,
I think early on you indicated that you wanted the |
It seems to be a bit too accepting currently: preparse_block("\n # This file was generated by Rcpp::compileAttributes\n # Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393\n")
#> $introduction
#> [1] "# This file was generated by Rcpp::compileAttributes\n# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393\n"
#> attr(,"file")
#> [1] ""
#> attr(,"row")
#> [1] 1
#>
#> attr(,"delimiter")
#> [1] "\n " This should return NULL because there's no roxygen there |
Revised parse.file will need to look something like this: parse_file <- function(file, env) {
parsed <- parse(file = file, keep.source = TRUE)
if (length(parsed) == 0) return()
refs <- getSrcref(parsed)
comment_refs <- comments(refs)
extract <- function(call, ref, comment_ref) {
comment_ref2 <- list(filename = file, lloc = as.vector(comment_ref))
block <- preparse_block(paste(as.character(comment_ref), collapse = ""))
if (is.null(block)) return()
preref <- parse_elements(block)
preref$object <- object_from_call(call, env, preref)
preref$srcref <- list(filename = file, lloc = as.vector(ref))
add_defaults(preref)
}
Map(extract, parsed, refs, comment_refs)
} Would be nice if |
Wire it up where appropriate.
The text was updated successfully, but these errors were encountered: