Created
October 21, 2011 22:32
-
-
Save jrochkind/1305162 to your computer and use it in GitHub Desktop.
add links to github from rubydoc.info docs in the 'github' area.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (match = window.location.pathname.match(/^\/github\/([^\/]+\/[^/]+)\/([^/]+)/)) { | |
var github_project = match[1]; | |
var github_commit = match[2]; | |
$(".source_code").each( function() { | |
if (match = $(this).find(".info.file").text().match(/^# File '([^']+)', line (\d+)/)) { | |
var file = match[1]; | |
var line = match[2]; | |
var url = "https://github.com/" + github_project + | |
"/blob/" + github_commit + "/" + | |
file + | |
"#L" + line; | |
$(this).before(' <a href="' + url + '">[View on Github]</a>'); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment