Add a DO NOT EDIT header to generated adoc files
Closes
MODIFY
asciidoctorj-documentation/build.gradle
asciidoctorj-documentation/build.gradle
+import org.apache.tools.ant.filters.*
+
jar.enabled = false
dependencies {
@@ -10,13 +12,15 @@ dependencies {
}
}
+
task processAsciidocFiles(type: Copy) {
+ def fromDir = 'src/main/asciidoc'
+
inputs.files fileTree(dir: 'src')
outputs.files fileTree(dir: rootProject.file('docs'), include: '*.adoc')
dependsOn test
-
- from 'src/main/asciidoc'
+ from fromDir
include '*.adoc'
into rootProject.file('docs')
eachFile { file ->
@@ -76,6 +80,19 @@ task processAsciidocFiles(type: Copy) {
line
}
}
+ // A Gradle issue makes calculating the source path a bit awkward: we cannot file.getFile() when using a a filter.
+ // See: https://github.com/gradle/gradle/issues/1588
+ def relativeSourceFile = file.getRelativeSourcePath().getFile(new File(fromDir))
+ def absoluteSourceFile = new File("$projectDir", relativeSourceFile.toString())
+ def rootProjectRelativeSourceFile = project.getRootProject().getProjectDir().toPath().
+ relativize(absoluteSourceFile.toPath())
+ def header = File.createTempFile("header",".ado")
+ header.write """|// THIS FILE IS GENERATED - DO NOT EDIT
+ |// Edit here: ${rootProjectRelativeSourceFile}
+ |// And then run: ./gradlew asciidoctorj-documentation:build
+ """.stripMargin().trim().concat("\n")
+ header.deleteOnExit()
+ file.filter ConcatFilter, prepend : header
}
}

MODIFY
docs/extension-migration-guide.adoc
docs/extension-migration-guide.adoc
+// THIS FILE IS GENERATED - DO NOT EDIT
+// Edit here: asciidoctorj-documentation/src/main/asciidoc/extension-migration-guide.adoc
+// And then run: ./gradlew asciidoctorj-documentation:build
= AsciidoctorJ: Extension Migration Guide
Robert Panzer <https://github.com/robertpanzer[@robertpanzer]>
:compat-mode!:

MODIFY
docs/integrator-guide.adoc
docs/integrator-guide.adoc
+// THIS FILE IS GENERATED - DO NOT EDIT
+// Edit here: asciidoctorj-documentation/src/main/asciidoc/integrator-guide.adoc
+// And then run: ./gradlew asciidoctorj-documentation:build
= AsciidoctorJ: Integrator's guide
Alex Soto <https://github.com/lordofthejars[@lordofthejars]>; Dan Allen <https://github.com/mojavelinux[@mojavelinux]>; Robert Panzer <https://github.com/robertpanzer[@robertpanzer]>
:compat-mode!:

Add a DO NOT EDIT header to generated adoc files

Closes #961