Project

Profile

Help

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

he / build-doc.gradle @ a755f9d7

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
  into "${buildDir}/javadoc_src"
33
  from ("${projectDir}/src/main/java") {
34
    include "net/**"
35
    include "com/**"
36
    include "javax/**"
37
    exclude "**/dotnet/**"
38
    exclude "net/sf/saxon/option/cpp/**"
39
    exclude "net/sf/saxon/testdriver/**"
40
    exclude "com/saxonica/functions/extfn/cpp/**"
41
    exclude "com/saxonica/js/**"
42
    exclude "com/saxonica/testdriver/**"
43
    exclude "com/saxonica/config/DotNetExtensionFunctionFactory.java"
44
    exclude "com/saxonica/config/DotNetExtensionLibrary.java"
45
    exclude "com/saxonica/config/DotNetPlatformPE.java"
46
    exclude "com/saxonica/config/JavaPlatformC.java"
47
    exclude "com/saxonica/expr/DotNetExtensionFunctionCall.java"
48
  }
49
}
50

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

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

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

    
87
  def command = ["javadoc",
88
                 "-sourcepath", "${buildDir}/javadoc_src",
89
                 "-Xdoclint:none",
90
                 "-d", "${buildDir}/javadoc",
91
                 "-package",
92
                 "-classpath", cp,
93
                 "-bottom", "Copyright (c) 2004-2021 Saxonica Limited. All rights reserved.",
94
                 "-doctitle", "Saxon ${saxonVersion} Java API Documentation",
95
                 "-group", "s9api Interface", "net.sf.saxon.s9api",
96
                 "-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",
97
                 "-group", "External Interfaces", "javax.xml.xquery",
98
                 "-source", "1.8"] + packages.keySet()
99

    
100
  commandLine command
101

    
102
  doFirst {
103
      mkdir "${buildDir}/javadoc"
104
    }
105
}
106

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

    
120
  def cp = ""
121
  configurations.documentation.resolve().each { path ->
122
    cp = cp + System.getProperty("path.separator") + path
123
  }
124

    
125
  // Any directory that contains a java file is assumed to be a
126
  // package...because that's the way packages work in Java.
127
  // Frustratingly, we have to base this on the main source directory,
128
  // not the one created by filter_sources_for_javadoc because this
129
  // calculation runs during the Gradle configuration phase when
130
  // that directory might not yet exist. FIXME: do this better
131
  def packages = [:]
132
  fileTree(dir: "${projectDir}/src/main/java",
133
           include: ["net/**", "com/**", "javax/**"],
134
           exclude: ["com/saxonica/testdriver/**",
135
                     "net/sf/saxon/testdriver/**",
136
                     "**/dotnet/**"]).each { pkg ->
137
    def fn = pkg.toString()
138
    fn = fn.substring("{$projectDir}/src/main/java".length()-1)
139
    def pos = fn.lastIndexOf("/")
140
    fn = fn.substring(0, pos).replaceAll("/", ".")
141
    packages[fn] = 1
142
  }
143

    
144
  def command = ["javadoc",
145
                 "-sourcepath", "${buildDir}/javadoc_src",
146
                 "-d", "${buildDir}/jeljavadoc",
147
                 "-package",
148
                 "-filename", "jeldoclet-out.xml",
149
                 "-includeNamespace",
150
                 "-outputEncoding", "utf-8",
151
                 "-classpath", cp,
152
                 "-doclet", "com.jeldoclet.JELDoclet",
153
                 "-docletpath", cp,
154
                 "-source", "1.8"] + packages.keySet()
155

    
156
  commandLine command
157

    
158
  doFirst {
159
      mkdir "${buildDir}/jeljavadoc"
160
    }
