def trac_ticket_role(name, rawtext, text, lineno, inliner, 
                     options={}, content=[]):
    app = inliner.document.settings.env.app
    try:
        base = app.config.trac_url
        if not base:
            raise AttributeError
    except AttributeError as err:
        msg = 'trac_url configuration value is not set (%s)'
        raise ValueError(msg % str(err))

    slash = '/' if base[-1] != '/' else ''
    prefix = 'ticket '
    node = nodes.literal(prefix, prefix)
    display = utils.unescape(text)
    uri = base + slash + 'ticket/' + text
    node += nodes.reference(rawtext, display, refuri=uri, **options)
    return [node], []
dataset/ETHPy150Open networkx/networkx/doc/sphinxext/customroles.py/trac_ticket_role/original