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:
+14
-4
@@ -1,14 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="false">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/kotlin" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/kotlin" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="stdlib" exported="" />
|
||||
<orderEntry type="module-library" exported="" scope="TEST">
|
||||
<library>
|
||||
<CLASSES>
|
||||
@@ -157,6 +158,15 @@
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<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-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" 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>
|
||||
</module>
|
||||
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
package org.jetbrains.kotlin.doc
|
||||
|
||||
import org.jetbrains.jet.cli.KotlinCompiler
|
||||
import org.jetbrains.jet.compiler.CompileEnvironment
|
||||
import org.jetbrains.jet.cli.CompilerArguments
|
||||
import java.io.PrintStream
|
||||
import java.io.File
|
||||
import kotlin.util.orEmpty
|
||||
|
||||
/**
|
||||
* Main for running the KDocCompiler
|
||||
*/
|
||||
fun main(args: Array<String?>): Unit {
|
||||
KotlinCompiler.doMain(KDocCompiler(), args);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A version of the [[KotlinCompiler]] which includes the [[KDoc]] compiler plugin and allows
|
||||
* command line validation or for the configuration to be provided via [[KDocArguments]]
|
||||
*/
|
||||
class KDocCompiler() : KotlinCompiler() {
|
||||
|
||||
override fun configureEnvironment(environment : CompileEnvironment?, arguments : CompilerArguments?, errStream : PrintStream?) {
|
||||
// TODO lets clear the docOutput as a temporary hack while
|
||||
// KotlinCompiler has a KDoc hook...
|
||||
val docOutputDir = if (arguments != null) {
|
||||
val answer = arguments.docOutputDir
|
||||
arguments.docOutputDir = null
|
||||
answer
|
||||
} else null
|
||||
|
||||
super.configureEnvironment(environment, arguments, errStream)
|
||||
val coreEnvironment = environment?.getMyEnvironment()
|
||||
if (coreEnvironment != null) {
|
||||
// now lets add the KDoc plugin
|
||||
val outDir = File(docOutputDir ?: "target/apidocs")
|
||||
val kdoc = KDoc(outDir)
|
||||
|
||||
if (arguments is KDocArguments) {
|
||||
kdoc.config = arguments.apply()
|
||||
}
|
||||
coreEnvironment.getCompilerPlugins().orEmpty().add(kdoc);
|
||||
}
|
||||
}
|
||||
|
||||
override fun createArguments() : CompilerArguments? {
|
||||
return KDocArguments()
|
||||
}
|
||||
|
||||
override fun usage(target : PrintStream?) {
|
||||
target?.println("Usage: KDocCompiler -docOutput <docOutputDir> [-output <outputDir>|-jar <jarFileName>] [-stdlib <path to runtime.jar>] [-src <filename or dirname>|-module <module file>] [-includeRuntime]");
|
||||
}
|
||||
}
|
||||
|
||||
class KDocArguments() : CompilerArguments() {
|
||||
|
||||
public var docConfig: KDocConfig = KDocConfig()
|
||||
|
||||
/**
|
||||
* Applies the command line arguments to the given KDoc configuration
|
||||
*/
|
||||
fun apply(): KDocConfig {
|
||||
// TODO...
|
||||
return docConfig
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add more configurations here when value attributes supported
|
||||
* see: KT-1522
|
||||
|
||||
@Argument(value = "docOutput", description = "KDoc output directory")
|
||||
public String docOutputDir;
|
||||
*/
|
||||
}
|
||||
Reference in New Issue
Block a user