Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.