Learn R Programming

Rd (version 0.2.0)

testing-Rd: Testing Rd types

These provide methods for testing if an object is valid.

Description

Testing Rd types

These provide methods for testing if an object is valid.

Usage

is_Rd_string(x, tags = NULL, strict = FALSE, reason = TRUE)

are_Rd_strings(x, tags = NULL, strict = FALSE)

is_Rd_tag(x, tags = NULL, strict = FALSE, reason = TRUE)

are_Rd_tags(x, tags = NULL, strict = FALSE)

is_Rd(x, strict = FALSE)

is_valid_Rd_list(x, tags = NULL, strict = FALSE, deep = !isTRUE(strict) || !missing(tags))

is_valid_Rd_object(x, tags = NULL, strict = FALSE, deep = !isTRUE(strict) || !missing(tags))

Arguments

x

object to test

tags

the type of tag(s) allowed in the Rd_tag attribute.

strict

if the class must be set. A value of NA indicates that the first level need not be classed but all subsequent must be.

reason

should the reason for failure be included. Used in assertthat::assert_that() and related functions.

deep

should contained elements also be checked for validity?

Functions

  • is_Rd_string: test if object is a valid Rd string type.

  • are_Rd_strings: Vector version of is_Rd_string.

  • is_Rd_tag: Check if a list is a valid Rd_tag object.

  • are_Rd_tags: Vector version of is_Rd_tag

  • is_Rd: check if a list is an Rd container object.

  • is_valid_Rd_list: Check that an object is a valid Rd list, an Rd_tag or Rd, but not an Rd_string

  • is_valid_Rd_object: Check that an object is valid

Examples

Run this code
# NOT RUN {
is_Rd_string('nope')
is_Rd_string(structure('Valid but not strict', Rd_tag='TEXT'))
is_Rd_string(structure('Valid but not strict', Rd_tag='TEXT'), strict=TRUE)
is_Rd_string(Rd_text('Valid and strict'), strict=TRUE)
are_Rd_strings(Rd( Rd_alias('example'), '\n'
                 , Rd_name('example'), '\n'
                 ))
is_Rd_tag(Rd('text'))
is_Rd_tag(Rd_alias('alias'))
are_Rd_tags(Rd( Rd_alias('example'), '\n'
              , Rd_name('example'), '\n'
              ))
is_Rd(list())
is_Rd(list(), strict=TRUE)
is_Rd(Rd(), strict=TRUE)
is_valid_Rd_list(Rd_name('name'))
is_valid_Rd_list(Rd('text'))
is_valid_Rd_list(Rd_text('text'))
is_valid_Rd_object(Rd_name('name'))
is_valid_Rd_object(Rd('text'))
is_valid_Rd_object(Rd_text('text'))
# }

Run the code above in your browser using DataLab