re-work of hdoc.py