Moving document generation to a member function of the given class