Refactor doc type generator to pattern match top level