Multiple issues have been filed about this environment variable, hence
give a warning. #932 might make this unnecessary when merged, but
hopefully this warning can be merged quickly.
This is the (partially) documented public API for Homebrew.
The main class you should look at is the {Formula} class (and classes linked from there). That's the class that's used to create Homebrew formulae (i.e. package descriptions). Assume anything else you stumble upon is private.