'Return a GitHub URL for a given filename.
`docroot`
Location of documentation in repository
`filename`
Name of file
`source_suffix`
File suffix of documentation format
`action`
`view` (default) or `edit`'

def get_github_url(self, docroot, filename, source_suffix='.rst', action='view'):

    repo_url = self.project.repo
    if ('github' not in repo_url):
        return ''
    if (not docroot):
        return ''
    else:
        if (docroot[0] != '/'):
            docroot = ('/%s' % docroot)
        if (docroot[(-1)] != '/'):
            docroot = ('%s/' % docroot)
    if (action == 'view'):
        action_string = 'blob'
    elif (action == 'edit'):
        action_string = 'edit'
    for regex in GITHUB_REGEXS:
        match = regex.search(repo_url)
        if match:
            (user, repo) = match.groups()
            break
    else:
        return ''
    repo = repo.rstrip('/')
    return GITHUB_URL.format(user=user, repo=repo, version=self.commit_name, docroot=docroot, path=filename, source_suffix=source_suffix, action=action_string)
