Skip to content

Commit

Permalink
Generalize jQuery matching for non Spark-core API docs
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewor14 committed Apr 9, 2014
1 parent c1bcb41 commit 982a473
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
4 changes: 4 additions & 0 deletions docs/css/api-docs.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
background-color: #257080;
}

.alphaComponent {
background-color: #bb0000;
}

.badge {
font-family: Arial, san-serif;
float: right;
Expand Down
15 changes: 7 additions & 8 deletions docs/js/api-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@

$(document).ready(function() {
var annotations = $("dt:contains('Annotations')").next("dd").children("span.name");
addBadges(annotations, "AlphaComponent", ":: AlphaComponent ::", "<span class='experimental badge'>ALPHA COMPONENT</span>");
addBadges(annotations, "AlphaComponent", ":: AlphaComponent ::", "<span class='alphaComponent badge'>Alpha Component</span>");
addBadges(annotations, "DeveloperApi", ":: DeveloperApi ::", "<span class='developer badge'>Developer API</span>");
addBadges(annotations, "Experimental", ":: Experimental ::", "<span class='experimental badge'>Experimental</span>");
});

function addBadges(allAnnotations, name, tag, html) {
var fullName = "org.apache.spark.annotations." + name;
var annotations = allAnnotations.children("a[name='" + fullName + "']");
var tags = $("p.comment:contains(" + tag + ")").add(
$("div.comment p:contains(" + tag + ")"));
var annotations = allAnnotations.filter(":contains('" + name + "')")
var tags = $(".cmt:contains(" + tag + ")")

// Remove identifier tags from comments
tags.each(function(index) {
Expand All @@ -21,7 +19,8 @@ function addBadges(allAnnotations, name, tag, html) {
});

// Add badges to all containers
tags.prevAll("h4.signature").prepend(html);
annotations.closest("div.fullcomment").prevAll("h4.signature").prepend(html);
annotations.closest("div.fullcommenttop").prepend(html);
tags.prevAll("h4.signature")
.add(annotations.closest("div.fullcommenttop"))
.add(annotations.closest("div.fullcomment").prevAll("h4.signature"))
.prepend(html);
}

0 comments on commit 982a473

Please sign in to comment.