This repository was archived by the owner on Dec 11, 2024. It is now read-only.
forked from mstein/elasticsearch-grails-plugin
-
Notifications
You must be signed in to change notification settings - Fork 80
/
Copy pathdocumentation.gradle
84 lines (75 loc) · 2.67 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
74
75
76
77
78
79
80
81
82
83
84
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,
elasticsearchVersion: project.elasticsearchVersion
]
import org.asciidoctor.gradle.AsciidoctorTask
tasks.withType(AsciidoctorTask) {
attributes asciidoctorAttributes
outputDir new File(buildDir, 'docs/manual')
separateOutputDirs = false
sourceDir = file('src/docs')
sources {
include 'index.adoc'
include 'ref/index.adoc'
}
}
task asciidoc(type: AsciidoctorTask, description: 'Generates single-page HTML and PDF') {
backends 'html5', 'pdf'
}
task docs(dependsOn: [asciidoc]) {
doLast {
File dir = new File(buildDir, 'docs/manual')
['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 quickRefDir = new File(buildDir, 'docs/manual/ref')
['pdf'].each { String ext ->
File f = new File(quickRefDir, 'index.' + ext)
if (f.exists()) {
f.renameTo new File(quickRefDir, project.name + '-' + project.version + '-' + 'quickReference' + '.' + 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/manual').path
include '**/*.png'
}
}
}