def create_api_role(name, problematic):
    def resolve_api_name(n, rawtext, text, lineno, inliner,
                options={}, content=[]):
        if docutils is None:
            raise AssertionError('requires docutils')

        # Check if there's separate text & targets
        m = _TARGET_RE.match(text)
        if m: text, target = m.groups()
        else: target = text

        # node in monotype font
        text = utils.unescape(text)
        node = nodes.literal(rawtext, text, **options)

        # Get the resolver from the register and create an url from it.
        try:
            url = api_register[name].get_url(target)
        except IndexError, exc:
            msg = inliner.reporter.warning(str(exc), line=lineno)
            if problematic:
                prb = inliner.problematic(rawtext, text, msg)
                return [prb], [msg]
            else:
                return [node], []

        if url is not None:
            node = nodes.reference(rawtext, '', node, refuri=url, **options)
        return [node], []

    roles.register_local_role(name, resolve_api_name)


#{ Command line parsing
#  --------------------
Create and register a new role to create links for an API documentation.
dataset/ETHPy150Open CollabQ/CollabQ/vendor/epydoc/docwriter/xlink.py/create_api_role