Project

Profile

Help

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

he / build-doc.gradle @ acdcff21

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 "com/saxonica/testdriver/**"
38
    exclude "net/sf/saxon/testdriver/**"
39
    exclude "**/dotnet/**"
40
    exclude "**/DotNetVerifier.java"
41
  }
42
}
43

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

    
56
  def cp = ""
57
  configurations.documentation.resolve().each { path ->
58
    cp = cp + System.getProperty("path.separator") + path
59
  }
60

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

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

    
93
  commandLine command
94

    
95
  doFirst {
96
      mkdir "${buildDir}/javadoc"
97
    }
98
}
99

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

    
113
  def cp = ""
114
  configurations.documentation.resolve().each { path ->
115
    cp = cp + System.getProperty("path.separator") + path
116
  }
117

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

    
137
  def command = ["javadoc",
138
                 "-sourcepath", "${buildDir}/javadoc_src",
139
                 "-d", "${buildDir}/jeljavadoc",
140
                 "-package",
141
                 "-filename", "jeldoclet-out.xml",
142
                 "-includeNamespace",
143
                 "-outputEncoding", "utf-8",
144
                 "-classpath", cp,
145
                 "-doclet", "com.jeldoclet.JELDoclet",
146
                 "-docletpath", cp,
147
                 "-source", "1.8"] + packages.keySet()
148

    
149
  commandLine command
150

    
151
  doFirst {
152
      mkdir "${buildDir}/jeljavadoc"
153
    }
