added a command line KDocCompiler so its easy to generate kdoc from command line or build tools. Also added generation of the kdoc documentation in a test case in the website project along with a simple html website

This commit is contained in:
James Strachan
2012-03-08 12:02:30 +00:00
parent cd42b6d527
commit b3bdfffca2
12 changed files with 216 additions and 50 deletions

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

@@ -18,15 +18,22 @@ class SiteGenerator(val sourceDir: File, val outputDir: File) : Runnable {
if (it.isFile()) {
var relativePath = sourceDir.relativePath(it)
println("Processing ${relativePath}")
var text = it.readText()
var output: String? = null
if (it.extension == "md") {
text = markdownProcessor.markdownToHtml(text, linkRendered) ?: ""
val text = it.readText()
output = markdownProcessor.markdownToHtml(text, linkRendered) ?: ""
relativePath = relativePath.trimTrailing(it.extension) + "html"
} else if (it.extension == "html") {
output = it.readText()
}
text = layout(relativePath, it, text)
val outFile = File(outputDir, relativePath)
outFile.directory.mkdirs()
outFile.writeText(text)
if (output != null) {
val text = layout(relativePath, it, output.sure())
outFile.writeText(text)
} else {
it.copyTo(outFile)
}
}
}
}
@@ -4,7 +4,7 @@ Welcome to [Kotlin](http://www.jetbrains.com/kotlin)!
Some handy links
* [API Docs](apidocs/index.html)
* [API Docs](versions/snapshot/apidocs/index.html)
* [Kotlin Blog](http://blog.jetbrains.com/kotlin/)
* [Web Demo](http://kotlin-demo.jetbrains.com/)
* [Issue Tracker](http://youtrack.jetbrains.com/issues/KT)
@@ -3,15 +3,60 @@ package org.jetbrains.kotlin.site
import junit.framework.TestCase
import java.io.File
import kotlin.util.arrayList
import org.jetbrains.kotlin.doc.KDocArguments
import org.jetbrains.kotlin.doc.KDocCompiler
class GenerateSiteTest : TestCase() {
val srcDir = findTemplateDir()
val siteOutputDir = File(srcDir, "../../../target/site")
// TODO find version from environment?
val version = "snapshot"
fun testGenerateSite(): Unit {
val srcDir = findTemplateDir()
val generator = SiteGenerator(srcDir, File(srcDir, "../../../target/site"))
val generator = SiteGenerator(srcDir, siteOutputDir)
generator.run()
}
fun testGenerateStdlibKDoc(): Unit {
val outDir = File(siteOutputDir, "versions/$version/apidocs")
println("Generating stdlib KDocs to $outDir")
copyDocResources(outDir)
val args = KDocArguments()
args.setSrc("../stdlib/src")
args.setDocOutputDir(outDir.toString())
args.setOutputDir("target/classes-stdlib")
val compiler = KDocCompiler()
compiler.exec(System.out, args)
}
/**
fun testGenerateJsKDoc(): Unit {
val args = KDocArguments()
args.docOutputDir = File(siteOutputDir, "versions/$version/apidocs").toString()
args.src = "../js/src"
args.outputDir = "target/classes-js"
val compiler = KDocCompiler()
compiler.exec(System.out, args)
}
*/
fun copyDocResources(outDir: File): Unit {
val sourceDir = File(srcDir, "../apidocs")
sourceDir.recurse {
if (it.isFile()) {
var relativePath = sourceDir.relativePath(it)
val outFile = File(outDir, relativePath)
outFile.directory.mkdirs()
it.copyTo(outFile)
}
}
}
fun findTemplateDir(): File {
val path = "src/main/templates"
for (p in arrayList(".", "apidocs", "library/apidocs")) {