Files
spring-integration/gradle/docs.gradle
Jay Bryant 99967772ed Use spring-asciidoctor-backends
Rather than `spring-doc-resources`, which is to be retired.

* Fix some problems with tabs in docs
2022-08-04 16:22:16 -04:00

127 lines
3.0 KiB
Groovy

ext {
backendVersion = '0.0.3'
}
configurations {
asciidoctorExtensions
}
dependencies {
asciidoctorExtensions "io.spring.asciidoctor.backends:spring-asciidoctor-backends:$backendVersion"
}
task checkAsciidocLinks {
inputs.dir("src/reference/asciidoc/")
doLast {
def errors = new ArrayList<>();
errors.add('*** Anchor reference errors found:')
inputs.files.filter{ f -> f.path.endsWith('.adoc') }.each { file ->
def doc = file.text
def anchors = new HashSet<>()
def matcher = (doc =~ /\[\[([^]]+)]]/)
while (matcher.find()) {
anchors.add(matcher.group(1))
}
matcher = (doc =~ /<<([^>]+)>>/)
while (matcher.find()) {
def anchor = matcher.group(1);
def hasComma = anchor.contains(',')
if (!anchor.startsWith('./')) {
if (hasComma) {
anchor = anchor.substring(0, anchor.indexOf(","));
}
if (!anchors.contains(anchor)) {
errors.add("\nAnchor '$anchor' not found in '${file.name}', " +
"if in another file, it needs to be qualified with './fileName.adoc#'")
}
}
else {
if (!hasComma) {
errors.add("\nExternal anchor '$anchor' in '${file.name}' should have a textual description (,...)")
}
}
}
}
if (errors.size() > 1) {
throw new InvalidUserDataException(errors.toString())
}
}
}
asciidoctorPdf {
dependsOn checkAsciidocLinks
inProcess = JAVA_EXEC
forkOptions {
jvmArgs '--add-opens', 'java.base/sun.nio.ch=ALL-UNNAMED', '--add-opens', 'java.base/java.io=ALL-UNNAMED'
}
baseDirFollowsSourceFile()
asciidoctorj {
sourceDir "src/reference/asciidoc/"
inputs.dir(sourceDir)
sources {
include 'index-single.adoc'
}
options doctype: 'book'
attributes 'icons': 'font',
'sectanchors': '',
'sectnums': '',
'toc': '',
'source-highlighter' : 'coderay',
revnumber: project.version,
'project-version': project.version
}
}
asciidoctorj {
version = '2.5.2'
options doctype: 'book', eruby: 'erubis'
attributes 'docinfo': 'shared',
stylesdir: 'css/',
stylesheet: 'stylesheet.css',
'linkcss': true,
'copycss': false,
'icons': 'font',
'sectanchors': '',
'source-highlighter': 'highlight.js',
'highlightjsdir': 'js/highlight',
'highlightjs-theme': 'github',
'idprefix': '',
'idseparator': '-',
'allow-uri-read': '',
'toc': 'left',
'toclevels': '4',
revnumber: project.version,
'project-version': project.version
}
asciidoctor {
dependsOn asciidoctorPdf
inProcess = JAVA_EXEC
forkOptions {
jvmArgs '--add-opens', 'java.base/sun.nio.ch=ALL-UNNAMED', '--add-opens', 'java.base/java.io=ALL-UNNAMED'
}
baseDirFollowsSourceFile()
configurations 'asciidoctorExtensions'
sourceDir "src/reference/asciidoc/"
inputs.dir(sourceDir)
outputOptions {
backends "spring-html"
}
resources {
from(sourceDir) {
include 'images/*', 'css/**', 'js/**'
}
}
}
task reference(dependsOn: asciidoctor) {
group = 'Documentation'
description = 'Generate the reference documentation'
}
reference.onlyIf { 'true' != System.env['NO_REFERENCE_TASK'] || project.hasProperty('ignoreEnvToStopReference') }