Plugins are written in OCaml. The compiled OCaml code is then loaded in Stog with the --plugin or --package options of stog (see ).

A plugin just registers new functions associated to tags. Here is an example:

Have a look at the Stog library reference documentation.

The plugin is simply compiled with ocamlfind ocamlopt -package stog -rectypes -shared -o plugin_example.cmxs plugin_example.ml for native code or ocamlfind ocamlc -package stog -rectypes -c plugin_example.ml for bytecode.

The plugin is used by specifying it one the stog command line:

stog --plugin plugin_example.cmxs ...

or, if the plugin is installed with ocamlfind:

stog --package plugin_example ...

With our plugin example, we can use the new "list":

first thingsecond thing
something else
]]>

This will be evaluated (reduced) to

first thingsecond thing
something else

The cache system (see ) must be aware of dependencies of each element on other elements and files.

If a new rule defined by a plugin uses a file or implies a dependency from an element to another, this rule must declare this dependency using the Stog_plug.add_dep function:

Stog_plug.add_dep : Stog_types.elt -> dependency -> unit

If a plugin computes information which could be cached, it can declare a new cache for this informations, using the Stog_plug.register_cache function:

val register_cache : (module Stog_cache.Cache) -> unit

The Cache module to provide is very simple; have a look at the Stog_cache.Cachemodule type.