Project

Profile

Help

How to connect?
Download (27 KB) Statistics
| Branch: | Revision:

he / build-doc.gradle @ ce99b9c2

1
task clone_expath_cg(
2
  type: Exec,
3
  description: "Clones the expath-cg github repository for doc builds"
4
) {
5
  commandLine "git",
6
    "clone",
7
    "https://github.com/expath/expath-cg.git",
8
    "${buildDir}/expath-cg"
9
}
10
clone_expath_cg.onlyIf {
11
  !file("${buildDir}/expath-cg").exists()
12
}
13

    
14
// ============================================================
15

    
16
task documentation(
17
  dependsOn: ["update_documentation", "gen_contents_ref", "gen_feature_matrix"],
18
  description: "Build the documentation and pages for website"
19
) {
20
  // Just a place to hang dependencies
21
}
22

    
23
// ============================================================
24

    
25
task filter_sources_for_javadoc(
26
  type: Copy,
27
  description: "Copy the Java source files for making JavaDoc (excludes some classes)"
28
) {
29
  inputs.files fileTree(dir: "${projectDir}/src/main/java")
30
  outputs.files fileTree(dir: "${buildDir}/javadoc_src")
31
  
32
  // N.B. these exclusions are also applied in the tasks below.
33
  into "${buildDir}/javadoc_src"
34
  from ("${projectDir}/src/main/java") {
35
    include "net/**"
36
    include "com/**"
37
    include "javax/**"
38
    exclude "**/dotnet/**"
39
    exclude "net/sf/saxon/option/cpp/**"
40
    exclude "net/sf/saxon/testdriver/**"
41
    exclude "com/saxonica/functions/extfn/cpp/**"
42
    exclude "com/saxonica/js/**"
43
    exclude "com/saxonica/testdriver/**"
44
    exclude "com/saxonica/config/DotNetExtensionFunctionFactory.java"
45
    exclude "com/saxonica/config/DotNetExtensionLibrary.java"
46
    exclude "com/saxonica/config/DotNetPlatformPE.java"
47
    exclude "com/saxonica/config/JavaPlatformC.java"
48
    exclude "com/saxonica/expr/DotNetExtensionFunctionCall.java"
49
  }
50
}
51

    
52
task product_javadoc(
53
  type: Exec,
54
  dependsOn: ["filter_sources_for_javadoc"],
55
  description: "Generate Javadoc files"
56
) {
57
  // If you can't do something the easy way, do it the hard way.
58
  // The Gradle JavaDoc plugin should be able to do this, but it doesn't
59
  // do the right thing and it's completely unclear why. (The symptom that
60
  // forced me to resort to this approach was including every file twice.)
61
  inputs.files fileTree(dir: "${buildDir}/javadoc_src")
62
  outputs.files fileTree(dir: "${buildDir}/javadoc")
63

    
64
  def cp = ""
65
  configurations.documentation.resolve().each { path ->
66
    cp = cp + System.getProperty("path.separator") + path
67
  }
68

    
69
  // Any directory that contains a java file is assumed to be a
70
  // package...because that's the way packages work in Java.
71
  // Frustratingly, we have to base this on the main source directory,
72
  // not the one created by filter_sources_for_javadoc because this
73
  // calculation runs during the Gradle configuration phase when
74
  // that directory might not yet exist. FIXME: do this better
75
  def packages = [:]
76
  fileTree(dir: "${projectDir}/src/main/java",
77
           include: ["net/**", "com/**", "javax/**"],
78
           exclude: ["**/dotnet/**",
79
                     "net/sf/saxon/option/cpp/**",
80
                     "net/sf/saxon/testdriver/**",
81
                     "com/saxonica/functions/extfn/cpp/**",
82
                     "com/saxonica/js/**",
83
                     "com/saxonica/testdriver/**",
84
                     "com/saxonica/config/DotNetExtensionFunctionFactory.java",
85
                     "com/saxonica/config/DotNetExtensionLibrary.java",
86
                     "com/saxonica/config/DotNetPlatformPE.java",
87
                     "com/saxonica/config/JavaPlatformC.java",
88
                     "com/saxonica/expr/DotNetExtensionFunctionCall.java"]).each { pkg ->
89
    def fn = pkg.toString()
90
    fn = fn.substring("{$projectDir}/src/main/java".length()-1)
91
    def pos = fn.lastIndexOf("/")
92
    fn = fn.substring(0, pos).replaceAll("/", ".")
93
    packages[fn] = 1
94
  }
95

    
96
  def command = ["javadoc",
97
                 "-sourcepath", "${buildDir}/javadoc_src",
98
                 "-Xdoclint:none",
99
                 "-d", "${buildDir}/javadoc",
100
                 "-protected",
101
                 "-classpath", cp,
102
                 "-bottom", "Copyright (c) 2004-2021 Saxonica Limited. All rights reserved.",
103
                 "-doctitle", "Saxon ${saxonVersion} Java API Documentation",
104
                 "-group", "s9api Interface", "net.sf.saxon.s9api",
105
                 "-group", "Other Interfaces", "net.sf.saxon:net.sf.saxon.lib:net.sf.saxon.om:net.sf.saxon.query:net.sf.saxon.sxpath:net.sf.saxon.value:net.sf.saxon.type:net.sf.saxon.xpath:net.sf.saxon.xqj",
106
                 "-group", "External Interfaces", "javax.xml.xquery",
107
                 "-source", "1.8"] + packages.keySet()
108

    
109
  commandLine command
110

    
111
  doFirst {
112
      mkdir "${buildDir}/javadoc"
113
    }
114
}
115

    
116
task product_jeljavadoc(
117
  type: Exec,
118
  dependsOn: ["filter_sources_for_javadoc"],
119
  description: "Generate Javadoc XML files"
120
) {
121
  // If you can't do something the easy way, do it the hard way.
122
  // The Gradle JavaDoc plugin should be able to do this, but it doesn't
123
  // do the right thing with package descriptions and it's completely
124
  // unclear why.
125
  inputs.files fileTree(dir: "${buildDir}/javadoc_src")
126
  inputs.file "${projectDir}/lib/jeldoc.jar"
127
  outputs.files fileTree(dir: "${buildDir}/jeljavadoc")
128

    
129
  def cp = ""
130
  configurations.documentation.resolve().each { path ->
131
    cp = cp + System.getProperty("path.separator") + path
132
  }
133

    
134
  // Any directory that contains a java file is assumed to be a
135
  // package...because that's the way packages work in Java.
136
  // Frustratingly, we have to base this on the main source directory,
137
  // not the one created by filter_sources_for_javadoc because this
138
  // calculation runs during the Gradle configuration phase when
139
  // that directory might not yet exist. FIXME: do this better
140
  def packages = [:]
141
  fileTree(dir: "${projectDir}/src/main/java",
142
           include: ["net/**", "com/**", "javax/**"],
143
           exclude: ["**/dotnet/**",
144
                     "net/sf/saxon/option/cpp/**",
145
                     "net/sf/saxon/testdriver/**",
146
                     "com/saxonica/functions/extfn/cpp/**",
147
                     "com/saxonica/js/**",
148
                     "com/saxonica/testdriver/**",
149
                     "com/saxonica/config/DotNetExtensionFunctionFactory.java",
150
                     "com/saxonica/config/DotNetExtensionLibrary.java",
151
                     "com/saxonica/config/DotNetPlatformPE.java",
152
                     "com/saxonica/config/JavaPlatformC.java",
153
                     "com/saxonica/expr/DotNetExtensionFunctionCall.java"]).each { pkg ->
154
    def fn = pkg.toString()
155
    fn = fn.substring("{$projectDir}/src/main/java".length()-1)
156
    def pos = fn.lastIndexOf("/")
157
    fn = fn.substring(0, pos).replaceAll("/", ".")
158
    packages[fn] = 1
159
  }
160

    
161
  def command = ["javadoc",
162
                 "-sourcepath", "${buildDir}/javadoc_src",
163
                 "-d", "${buildDir}/jeljavadoc",
164
                 "-package",
165
                 "-filename", "jeldoclet-out.xml",
166
                 "-includeNamespace",
167
                 "-outputEncoding", "utf-8",
168
                 "-classpath", cp,
169
                 "-doclet", "com.jeldoclet.JELDoclet",
170
                 "-docletpath", cp,
171
                 "-source", "1.8"] + packages.keySet()
172

    
173
  commandLine command
174

    
175
  doFirst {
176
      mkdir "${buildDir}/jeljavadoc"
177
    }
178
}
179

    
180
task product_xsljavadoc(
181
  type: JavaExec,
182
  dependsOn: ["product_jeljavadoc"],
183
  description: "Convert javadoc XML into format for documentation"
184
) {
185
  inputs.files fileTree(dir: "${buildDir}/jeljavadoc")
186
  inputs.file "${projectDir}/tools/docs/javadoc/chunk-javadoc.xsl"
187
  outputs.files fileTree(dir: "${buildDir}/javadoc-xml")
188
  classpath = configurations.documentation
189
  main = "com.saxonica.Transform"
190
  args "-s:${buildDir}/jeljavadoc/jeldoclet-out.xml",
191
    "-xsl:${projectDir}/tools/docs/javadoc/chunk-javadoc.xsl",
192
    "-o:${buildDir}/javadoc-xml/out",
193
    "base-output=${buildDir}/javadoc-xml/"
194
}
195

    
196
task javadoc_linkchecker(
197
  type: JavaExec,
198
  dependsOn: ["product_xsljavadoc"],
199
  description: "Generate report of links"
200
) {
201
  inputs.files fileTree(dir: "${buildDir}/javadoc-xml")
202
  inputs.file "${projectDir}/tools/docs/javadoc/check-tag-links.xsl"
203
  outputs.file "${buildDir}/javadoc-tag-check.xml"
204
  classpath = configurations.documentation
205
  main = "com.saxonica.Transform"
206
  args "-s:${buildDir}/javadoc-xml/javadoc-types.xml",
207
    "-xsl:${projectDir}/tools/docs/javadoc/check-tag-links.xsl",
208
    "-o:${buildDir}/javadoc-tag-check.xml"
209
}
210

    
211
task dotnet_doc_parsecs(
212
  type: JavaExec,
213
  dependsOn: ["een_csharpApi"],
214
  description: "Parse dotnet cs files for docs"
215
) {
216
  inputs.files fileTree(dir: "${buildDir}/n/csharp/api/Saxon.Api")
217
  inputs.file "${projectDir}/tools/docs/dotnet/parsecs.xsl"
218
  outputs.file "${buildDir}/dotnetdoc/names.xml"
219
  classpath = configurations.documentation
220
  main = "com.saxonica.Transform"
221
  args "-it:main",
222
    "-s:${projectDir}/tools/docs/dotnet/parsecs.xsl",
223
    "-xsl:${projectDir}/tools/docs/dotnet/parsecs.xsl",
224
    "-o:${buildDir}/dotnetdoc/names.xml",
225
    "inputdir=${buildDir}/n/csharp/api/Saxon.Api"
226
}
227

    
228
task dotnet_doc_merge(
229
  type: JavaExec,
230
  dependsOn: ["dotnet_doc_parsecs"],
231
  description: "Merge API docs for dotnet"
232
) {
233
  inputs.file "${buildDir}/dotnetdoc/names.xml"
234
  inputs.file "${buildDir}/n/saxon-ee-api-${saxonVersion}.xml"
235
  inputs.file "${projectDir}/tools/docs/dotnet/merge.xsl"
236
  outputs.file "${buildDir}/dotnetdoc/merged.xml"
237
  classpath = configurations.documentation
238
  main = "com.saxonica.Transform"
239
  args "-it:main",
240
    "-s:${buildDir}/dotnetdoc/names.xml",
241
    "-xsl:${projectDir}/tools/docs/dotnet/merge.xsl",
242
    "-o:${buildDir}/dotnetdoc/merged.xml",
243
    "names-file=${buildDir}/dotnetdoc/names.xml",
244
    "api-doc-file=${buildDir}/n/saxon-ee-api-${saxonVersion}.xml"
245
}
246

    
247
task dotnet_doc_css(
248
  type: Copy,
249
  description: "Copies the CSS for dotnet docs"
250
) {
251
  into "${buildDir}/dotnetdoc-html"
252
  from "${projectDir}/tools/docs/dotnet/saxon-dotnetdoc.css"
253
}
254

    
255
task dotnet_doc_html(
256
  type: JavaExec,
257
  dependsOn: ["dotnet_doc_merge", "dotnet_doc_css"],
258
  description: "Create HTML output for dotnet docs"
259
) {
260
  inputs.file "${buildDir}/dotnetdoc/merged.xml"
261
  inputs.file "${projectDir}/tools/docs/dotnet/tohtml.xsl"
262
  outputs.file "${buildDir}/dotnetdoc-html/index.html"
263
  classpath = configurations.documentation
264
  main = "com.saxonica.Transform"
265
  args "-s:${buildDir}/dotnetdoc/merged.xml",
266
    "-xsl:${projectDir}/tools/docs/dotnet/tohtml.xsl",
267
    "-o:${buildDir}/dotnetdoc-html/index.html"
268
}
269

    
270
task dotnet_doc_jel(
271
  type: JavaExec,
272
  dependsOn: ["dotnet_doc_merge"],
273
  description: "Create HTML output for dotnet docs"
274
) {
275
  inputs.file "${buildDir}/dotnetdoc/merged.xml"
276
  inputs.file "${projectDir}/tools/docs/dotnet/convert-to-jel-package.xsl"
277
  outputs.file "${buildDir}/dotnetdoc-xml/packages/Saxon.Api.xml"
278
  classpath = configurations.documentation
279
  main = "com.saxonica.Transform"
280
  args "-s:${buildDir}/dotnetdoc/merged.xml",
281
    "-xsl:${projectDir}/tools/docs/dotnet/convert-to-jel-package.xsl",
282
    "-o:${buildDir}/dotnetdoc-xml/packages/Saxon.Api.xml"
283
}
284

    
285
task app_dotnetdoc(
286
  type: Copy,
287
  dependsOn: ["dotnet_doc_jel"],
288
  description: "Copy the XML dotnet docs to the viewer app"
289
) {
290
  into "${buildDir}/userdoc/viewer_appJS/dotnetdoc-xml"
291
  from "${buildDir}/dotnetdoc-xml"
292
}
293

    
294
task app_javadoc(
295
  type: Copy,
296
  dependsOn: ["product_xsljavadoc"],
297
  description: "Copy the XML javadoc docs to the viewer app"
298
) {
299
  into "${buildDir}/userdoc/viewer_appJS/javadoc-xml"
300
  from "${buildDir}/javadoc-xml"
301
}
302

    
303
task resources_dotnetdoc(
304
  dependsOn: ["resources_dotnetdoc_css", "resources_dotnetdoc_apidoc"],
305
  description: "Copy dotnet files into the resources folder"
306
) {
307
  // nop
308
}
309

    
310
task resources_dotnetdoc_css(
311
  type: Copy,
312
  dependsOn: ["dotnet_doc_jel"],
313
  description: "Copy the dotnet CSS into the resources folder"
314
) {
315
  into "${buildDir}/resources/doc/dotnetdoc"
316
  from ("${projectDir}/tools/docs/dotnet") {
317
    include "saxon-dotnetdoc.css"
318
  }
319
}
320

    
321
task resources_dotnetdoc_apidoc(
322
  type: Copy,
323
  dependsOn: ["dotnet_doc_jel"],
324
  description: "Copy the dotnet API docs into the resources folder"
325
) {
326
  into "${buildDir}/resources/doc/dotnetdoc"
327
  from ("${buildDir}/n") {
328
    include "saxon-ee-api-${saxonVersion}.xml"
329
    rename("saxon-ee-api-${saxonVersion}.xml", "apidoc.xml")
330
  }
331
}
332

    
333
// ============================================================
334

    
335
task gen_doc(
336
  dependsOn: ["gen_doc_icu_uca", "gen_xslt_element_reference",
337
              "gen_xslt_element_reference", "element_doc", "expath_doc",
338
              "doc_FeatureKeysDoc", "doc_ConfigFileDoc"],
339
  description: "Collects up, generates and copies the documentation source into the canonical location"
340
) {
341
  // Just a place to hang dependencies
342
}  
343

    
344
task copy_userdoc_sources(
345
  type: Copy,
346
  dependsOn: ["copy_userdoc_implement"],
347
  description: "Copy the 'real', unpreprocessed sources"
348
) {
349
  into "${buildDir}/userdoc/src"
350
  from ("${projectDir}/src/userdoc") {
351
    // Excluded files are transformed by other tasks into "src" for the docbuild
352
    exclude "extensions/**"
353
    exclude "elements/**"
354
  }
355
}
356

    
357
task copy_userdoc_implement(
358
  type: Copy,
359
  description: "Copy the app implement file"
360
) {
361
  from "${projectDir}/src/viewer_appJS/doc"
362
  into "${buildDir}/userdoc/src"
363
}
364

    
365
task doc_FeatureKeysDoc(
366
  type: JavaExec,
367
  dependsOn: ["copy_userdoc_sources"],
368
  description: "Construct the documentation for feature keys"
369
) {
370
  inputs.files fileTree(dir: "${projectDir}/tools/featureKeys")
371
  outputs.file "${buildDir}/userdoc/src/featureKeys/FeatureKeysDoc.xml"
372
  classpath = configurations.preprocessor
373
  main = "net.sf.saxon.Transform"
374
  args "${projectDir}/tools/featureKeys/FeatureKeys.xml",
375
    "-xsl:${projectDir}/tools/featureKeys/FeatureKeysToDoc.xsl",
376
    "-o:${buildDir}/userdoc/src/featureKeys/FeatureKeysDoc.xml"
377
}
378

    
379
task doc_ConfigFileDoc(
380
  type: JavaExec,
381
  dependsOn: ["copy_userdoc_sources", "doc_FeatureKeysDoc"],
382
  description: "Construct the documentation for the configuration file"
383
) {
384
  inputs.files fileTree(dir: "${projectDir}/tools/featureKeys")
385
  outputs.files fileTree(dir: "${buildDir}/userdoc/src/featureKeys")
386
  classpath = configurations.preprocessor
387
  main = "net.sf.saxon.Transform"
388
  args "${projectDir}/tools/featureKeys/AdditionalFeatures.xml",
389
    "-xsl:${projectDir}/tools/featureKeys/ToConfigFileDoc.xsl",
390
    "-o:${buildDir}/userdoc/src/featureKeys/ConfigFileDoc.xml"
391
}
392

    
393
task gen_doc_icu_uca(
394
  type: JavaExec,
395
  dependsOn: ["copy_userdoc_sources"],
396
  description: "Generate the ICU/UCA documentation"
397
) {
398
  inputs.files fileTree(dir: "${projectDir}/src/userdoc")
399
  inputs.files fileTree(dir: "${projectDir}/tools/docs/userdoc")
400
  outputs.files fileTree(dir: "${buildDir}/userdoc/src/extensibility")
401
  classpath = configurations.documentation
402
  main = "com.saxonica.Transform"
403
  args "-it:go",
404
    "-s:${projectDir}/src/userdoc/catalog.xml",
405
    "-xsl:${projectDir}/tools/docs/userdoc/document-ICU.xsl",
406
    "output=${buildDir}/userdoc/src/extensibility/"
407
}
408

    
409
task gen_xslt_element_reference_preprocess(
410
  type: JavaExec,
411
  dependsOn: ["copy_userdoc_sources"],
412
  description: "Preprocess input for the XSLT Element reference documentation"
413
) {
414
  inputs.files fileTree(dir: "${projectDir}/src/userdoc/elements")
415
  inputs.files fileTree(dir: "${projectDir}/tools/docs/userdoc")
416
  outputs.file "${buildDir}/userdoc/tmp/xsl-elements-expanded.xml"
417
  classpath = configurations.documentation
418
  main = "com.saxonica.Transform"
419
  args "-s:${projectDir}/src/userdoc/elements/xsl-elements.xml",
420
    "-o:${buildDir}/userdoc/tmp/xsl-elements-expanded.xml",
421
    "-xsl:${projectDir}/tools/docs/userdoc/genElementDoc.xsl"
422
}
423

    
424
task gen_xslt_element_reference(
425
  type: JavaExec,
426
  dependsOn: ["gen_xslt_element_reference_preprocess"],
427
  description: "Generate the XSLT Element reference documentation"
428
) {
429
  inputs.file "${buildDir}/userdoc/tmp/xsl-elements-expanded.xml" 
430
  inputs.files fileTree(dir: "${projectDir}/tools/docs/userdoc")
431
  outputs.file "${buildDir}/userdoc/src/xsl-elements.xml"
432
  classpath = configurations.documentation
433
  main = "com.saxonica.Transform"
434
  args "-s:${buildDir}/userdoc/tmp/xsl-elements-expanded.xml",
435
    "-xsl:${projectDir}/tools/docs/userdoc/elements-body.xsl",
436
    "-o:${buildDir}/userdoc/src/xsl-elements.xml"
437
}
438

    
439
task element_doc() {
440
  // Just a place to hang dependencies
441
}
442

    
443
["instructions", "serialization-params"].each { target ->
444
  Task t = task "gen_element_doc_${target}"(
445
    type: JavaExec,
446
    description: "Expand element documentation for ${target}"
447
  ) {
448
    inputs.file "${projectDir}/src/userdoc/extensions/${target}.xml"
449
    inputs.files fileTree(dir: "${projectDir}/tools/docs/userdoc")
450
    outputs.file file("${buildDir}/userdoc/src/extensions/${target}.xml")
451
    classpath = configurations.documentation
452
    main = "com.saxonica.Transform"
453
    args "-s:${projectDir}/src/userdoc/extensions/${target}.xml",
454
      "-xsl:${projectDir}/tools/docs/userdoc/elements-body.xsl",
455
      "-o:${buildDir}/userdoc/src/extensions/${target}.xml"
456
  }
457
  element_doc.dependsOn t
458
}  
459

    
460
// Different from preceding because it doesn't go in extensions ¯\_(ツ)_/¯
461
["sql-extension"].each { target ->
462
  Task t = task "gen_element_doc_${target}"(
463
    type: JavaExec,
464
    description: "Expand element documentation for ${target}"
465
  ) {
466
    inputs.file "${projectDir}/src/userdoc/extensions/${target}.xml"
467
    inputs.files fileTree(dir: "${projectDir}/tools/docs/userdoc")
468
    outputs.file "${buildDir}/userdoc/src/${target}.xml"
469
    classpath = configurations.documentation
470
    main = "com.saxonica.Transform"
471
    args "-s:${projectDir}/src/userdoc/extensions/${target}.xml",
472
      "-xsl:${projectDir}/tools/docs/userdoc/elements-body.xsl",
473
      "-o:${buildDir}/userdoc/src/${target}.xml"
474
  }
475
  element_doc.dependsOn t
476
}  
477

    
478
task expath_doc() {
479
  // Just a place to hang dependencies
480
}
481
["binary", "archive", "file"].each { target ->
482
  Task t = task "expath_doc_${target}"(
483
    type: JavaExec,
484
    dependsOn: ["clone_expath_cg"],
485
    description: "Expand EXPath documentation for ${target}"
486
  ) {
487
    inputs.file "${projectDir}/src/userdoc/functions/EXPath/functions-${target}.xml"
488
    inputs.files fileTree(dir: "${projectDir}/tools/docs/userdoc")
489
    outputs.file "${buildDir}/userdoc/src/functions/EXPath/functions-${target}.xml"
490
    classpath = configurations.documentation
491
    main = "com.saxonica.Transform"
492
    args "-xi:on",
493
      "-s:${projectDir}/src/userdoc/functions/EXPath/functions-${target}.xml",
494
      "-xsl:${projectDir}/tools/docs/userdoc/genFunctionDoc.xsl",
495
      "-o:${buildDir}/userdoc/src/functions/EXPath/functions-${target}.xml",
496
      "GitHub=${projectDir}/build"
497
  }
498
  expath_doc.dependsOn t
499
}
500

    
501
task expand_userdoc_sections(
502
  type: JavaExec,
503
  dependsOn: ["gen_doc"],
504
  description: "Expand documentation sections from inclusions for app"
505
) {
506
  inputs.file "${buildDir}/userdoc/src/catalog.xml"
507
  inputs.files fileTree(dir: "${buildDir}/userdoc/src")
508
  inputs.files fileTree(dir: "${projectDir}/tools/docs/userdoc")
509
  outputs.file "${buildDir}/userdoc/expanded/catalog.xml"
510
  classpath = configurations.documentation
511
  main = "com.saxonica.Transform"
512
  args "-xi:on",
513
    "-s:${buildDir}/userdoc/src/catalog.xml",
514
    "-xsl:${projectDir}/tools/docs/userdoc/doc-include.xsl",
515
    "-o:${buildDir}/userdoc/expanded/catalog.xml",
516
    "output-uri=${buildDir}/userdoc/expanded/"
517
}
518

    
519
task userdoc_changes(
520
  type: JavaExec,
521
  dependsOn: ["expand_userdoc_sections"],
522
  description: "Preprocess the changes.xml file to turn it into a standard article"
523
) {
524
  inputs.file "${buildDir}/userdoc/expanded/changes.xml"
525
  inputs.files fileTree(dir: "${projectDir}/tools/docs/to-static")
526
  outputs.file "${buildDir}/userdoc/expanded/changes-article.xml"
527
  classpath = configurations.documentation
528
  main = "com.saxonica.Transform"
529
  args "-s:${buildDir}/userdoc/expanded/changes.xml",
530
    "-xsl:${projectDir}/tools/docs/to-static/c-changes.xsl",
531
    "-o:${buildDir}/userdoc/expanded/changes-article.xml"
532
}
533

    
534
task userdoc_functions(
535
  type: JavaExec,
536
  dependsOn: ["expand_userdoc_sections"],
537
  description: "Preprocess the functions.xml file to turn it into a standard article"
538
) {
539
  inputs.file "${buildDir}/userdoc/expanded/functions.xml"
540
  inputs.files fileTree(dir: "${projectDir}/tools/docs/to-static")
541
  outputs.file "${buildDir}/userdoc/expanded/functions-article.xml"
542
  classpath = configurations.documentation
543
  main = "com.saxonica.Transform"
544
  args "-s:${buildDir}/userdoc/expanded/functions.xml",
545
    "-xsl:${projectDir}/tools/docs/to-static/c-functions.xsl",
546
    "-o:${buildDir}/userdoc/expanded/functions-article.xml"
547
}
548

    
549
// ============================================================
550

    
551
task viewer_app_sef(
552
  type: JavaExec,
553
  description: "Compile the viewer_app stylesheet"
554
) {
555
  inputs.files fileTree(dir: "${projectDir}/src/viewer_appJS/xsl")
556
  outputs.file "${buildDir}/userdoc/viewer_appJS/xsl/viewer_app.sef.json"
557
  classpath = configurations.documentation
558
  main = "com.saxonica.Transform"
559
  args "-xsl:${projectDir}/src/viewer_appJS/xsl/viewer_app.xsl",
560
    "-export:${buildDir}/userdoc/viewer_appJS/xsl/viewer_app.sef.json",
561
    "-target:JS", "-nogo", "-relocate:on", "-ns:##html5",
562
    "--generateByteCode:off",
563
    "SEFbuildDate=${DSTAMP}"
564
}
565

    
566
// ============================================================
567

    
568
task userdoc_html(
569
  dependsOn: ["userdoc_articles"],
570
  description: "Creates the static HTML version of the user documentation"
571
) {
572
  // Just a place to hang dependencies
573
}
574

    
575
task userdoc_articles(
576
  type: JavaExec,
577
  dependsOn: ["expand_userdoc_sections", "app_javadoc", "app_dotnetdoc",
578
              "userdoc_changes", "userdoc_functions"],
579
  description: "Process all the articles"
580
) {
581
  inputs.files fileTree(dir: "${buildDir}/userdoc/expanded")
582
  inputs.files fileTree(dir: "${projectDir}/tools/docs/to-static")
583
  outputs.files fileTree(dir: "${buildDir}/userdoc/html")
584
  classpath = configurations.documentation
585
  main = "com.saxonica.Transform"
586
  args "-s:${buildDir}/userdoc/expanded/catalog.xml",
587
    "-xsl:${projectDir}/tools/docs/to-static/s-viewer_app.xsl",
588
    "-o:${buildDir}/userdoc/html/dummy.xml",
589
    "changes-article=${buildDir}/userdoc/expanded/changes-article.xml",
590
    "functions-article=${buildDir}/userdoc/expanded/functions-article.xml",
591
    "base-uri=${buildDir}/userdoc/html/"
592
}
593

    
594
task userdoc_publish_viewer_appJS(
595
  type: Copy,
596
  description: "Copy viewer_appJS to build"
597
) {
598
  into "${buildDir}/userdoc/viewer_appJS"
599
  from ("${projectDir}/src/viewer_appJS") {
600
    exclude "readme.txt"
601
  }
602
}
603

    
604
task userdoc_viewer_appJS(
605
  type: Copy,
606
  dependsOn: ["userdoc_articles", "userdoc_publish_viewer_appJS", "viewer_app_sef"],
607
  description: "Copy transformed articles to app docs"
608
) {
609
  into "${buildDir}/userdoc/viewer_appJS/doc"
610
  from ("build/userdoc/expanded") {
611
    include "*.xml"
612
    exclude "functions-article.xml"
613
    exclude "changes-article.xml"
614
  }
615
}
616

    
617
task userdoc_publish_javadoc_html(
618
  type: Copy,
619
  dependsOn: ["userdoc_html", "product_javadoc"],
620
  description: "Copy dotnet docs into HTML output"
621
) {
622
  into "${buildDir}/userdoc/html/javadoc"
623
  from "build/javadoc"
624
  doFirst {
625
    mkdir "${buildDir}/userdoc/html/javadoc"
626
  }
627
}
628

    
629
task userdoc_publish_html_images(
630
  type: Copy,
631
  description: "Copy viewer_appJS images to the html output directory"
632
) {
633
  into "${buildDir}/userdoc/html/image"
634
  from "${projectDir}/src/viewer_appJS/image"
635
}
636

    
637
task userdoc_publish_html_style(
638
  type: Copy,
639
  description: "Copy viewer_appJS CSS to the html output directory"
640
) {
641
  into "${buildDir}/userdoc/html"
642
  from "${projectDir}/src/viewer_appJS/viewer_app.css"
643
  filter { line ->
644
    line.contains("url('saxon-base.css')")
645
            ? line.replace("saxon-base.css", "../../saxon-base.css")
646
            : line
647
  }
648
}
649

    
650
task userdoc_publish_html(
651
  type: Copy,
652
  dependsOn: ["userdoc_publish_javadoc_html", "dotnet_doc_html",
653
              "userdoc_publish_html_style", "userdoc_publish_html_images"],
654
  description: "Publish the HTML documentation"
655
) {
656
  into "${buildDir}/userdoc/html/dotnetdoc"
657
  from "build/dotnetdoc-html"
658
  doFirst {
659
    mkdir "${buildDir}/userdoc/html/dotnetdoc"
660
  }
661
}
662

    
663
// ============================================================
664

    
665
task update_documentation(
666
  dependsOn: ["copy_xml_documentation", "copy_html_documentation"],
667
  description: "Update documentation from viewer app"
668
) {
669
  // Just a place to hang dependencies
670
}
671

    
672
task copy_xml_documentation(
673
  type: Copy,
674
  dependsOn: ["userdoc_viewer_appJS"],
675
  description: "Update XML version of documentation from viewer app"
676
) {
677
  into "${buildDir}/website/documentation"
678
  from "${buildDir}/userdoc/viewer_appJS"
679
}
680

    
681
task copy_html_documentation(
682
  type: Copy,
683
  dependsOn: ["userdoc_publish_html"],
684
  description: "Update HTML version of user documentation"
685
) {
686
  into "${buildDir}/website/html/documentation"
687
  from "${buildDir}/userdoc/html"
688
}
689

    
690
// ============================================================
691

    
692
task gen_contents_ref(
693
  type: JavaExec,
694
  dependsOn: ["copy_xml_documentation"],
695
  description: "Creates the contents reference file for the user documentation (used for website pages)"
696
) {
697
  inputs.file "${buildDir}/website/documentation/doc/catalog.xml"
698
  inputs.file "${projectDir}/tools/docs/userdoc/contents-builder.xsl"
699
  outputs.file "${buildDir}/website/documentation/contents.xml"
700
  classpath = configurations.documentation
701
  main = "com.saxonica.Transform"
702
  args "${buildDir}/website/documentation/doc/catalog.xml",
703
    "-xsl:${projectDir}/tools/docs/userdoc/contents-builder.xsl",
704
    "-o:${buildDir}/website/documentation/contents.xml",
705
    "version-number=${saxonMajorVersion}"
706
}
707

    
708
task gen_feature_matrix(
709
        type: JavaExec,
710
        description: "Creates the base feature matrix file for the website"
711
) {
712
  inputs.file "${projectDir}/tools/docs/feature-matrix/feature-matrix.xml"
713
  inputs.file "${projectDir}/tools/docs/feature-matrix/feature-matrix-to-overview-chart.xsl"
714
  outputs.file "${buildDir}/website/products/feature-matrix-${saxonMajorVersion}.xml"
715
  classpath = configurations.documentation
716
  main = "com.saxonica.Transform"
717
  args "${projectDir}/tools/docs/feature-matrix/feature-matrix.xml",
718
          "-xsl:${projectDir}/tools/docs/feature-matrix/feature-matrix-to-overview-chart.xsl",
719
          "-o:${buildDir}/website/products/feature-matrix-${saxonMajorVersion}.xml"
720
}
721

    
722
task gen_prod_desc(
723
        type: JavaExec,
724
        description: "Creates the base product description file"
725
) {
726
  inputs.file "${projectDir}/tools/docs/feature-matrix/feature-matrix.xml"
727
  inputs.file "${projectDir}/tools/docs/feature-matrix/feature-matrix-to-prod-desc.xsl"
728
  outputs.file "${buildDir}/proddesc/prod-desc.xml"
729
  classpath = configurations.documentation
730
  main = "com.saxonica.Transform"
731
  args "${projectDir}/tools/docs/feature-matrix/feature-matrix.xml",
732
          "-xsl:${projectDir}/tools/docs/feature-matrix/feature-matrix-to-prod-desc.xsl",
733
          "-o:${buildDir}/proddesc/prod-desc.xml"
734
}
735

    
736
task gen_prod_desc_fo(
737
        type: JavaExec,
738
        dependsOn: ["gen_prod_desc"],
739
        description: "Creates the FO and HTML versions of the product descriptions"
740
) {
741
  inputs.file "${buildDir}/proddesc/prod-desc.xml"
742
  inputs.file "${projectDir}/tools/docs/feature-matrix/PD/prod-desc-to-fo.xsl"
743
  outputs.file "${buildDir}/proddesc/PD/dummy.xml"
744
  classpath = configurations.documentation
745
  main = "com.saxonica.Transform"
746
  args "${buildDir}/proddesc/prod-desc.xml",
747
          "-xsl:${projectDir}/tools/docs/feature-matrix/PD/prod-desc-to-fo.xsl",
748
          "-o:${buildDir}/proddesc/PD/dummy.xml"
749
}
750

    
751
// TODO Next step to generate the PDFs never worked in Ant, we had to do it manually.
752
// Open each build/proddesc/PD/fo/*.fo document in Oxygen and run from there:
753
// run Apply Configuration Scenario FO PDF (default)
754
// The generated PDFs should then be copied to build/website/products/PD${saxonMajorVersion}/
(6-6/14)