154
}
155

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

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

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

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

    
223
task dotnet_doc_css(
224
  type: Copy,
225
  description: "Copies the CSS for dotnet docs"
226
) {
227
  into "${buildDir}/dotnetdoc-html"
228
  from "${projectDir}/tools/docs/dotnet/saxon-dotnetdoc.css"
229
}
230

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

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

    
261
task app_dotnetdoc(
262
  type: Copy,
263
  dependsOn: ["dotnet_doc_jel"],
264
  description: "Copy the XML dotnet docs to the viewer app"
265
) {
266
  into "${buildDir}/userdoc/viewer_appJS/dotnetdoc-xml"
267
  from "${buildDir}/dotnetdoc-xml"
268
}
269

    
270
task app_javadoc(
271
  type: Copy,
272
  dependsOn: ["product_xsljavadoc"],
273
  description: "Copy the XML javadoc docs to the viewer app"
274
) {
275
  into "${buildDir}/userdoc/viewer_appJS/javadoc-xml"
276
  from "${buildDir}/javadoc-xml"
277
}
278

    
279
task resources_dotnetdoc(
280
  dependsOn: ["resources_dotnetdoc_css", "resources_dotnetdoc_apidoc"],
281
  description: "Copy dotnet files into the resources folder"
282
) {
283
  // nop
284
}
285

    
286
task resources_dotnetdoc_css(
287
  type: Copy,
288
  dependsOn: ["dotnet_doc_jel"],
289
  description: "Copy the dotnet CSS into the resources folder"
290
) {
291
  into "${buildDir}/resources/doc/dotnetdoc"
292
  from ("${projectDir}/tools/docs/dotnet") {
293
    include "saxon-dotnetdoc.css"
294
  }
295
}
296

    
297
task resources_dotnetdoc_apidoc(
298
  type: Copy,
299
  dependsOn: ["dotnet_doc_jel"],
300
  description: "Copy the dotnet API docs into the resources folder"
301
) {
302
  into "${buildDir}/resources/doc/dotnetdoc"
303
  from ("${buildDir}/n") {
304
    include "saxon-ee-api-${saxonVersion}.xml"
305
    rename("saxon-ee-api-${saxonVersion}.xml", "apidoc.xml")
306
  }
307
}
308

    
309
// ============================================================
310

    
311
task gen_doc(
312
  dependsOn: ["gen_doc_icu_uca", "gen_xslt_element_reference",
313
              "gen_xslt_element_reference", "element_doc", "expath_doc",
314
              "doc_FeatureKeysDoc", "doc_ConfigFileDoc"],
315
  description: "Collects up, generates and copies the documentation source into the canonical location"
316
) {
317
  // Just a place to hang dependencies
318
}  
319

    
320
task copy_userdoc_sources(
321
  type: Copy,
322
  dependsOn: ["copy_userdoc_implement"],
323
  description: "Copy the 'real', unpreprocessed sources"
324
) {
325
  into "${buildDir}/userdoc/src"
326
  from ("${projectDir}/src/userdoc") {
327
    // Excluded files are transformed by other tasks into "src" for the docbuild
328
    exclude "extensions/**"
329
    exclude "elements/**"
330
  }
331
}
332

    
333
task copy_userdoc_implement(
334
  type: Copy,
335
  description: "Copy the app implement file"
336
) {
337
  from "${projectDir}/src/viewer_appJS/doc"
338
  into "${buildDir}/userdoc/src"
339
}
340

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

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

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

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

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

    
415
task element_doc() {
416
  // Just a place to hang dependencies
417
}
418

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

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

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

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

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

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

    
525
// ============================================================
526

    
527
task viewer_app_sef(
528
  type: JavaExec,
529
  description: "Compile the viewer_app"
530
) {
531
  inputs.files fileTree(dir: "${projectDir}/src/viewer_appJS/xsl")
532
  outputs.file "${buildDir}/viewer_app/xsl/viewer_app.sef.json"
533
  classpath = configurations.documentation
534
  main = "com.saxonica.Transform"
535
  args "-xsl:${projectDir}/src/viewer_appJS/xsl/viewer_app.xsl",
536
    "-export:${buildDir}/viewer_app/xsl/viewer_app.sef.json",
537
    "-target:JS", "-nogo", "-relocate:on", "-ns:##html5",
538
    "--generateByteCode:off",
539
    "SEFbuildDate=${DSTAMP}"
540
}
541

    
542
// ============================================================
543

    
544
task userdoc_html(
545
  dependsOn: ["userdoc_articles"],
546
  description: "Creates the static HTML version of the user documentation"
547
) {
548
  // Just a place to hang dependencies
549
}
550

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

    
570
task userdoc_publish_viewer_appJS(
571
  type: Copy,
572
  description: "Copy viewer_appJS to build"
573
) {
574
  into "${buildDir}/userdoc/viewer_appJS"
575
  from ("${projectDir}/src/viewer_appJS") {
576
    exclude "readme.txt"
577
  }
578
}
579

    
580
task userdoc_viewer_appJS(
581
  type: Copy,
582
  dependsOn: ["userdoc_articles", "userdoc_publish_viewer_appJS"],
583
  description: "Copy transformed articles to app docs"
584
) {
585
  into "${buildDir}/userdoc/viewer_appJS/doc"
586
  from ("build/userdoc/expanded") {
587
    include "*.xml"
588
    exclude "functions-article.xml"
589
    exclude "changes-article.xml"
590
  }
591
}
592

    
593
task userdoc_publish_javadoc_html(
594
  type: Copy,
595
  dependsOn: ["userdoc_html", "product_javadoc"],
596
  description: "Copy dotnet docs into HTML output"
597
) {
598
  into "${buildDir}/userdoc/html/javadoc"
599
  from "build/javadoc"
600
  doFirst {
601
    mkdir "${buildDir}/userdoc/html/javadoc"
602
  }
603
}
604

    
605
task userdoc_publish_html_images(
606
  type: Copy,
607
  description: "Copy viewer_appJS images to the html output directory"
608
) {
609
  into "${buildDir}/userdoc/html/image"
610
  from "${projectDir}/src/viewer_appJS/image"
611
}
612

    
613
task userdoc_publish_html_style(
614
  type: Copy,
615
  description: "Copy viewer_appJS CSS to the html output directory"
616
) {
617
  into "${buildDir}/userdoc/html"
618
  from "${projectDir}/src/viewer_appJS/viewer_app.css"
619
  filter { line ->
620
    line.contains("url('saxon-base.css')")
621
            ? line.replace("saxon-base.css", "../../saxon-base.css")
622
            : line
623
  }
624
}
625

    
626
task userdoc_publish_html(
627
  type: Copy,
628
  dependsOn: ["userdoc_publish_javadoc_html", "dotnet_doc_html",
629
              "userdoc_publish_html_style", "userdoc_publish_html_images"],
630
  description: "Publish the HTML documentation"
631
) {
632
  into "${buildDir}/userdoc/html/dotnetdoc"
633
  from "build/dotnetdoc-html"
634
  doFirst {
635
    mkdir "${buildDir}/userdoc/html/dotnetdoc"
636
  }
637
}
638

    
639
// ============================================================
640

    
641
task update_documentation(
642
  dependsOn: ["copy_xml_documentation", "copy_html_documentation"],
643
  description: "Update documentation from viewer app"
644
) {
645
  // Just a place to hang dependencies
646
}
647

    
648
task copy_xml_documentation(
649
  type: Copy,
650
  dependsOn: ["userdoc_viewer_appJS"],
651
  description: "Update XML version of documentation from viewer app"
652
) {
653
  into "${buildDir}/website/documentation"
654
  from "${buildDir}/userdoc/viewer_appJS"
655
}
656

    
657
task copy_html_documentation(
658
  type: Copy,
659
  dependsOn: ["userdoc_publish_html"],
660
  description: "Update HTML version of user documentation"
661
) {
662
  into "${buildDir}/website/html/documentation"
663
  from "${buildDir}/userdoc/html"
664
}
665

    
666
// ============================================================
667

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

    
684
task gen_feature_matrix(
685
        type: JavaExec,
686
        description: "Creates the base feature matrix file for the website"
687
) {
688
  inputs.file "${projectDir}/tools/docs/feature-matrix/feature-matrix.xml"
689
  inputs.file "${projectDir}/tools/docs/feature-matrix/feature-matrix-to-overview-chart.xsl"
690
  outputs.file "${buildDir}/website/products/feature-matrix-${saxonMajorVersion}.xml"
691
  classpath = configurations.documentation
692
  main = "com.saxonica.Transform"
693
  args "${projectDir}/tools/docs/feature-matrix/feature-matrix.xml",
694
          "-xsl:${projectDir}/tools/docs/feature-matrix/feature-matrix-to-overview-chart.xsl",
695
          "-o:${buildDir}/website/products/feature-matrix-${saxonMajorVersion}.xml"
696
}
697

    
698
task gen_prod_desc(
699
        type: JavaExec,
700
        description: "Creates the base product description file"
701
) {
702
  inputs.file "${projectDir}/tools/docs/feature-matrix/feature-matrix.xml"
703
  inputs.file "${projectDir}/tools/docs/feature-matrix/feature-matrix-to-prod-desc.xsl"
704
  outputs.file "${buildDir}/proddesc/prod-desc.xml"
705
  classpath = configurations.documentation
706
  main = "com.saxonica.Transform"
707
  args "${projectDir}/tools/docs/feature-matrix/feature-matrix.xml",
708
          "-xsl:${projectDir}/tools/docs/feature-matrix/feature-matrix-to-prod-desc.xsl",
709
          "-o:${buildDir}/proddesc/prod-desc.xml"
710
}
711

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

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