-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAsciiDocBasics.gradle
247 lines (205 loc) · 6.18 KB
/
AsciiDocBasics.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
/*
* This build file is part of the docToolchain
*/
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.7'
}
}
import org.asciidoctor.gradle.AsciidoctorTask
configurations.all {
resolutionStrategy {
force 'org.codehaus.groovy:groovy-all:2.4.12'
}
}
// configuration
def config
if (docDir.startsWith('.')) {
docDir = new File(projectDir, docDir).canonicalPath
}
if (pdfThemeDir.startsWith('.')) {
pdfThemeDir = new File(projectDir, pdfThemeDir).canonicalPath
}
logger.info "docToolchain> docDir: ${docDir}"
logger.info "docToolchain> mainConfigFile: ${mainConfigFile}"
logger.info "docToolchain> pdfThemeDir: ${pdfThemeDir}"
def configSlurper = new ConfigSlurper()
configSlurper.setBinding([inputPath: inputPath])
config = configSlurper.parse(new File(docDir, mainConfigFile).text)
logger.info "docToolchain> inputPath: ${inputPath}"
logger.info "docToolchain> inputFiles: ${config.inputFiles}"
logger.info "docToolchain> outputPath: ${config.outputPath}"
ext {
srcDir = "${docDir}/${inputPath}"
targetDir = "${docDir}/${config.outputPath}"
javaVersion = System.getProperty("java.version")
currentDate = new Date().format("d. MMM yyyy")
// where HTMLSanityCheck checking results ares stored
checkingResultsPath = "${docDir}/${config.outputPath}/report/htmlchecks"
sourceFiles = config.inputFiles
}
dependencies {
asciidoctor 'org.asciidoctor:asciidoctorj-pdf:1.5.0-alpha.17'
// carefull!
// asciidoctor 1.5.6 needs diagram 1.5.4.1
// but then reveal.js is broken...
// https://github.com/asciidoctor/asciidoctor-diagram/issues/161
asciidoctor 'org.asciidoctor:asciidoctorj-diagram:1.5.16'
}
asciidoctorj {
version = '1.5.8'
}
//tag::AsciidoctorTask[]
// common settings for asciidoctor
// this is needed for PDF generation with plantUML
tasks.withType(org.asciidoctor.gradle.AsciidoctorTask) { docTask ->
config.taskInputsDirs.each {
inputs.dir new File(docDir, it)
}
config.taskInputsFiles.each {
inputs.file new File(docDir, it)
}
// configure source and output files and folders
outputDir = file(targetDir)
sourceDir = file(srcDir)
attributes \
'pdf-stylesdir': "${pdfThemeDir}@",
'pdf-style': 'custom@',
'source-highlighter': 'coderay@',
'imagesdir': 'images@',
'toc': 'left@',
'icons': 'font@',
'javaVersion' : "$javaVersion",
'currentDate' : "$currentDate",
'allow-uri-read' : 'true@',
// 'sectanchors@' : true,
'manualdir' : "https://github.com/docToolchain/docToolchain/edit/master/src/docs/",
'targetDir' : targetDir
// Here we can add the code for extensions we write.
extensions {
inlinemacro (name: "jira") {
parent, target, attributes ->
options = [
"type": ":link",
"target": jiraRoot+"/browse/${target}".toString(),
"id": "${target}"
]
// Create the link to the issue.
createInline(parent, "anchor", target, attributes, options).render()
}
}
// good to see what the build is doing...
logDocuments = true
requires = ['asciidoctor-diagram']
}
//end::AsciidoctorTask[]
//tag::generateHTML[]
task generateHTML (
type: AsciidoctorTask,
group: 'docToolchain',
description: 'use html5 as asciidoc backend') {
attributes \
'plantUMLDir' : ''
onlyIf {
!sourceFiles.findAll {
'html' in it.formats
}.empty
}
sources {
sourceFiles.findAll {
'html' in it.formats
}.each {
include it.file
}
}
backends = ['html5']
}
//end::generateHTML[]
//tag::generatePDF[]
task generatePDF (
type: AsciidoctorTask,
group: 'docToolchain',
description: 'use pdf as asciidoc backend') {
attributes \
'plantUMLDir' : file("${docDir}/${config.outputPath}/images/plantUML/").path
onlyIf {
!sourceFiles.findAll {
'pdf' in it.formats
}.empty
}
sources {
sourceFiles.findAll {
'pdf' in it.formats
}.each {
include it.file
}
}
backends = ['pdf']
}
//end::generatePDF[]
//tag::generateDocbook[]
task generateDocbook (
type: AsciidoctorTask,
group: 'docToolchain',
description: 'use docbook as asciidoc backend') {
onlyIf {
!sourceFiles.findAll {
'docbook' in it.formats
}.empty
}
sources {
sourceFiles.findAll {
'docbook' in it.formats
}.each {
include it.file
}
}
backends = ['docbook']
}
//end::generateDocbook[]
//tag::generateDeck[]
task generateDeck (
type: AsciidoctorTask,
group: 'docToolchain',
description: 'use revealJs as asciidoc backend to create a presentation') {
attributes \
'plantUMLDir' : '',
'idprefix': 'slide-',
'idseparator': '-',
'docinfo1': '',
'revealjs_theme': 'black',
'revealjs_progress': 'true',
'revealjs_touch': 'true',
'revealjs_hideAddressBar': 'true',
'revealjs_transition': 'linear',
'revealjs_history': 'true',
'revealjs_slideNumber': 'true'
options template_dirs : [new File('resources/asciidoctor-reveal.js','templates/slim').absolutePath ]
onlyIf {
!sourceFiles.findAll {
'revealjs' in it.formats
}.empty
}
sources {
sourceFiles.findAll {
'revealjs' in it.formats
}.each {
include it.file
}
}
outputDir = file(targetDir+'/decks/')
resources {
from('resources') {
include 'reveal.js/**'
}
from(sourceDir) {
include 'images/**'
}
into("ppt")
logger.info "${docDir}/${config.outputPath}/ppt/images"
}
}
//end::generateDeck[]