Skip to content

Instantly share code, notes, and snippets.

@jrochkind
Created October 21, 2011 22:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jrochkind/1305162 to your computer and use it in GitHub Desktop.
Save jrochkind/1305162 to your computer and use it in GitHub Desktop.
add links to github from rubydoc.info docs in the 'github' area.
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