check_blocks() checks the object blocks of a blocks file on 2 rules.
It reports each rule as PASS, FAIL or SKIP, and it does not print or stop.
Usage
check_blocks(
blocks,
block_class = "writeit_block",
require_block = TRUE,
messages = writeit_messages()
)Arguments
- blocks
The object
blocksof a blocks file.- block_class
The class of a block that
block()declares. A package with its own block function passes its own class.- require_block
TRUEwhen each block MUST be of the classblock_class. WithFALSE, a block MAY be a plain function of the results object.- messages
The texts that name a function in a detail, a named list as
writeit_messages()gives. The details use its elementblock.
Value
A data.frame with 2 rows, one for each rule, and the columns
rule, status and detail. status is "PASS", "FAIL" or
"SKIP".
Details
The 2 rules, in the order of the rows:
blocks_list:blocksis a list with 1 or more elements. Each element has a name that is notNAand not empty, and no name is there twice. Each element is a function or an object of the classblock_class.NULLgives FAIL. The detail names each fault.block_class: withrequire_block = TRUE, each element is of the classblock_class, and the detail names each element that is not. Withrequire_block = FALSE, the rule gives PASS and says that plain functions are allowed. Withrequire_block = TRUE, it gives SKIP whenblocksis not a list with 1 or more elements.
A detail names an element by its name, or as element <i> when its name
is NA or empty.
See also
Other blocks:
block(),
house_formatters(),
make_blocks(),
read_blocks(),
txt(),
write_blocks()
Examples
blocks <- list(
estimates = block(function(results) return(results$estimates), "ci"),
counts = function(results) return(results$counts)
)
check_blocks(blocks)
#> rule status
#> 1 blocks_list PASS
#> 2 block_class FAIL
#> detail
#> 1 blocks is a list of 2 blocks, each with a name of its own
#> 2 these elements of blocks are not of the class writeit_block: counts. Declare each block with writeit::block()
check_blocks(blocks, require_block = FALSE)
#> rule status
#> 1 blocks_list PASS
#> 2 block_class PASS
#> detail
#> 1 blocks is a list of 2 blocks, each with a name of its own
#> 2 require_block is FALSE, so plain functions are allowed as blocks