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:
+43
-29
@@ -24,6 +24,49 @@
|
||||
<artifactId>pegdown</artifactId>
|
||||
<version>${pegdown.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- add the kdoc dependency for generating kdoc -->
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kdoc</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>picocontainer</groupId>
|
||||
<artifactId>picocontainer</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${kotlin-sdk}/lib/picocontainer.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>trove4j</groupId>
|
||||
<artifactId>trove4j</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${kotlin-sdk}/lib/trove4j.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>11.0.1</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${kotlin-sdk}/lib/guava-11.0.1.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>asm</groupId>
|
||||
<artifactId>asm-commons</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${kotlin-sdk}/lib/asm-commons.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>asm</groupId>
|
||||
<artifactId>asm</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${kotlin-sdk}/lib/asm.jar</systemPath>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
@@ -35,35 +78,6 @@
|
||||
<plugin>
|
||||
<groupId>com.goldin.plugins</groupId>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile-kotlin-sources</id>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<docOutput>${project.basedir}/target/site/apidocs</docOutput>
|
||||
<sources>
|
||||
<src>${project.basedir}/../stdlib/src</src>
|
||||
<src>${project.basedir}/../kunit/src</src>
|
||||
</sources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kdoc</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<!-- TODO not sure why I need to add the transitive dependencies too? -->
|
||||
<dependency>
|
||||
<groupId>org.pegdown</groupId>
|
||||
<artifactId>pegdown</artifactId>
|
||||
<version>${pegdown.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
|
||||
|
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")) {
|
||||
|
||||
@@ -11,14 +11,20 @@
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Maven: org.jetbrains.kotlin:stdlib:1.0-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jetbrains.kotlin:kotlin-compiler:0.2.3.8" level="project" />
|
||||
<orderEntry type="module" module-name="stdlib" />
|
||||
<orderEntry type="library" name="Maven: org.pegdown:pegdown:1.1.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.parboiled:parboiled-core:1.0.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.parboiled:parboiled-java:1.0.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: asm:asm:3.3.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: asm:asm:1.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: asm:asm-util:3.3.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: asm:asm-tree:3.3.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: asm:asm-analysis:3.3.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jetbrains.kotlin:kotlin-compiler:0.2.3.8" level="project" />
|
||||
<orderEntry type="module" module-name="kdoc" scope="TEST" />
|
||||
<orderEntry type="library" name="Maven: picocontainer:picocontainer:1.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: trove4j:trove4j:1.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: guava:guava:11.0.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: asm:asm-commons:1.0" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.9" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
|
||||
</component>
|
||||
|
||||
Reference in New Issue
Block a user