6.2. Modules and Libraries


6.2.1. Modules

SDF can be extended by using modules. A module is a normal SDF file which typically contains reusable entities like macros, filters and styles. Modules are loaded by the use macro. For example:

   !use "delphi"

By convention, modules are given the sdm extension. The use macro adds this extension if none is provided. Modules can also be loaded by using sdf's -u option.


6.2.2. Libraries

A collection of related modules can be placed into a library which is simply a subdirectory under the sdf/home directory on Perl's library path. Libraries can be loaded by the inherit macro which essentially does the following:

  1. appends the matching directory onto the include path
  2. loads the matching main module.

For example:

   !inherit "images"
  1. appends sdf/home/images onto the include path
  2. loads the sdf/home/images/images.sdm module.

6.2.3. The Configuration Library

After loading the standard library (stdlib), SDF loads the configuration library, if any. This is typically specified via the OPT_CONFIG variable being initialised on the top line of the file via the init macro. It can also be set via sdf's -c option.

While sdf only supports a single configuration library, additonal libraries can be loaded via the inherit macro. Furthermore, a library can inherit things from other libraries, making it easy to create new ones.