Skip to content

Commit 44c931f

Browse files
committed
[SPARK-8353] [DOCS] Show anchor links when hovering over documentation headers
This patch uses [AnchorJS](https://bryanbraun.github.io/anchorjs/) to show deep anchor links when hovering over headers in the Spark documentation. For example: ![image](https://cloud.githubusercontent.com/assets/50748/8240800/1502f85c-15ba-11e5-819a-97b231370a39.png) This makes it easier for users to link to specific sections of the documentation. I also removed some dead Javascript which isn't used in our current docs (it was introduced for the old AMPCamp training, but isn't used anymore). Author: Josh Rosen <[email protected]> Closes apache#6808 from JoshRosen/SPARK-8353 and squashes the following commits: e59d8a7 [Josh Rosen] Suppress underline on hover f518b6a [Josh Rosen] Turn on for all headers, since we use H1s in a bunch of places a9fec01 [Josh Rosen] Add anchor links when hovering over headers; remove some dead JS code
1 parent 9b20027 commit 44c931f

File tree

5 files changed

+19
-28
lines changed

5 files changed

+19
-28
lines changed

LICENSE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,3 +950,4 @@ The following components are provided under the MIT License. See project link fo
950950
(MIT License) scopt (com.github.scopt:scopt_2.10:3.2.0 - https://github.com/scopt/scopt)
951951
(The MIT License) Mockito (org.mockito:mockito-all:1.8.5 - http://www.mockito.org)
952952
(MIT License) jquery (https://jquery.org/license/)
953+
(MIT License) AnchorJS (https://github.com/bryanbraun/anchorjs)

docs/_layouts/global.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ <h1 class="title">{{ page.title }}</h1>
138138

139139
<script src="js/vendor/jquery-1.8.0.min.js"></script>
140140
<script src="js/vendor/bootstrap.min.js"></script>
141+
<script src="js/vendor/anchor.min.js"></script>
141142
<script src="js/main.js"></script>
142143

143144
<!-- MathJax Section -->

docs/css/main.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,3 +146,8 @@ ul.nav li.dropdown ul.dropdown-menu li.dropdown-submenu ul.dropdown-menu {
146146
.MathJax .mi { color: inherit }
147147
.MathJax .mf { color: inherit }
148148
.MathJax .mh { color: inherit }
149+
150+
/**
151+
* AnchorJS (anchor links when hovering over headers)
152+
*/
153+
a.anchorjs-link:hover { text-decoration: none; }

docs/js/main.js

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -68,46 +68,24 @@ function codeTabs() {
6868
});
6969
}
7070

71-
function makeCollapsable(elt, accordionClass, accordionBodyId, title) {
72-
$(elt).addClass("accordion-inner");
73-
$(elt).wrap('<div class="accordion ' + accordionClass + '"></div>')
74-
$(elt).wrap('<div class="accordion-group"></div>')
75-
$(elt).wrap('<div id="' + accordionBodyId + '" class="accordion-body collapse"></div>')
76-
$(elt).parent().before(
77-
'<div class="accordion-heading">' +
78-
'<a class="accordion-toggle" data-toggle="collapse" href="#' + accordionBodyId + '">' +
79-
title +
80-
'</a>' +
81-
'</div>'
82-
);
83-
}
84-
85-
// Enable "view solution" sections (for exercises)
86-
function viewSolution() {
87-
var counter = 0
88-
$("div.solution").each(function() {
89-
var id = "solution_" + counter
90-
makeCollapsable(this, "", id,
91-
'<i class="icon-ok-sign" style="text-decoration: none; color: #0088cc">' +
92-
'</i>' + "View Solution");
93-
counter++;
94-
});
95-
}
9671

9772
// A script to fix internal hash links because we have an overlapping top bar.
9873
// Based on https://github.com/twitter/bootstrap/issues/193#issuecomment-2281510
9974
function maybeScrollToHash() {
100-
console.log("HERE");
10175
if (window.location.hash && $(window.location.hash).length) {
102-
console.log("HERE2", $(window.location.hash), $(window.location.hash).offset().top);
10376
var newTop = $(window.location.hash).offset().top - 57;
10477
$(window).scrollTop(newTop);
10578
}
10679
}
10780

10881
$(function() {
10982
codeTabs();
110-
viewSolution();
83+
// Display anchor links when hovering over headers. For documentation of the
84+
// configuration options, see the AnchorJS documentation.
85+
anchors.options = {
86+
placement: 'left'
87+
};
88+
anchors.add();
11189

11290
$(window).bind('hashchange', function() {
11391
maybeScrollToHash();

docs/js/vendor/anchor.min.js

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)