tools: Move gendoc.py to tools, and make it a little more generic.