Make :ROLE:`TYPE` handling more general