minor refactoring of langdoc.py