def METHOD_NAME(self, doc_format):
    try:
        return {
            "ROBOT": html_format,
            "TEXT": self._format_text,
            "HTML": lambda doc: doc,
            "REST": self._format_rest,
        }[doc_format]
    except KeyError:
        raise RuntimeError("Invalid documentation format '%s'." % doc_format)