fc78384704
I used the sbt-unidoc plugin (https://github.com/sbt/sbt-unidoc) to create a unified Scaladoc of our public packages, and generate Javadocs as well. One limitation is that I haven't found an easy way to exclude packages in the Javadoc; there is a SBT task that identifies Java sources to run javadoc on, but it's been very difficult to modify it from outside to change what is set in the unidoc package. Some SBT-savvy people should help with this. The Javadoc site also lacks package-level descriptions and things like that, so we may want to look into that. We may decide not to post these right now if it's too limited compared to the Scala one. Example of the built doc site: http://people.csail.mit.edu/matei/spark-unified-docs/ Author: Matei Zaharia <matei@databricks.com> This patch had conflicts when merged, resolved by Committer: Patrick Wendell <pwendell@gmail.com> Closes #457 from mateiz/better-docs and squashes the following commits: a63d4a3 [Matei Zaharia] Skip Java/Scala API docs for Python package 5ea1f43 [Matei Zaharia] Fix links to Java classes in Java guide, fix some JS for scrolling to anchors on page load f05abc0 [Matei Zaharia] Don't include java.lang package names 995e992 [Matei Zaharia] Skip internal packages and class names with $ in JavaDoc a14a93c [Matei Zaharia] typo 76ce64d [Matei Zaharia] Add groups to Javadoc index page, and a first package-info.java ed6f994 [Matei Zaharia] Generate JavaDoc as well, add titles, update doc site to use unified docs acb993d [Matei Zaharia] Add Unidoc plugin for the projects we want Unidoced
99 lines
3.3 KiB
JavaScript
Executable file
99 lines
3.3 KiB
JavaScript
Executable file
function codeTabs() {
|
|
var counter = 0;
|
|
var langImages = {
|
|
"scala": "img/scala-sm.png",
|
|
"python": "img/python-sm.png",
|
|
"java": "img/java-sm.png"
|
|
};
|
|
$("div.codetabs").each(function() {
|
|
$(this).addClass("tab-content");
|
|
|
|
// Insert the tab bar
|
|
var tabBar = $('<ul class="nav nav-tabs" data-tabs="tabs"></ul>');
|
|
$(this).before(tabBar);
|
|
|
|
// Add each code sample to the tab bar:
|
|
var codeSamples = $(this).children("div");
|
|
codeSamples.each(function() {
|
|
$(this).addClass("tab-pane");
|
|
var lang = $(this).data("lang");
|
|
var image = $(this).data("image");
|
|
var notabs = $(this).data("notabs");
|
|
var capitalizedLang = lang.substr(0, 1).toUpperCase() + lang.substr(1);
|
|
var id = "tab_" + lang + "_" + counter;
|
|
$(this).attr("id", id);
|
|
if (image != null && langImages[lang]) {
|
|
var buttonLabel = "<img src='" +langImages[lang] + "' alt='" + capitalizedLang + "' />";
|
|
} else if (notabs == null) {
|
|
var buttonLabel = "<b>" + capitalizedLang + "</b>";
|
|
} else {
|
|
var buttonLabel = ""
|
|
}
|
|
tabBar.append(
|
|
'<li><a class="tab_' + lang + '" href="#' + id + '">' + buttonLabel + '</a></li>'
|
|
);
|
|
});
|
|
|
|
codeSamples.first().addClass("active");
|
|
tabBar.children("li").first().addClass("active");
|
|
counter++;
|
|
});
|
|
$("ul.nav-tabs a").click(function (e) {
|
|
// Toggling a tab should switch all tabs corresponding to the same language
|
|
// while retaining the scroll position
|
|
e.preventDefault();
|
|
var scrollOffset = $(this).offset().top - $(document).scrollTop();
|
|
$("." + $(this).attr('class')).tab('show');
|
|
$(document).scrollTop($(this).offset().top - scrollOffset);
|
|
});
|
|
}
|
|
|
|
function makeCollapsable(elt, accordionClass, accordionBodyId, title) {
|
|
$(elt).addClass("accordion-inner");
|
|
$(elt).wrap('<div class="accordion ' + accordionClass + '"></div>')
|
|
$(elt).wrap('<div class="accordion-group"></div>')
|
|
$(elt).wrap('<div id="' + accordionBodyId + '" class="accordion-body collapse"></div>')
|
|
$(elt).parent().before(
|
|
'<div class="accordion-heading">' +
|
|
'<a class="accordion-toggle" data-toggle="collapse" href="#' + accordionBodyId + '">' +
|
|
title +
|
|
'</a>' +
|
|
'</div>'
|
|
);
|
|
}
|
|
|
|
function viewSolution() {
|
|
var counter = 0
|
|
$("div.solution").each(function() {
|
|
var id = "solution_" + counter
|
|
makeCollapsable(this, "", id,
|
|
'<i class="icon-ok-sign" style="text-decoration: none; color: #0088cc">' +
|
|
'</i>' + "View Solution");
|
|
counter++;
|
|
});
|
|
}
|
|
|
|
// A script to fix internal hash links because we have an overlapping top bar.
|
|
// Based on https://github.com/twitter/bootstrap/issues/193#issuecomment-2281510
|
|
function maybeScrollToHash() {
|
|
console.log("HERE");
|
|
if (window.location.hash && $(window.location.hash).length) {
|
|
console.log("HERE2", $(window.location.hash), $(window.location.hash).offset().top);
|
|
var newTop = $(window.location.hash).offset().top - 57;
|
|
$(window).scrollTop(newTop);
|
|
}
|
|
}
|
|
|
|
$(function() {
|
|
codeTabs();
|
|
viewSolution();
|
|
|
|
$(window).bind('hashchange', function() {
|
|
maybeScrollToHash();
|
|
});
|
|
|
|
// Scroll now too in case we had opened the page on a hash, but wait a bit because some browsers
|
|
// will try to do *their* initial scroll after running the onReady handler.
|
|
$(window).load(function() { setTimeout(function() { maybeScrollToHash(); }, 25); });
|
|
});
|