def add_github_roles(app, repo):
from docutils.nodes import reference<EOL>from docutils.parsers.rst.roles import set_classes<EOL>base_url = '<STR_LIT>'.format(repo)<EOL>def github_role(name, rawtext, text, lineno, inliner,<EOL>options=None, content=None):<EOL><INDENT>if '<STR_LIT:#>' in text:<EOL><INDENT>t, n = text.split('<STR_LIT:#>', <NUM_LIT:1>)<EOL>if t.lower() in ['<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>url = base_url + '<STR_LIT>'.format(n)<EOL><DEDENT>elif t.lower() in ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>url = base_url + '<STR_LIT>'.format(n)<EOL><DEDENT>elif t.lower() in ['<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>url = base_url + '<STR_LIT>'.format(n)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>url = base_url + '<STR_LIT:/>' + text<EOL><DEDENT>options = options or {'<STR_LIT>': ['<STR_LIT>']}<EOL>set_classes(options)<EOL>node = reference(rawtext, text, refuri=url, **options)<EOL>return [node], []<EOL><DEDENT>app.add_role('<STR_LIT>', github_role)<EOL>
Add ``gh`` role to your sphinx documents. It can generate GitHub
    links easily::

        :gh:`issue#57` will generate the issue link
        :gh:`PR#85` will generate the pull request link

    Use this function in ``conf.py`` to enable this feature::

        def setup(app):
            sphinx_typlog_theme.add_github_roles(app, 'lepture/authlib')

    :param app: sphinx app
    :param repo: GitHub repo, e.g. "lepture/authlib"