pretext is a library designed for generating formatted source code.
pretext templates are first-class values independent of their indentation. Templates are built by applying pretext's combinators to strings, ShowS values, and other templates. The indentation of any part of a template is determined only once the template is converted to a string.
Downloads are available on the Files page.
This project is distributed under the GNU General Public License version 3.
There is no documentation for the Python code but there is complete Haddock documentation for the Haskell source. Both versions of the code have extensive test suites that can be used as examples.
There are several short term goals for this project after version 0.3:
- Add a template engine (like ASP, JSP, stringtemplate, T4, etc.).
- Make pretext generate an implementation of itself in several tolerable languages.
- Implement features from unpublished experimental versions of pretext:
- Haskell varargs which allow the programmer to freely mix Pretext, PretextArg, ShowS, and String parameters.
- Multiple formatting contexts. These are useful for generating languages like C mixed with C preprocessor directives. The C code is indented under one context while the preprocessor directives are indented independently under a second context.
2011.02 UPDATE: based on new information, I expect to make significant changes to the design (again)... (eventually)