Skip to content

Commit a80a58e

Browse files
committed
Make doc pubisher more lenient and pass variables to template engine
1 parent b12e898 commit a80a58e

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

grails-docs/src/main/groovy/grails/doc/DocPublisher.groovy

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,8 @@ class DocPublisher {
283283
def fullToc = new StringBuilder()
284284

285285
def pathToRoot = ".."
286-
def vars = [
286+
Map vars = new LinkedHashMap(engineProperties)
287+
vars.putAll(
287288
encoding: encoding,
288289
title: title,
289290
docTitle: title,
@@ -304,7 +305,7 @@ class DocPublisher {
304305
next: null,
305306
legacyLinks: legacyLinks,
306307
sourceRepo: sourceRepo,
307-
]
308+
)
308309

309310
if(engine instanceof AsciiDocEngine) {
310311
// pass attributes to asciidoc
@@ -445,6 +446,7 @@ class DocPublisher {
445446
context.set(DocEngine.CONTEXT_PATH, path)
446447

447448
def varsCopy = [*:vars]
449+
varsCopy.putAll(engineProperties)
448450
varsCopy.name = section.name
449451
varsCopy.title = section.title
450452
varsCopy.path = path

grails-docs/src/main/groovy/grails/doc/gradle/PublishGuide.groovy

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ import org.gradle.api.tasks.*
2525
*/
2626
class PublishGuide extends DefaultTask {
2727
@InputDirectory File sourceDir = new File(project.projectDir, "src")
28-
@OutputDirectory File targetDir = project.outputDir as File
29-
@InputDirectory File resourcesDir = new File(project.projectDir, "resources")
30-
@Input List propertiesFiles = []
31-
@Input String language = ""
32-
@Input boolean asciidoc = false
28+
@OutputDirectory File targetDir = new File(project.buildDir, "docs")
29+
@InputDirectory @Optional File resourcesDir = new File(project.projectDir, "resources")
30+
@Input @Optional List propertiesFiles = []
31+
@Input @Optional String language = ""
32+
@Input @Optional boolean asciidoc = false
3333
@Input @Optional String sourceRepo
3434
@Input @Optional Properties properties = new Properties()
3535
Collection macros = []
@@ -38,8 +38,11 @@ class PublishGuide extends DefaultTask {
3838
@TaskAction
3939
def publishGuide() {
4040
def props = new Properties()
41-
new File("${resourcesDir}/doc.properties").withInputStream {input ->
42-
props.load(input)
41+
def docProperties = new File("${resourcesDir}/doc.properties")
42+
if(docProperties.exists()) {
43+
docProperties.withInputStream { input ->
44+
props.load(input)
45+
}
4346
}
4447

4548
// Add properties from any optional properties files too.
@@ -55,7 +58,7 @@ class PublishGuide extends DefaultTask {
5558
publisher.ant = project.ant
5659
publisher.asciidoc = asciidoc
5760
publisher.workDir = workDir
58-
publisher.apiDir = "${project.outputDir}" as File
61+
publisher.apiDir = targetDir
5962
publisher.language = language ?: ''
6063
publisher.sourceRepo = sourceRepo
6164
publisher.images = project.file("${resourcesDir}/img")

0 commit comments

Comments
 (0)