Skip to content

Commit d42f96d

Browse files
author
Jay Bryant
committed
Dynamic ToC and PDF output
I updated the document-production parts of the build files to pick up the dynamic ToC (tocbot) that we use across the portfolio. I also added PDF output (again, in keeping with the rest of the portfolio). In doing so, I updated various versions and other settings.
1 parent 513a0e9 commit d42f96d

File tree

2 files changed

+84
-5
lines changed

2 files changed

+84
-5
lines changed

build.gradle

+9
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,15 @@ task docsZip(type: Zip, dependsOn: [':docs:asciidoctor', ':api', ':buildSamples'
244244
destinationDir = file("${project.buildDir}/distributions")
245245

246246
from(project.tasks.findByPath(':docs:asciidoctor')) {
247+
include "index.html"
248+
include "css/**"
249+
include "js/**"
250+
include "images/**"
251+
into 'reference'
252+
}
253+
254+
from(project.tasks.findByPath(':docs:makePDF')) {
255+
include "index.pdf"
247256
into 'reference'
248257
}
249258

docs/build.gradle

+75-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ repositories {
88
}
99

1010
dependencies {
11-
asciidoctor 'io.spring.asciidoctor:spring-asciidoctor-extensions:0.1.2.RELEASE'
11+
asciidoctor 'io.spring.asciidoctor:spring-asciidoctor-extensions:0.2.0.RELEASE'
12+
asciidoctor "org.asciidoctor:asciidoctorj-pdf:1.5.0-alpha.16"
1213
testCompile project(':spring-restdocs-mockmvc')
1314
testCompile project(':spring-restdocs-restassured')
1415
testCompile project(':spring-restdocs-webtestclient')
@@ -19,13 +20,82 @@ dependencies {
1920
testCompile 'org.junit.jupiter:junit-jupiter-api'
2021
}
2122

23+
ext {
24+
docResourcesVersion = '0.1.3.RELEASE'
25+
}
26+
2227
tasks.findByPath("artifactoryPublish")?.enabled = false
2328

24-
asciidoctor {
29+
configurations {
30+
docs
31+
}
32+
33+
dependencies {
34+
docs "io.spring.docresources:spring-doc-resources:${docResourcesVersion}@zip"
35+
}
36+
37+
task prepareAsciidocBuild(type: Sync) {
38+
dependsOn configurations.docs
39+
// copy doc resources
40+
from {
41+
configurations.docs.collect { zipTree(it) }
42+
}
43+
// and doc sources
44+
from "../docs/src/docs/asciidoc/"
45+
// to a build directory of your choice
46+
into "$buildDir/asciidoc/assemble"
47+
}
48+
49+
task copyExamples(type: Copy) {
50+
dependsOn prepareAsciidocBuild
51+
from "../docs/src/test/java"
52+
into "$buildDir/asciidoc/assemble/examples/java"
53+
}
54+
55+
task('makePDF', type: org.asciidoctor.gradle.AsciidoctorTask){
56+
dependsOn copyExamples
57+
backends 'pdf'
58+
sourceDir "$buildDir/asciidoc/assemble"
2559
sources {
2660
include 'index.adoc'
2761
}
28-
attributes 'revnumber': project.version,
29-
'branch-or-tag': project.version.endsWith('SNAPSHOT') ? 'master': "v${project.version}"
30-
inputs.files(sourceSets.test.java)
62+
options doctype: 'book', eruby: 'erubis'
63+
logDocuments = true
64+
attributes 'icons': 'font',
65+
'examples-dir': 'examples/java',
66+
'sectanchors': '',
67+
'sectnums': '',
68+
'toc': '',
69+
'source-highlighter' : 'coderay',
70+
revnumber: project.version
71+
}
72+
73+
asciidoctor {
74+
dependsOn makePDF
75+
backends 'html5'
76+
sourceDir "$buildDir/asciidoc/assemble"
77+
resources {
78+
from(sourceDir) {
79+
include 'images/*', 'css/**', 'js/**'
80+
}
81+
}
82+
options doctype: 'book', eruby: 'erubis'
83+
logDocuments = true
84+
attributes 'docinfo': 'shared',
85+
'examples-dir': 'examples/java',
86+
// use provided stylesheet
87+
stylesdir: "css/",
88+
stylesheet: 'spring.css',
89+
'linkcss': true,
90+
'icons': 'font',
91+
'sectanchors': '',
92+
// use provided highlighter
93+
'source-highlighter=highlight.js',
94+
'highlightjsdir=js/highlight',
95+
'highlightjs-theme=atom-one-dark-reasonable',
96+
'idprefix': '',
97+
'idseparator': '-',
98+
'spring-version': project.version,
99+
'allow-uri-read': '',
100+
revnumber: project.version
31101
}

0 commit comments

Comments
 (0)