[DDMD] [refactor] Move Module::gendocfile and related functions into free functions