Create an orderly plugin. A plugin is typically defined by a
package and is used to extend orderly by enabling new
functionality, declared in orderly_config.yml
and your orderly file,
and affecting the running of reports primarily by creating new
objects in the report environment. This system is discussed in
more detail in vignette("plugins")
, but will be expanded (likely
in breaking ways) soon.
Usage
orderly_plugin_register(
name,
config,
serialise = NULL,
deserialise = NULL,
cleanup = NULL,
schema = NULL
)
Arguments
- name
The name of the plugin, typically the package name
- config
A function to read, check and process the configuration section in
orderly_config.yml
. This function will be passed the deserialised data from the plugin's section oforderly_config.yml
, and the full path to that file. As the order of loading of plugins is not defined, each plugin must standalone and should not try and interact with other plugins at load. It should return a processed copy of the configuration data, to be passed in as the second argument toread
.- serialise
A function to serialise any metadata added by the plugin's functions to the outpack metadata. It will be passed a list of all entries pushed in via
orderly_plugin_add_metadata()
; this is a named list with names corresponding to thefield
argument toorderly_plugin_add_metadata
and each list element being an unnamed list with values corresponding todata
. IfNULL
, then no serialisation is done, and no metadata from your plugin will be added.- deserialise
A function to deserialise any metadata serialised by the
serialise
function. This is intended to help deal with issues disambiguating unserialising objects from json (scalars vs arrays of lenth 1, data.frames vs lists-of-lists etc), and will make your plugin nicer to work withorderly_metadata_extract()
. This function will be given a single argumentdata
which is the data fromjsonlite::fromJSON(..., simplifyVector = FALSE)
and you should apply any required simplifications yourself, returning a modified copy of the argument.- cleanup
Optionally, a function to clean up any state that your plugin uses. You can call
orderly_plugin_context
from within this function and access anything you need from that. If not given, then no cleanup is done.- schema
Optionally a path, within the package, to a schema for the metadata created by this plugin; you should omit the
.json
extension. So if your file contains in its sources the fileinst/plugin/myschema.json
you would passplugin/myschema
. Seevignette("plugins")
for details.