parsetools (version 0.1.1)

get_parse_data: Parse Data

Description

Parsing data is at the core of parse tools and thus at the core of the documentation package. The get_parse_data function is essentially a customized version of <getParseData> that will return a cleaned up version of the parse data for a variety of objects. This version also fails less often, even reparsing text when needed.

valid_parse_data

The valid_parse_data function tests if the object df conforms to the expected conventions of a parse-data object. Returns TRUE if valid otherwise returns the reason it is not valid.

as_parse_data

The as_parse_data function tests if a data frame is valid through valid_parse_data then returns the data with the comments classified, as is expected for parse-data objects. All parse data for use with parsetools functions should be obtained either through get_parse_data or converted through as_parse_data.

Usage

get_parse_data(x, ...)

# S3 method for srcfile get_parse_data(x, ...)

# S3 method for srcref get_parse_data(x, ..., ignore.groups = TRUE, include.doc.comments = TRUE, include.regular.comments = FALSE)

# S3 method for function get_parse_data(x, ...)

valid_parse_data(df)

as_parse_data(df)

Arguments

x

an object to get parse-data from.

...

options for specific type of objects.

ignore.groups

Should groupings be ignored?

include.doc.comments

include associated documentation comments.

include.regular.comments

include associated regular comments.

df

a data.frame object.

Methods (by class)

  • function: Get parse information from a function. The function must have a srcref.

Examples

Run this code
# NOT RUN {
    text <- "    my_function <- function(object #< An object to do something with
            ){
        #' A title
        #'
        #' A Description
        print(\"It Works!\")
        #< A return value.
    }"
    source(textConnection(text), keep.source = TRUE)

    # Get parse data from a function
    (pd <- get_parse_data(my_function))
    # which must have a srcref attribute.
    # You can call the get_parse data directly on the srcref object.
    src <- utils::getSrcref(my_function)
    pd2 <- get_parse_data(src)

    identical(pd, pd2)

    # Objects must have a srcref.
    utils::getSrcref(rnorm)
    tools::assertError(get_parse_data(rnorm), verbose = TRUE)
# }

Run the code above in your browser using DataLab