Skip to content

Commit 9fae0ad

Browse files
committed
GRAILS-4660 added index.html for docs
1 parent feea140 commit 9fae0ad

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

scripts/_GrailsDocs.groovy

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ links = ['http://java.sun.com/j2se/1.5.0/docs/api/']
4040
docsDisabled = { argsMap.nodoc == true }
4141
pdfEnabled = { argsMap.pdf == true }
4242

43+
createdManual = false
44+
createdPdf = false
45+
4346
target(docs: "Produces documentation for a Grails project") {
4447
parseArguments()
4548
if (argsMap.init) {
@@ -89,7 +92,7 @@ And provide a detailed description
8992
}
9093

9194
target(docsInternal:"Actual documentation task") {
92-
depends(compile, javadoc, groovydoc, refdocs, pdf)
95+
depends(compile, javadoc, groovydoc, refdocs, pdf, createIndex)
9396
}
9497

9598
target(setupDoc:"Sets up the doc directories") {
@@ -221,6 +224,8 @@ ${m.arguments?.collect { '* @'+GrailsNameUtils.getPropertyName(it)+'@\n' }}
221224

222225
publisher.publish()
223226

227+
createdManual = true
228+
224229
println "Built user manual at ${refDocsDir}/index.html"
225230
}
226231
}
@@ -239,11 +244,48 @@ target(pdf: "Produces PDF documentation") {
239244
event("DocStart", ['pdf'])
240245

241246
PdfBuilder.build(grailsSettings.docsOutputDir.canonicalPath, grailsHome)
247+
248+
createdPdf = true
249+
242250
println "Built user manual PDF at ${refDocsDir}/guide/single.pdf"
243251

244252
event("DocEnd", ['pdf'])
245253
}
246254

255+
target(createIndex: "Produces an index.html page in the root directory") {
256+
if (docsDisabled()) {
257+
return
258+
}
259+
260+
new File("${grailsSettings.docsOutputDir}/index.html").withWriter { writer ->
261+
writer.write """\
262+
<html>
263+
264+
<head>
265+
<title>$grailsAppName Documentation</title>
266+
</head>
267+
268+
<body>
269+
<a href="api/index.html">Java API docs</a><br />
270+
<a href="gapi/index.html">Groovy API docs</a><br />
271+
"""
272+
273+
if (createdManual) {
274+
writer.write '\t\t<a href="manual/index.html">Manual (Frames)</a><br />\n'
275+
writer.write '\t\t<a href="manual/guide/single.html">Manual (Single)</a><br />\n'
276+
}
277+
278+
if (createdPdf) {
279+
writer.write '\t\t<a href="manual/guide/single.pdf">Manual (PDF)</a><br />\n'
280+
}
281+
282+
writer.write """\
283+
</body>
284+
</html>
285+
"""
286+
}
287+
}
288+
247289
def readPluginMetadataForDocs(DocPublisher publisher) {
248290
def basePlugin = loadBasePlugin()
249291
if (basePlugin) {

0 commit comments

Comments
 (0)