161
}
162

    
163
task product_xsljavadoc(
164
  type: JavaExec,
165
  dependsOn: ["product_jeljavadoc"],
166
  description: "Convert javadoc XML into format for documentation"
167
) {
168
  inputs.files fileTree(dir: "${buildDir}/jeljavadoc")
169
  inputs.file "${projectDir}/tools/docs/javadoc/chunk-javadoc.xsl"
170
  outputs.files fileTree(dir: "${buildDir}/javadoc-xml")
171
  classpath = configurations.documentation
172
  main = "com.saxonica.Transform"
173
  args "-s:${buildDir}/jeljavadoc/jeldoclet-out.xml",
174
    "-xsl:${projectDir}/tools/docs/javadoc/chunk-javadoc.xsl",
175
    "-o:${buildDir}/javadoc-xml/out",
176
    "base-output=${buildDir}/javadoc-xml/"
177
}
178

    
179
task javadoc_linkchecker(
180
  type: JavaExec,
181
  dependsOn: ["product_xsljavadoc"],
182
  description: "Generate report of links"
183
) {
184
  inputs.files fileTree(dir: "${buildDir}/javadoc-xml")
185
  inputs.file "${projectDir}/tools/docs/javadoc/check-tag-links.xsl"
186
  outputs.file "${buildDir}/javadoc-tag-check.xml"
187
  classpath = configurations.documentation
188
  main = "com.saxonica.Transform"
189
  args "-s:${buildDir}/javadoc-xml/javadoc-types.xml",
190
    "-xsl:${projectDir}/tools/docs/javadoc/check-tag-links.xsl",
191
    "-o:${buildDir}/javadoc-tag-check.xml"
192
}
193

    
194
task dotnet_doc_parsecs(
195
  type: JavaExec,
196
  dependsOn: ["een_csharpApi"],
197
  description: "Parse dotnet cs files for docs"
198
) {
199
  inputs.files fileTree(dir: "${buildDir}/n/csharp/api/Saxon.Api")
200
  inputs.file "${projectDir}/tools/docs/dotnet/parsecs.xsl"
201
  outputs.file "${buildDir}/dotnetdoc/names.xml"
202
  classpath = configurations.documentation
203
  main = "com.saxonica.Transform"
204
  args "-it:main",
205
    "-s:${projectDir}/tools/docs/dotnet/parsecs.xsl",
206
    "-xsl:${projectDir}/tools/docs/dotnet/parsecs.xsl",
207
    "-o:${buildDir}/dotnetdoc/names.xml",
208
    "inputdir=${buildDir}/n/csharp/api/Saxon.Api"
209
}
210

    
211
task dotnet_doc_merge(
212
  type: JavaExec,
213
  dependsOn: ["dotnet_doc_parsecs"],
214
  description: "Merge API docs for dotnet"
215
) {
216
  inputs.file "${buildDir}/dotnetdoc/names.xml"
217
  inputs.file "${buildDir}/n/saxon-ee-api-${saxonVersion}.xml"
218
  inputs.file "${projectDir}/tools/docs/dotnet/merge.xsl"
219
  outputs.file "${buildDir}/dotnetdoc/merged.xml"
220
  classpath = configurations.documentation
221
  main = "com.saxonica.Transform"
222
  args "-it:main",
223
    "-s:${buildDir}/dotnetdoc/names.xml",
224
    "-xsl:${projectDir}/tools/docs/dotnet/merge.xsl",
225
    "-o:${buildDir}/dotnetdoc/merged.xml",
226
    "names-file=${buildDir}/dotnetdoc/names.xml",
227
    "api-doc-file=${buildDir}/n/saxon-ee-api-${saxonVersion}.xml"
228
}
229

    
230
task dotnet_doc_css(
231
  type: Copy,
232
  description: "Copies the CSS for dotnet docs"
233
) {
234
  into "${buildDir}/dotnetdoc-html"
235
  from "${projectDir}/tools/docs/dotnet/saxon-dotnetdoc.css"
236
}
237

    
238
task dotnet_doc_html(
239
  type: JavaExec,
240
  dependsOn: ["dotnet_doc_merge", "dotnet_doc_css"],
241
  description: "Create HTML output for dotnet docs"
242
) {
243
  inputs.file "${buildDir}/dotnetdoc/merged.xml"
244
  inputs.file "${projectDir}/tools/docs/dotnet/tohtml.xsl"
245
  outputs.file "${buildDir}/dotnetdoc-html/index.html"
246
  classpath = configurations.documentation
247
  main = "com.saxonica.Transform"
248
  args "-s:${buildDir}/dotnetdoc/merged.xml",
249
    "-xsl:${projectDir}/tools/docs/dotnet/tohtml.xsl",
250
    "-o:${buildDir}/dotnetdoc-html/index.html"
251
}
252

    
253
task dotnet_doc_jel(
254
  type: JavaExec,
255
  dependsOn: ["dotnet_doc_merge"],
256
  description: "Create HTML output for dotnet docs"
257
) {
258
  inputs.file "${buildDir}/dotnetdoc/merged.xml"
259
  inputs.file "${projectDir}/tools/docs/dotnet/convert-to-jel-package.xsl"
260
  outputs.file "${buildDir}/dotnetdoc-xml/packages/Saxon.Api.xml"
261
  classpath = configurations.documentation
262
  main = "com.saxonica.Transform"
263
  args "-s:${buildDir}/dotnetdoc/merged.xml",
264
    "-xsl:${projectDir}/tools/docs/dotnet/convert-to-jel-package.xsl",
265
    "-o:${buildDir}/dotnetdoc-xml/packages/Saxon.Api.xml"
266
}
267

    
268
task app_dotnetdoc(
269
  type: Copy,
270
  dependsOn: ["dotnet_doc_jel"],
271
  description: "Copy the XML dotnet docs to the viewer app"
272
) {
273
  into "${buildDir}/userdoc/viewer_appJS/dotnetdoc-xml"
274
  from "${buildDir}/dotnetdoc-xml"
275
}
276

    
277
task app_javadoc(
278
  type: Copy,
279
  dependsOn: ["product_xsljavadoc"],
280
  description: "Copy the XML javadoc docs to the viewer app"
281
) {
282
  into "${buildDir}/userdoc/viewer_appJS/javadoc-xml"
283
  from "${buildDir}/javadoc-xml"
284
}
285

    
286
task resources_dotnetdoc(
287
  dependsOn: ["resources_dotnetdoc_css", "resources_dotnetdoc_apidoc"],
288
  description: "Copy dotnet files into the resources folder"
289
) {
290
  // nop
291
}
292

    
293
task resources_dotnetdoc_css(
294
  type: Copy,
295
  dependsOn: ["dotnet_doc_jel"],
296
  description: "Copy the dotnet CSS into the resources folder"
297
) {
298
  into "${buildDir}/resources/doc/dotnetdoc"
299
  from ("${projectDir}/tools/docs/dotnet") {
300
    include "saxon-dotnetdoc.css"
301
  }
302
}
303

    
304
task resources_dotnetdoc_apidoc(
305
  type: Copy,
306
  dependsOn: ["dotnet_doc_jel"],
307
  description: "Copy the dotnet API docs into the resources folder"
308
) {
309
  into "${buildDir}/resources/doc/dotnetdoc"
310
  from ("${buildDir}/n") {
311
    include "saxon-ee-api-${saxonVersion}.xml"
312
    rename("saxon-ee-api-${saxonVersion}.xml", "apidoc.xml")
313
  }
314
}
315

    
316
// ============================================================
317

    
318
task gen_doc(
319
  dependsOn: ["gen_doc_icu_uca", "gen_xslt_element_reference",
320
              "gen_xslt_element_reference", "element_doc", "expath_doc",
321
              "doc_FeatureKeysDoc", "doc_ConfigFileDoc"],
322
  description: "Collects up, generates and copies the documentation source into the canonical location"
323
) {
324
  // Just a place to hang dependencies
325
}  
326

    
327
task copy_userdoc_sources(
328
  type: Copy,
329
  dependsOn: ["copy_userdoc_implement"],
330
  description: "Copy the 'real', unpreprocessed sources"
331
) {
332
  into "${buildDir}/userdoc/src"
333
  from ("${projectDir}/src/userdoc") {
334
    // Excluded files are transformed by other tasks into "src" for the docbuild
335
    exclude "extensions/**"
336
    exclude "elements/**"
337
  }
338
}
339

    
340
task copy_userdoc_implement(
341
  type: Copy,
342
  description: "Copy the app implement file"
343
) {
344
  from "${projectDir}/src/viewer_appJS/doc"
345
  into "${buildDir}/userdoc/src"
346
}
347

    
348
task doc_FeatureKeysDoc(
349
  type: JavaExec,
350
  dependsOn: ["copy_userdoc_sources"],
351
  description: "Construct the documentation for feature keys"
352
) {
353
  inputs.files fileTree(dir: "${projectDir}/tools/featureKeys")
354
  outputs.file "${buildDir}/userdoc/src/featureKeys/FeatureKeysDoc.xml"
355
  classpath = configurations.preprocessor
356
  main = "net.sf.saxon.Transform"
357
  args "${projectDir}/tools/featureKeys/FeatureKeys.xml",
358
    "-xsl:${projectDir}/tools/featureKeys/FeatureKeysToDoc.xsl",
359
    "-o:${buildDir}/userdoc/src/featureKeys/FeatureKeysDoc.xml"
360
}
361

    
362
task doc_ConfigFileDoc(
363
  type: JavaExec,
364
  dependsOn: ["copy_userdoc_sources", "doc_FeatureKeysDoc"],
365
  description: "Construct the documentation for the configuration file"
366
) {
367
  inputs.files fileTree(dir: "${projectDir}/tools/featureKeys")
368
  outputs.files fileTree(dir: "${buildDir}/userdoc/src/featureKeys")
369
  classpath = configurations.preprocessor
370
  main = "net.sf.saxon.Transform"
371
  args "${projectDir}/tools/featureKeys/AdditionalFeatures.xml",
372
    "-xsl:${projectDir}/tools/featureKeys/ToConfigFileDoc.xsl",
373
    "-o:${buildDir}/userdoc/src/featureKeys/ConfigFileDoc.xml"
374
}
375

    
376
task gen_doc_icu_uca(
377
  type: JavaExec,
378
  dependsOn: ["copy_userdoc_sources"],
379
  description: "Generate the ICU/UCA documentation"
380
) {
381
  inputs.files fileTree(dir: "${projectDir}/src/userdoc")
382
  inputs.files fileTree(dir: "${projectDir}/tools/docs/userdoc")
383
  outputs.files fileTree(dir: "${buildDir}/userdoc/src/extensibility")
384
  classpath = configurations.documentation
385
  main = "com.saxonica.Transform"
386
  args "-it:go",
387
    "-s:${projectDir}/src/userdoc/catalog.xml",
388
    "-xsl:${projectDir}/tools/docs/userdoc/document-ICU.xsl",
389
    "output=${buildDir}/userdoc/src/extensibility/"
390
}
391

    
392
task gen_xslt_element_reference_preprocess(
393
  type: JavaExec,
394
  dependsOn: ["copy_userdoc_sources"],
395
  description: "Preprocess input for the XSLT Element reference documentation"
396
) {
397
  inputs.files fileTree(dir: "${projectDir}/src/userdoc/elements")
398
  inputs.files fileTree(dir: "${projectDir}/tools/docs/userdoc")
399
  outputs.file "${buildDir}/userdoc/tmp/xsl-elements-expanded.xml"
400
  classpath = configurations.documentation
401
  main = "com.saxonica.Transform"
402
  args "-s:${projectDir}/src/userdoc/elements/xsl-elements.xml",
403
    "-o:${buildDir}/userdoc/tmp/xsl-elements-expanded.xml",
404
    "-xsl:${projectDir}/tools/docs/userdoc/genElementDoc.xsl"
405
}
406

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

    
422
task element_doc() {
423
  // Just a place to hang dependencies
424
}
425

    
426
["instructions", "serialization-params"].each { target ->
427
  Task t = task "gen_element_doc_${target}"(
428
    type: JavaExec,
429
    description: "Expand element documentation for ${target}"
430
  ) {
431
    inputs.file "${projectDir}/src/userdoc/extensions/${target}.xml"
432
    inputs.files fileTree(dir: "${projectDir}/tools/docs/userdoc")
433
    outputs.file file("${buildDir}/userdoc/src/extensions/${target}.xml")
434
    classpath = configurations.documentation
435
    main = "com.saxonica.Transform"
436
    args "-s:${projectDir}/src/userdoc/extensions/${target}.xml",
437
      "-xsl:${projectDir}/tools/docs/userdoc/elements-body.xsl",
438
      "-o:${buildDir}/userdoc/src/extensions/${target}.xml"
439
  }
440
  element_doc.dependsOn t
441
}  
442

    
443
// Different from preceding because it doesn't go in extensions ¯\_(ツ)_/¯
444
["sql-extension"].each { target ->
445
  Task t = task "gen_element_doc_${target}"(
446
    type: JavaExec,
447
    description: "Expand element documentation for ${target}"
448
  ) {
449
    inputs.file "${projectDir}/src/userdoc/extensions/${target}.xml"
450
    inputs.files fileTree(dir: "${projectDir}/tools/docs/userdoc")
451
    outputs.file "${buildDir}/userdoc/src/${target}.xml"
452
    classpath = configurations.documentation
453
    main = "com.saxonica.Transform"
454
    args "-s:${projectDir}/src/userdoc/extensions/${target}.xml",
455
      "-xsl:${projectDir}/tools/docs/userdoc/elements-body.xsl",
456
      "-o:${buildDir}/userdoc/src/${target}.xml"
457
  }
458
  element_doc.dependsOn t
459
}  
460

    
461
task expath_doc() {
462
  // Just a place to hang dependencies
463
}
464
["binary", "archive", "file"].each { target ->
465
  Task t = task "expath_doc_${target}"(
466
    type: JavaExec,
467
    dependsOn: ["clone_expath_cg"],
468
    description: "Expand EXPath documentation for ${target}"
469
  ) {
470
    inputs.file "${projectDir}/src/userdoc/functions/EXPath/functions-${target}.xml"
471
    inputs.files fileTree(dir: "${projectDir}/tools/docs/userdoc")
472
    outputs.file "${buildDir}/userdoc/src/functions/EXPath/functions-${target}.xml"
473
    classpath = configurations.documentation
474
    main = "com.saxonica.Transform"
475
    args "-xi:on",
476
      "-s:${projectDir}/src/userdoc/functions/EXPath/functions-${target}.xml",
477
      "-xsl:${projectDir}/tools/docs/userdoc/genFunctionDoc.xsl",
478
      "-o:${buildDir}/userdoc/src/functions/EXPath/functions-${target}.xml",
479
      "GitHub=${projectDir}/build"
480
  }
481
  expath_doc.dependsOn t
482
}
483

    
484
task expand_userdoc_sections(
485
  type: JavaExec,
486
  dependsOn: ["gen_doc"],
487
  description: "Expand documentation sections from inclusions for app"
488
) {
489
  inputs.file "${buildDir}/userdoc/src/catalog.xml"
490
  inputs.files fileTree(dir: "${buildDir}/userdoc/src")
491
  inputs.files fileTree(dir: "${projectDir}/tools/docs/userdoc")
492
  outputs.file "${buildDir}/userdoc/expanded/catalog.xml"
493
  classpath = configurations.documentation
494
  main = "com.saxonica.Transform"
495
  args "-xi:on",
496
    "-s:${buildDir}/userdoc/src/catalog.xml",
497
    "-xsl:${projectDir}/tools/docs/userdoc/doc-include.xsl",
498
    "-o:${buildDir}/userdoc/expanded/catalog.xml",
499
    "output-uri=${buildDir}/userdoc/expanded/"
500
}
501

    
502
task userdoc_changes(
503
  type: JavaExec,
504
  dependsOn: ["expand_userdoc_sections"],
505
  description: "Preprocess the changes.xml file to turn it into a standard article"
506
) {
507
  inputs.file "${buildDir}/userdoc/expanded/changes.xml"
508
  inputs.files fileTree(dir: "${projectDir}/tools/docs/to-static")
509
  outputs.file "${buildDir}/userdoc/expanded/changes-article.xml"
510
  classpath = configurations.documentation
511
  main = "com.saxonica.Transform"
512
  args "-s:${buildDir}/userdoc/expanded/changes.xml",
513
    "-xsl:${projectDir}/tools/docs/to-static/c-changes.xsl",
514
    "-o:${buildDir}/userdoc/expanded/changes-article.xml"
515
}
516

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

    
532
// ============================================================
533

    
534
task viewer_app_sef(
535
  type: JavaExec,
536
  description: "Compile the viewer_app stylesheet"
537
) {
538
  inputs.files fileTree(dir: "${projectDir}/src/viewer_appJS/xsl")
539
  outputs.file "${buildDir}/userdoc/viewer_appJS/xsl/viewer_app.sef.json"
540
  classpath = configurations.documentation
541
  main = "com.saxonica.Transform"
542
  args "-xsl:${projectDir}/src/viewer_appJS/xsl/viewer_app.xsl",
543
    "-export:${buildDir}/userdoc/viewer_appJS/xsl/viewer_app.sef.json",
544
    "-target:JS", "-nogo", "-relocate:on", "-ns:##html5",
545
    "--generateByteCode:off",
546
    "SEFbuildDate=${DSTAMP}"
547
}
548

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

    
551
task userdoc_html(
552
  dependsOn: ["userdoc_articles"],
553
  description: "Creates the static HTML version of the user documentation"
554
) {
555
  // Just a place to hang dependencies
556
}
557

    
558
task userdoc_articles(
559
  type: JavaExec,
560
  dependsOn: ["expand_userdoc_sections", "app_javadoc", "app_dotnetdoc",
561
              "userdoc_changes", "userdoc_functions"],
562
  description: "Process all the articles"
563
) {
564
  inputs.files fileTree(dir: "${buildDir}/userdoc/expanded")
565
  inputs.files fileTree(dir: "${projectDir}/tools/docs/to-static")
566
  outputs.files fileTree(dir: "${buildDir}/userdoc/html")
567
  classpath = configurations.documentation
568
  main = "com.saxonica.Transform"
569
  args "-s:${buildDir}/userdoc/expanded/catalog.xml",
570
    "-xsl:${projectDir}/tools/docs/to-static/s-viewer_app.xsl",
571
    "-o:${buildDir}/userdoc/html/dummy.xml",
572
    "changes-article=${buildDir}/userdoc/expanded/changes-article.xml",
573
    "functions-article=${buildDir}/userdoc/expanded/functions-article.xml",
574
    "base-uri=${buildDir}/userdoc/html/"
575
}
576

    
577
task userdoc_publish_viewer_appJS(
578
  type: Copy,
579
  description: "Copy viewer_appJS to build"
580
) {
581
  into "${buildDir}/userdoc/viewer_appJS"
582
  from ("${projectDir}/src/viewer_appJS") {
583
    exclude "readme.txt"
584
  }
585
}
586

    
587
task userdoc_viewer_appJS(
588
  type: Copy,
589
  dependsOn: ["userdoc_articles", "userdoc_publish_viewer_appJS", "viewer_app_sef"],
590
  description: "Copy transformed articles to app docs"
591
) {
592
  into "${buildDir}/userdoc/viewer_appJS/doc"
593
  from ("build/userdoc/expanded") {
594
    include "*.xml"
595
    exclude "functions-article.xml"
596
    exclude "changes-article.xml"
597
  }
598
}
599

    
600
task userdoc_publish_javadoc_html(
601
  type: Copy,
602
  dependsOn: ["userdoc_html", "product_javadoc"],
603
  description: "Copy dotnet docs into HTML output"
604
) {
605
  into "${buildDir}/userdoc/html/javadoc"
606
  from "build/javadoc"
607
  doFirst {
608
    mkdir "${buildDir}/userdoc/html/javadoc"
609
  }
610
}
611

    
612
task userdoc_publish_html_images(
613
  type: Copy,
614
  description: "Copy viewer_appJS images to the html output directory"
615
) {
616
  into "${buildDir}/userdoc/html/image"
617
  from "${projectDir}/src/viewer_appJS/image"
618
}
619

    
620
task userdoc_publish_html_style(
621
  type: Copy,
622
  description: "Copy viewer_appJS CSS to the html output directory"
623
) {
624
  into "${buildDir}/userdoc/html"
625
  from "${projectDir}/src/viewer_appJS/viewer_app.css"
626
  filter { line ->
627
    line.contains("url('saxon-base.css')")
628
            ? line.replace("saxon-base.css", "../../saxon-base.css")
629
            : line
630
  }
631
}
632

    
633
task userdoc_publish_html(
634
  type: Copy,
635
  dependsOn: ["userdoc_publish_javadoc_html", "dotnet_doc_html",
636
              "userdoc_publish_html_style", "userdoc_publish_html_images"],
637
  description: "Publish the HTML documentation"
638
) {
639
  into "${buildDir}/userdoc/html/dotnetdoc"
640
  from "build/dotnetdoc-html"
641
  doFirst {
642
    mkdir "${buildDir}/userdoc/html/dotnetdoc"
643
  }
644
}
645

    
646
// ============================================================
647

    
648
task update_documentation(
649
  dependsOn: ["copy_xml_documentation", "copy_html_documentation"],
650
  description: "Update documentation from viewer app"
651
) {
652
  // Just a place to hang dependencies
653
}
654

    
655
task copy_xml_documentation(
656
  type: Copy,
657
  dependsOn: ["userdoc_viewer_appJS"],
658
  description: "Update XML version of documentation from viewer app"
659
) {
660
  into "${buildDir}/website/documentation"
661
  from "${buildDir}/userdoc/viewer_appJS"
662
}
663

    
664
task copy_html_documentation(
665
  type: Copy,
666
  dependsOn: ["userdoc_publish_html"],
667
  description: "Update HTML version of user documentation"
668
) {
669
  into "${buildDir}/website/html/documentation"
670
  from "${buildDir}/userdoc/html"
671
}
672

    
673
// ============================================================
674

    
675
task gen_contents_ref(
676
  type: JavaExec,
677
  dependsOn: ["copy_xml_documentation"],
678
  description: "Creates the contents reference file for the user documentation (used for website pages)"
679
) {
680
  inputs.file "${buildDir}/website/documentation/doc/catalog.xml"
681
  inputs.file "${projectDir}/tools/docs/userdoc/contents-builder.xsl"
682
  outputs.file "${buildDir}/website/documentation/contents.xml"
683
  classpath = configurations.documentation
684
  main = "com.saxonica.Transform"
685
  args "${buildDir}/website/documentation/doc/catalog.xml",
686
    "-xsl:${projectDir}/tools/docs/userdoc/contents-builder.xsl",
687
    "-o:${buildDir}/website/documentation/contents.xml",
688
    "version-number=${saxonMajorVersion}"
689
}
690

    
691
task gen_feature_matrix(
692
        type: JavaExec,
693
        description: "Creates the base feature matrix file for the website"
694
) {
695
  inputs.file "${projectDir}/tools/docs/feature-matrix/feature-matrix.xml"
696
  inputs.file "${projectDir}/tools/docs/feature-matrix/feature-matrix-to-overview-chart.xsl"
697
  outputs.file "${buildDir}/website/products/feature-matrix-${saxonMajorVersion}.xml"
698
  classpath = configurations.documentation
699
  main = "com.saxonica.Transform"
700
  args "${projectDir}/tools/docs/feature-matrix/feature-matrix.xml",
701
          "-xsl:${projectDir}/tools/docs/feature-matrix/feature-matrix-to-overview-chart.xsl",
702
          "-o:${buildDir}/website/products/feature-matrix-${saxonMajorVersion}.xml"
703
}
704

    
705
task gen_prod_desc(
706
        type: JavaExec,
707
        description: "Creates the base product description file"
708
) {
709
  inputs.file "${projectDir}/tools/docs/feature-matrix/feature-matrix.xml"
710
  inputs.file "${projectDir}/tools/docs/feature-matrix/feature-matrix-to-prod-desc.xsl"
711
  outputs.file "${buildDir}/proddesc/prod-desc.xml"
712
  classpath = configurations.documentation
713
  main = "com.saxonica.Transform"
714
  args "${projectDir}/tools/docs/feature-matrix/feature-matrix.xml",
715
          "-xsl:${projectDir}/tools/docs/feature-matrix/feature-matrix-to-prod-desc.xsl",
716
          "-o:${buildDir}/proddesc/prod-desc.xml"
717
}
718

    
719
task gen_prod_desc_fo(
720
        type: JavaExec,
721
        dependsOn: ["gen_prod_desc"],
722
        description: "Creates the FO and HTML versions of the product descriptions"
723
) {
724
  inputs.file "${buildDir}/proddesc/prod-desc.xml"
725
  inputs.file "${projectDir}/tools/docs/feature-matrix/PD/prod-desc-to-fo.xsl"
726
  outputs.file "${buildDir}/proddesc/PD/dummy.xml"
727
  classpath = configurations.documentation
728
  main = "com.saxonica.Transform"
729
  args "${buildDir}/proddesc/prod-desc.xml",
730
          "-xsl:${projectDir}/tools/docs/feature-matrix/PD/prod-desc-to-fo.xsl",
731
          "-o:${buildDir}/proddesc/PD/dummy.xml"
732
}
733

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