Skip to content

Commit ee3913c

Browse files
committed
Use Tocbot for Table of Contents
1 parent 8aaa7e9 commit ee3913c

File tree

13 files changed

+211
-12
lines changed

13 files changed

+211
-12
lines changed

gradle/docs.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ asciidoctor {
8383
sources {
8484
include '*.adoc'
8585
}
86+
resources {
87+
from(sourceDir) {
88+
include 'images/**', 'tocbot-3.0.2/**'
89+
}
90+
}
8691
logDocuments = true
8792
backends = ["html5"]
8893
// only ouput PDF documentation for non-SNAPSHOT builds

src/docs/asciidoc/core.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
:doc-root: https://docs.spring.io
44
:api-spring-framework: {doc-root}/spring-framework/docs/{spring-version}/javadoc-api/org/springframework
55
:toc: left
6-
:toclevels: 2
6+
:toclevels: 4
77
:docinfo1:
88

99
This part of the reference documentation covers all of those technologies that are

src/docs/asciidoc/data-access.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
:doc-root: https://docs.spring.io
44
:api-spring-framework: {doc-root}/spring-framework/docs/{spring-version}/javadoc-api/org/springframework
55
:toc: left
6-
:toclevels: 2
6+
:toclevels: 4
77
:docinfo1:
88

99
This part of the reference documentation is concerned with data access and the

src/docs/asciidoc/docinfo-footer.html

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,46 @@
1+
<script src="tocbot-3.0.2/tocbot.js"></script>
12
<script>
2-
var rootLink = document.createElement("a");
3-
rootLink.setAttribute("href", "index.html");
4-
rootLink.innerHTML = "<i class=\"fa fa-chevron-left\" aria-hidden=\"true\"></i>&nbsp;&nbsp;Back to index";
3+
4+
// Tocbot dynamic TOC, works with tocbot 3.0.2
5+
// Source: https://github.com/asciidoctor/asciidoctor/issues/699#issuecomment-321066006
6+
7+
var oldtoc = document.getElementById('toctitle').nextElementSibling;
8+
var newtoc = document.createElement('div');
9+
newtoc.setAttribute('id', 'tocbot');
10+
newtoc.setAttribute('class', 'js-toc');
11+
oldtoc.parentNode.replaceChild(newtoc, oldtoc);
12+
tocbot.init({ contentSelector: '#content',
13+
headingSelector: 'h1, h2, h3, h4, h5',
14+
smoothScroll: false });
15+
var handleTocOnResize = function() {
16+
var width = window.innerWidth
17+
|| document.documentElement.clientWidth
18+
|| document.body.clientWidth;
19+
if (width < 768) {
20+
tocbot.refresh({ contentSelector: '#content',
21+
headingSelector: 'h1, h2, h3, h4, h5',
22+
collapseDepth: 6,
23+
activeLinkClass: 'ignoreactive',
24+
throttleTimeout: 1000,
25+
smoothScroll: false });
26+
}
27+
else {
28+
tocbot.refresh({ contentSelector: '#content',
29+
headingSelector: 'h1, h2, h3, h4, h5',
30+
smoothScroll: false });
31+
}
32+
};
33+
window.addEventListener('resize', handleTocOnResize);
34+
handleTocOnResize();
35+
36+
37+
var link = document.createElement("a");
38+
link.setAttribute("href", "index.html");
39+
link.innerHTML = "<i class=\"fa fa-chevron-left\" aria-hidden=\"true\"></i>&nbsp;&nbsp;Back to index";
540
var p = document.createElement("p");
6-
p.appendChild(rootLink);
41+
p.appendChild(link);
742
var toc = document.getElementById('toc')
8-
var sectlevel1 = toc.getElementsByClassName("sectlevel1")[0]
9-
toc.insertBefore(p, sectlevel1);
43+
var next = document.getElementById('toctitle').nextElementSibling;
44+
toc.insertBefore(p, next);
45+
1046
</script>

src/docs/asciidoc/integration.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
:doc-spring-amqp: {doc-root}/spring-amqp/docs/current/reference
66
:doc-spring-gemfire: {doc-root}/spring-gemfire/docs/current/reference
77
:toc: left
8-
:toclevels: 2
8+
:toclevels: 4
99
:docinfo1:
1010

1111
This part of the reference documentation covers the Spring Framework's integration with

src/docs/asciidoc/kotlin.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
:doc-root: https://docs.spring.io
44
:api-spring-framework: {doc-root}/spring-framework/docs/{spring-version}/javadoc-api/org/springframework
55
:toc: left
6-
:toclevels: 2
6+
:toclevels: 4
77
:docinfo1:
88

99
[[introduction]]

src/docs/asciidoc/stylesheets/spring.css

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
11
@import url(https://fonts.googleapis.com/css?family=Varela+Round|Montserrat:400,700);
2+
@import url('../tocbot-3.0.2/tocbot.css');
3+
4+
/* See https://github.com/asciidoctor/asciidoctor/issues/699#issuecomment-321066006 */
5+
/* ================================================================================ */
6+
#tocbot a.toc-link.node-name--H1{ font-style: italic }
7+
@media screen{
8+
#tocbot > ul.toc-list{ margin-bottom: 0.5em; margin-left: 0.125em }
9+
#tocbot ul.sectlevel0, #tocbot a.toc-link.node-name--H1 + ul{
10+
padding-left: 0 }
11+
#tocbot a.toc-link{ height:100% }
12+
.is-collapsible{ max-height:3000px; overflow:hidden; }
13+
.is-collapsed{ max-height:0 }
14+
.is-active-link{ font-weight:700 }
15+
}
16+
@media print{
17+
#tocbot a.toc-link.node-name--H4{ display:none }
18+
}
19+
/* ================================================================================ */
20+
221
/*! normalize.css v2.1.2 | MIT License | git.io/normalize */
322
/* ========================================================================== HTML5 display definitions ========================================================================== */
423
/** Correct `block` display not defined in IE 8/9. */

src/docs/asciidoc/testing.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
:api-spring-framework: {doc-root}/spring-framework/docs/{spring-version}/javadoc-api/org/springframework
55
:doc-spring-boot: {doc-root}/spring-boot/docs/current/reference
66
:toc: left
7-
:toclevels: 2
7+
:toclevels: 4
88
:docinfo1:
99

1010
The adoption of the test-driven-development (TDD) approach to software

src/docs/asciidoc/tocbot-3.0.2/styles.css

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

src/docs/asciidoc/tocbot-3.0.2/tocbot.css

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

src/docs/asciidoc/tocbot-3.0.2/tocbot.js

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

src/docs/asciidoc/tocbot-3.0.2/tocbot.min.js

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

src/docs/asciidoc/web.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
:doc-root: https://docs.spring.io
44
:api-spring-framework: {doc-root}/spring-framework/docs/{spring-version}/javadoc-api/org/springframework
55
:toc: left
6-
:toclevels: 2
6+
:toclevels: 4
77
:docinfo1:
88

99
This part of the documentation covers support for Servlet stack, web applications built on the

0 commit comments

Comments
 (0)