/
documentation.gradle
73 lines (65 loc) · 2.04 KB
/
documentation.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
buildscript {
repositories {
maven { url 'https://repo.grails.org/grails/core' }
}
dependencies {
classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.3'
classpath 'org.asciidoctor:asciidoctorj-epub3:1.5.0-alpha.6'
classpath 'org.asciidoctor:asciidoctorj-pdf:1.5.0-alpha.11'
}
}
apply plugin: 'org.asciidoctor.convert'
def asciidoctorAttributes = [
copyright : 'Apache License, Version 2.0',
docinfo1 : 'true',
doctype : 'book',
encoding : 'utf-8',
icons : 'font',
id : project.name + ':' + project.version,
idprefix : '',
idseparator : '-',
lang : 'en',
linkattrs : true,
numbered : '',
producer : 'Asciidoctor',
revnumber : project.version,
setanchors : true,
'source-highlighter' : 'prettify',
toc : 'left',
toc2 : '',
toclevels : '2',
grailsVersion : project.grailsVersion,
ckeditorVersion : project.ckeditorVersion
]
import org.asciidoctor.gradle.AsciidoctorTask
tasks.withType(AsciidoctorTask) {
attributes asciidoctorAttributes
outputDir new File(buildDir, 'docs/docs')
separateOutputDirs = false
sourceDir = file('src/docs')
sources {
include 'index.adoc'
}
}
task asciidoc(type: AsciidoctorTask, description: 'Generates single-page HTML and PDF') {
backends 'html5', 'pdf'
}
task docs(dependsOn: [asciidoc]) << {
File dir = new File(buildDir, 'docs/docs')
['pdf'].each { String ext ->
File f = new File(dir, 'index.' + ext)
if (f.exists()) {
f.renameTo new File(dir, project.name + '-' + project.version + '.' + ext)
}
}
File ghpages = new File(buildDir, 'docs/index.html')
if (ghpages.exists()) {
ghpages.delete()
}
ghpages << file('src/docs/index.tmpl').text.replaceAll('@VERSION@', project.version)
copy {
from 'src/docs'
into new File(buildDir, 'docs').path
include '**/*.png'
}
}