forked from neo4j/docs-drivers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
727 lines (664 loc) · 26.6 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
import org.ajoberstar.grgit.*
import org.neo4j.doc.build.xslt.XsltTask
import org.neo4j.doc.build.docbook.DocBookPlugin
buildscript {
ext {
asciidoctorjVersion = '1.5.6'
asciidoctorjPdfVersion = '1.5.0-alpha.16'
asciidoctorGroovyDslVersion = '1.0.0.Alpha2'
gradleGitVersion = '1.4.2'
catalogDir = "$projectDir/docbook/catalog"
}
repositories {
jcenter()
}
dependencies {
classpath "org.asciidoctor:asciidoctorj:$asciidoctorjVersion"
classpath "org.asciidoctor:asciidoctorj-pdf:$asciidoctorjPdfVersion"
classpath "org.asciidoctor:asciidoctorj-groovy-dsl:$asciidoctorGroovyDslVersion"
classpath "org.ajoberstar:gradle-git:$gradleGitVersion"
classpath 'net.sf.docbook:docbook-xsl:1.79.1:ns-resources@zip'
classpath fileTree(dir: "${rootProject.projectDir}/lib", include: '*.jar')
classpath files(catalogDir)
classpath "org.dom4j:dom4j:2.1.1"
classpath "jaxen:jaxen:1.1.6"
}
}
plugins {
id 'base'
id 'de.undercouch.download' version '3.2.0'
id 'org.neo4j.doc.build.vale' version '1.0-alpha01'
id 'org.neo4j.doc.build.saxon' version '1.0-alpha01'
id 'org.neo4j.doc.build.docbook' version '1.0-alpha11'
id 'maven-publish'
}
version '1.7'
repositories {
mavenLocal()
maven {
url System.env.ARTIFACTORY_URI
credentials {
username System.env.ARTIFACTORY_USERNAME
password System.env.ARTIFACTORY_PASSWORD
}
}
}
configurations {
olinkdb {
description "olinkdb dependencies"
}
}
def traceDocbook = hasProperty('traceDocbook') ? true : false
if (!project.hasProperty("neo4jVersion")) { ext.neo4jVersion = "3.5.0-SNAPSHO" }
if (!project.hasProperty("driverVersion")) { ext.driverVersion = version }
if (!project.hasProperty("ogmVersion")) { ext.ogmVersion = "2.1.2" }
ext {
codeMirrorVersion = '5.36.0'
// Set `neo4jDocVersion` for use in the generated docs
// Those docs that follow Neo4j versions do so tracking `major.minor[-prerelease]`
// So, drop the patch version:
neo4jVersionParts = neo4jVersion.split('-')
neo4jDocVersion = neo4jVersionParts[0][0..2]
if (1 < neo4jVersionParts.size()) {
neo4jDocVersion += "-preview"
}
// Make it a little easier to build release and pre-release OGM docs.
ogmDocVersion = ogmVersion.tokenize('.')[0..1].join(".")
if (ogmVersion.contains("-")) {ogmDocVersion += "-pre"}
driverVersionMapUrl = 'https://s3-eu-west-1.amazonaws.com/drivers.neo4j.com/version-tracker/version.json'
getDriverVersionMap = {
if (!project.hasProperty('driverVersionMap')) {
def versionsFile = "$buildDir/driverVersions.json"
download {
src driverVersionMapUrl
dest versionsFile
onlyIfNewer true
overwrite true
}
ext.driverVersionMap = new groovy.json.JsonSlurper().parseText(file(versionsFile).text)
} else {
ext.driverVersionMap
}
}
getVersionFromSeries = { series, language ->
version = getDriverVersionMap().driverLanguages[language].driverSeries[series]
if (null == version) { version = series }
version
}
// Driver version can be overridden: `-PdriverVersion=`
if (!project.hasProperty('driverVersion')) {
ext.driverVersion = getDriverVersionMap().serverSeries[neo4jSeries].recommendedDriverSeries
}
driverSeries = driverVersion.tokenize('.-')[0..1].join('.')
// Driver API doc versions can be overridden: `-PdotnetDriverApiDocVersion=`
// Default to `driverVersion`
["dotnetDriverApiDocVersion", "goDriverApiDocVersion", "javaDriverApiDocVersion", "javascriptDriverApiDocVersion", "pythonDriverApiDocVersion"].each {
if (!project.hasProperty(it)) { ext."$it" = driverVersion }
}
driverLanguages = [
'dotnet': [
'name' : 'C#',
'version': getVersionFromSeries(driverSeries, 'dotnet'),
'gitref' : getVersionFromSeries(driverSeries, 'dotnet'),
'url' : 'https://www.nuget.org/packages/Neo4j.Driver'
],
'go': [
'name' : 'Go',
'version': getVersionFromSeries(driverSeries, 'go'),
'gitref' : getVersionFromSeries(driverSeries, 'go'),
'url' : 'https://github.com/neo4j/neo4j-go-driver'
],
'java': [
'name' : 'Java',
'version': getVersionFromSeries(driverSeries, 'java'),
'gitref' : getVersionFromSeries(driverSeries, 'java'),
'url' : 'http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.neo4j.driver%22%20AND%20a%3A%22neo4j-java-driver%22'
],
'javascript': [
'name' : 'JavaScript',
'version': getVersionFromSeries(driverSeries, 'javascript'),
'gitref' : getVersionFromSeries(driverSeries, 'javascript'),
'url' : 'https://www.npmjs.com/package/neo4j-driver'
],
'python' : [
'name' : 'Python',
'version': getVersionFromSeries(driverSeries, 'python'),
'gitref' : getVersionFromSeries(driverSeries, 'python'),
'url' : 'https://pypi.python.org/pypi/neo4j-driver'
]
]
driverLanguages.each { lang, info ->
println "$lang driver version: $info.version"
}
driverDocVersion = driverVersion
versions = [
'driverDocs' : driverVersion,
'neo4jDocs' : neo4jDocVersion,
'ogmDocs' : ogmDocVersion,
'kerberosAddOn' : '1.0',
]
copyrightYear = '2019'
docsBaseUri = "https://neo4j.com/docs"
crossReferenceBase = [ // We have no strategy for cross references yet; always link to current.
'cypher-manual' : "${docsBaseUri}/cypher-manual/current",
'driver-manual' : "${docsBaseUri}/driver-manual/${versions.driverDocs}",
'operations-manual' : "${docsBaseUri}/operations-manual/current",
'java-reference' : "${docsBaseUri}/java-reference/current",
'rest-docs' : "${docsBaseUri}/rest-docs/current",
'getting-started' : "${docsBaseUri}/getting-started/current",
'status-codes' : "${docsBaseUri}/status-codes/current",
'ogm-manual' : "${docsBaseUri}/ogm-manual/current",
'graph-algorithms' : "${docsBaseUri}/graph-algorithms/current",
'kerberos-add-on' : "${docsBaseUri}/add-on/kerberos/current"
]
asciidoctorAttributes = [
'common': [
'copyright-year' : copyrightYear,
'copyright' : "${copyrightYear} Neo4j, Inc.",
'common-license-page-uri' : "${docsBaseUri}/license",
'driver-version' : driverVersion,
'doctype' : 'book',
'icons' : 'font',
'attribute-missing' : 'warn',
'docs-version' : versions.driverDocs,
'common-license-page-uri' : "$docsBaseUri/license/",
'dotnet-driver-apidoc-version' : dotnetDriverApiDocVersion,
'go-driver-apidoc-version' : goDriverApiDocVersion,
'java-driver-apidoc-version' : javaDriverApiDocVersion,
'javascript-driver-apidoc-version' : javascriptDriverApiDocVersion,
'python-driver-apidoc-version' : pythonDriverApiDocVersion,
'codemirror-version' : codeMirrorVersion,
'kerberos-add-on-base-uri' : crossReferenceBase['kerberos-add-on'],
],
'docbook': [
'imagesdir' : 'images',
'docinfo1' : '',
],
'html': [
'stylesdir' : 'css',
'linkcss' : '',
'imagesdir' : 'images',
],
'pdf': [
'source-highlighter': 'rouge',
'pdf-style' : 'neo',
'toc' : '',
'showlinks' : '',
'nonhtmloutput' : '',
// 'pdf-fontsdir' : "$rootProject.buildDir/fonts".toString(),
]
]
asciidocSourceDir = "$projectDir/asciidoc"
distDir = "$buildDir/distributions"
docId = 'driver-manual'
fonts = [
'Open Sans.zip' : 'https://www.google.com/fonts/download?kit=3hvsV99qyKCBS55e5pvb3ltkqrIMaAZWyLYEoB48lSQ',
'Inconsolata.zip': 'https://www.google.com/fonts/download?kit=CNj0Ze1H6w4FVgc32wmZS4fD-WQWLbF4rYwcBGowFYY',
'Lora.zip' : 'https://www.google.com/fonts/download?kit=iwrHM7FQEcKgsUvDuXxrPg',
]
olinkdb = "$buildDir/olinkdb/olinkdb.xml"
}
dependencies {
olinkdb "org.neo4j.doc:driver-manual:$driverDocVersion:olinkdb@jar"
olinkdb "org.neo4j.doc:http-api:$neo4jDocVersion:olinkdb@jar"
olinkdb "org.neo4j.doc:operations-manual:$neo4jDocVersion:olinkdb@jar"
olinkdb "org.neo4j.doc:cypher-manual:$neo4jDocVersion:olinkdb@jar"
olinkdb "org.neo4j.doc:getting-started:$neo4jDocVersion:olinkdb@jar"
olinkdb "org.neo4j.doc:status-codes:$neo4jDocVersion:olinkdb@jar"
}
task prepareOlinkDb(dependsOn: configurations.olinkdb) {
ext.outputDir = "$buildDir/olinkdb/"
inputs.files configurations.olinkdb
outputs.dir outputDir
doLast {
def olinkdb = """\
<?xml version="1.0"?>
<targetset>
<targetsetinfo>
Neo4j documentation library olink target database.
</targetsetinfo>
<!-- Site map for generating relative paths between documents -->
<sitemap>
<dir name="irrelevant-name">"""
mkdir(outputDir)
configurations.olinkdb.dependencies.each { dep ->
def files = configurations.olinkdb.files.grep {
it.name.contains(dep.name)
}
if (!1==files.size()) {
Logger.ERROR("Shit pommes frites, why are you doing this in a build script?")
}
copy {
from zipTree(files[0])
into outputDir
}
olinkdb += file("${outputDir}/${dep.name}-entry.xml").text
}
olinkdb += """
</dir>
</sitemap>
</targetset>"""
file("$outputDir/olinkdb.xml").text = olinkdb
}
}
task('downloadFonts') {
description 'Download from Google Fonts.'
outputs.dir "$buildDir/font-downloads"
outputs.upToDateWhen {
file("$buildDir/font-downloads").exists()
}
doLast {
fonts.each { name, url ->
download {
src url
dest "$buildDir/font-downloads/${name}"
overwrite false
}
}
}
}
downloadFonts.finalizedBy 'unzipDownloadedFonts'
task('unzipDownloadedFonts', dependsOn: 'downloadFonts', type: Copy) {
description 'Unzip zip files with fonts.'
fonts.each { name, url ->
from zipTree("$buildDir/font-downloads/${name}")
}
into "$buildDir/fonts"
}
// defaultTasks 'asciidoctorHtml', 'asciidoctorPdf'
ext {
adoc = null
// a wrapper closure around executing a string
// can take either a string or a list of strings (for arguments with spaces)
runCommand = { strList ->
assert ( strList instanceof String ||
( strList instanceof List && strList.each{ it instanceof String } ) \
)
def proc = strList.execute()
// proc.in.eachLine { line -> println line }
proc.out.close()
proc.waitFor()
// print "[INFO] ( "
// if(strList instanceof List) {
// strList.each { print "${it} " }
// } else {
// print strList
// }
// println " )"
if (proc.exitValue()) {
println "gave the following error: "
println "[ERROR] ${proc.getErrorStream()}"
}
assert !proc.exitValue()
}
}
project.ext.driverLanguages.each { lang, info ->
project.ext.asciidoctorAttributes.common["$lang-driver-version"] = info['version']
project.ext.asciidoctorAttributes.common["$lang-root"] = targetGitdir(lang, info['gitref'])
project.ext.asciidoctorAttributes.html["include-with-$lang"] = ''
project.ext.asciidoctorAttributes.docbook["include-with-$lang"] = ''
task ("${lang}DriverApiDocs", type: Tar) {
description "Package API docs for the ${lang} driver."
baseName "${lang}-driver"
version driverVersion
extension "tar.gz"
compression Compression.GZIP
from {
file("${projectDir}/shared/${lang}-driver-api-docs").exists() ? "${projectDir}/shared/${lang}-driver-api-docs" : "apidocs/${lang}"
}
into {
"api/${baseName}/${driverVersion}"
}
destinationDir file("${buildDir}/distributions")
}
task ("${lang}DriverSources") {
description "Clones the ${lang} driver sources from GitHub or uses local checkouts."
def targetDir = targetGitdir(lang, info['gitref'])
outputs.dir targetDir
onlyIf { !file(targetDir).exists() }
doLast {
println "Cloning neo4j-$lang-driver repository."
Grgit.clone(dir: targetDir,
uri: "https://github.com/neo4j/neo4j-$lang-driver.git",
refToCheckout: info['gitref'])
}
}
}
def targetGitdir(lang, gitref) {
if (project.hasProperty('localDriverSources')) {
file("$projectDir/../neo4j-$lang-driver")
} else {
file("${rootProject.buildDir}/driver-sources/${lang}-driver/${gitref}")
}
}
def deps = driverLanguages.collect {"${it.getKey()}DriverApiDocs"}
task driverApiDocsPackage(dependsOn: deps) {
description 'Package the driver API docs.'
}
def driverSourcesTasks = driverLanguages.collect {"${it.getKey()}DriverSources"}
task prepareDriverSources(dependsOn: driverSourcesTasks){
description "Prepare driver sources."
}
def getAsciidoctor(withTabbedExampleProcessor) {
project.ext.adoc = org.asciidoctor.Asciidoctor.Factory.create()
if (withTabbedExampleProcessor) {
adoc.rubyExtensionRegistry()
.loadClass(new FileInputStream(file("${rootProject.projectDir}/extensions/tabbed_example_processor.rb")))
.treeprocessor("TabbedExampleProcessor")
}
project.ext.adoc
}
task docbook(dependsOn: prepareDriverSources) {
description 'Build DocBook.'
ext.sourceDir = asciidocSourceDir
ext.sourceFile = file("$sourceDir/index.adoc")
ext.outputDir = "$buildDir/docbook/${versions.driverDocs}"
inputs.dir sourceDir
outputs.dir outputDir
def templateDir = "${rootProject.projectDir}/templates/docbook"
doLast {
def attrs = asciidoctorAttributes.common + asciidoctorAttributes.docbook + [
'driver-manual-version' : versions.driverDocs,
'project-root' : "${rootProject.projectDir}",
]
def opts = org.asciidoctor.OptionsBuilder.options()
.backend('docbook5')
.safe(org.asciidoctor.SafeMode.UNSAFE)
.toDir(file(outputDir))
.templateDir(new File(templateDir))
.mkDirs(true)
.attributes(attrs)
getAsciidoctor(true).convertFile(sourceFile, opts.get())
}
doLast {
copy {
from("$projectDir/asciidoc") {
include 'images/**'
}
into outputDir
}
}
finalizedBy 'preprocess'
}
preprocess {
dependsOn docbook
def sourceFile = "${docbook.outputDir}/index.xml"
input sourceFile
outFile sourceFile
parameters([
"book-id": "$docId"
])
doFirst {
def cmd = ["${projectDir}/bin/post-process.sh", sourceFile, "${projectDir}/bin/post-process.sed"]
runCommand(cmd)
}
}
task makeTargetDb(type: XsltTask, dependsOn: docbook) {
description 'Create database of olink targets.'
ext.docVersion = driverDocVersion
ext.sourceFile = "${buildDir}/docbook/${docVersion}/index.xml"
ext.contentMap = "${projectDir}/docbook/content-map.xml"
ext.outputDir = "${buildDir}/tmp/olinkdb"
ext.outputFile = "${outputDir}/${docId}/${docVersion}/target.db"
ext.stylesheet = "xsl/chunk-from-toc/xhtml/chunktoc.xsl"
inputs.file {sourceFile}
inputs.file {contentMap}
outputs.dir {outputDir}
doFirst {
def url = DocBookPlugin.getClassLoader().getResource(ext.stylesheet)
stylesheet url
input sourceFile
sourceSaxParser "org.apache.xml.resolver.tools.ResolvingXMLReader"
stylesheetSaxParser "org.apache.xml.resolver.tools.ResolvingXMLReader"
uriResolver "org.apache.xml.resolver.tools.CatalogResolver"
usingUrls true
usingClasspathUrls true
if (hasProperty('traceDocbook')) { verbose true }
// Stylesheet parameters
parameters([
"base.dir": "${outputDir}",
"chunk.section.depth": "8",
"chunk.first.sections": "1",
"use.id.as.dirname": "1",
"chunk.toc": "${contentMap}",
"collect.xref.targets": "only",
"targets.filename": "${outputFile}",
])
}
doLast {
def relpath = java.nio.file.Paths.get(outputDir).relativize(java.nio.file.Paths.get(outputFile))
def before = ""
def after = ""
relpath.iterator().dropRight(1).each {
before += "<dir name=\"$it\">"
after += "</dir>"
}
def entry = """
$before
<document targetdoc=\"${docId}\">
<xi:include href=\"${relpath}\" xmlns:xi=\"http://www.w3.org/2001/XInclude\">
</xi:include>
</document>
$after"""
file("${outputDir}/${docId}-entry.xml").text = entry
}
}
task packageOlinkDb(type: Jar, dependsOn: [makeTargetDb, makeTargetDb]) {
baseName docId
version neo4jDocVersion
classifier "olinkdb"
destinationDir file("$buildDir/distributions")
from {
makeTargetDb
}
}
publishing {
publications {
maven(MavenPublication) {
groupId = 'org.neo4j.doc'
artifactId = docId
version = driverDocVersion
artifact packageOlinkDb
}
}
repositories {
maven {
name 'preview'
url System.env.PUBLISH_REPO
credentials {
username System.env.PUBLISH_USERNAME
password System.env.PUBLISH_PASSWORD
}
}
}
}
task sitemap() {
ext.contentMapXml = file("${projectDir}/docbook/content-map.xml")
def siteMapDir = "$buildDir/sitemap/$version"
outputs.dir siteMapDir
doLast {
def siteMap = org.dom4j.DocumentHelper.createDocument()
def urlset = siteMap.addElement("urlset", "http://www.sitemaps.org/schemas/sitemap/0.9")
def contentMap = new org.dom4j.io.SAXReader().read(contentMapXml)
contentMap.selectNodes('//processing-instruction("dbhtml")')
.collect { pi ->
pi.getText() // filename="installation/index.html"
.replaceAll("filename=|\"", "") // installation/index.html
}.each { filename ->
def url = "${docsBaseUri}/driver-manual/current" + "/" + filename
urlset.addElement("url").addElement("loc").addText(url)
}
mkdir(siteMapDir)
new org.dom4j.io.XMLWriter(
new FileOutputStream(file("$siteMapDir/sitemap.xml")),
org.dom4j.io.OutputFormat.createPrettyPrint()
).write(siteMap)
}
}
task makeToc(type: XsltTask, dependsOn: docbook) {
description 'Create a table of contents aka complete content map.'
ext.sourceDir = docbook.outputDir
ext.sourceFile = "$sourceDir/index.xml"
ext.outputFile = "$buildDir/docbook/${versions.driverDocs}/toc.xml"
def outputDir = "$buildDir/docbook/${versions.driverDocs}/_trash"
def url = DocBookPlugin.getClassLoader().getResource("xsl/create-toc/xhtml/maketoc.xsl")
stylesheet url
input sourceFile
outFile outputFile
sourceSaxParser "org.apache.xml.resolver.tools.ResolvingXMLReader"
stylesheetSaxParser "org.apache.xml.resolver.tools.ResolvingXMLReader"
uriResolver "org.apache.xml.resolver.tools.CatalogResolver"
usingUrls true
usingClasspathUrls true
if (hasProperty('traceDocbook')) { verbose true }
parameters([
"base.dir": "${outputDir}",
"chunk.section.depth": "8",
"chunk.first.sections": "1",
"use.id.as.dirname": "1",
])
}
html {
dependsOn docbook, prepareOlinkDb
ext.sourceDir = docbook.outputDir
ext.sourceFile = "$sourceDir/index.xml"
ext.outputDir = "$buildDir/html/${versions.driverDocs}"
ext.contentMap = "$projectDir/docbook/content-map.xml"
inputs.file sourceFile
inputs.dir 'css'
inputs.dir 'images'
inputs.dir 'javascript'
outputs.dir outputDir
def libraryLinks = [
"Operations_Manual=${crossReferenceBase['operations-manual']}/",
"Cypher_Manual=${crossReferenceBase['cypher-manual']}/",
"Driver_Manual=${crossReferenceBase['driver-manual']}/",
"Docs_Library=${docsBaseUri}/",
].join(" ")
def scripts = [
'//ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js',
'//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js',
"//cdnjs.cloudflare.com/ajax/libs/codemirror/$codeMirrorVersion/codemirror.min.js",
"//cdnjs.cloudflare.com/ajax/libs/codemirror/$codeMirrorVersion/addon/runmode/runmode.min.js",
"//cdnjs.cloudflare.com/ajax/libs/codemirror/$codeMirrorVersion/mode/javascript/javascript.min.js",
"//cdnjs.cloudflare.com/ajax/libs/codemirror/$codeMirrorVersion/mode/shell/shell.min.js",
"//cdnjs.cloudflare.com/ajax/libs/codemirror/$codeMirrorVersion/mode/python/python.min.js",
"//cdnjs.cloudflare.com/ajax/libs/codemirror/$codeMirrorVersion/mode/xml/xml.min.js",
"//cdnjs.cloudflare.com/ajax/libs/codemirror/$codeMirrorVersion/mode/clike/clike.min.js",
"//cdnjs.cloudflare.com/ajax/libs/codemirror/$codeMirrorVersion/mode/cypher/cypher.min.js",
"//cdnjs.cloudflare.com/ajax/libs/codemirror/$codeMirrorVersion/mode/properties/properties.min.js",
"//cdnjs.cloudflare.com/ajax/libs/codemirror/$codeMirrorVersion/mode/groovy/groovy.min.js",
"//cdnjs.cloudflare.com/ajax/libs/codemirror/$codeMirrorVersion/mode/go/go.min.js",
'javascript/colorize.js',
'javascript/tabs-for-chunked.js',
'javascript/mp-nav.js',
'javascript/versionswitcher.js',
'javascript/version.js',
'//s3-eu-west-1.amazonaws.com/alpha.neohq.net/docs/new-manual/assets/search.js',
].join(" ")
def styles = [
'//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css',
'//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.1.0/css/font-awesome.min.css',
'//fonts.googleapis.com/css?family=Open+Sans:400,300,400italic,600,300italic',
"//cdnjs.cloudflare.com/ajax/libs/codemirror/$codeMirrorVersion/codemirror.min.css",
"//cdnjs.cloudflare.com/ajax/libs/codemirror/$codeMirrorVersion/theme/neo.min.css",
'css/chunked-base.css',
'css/extra.css'
].join(" ")
inputs.dir sourceDir
input sourceFile
// Stylesheet parameters
parameters([
"base.dir": "${outputDir}",
"html.ext": ".html",
"make.clean.html": "1",
"chunker.output.method": "html",
"chunker.output.encoding": "UTF-8",
"chunker.output.indent": "yes",
"use.id.as.dirname": "1",
"html.stylesheet": styles,
"html.script": scripts,
"neo.newsearch": "1",
"neo.documentation.library.links": libraryLinks,
"toc-filename": "${outputDir}/toc.html",
"generate.toc": "''",
"chunk.toc": "${contentMap}",
"header.rule": "0",
"target.database.document": "file://${olinkdb}",
"current.docid": docId,
])
doLast {
copy {
from(docbook.outputDir) {
include 'images/**'
}
from(projectDir) {
include 'javascript/**'
include 'css/**'
}
into outputDir
}
}
}
task packageHtml(type: Tar, dependsOn: [html, sitemap]) {
description 'Package HTML for distribution.'
baseName 'driver-manual'
extension 'tar.gz'
version versions.driverDocs
compression = Compression.GZIP
from { html }
from { sitemap }
into "$baseName/$version"
destinationDir file(distDir)
}
task pdf(dependsOn: [prepareDriverSources, unzipDownloadedFonts]) {
description 'Build PDF.'
ext.sourceDir = asciidocSourceDir
ext.sourceFile = file("$sourceDir/index.adoc")
ext.outputDir = "$buildDir/pdf/"
ext.outputFilename = "neo4j-driver-manual-${versions.driverDocs}.pdf"
ext.imagesDir = "images"
inputs.dir sourceDir
def pdfStylesDir = "${rootProject.projectDir}/src/main/pdf-theme"
def pdfFontDir = "${buildDir}/fonts"
def forLang
// outputs.dir outputDir
doLast {
project.ext.driverLanguages.each { lang, info ->
println "[+] Driver Manual PDF for ${lang}"
switch (lang) {
case "dotnet" : forLang = "for C#"; break;
case "java" : forLang = "for Java"; break;
case "javascript" : forLang = "for JavaScript"; break;
case "python" : forLang = "for Python"; break;
case "go" : forLang = "for Go"; break;
default: forLang = "";
}
def attrs = asciidoctorAttributes.common + asciidoctorAttributes.pdf + [
('include-with-' + lang) : true,
'driver-manual-version' : versions.driverDocs,
'project-root' : "${rootProject.projectDir}",
'imagesdir' : imagesDir.toString(),
'pdf-stylesdir' : pdfStylesDir.toString(),
'pdf-fontsdir' : pdfFontDir.toString(),
'for-lang' : forLang
]
def opts = org.asciidoctor.OptionsBuilder.options()
.backend('pdf')
.safe(org.asciidoctor.SafeMode.UNSAFE)
.toFile(file("$outputDir/neo4j-driver-manual-${versions.driverDocs}-${lang}.pdf"))
.mkDirs(true)
.attributes(attrs)
getAsciidoctor(true).convertFile(sourceFile, opts.get())
}
}
}
task packagePdf(type: Copy, dependsOn: pdf) {
from (pdf.outputDir) {
include '*.pdf'
}
into "$distDir/pdf"
}
assemble.dependsOn packageHtml, pdf
check.dependsOn vale
// vim: set fdm=expr: