The legal styles we’re building on CitationStylist will need to share
a lot of code, since citation forms are jurisdiction-specific. This
looked like becoming a maintenance headache, so I spent the better
part of yesterday building a Python script to populate self-contained
macro sets from a “home” style to others that depend on it. It’s
worked out pretty well, so this afternoon I did some more work to
generalize the script. It’s now available here:
https://bitbucket.org/fbennett/cslmodules
A README in the repo explains how it works, but basically you set up a
config file for each style that has dependencies, indicating the names
of the code bundles it needs and the style that contains each one. The
script will then check for a -bundle-start macro in both the
receiving and the source style, and if both are found, it will grab
all macros ultimately called through the -bundle-start macro and
move them across. To allow small variations in formatting, macros that
don’t change apart from a small list of “cosmetic” attributes are not
overwritten.
The script might be useful for sharing code within a family of styles,
or for self-contained citation types (patent?) that might be shared
more widely.
Hope it’s useful.
Frank