parsing_justifications: Parsing justifications

parse_justificationsR Documentation

Parsing justifications

Description

This function is normally called by load_justifications(); however, sometimes it may be desirable to parse justifications embedded in more complex objects, for example as provided by yum::load_and_simplify(). Therefore, this function can also be called directly.

Usage

parse_justifications(
  x,
  justifierFields = "^date$|^framework$",
  fromFile = NULL,
  path = NULL,
  storeDecisionGraphSvg = FALSE,
  silent = TRUE
)

## S3 method for class 'justifierDecisionGraph'
print(x, ...)

## S3 method for class 'justifierDecisionGraph'
plot(x, ...)

Arguments

x

An object resulting from a call to yum::load_and_simplify().

justifierFields

Which fields to copy from justifier metadata to the elements within the specified scope.

fromFile

The file from which the justifier specifications were read.

path

The path holding these justifier specifications (not necessary if fromFile is provided).

storeDecisionGraphSvg

Whether to also produce (and return) the SVG for the decision graph.

silent

Whether to be chatty or quiet.

...

Additional arguments are passed on to graphics::plot() for the print method or to DiagrammeR::render_graph() for the plot method.

Details

While there is some flexibility in how justifications can be specified, they are most easily processed further if they all follow the same conventions. This function ensures this. The convention is as follows:

  • all specifications are provided in four 'flat' lists, named after the types of elements they contain;

  • all elements have a unique identifier

  • all references to other elements are indeed only references to the other elements' id's in these 'flat lists'

Value

The parsed justifier object.

Examples

### Specify an example text
exampleFile <-
  system.file("extdata",
              "simple-example.jmd",
              package="justifier");

### Show contents
cat(readLines(exampleFile), sep="\n");

### Load it with yum::load_and_simplify()
loadedMinutes <- yum::load_and_simplify(exampleFile);

### Show contents
names(loadedMinutes);

### Parse 'manually'
parsedJustifications <- justifier::parse_justifications(loadedMinutes);

### Show contents
names(parsedJustifications);


justifier documentation built on March 7, 2023, 6:59 p.m.