RF: refactor API generation for generality

Make the apidoc and template generation a little more generic for
sharing between projects.
NF: .gitignore generated reference directory
Merge pull request #367 from matthew-brett/apigen-patches

MRG: refactor API generation for sharing