get_parse_data: Parse Data

Description Usage Arguments Methods (by class) Examples

View source: R/get_parse_data.R

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
get_parse_data(x, ...)

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

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

## S3 method for class ''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)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
    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)

RDocTaskForce/parsetools documentation built on April 10, 2020, 11:58 p.m.