Libraries written in Kotlin are factored out into a separate project
This commit is contained in:
@@ -0,0 +1 @@
|
||||
target
|
||||
@@ -0,0 +1,11 @@
|
||||
import kotlin.modules.*
|
||||
|
||||
fun project() {
|
||||
module("apidocs") {
|
||||
classpath += "kunit/lib/junit-4.9.jar"
|
||||
|
||||
addSourceFiles("../stdlib/ktSrc")
|
||||
addSourceFiles("../stdlib/src")
|
||||
addSourceFiles("../kunit/src/main/kotlin")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<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" />
|
||||
</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>
|
||||
<root url="jar://$MODULE_DIR$/../testlib/lib/junit-4.9.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library" exported="">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../../dist/kotlinc/lib/intellij-core.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library" exported="">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../../dist/kotlinc/lib/kotlin-compiler.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="file://$MODULE_DIR$/../compiler/cli/src" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../../dist/kotlinc/lib/annotations.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../../dist/kotlinc/lib/asm-commons.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../../dist/kotlinc/lib/asm.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../../dist/kotlinc/lib/cli-10.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../../dist/kotlinc/lib/guava-11.0.1.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../../dist/kotlinc/lib/picocontainer.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../../dist/kotlinc/lib/trove4j.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../../lib/asm-util-3.3.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../../lib/asm-tree-3.3.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../../lib/asm-analysis-3.3.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../../lib/parboiled-core-1.0.2.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../../lib/parboiled-java-1.0.2.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../../lib/pegdown-1.1.0.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
</component>
|
||||
</module>
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import kotlin.modules.*
|
||||
|
||||
fun project() {
|
||||
module("kdoc") {
|
||||
classpath += "dist/kotlinc/lib/intellij-core.jar"
|
||||
classpath += "dist/kotlinc/lib/kotlin-compiler.jar"
|
||||
|
||||
// TODO its a bit sad we can't use patterns here...
|
||||
addClasspathEntry("dist/kotlinc/lib/pegdown-1.1.0.jar")
|
||||
addClasspathEntry("dist/kotlinc/lib/parboiled-core-1.0.2.jar")
|
||||
addClasspathEntry("dist/kotlinc/lib/parboiled-java-1.0.2.jar")
|
||||
|
||||
addSourceFiles("src/main/kotlin")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kdoc</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<junit-version>4.8.1</junit-version>
|
||||
<kotlin-compiler.version>0.2.3.8</kotlin-compiler.version>
|
||||
<kotlin-maven-plugin.version>0.2.3.8-beta-6</kotlin-maven-plugin.version>
|
||||
<kotlin-sdk>${project.basedir}/../dist/kotlinc</kotlin-sdk>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>evgeny-goldin.org</id>
|
||||
<url>http://evgeny-goldin.org/artifactory/repo/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>evgeny-goldin.org</id>
|
||||
<url>http://evgeny-goldin.org/artifactory/repo/</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<dependencies>
|
||||
<!-- TODO a dirty hack until we have the artifacts in a mvn repo -->
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-compiler</artifactId>
|
||||
<version>${kotlin-compiler.version}</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${kotlin-sdk}/lib/kotlin-compiler.jar</systemPath>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.pegdown</groupId>
|
||||
<artifactId>pegdown</artifactId>
|
||||
<version>1.1.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
|
||||
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>com.goldin.plugins</groupId>
|
||||
<artifactId>ivy-maven-plugin</artifactId>
|
||||
<version>${kotlin-maven-plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>add-ivy-dependencies</id>
|
||||
<goals>
|
||||
<goal>ivy</goal>
|
||||
</goals>
|
||||
<phase>initialize</phase>
|
||||
<configuration>
|
||||
<ivyconf>${project.basedir}/src/main/resources/ivyconf.xml</ivyconf>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>ivy.org</groupId>
|
||||
<artifactId>bt343</artifactId>
|
||||
<version>latest.lastSuccessful</version>
|
||||
<classifier>core/intellij-core</classifier>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ivy.org</groupId>
|
||||
<artifactId>bt344</artifactId>
|
||||
<version>latest.lastSuccessful</version>
|
||||
<classifier>kotlin-runtime</classifier>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<scope>compile</scope>
|
||||
<verbose>true</verbose>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>com.goldin.plugins</groupId>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<version>${kotlin-maven-plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile-kotlin-sources</id>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
<goal>testCompile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,12 @@
|
||||
package org.jetbrains.kotlin.doc
|
||||
|
||||
import org.jetbrains.kotlin.doc.model.KModel
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* A simple plugin to KDoc to generate information from the model into a directory
|
||||
* which can be implemented using any kind of layout or format.
|
||||
*/
|
||||
trait Doclet {
|
||||
fun generate(model: KModel, outputDir: File): Unit
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package org.jetbrains.kotlin.doc
|
||||
|
||||
import kotlin.*
|
||||
import kotlin.util.*
|
||||
|
||||
import org.jetbrains.kotlin.doc.templates.*
|
||||
import org.jetbrains.kotlin.template.TextTemplate
|
||||
import org.jetbrains.kotlin.doc.model.*
|
||||
|
||||
import java.io.File
|
||||
import java.util.List
|
||||
import java.util.HashSet
|
||||
import java.util.*
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext.*
|
||||
import org.jetbrains.jet.compiler.CompilerPlugin
|
||||
import org.jetbrains.jet.lang.psi.JetFile
|
||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor
|
||||
import org.jetbrains.jet.lexer.JetTokens
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor
|
||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor
|
||||
import org.jetbrains.jet.lang.types.JetType
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.jet.lang.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.jet.lang.resolve.java.JavaNamespaceDescriptor
|
||||
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ExtensionReceiver
|
||||
import org.jetbrains.jet.util.slicedmap.WritableSlice
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils
|
||||
|
||||
/** Creates JavaDoc style HTML output from the model */
|
||||
class JavadocStyleHtmlDoclet() : Doclet {
|
||||
|
||||
override fun generate(model: KModel, outputDir: File): Unit {
|
||||
fun run(fileName: String, template: TextTemplate): Unit {
|
||||
val file = File(outputDir, fileName)
|
||||
file.getParentFile()?.mkdirs()
|
||||
|
||||
log("Generating $fileName")
|
||||
template.renderTo(file)
|
||||
}
|
||||
|
||||
fun generateExtensionFunctions(p: KPackage): Unit {
|
||||
val map = inheritedExtensionFunctions(p.functions)
|
||||
val pmap = inheritedExtensionProperties(p.properties)
|
||||
val classes = hashSet<KClass>()
|
||||
classes.addAll(map.keySet())
|
||||
classes.addAll(pmap.keySet())
|
||||
for (c in classes) {
|
||||
if (c != null) {
|
||||
val functions = map.get(c).orEmpty()
|
||||
val properties = pmap.get(c).orEmpty()
|
||||
run("${p.nameAsPath}/${c.nameAsPath}-extensions.html",
|
||||
ClassExtensionsTemplate(model, p, c, functions, properties))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
println("Generating kdoc to $outputDir")
|
||||
run("allclasses-frame.html", AllClassesFrameTemplate(model, " target=\"classFrame\""))
|
||||
run("allclasses-noframe.html", AllClassesFrameTemplate(model))
|
||||
// run("constant-values.html", ConstantValuesTemplate(model))
|
||||
// run("deprecated-list.html", DeprecatedListTemplate(model))
|
||||
run("help-doc.html", HelpDocTemplate(model))
|
||||
// run("index-all.html", IndexAllTemplate(model))
|
||||
run("index.html", IndexTemplate(model))
|
||||
run("overview-frame.html", OverviewFrameTemplate(model))
|
||||
run("overview-summary.html", OverviewSummaryTemplate(model))
|
||||
run("overview-tree.html", OverviewTreeTemplate(model))
|
||||
run("package-list", PackageListTemplate(model))
|
||||
// run("serialized-form.html", SerializedFormTemplate(model))
|
||||
for (p in model.packages) {
|
||||
run("${p.nameAsPath}/package-frame.html", PackageFrameTemplate(model, p))
|
||||
run("${p.nameAsPath}/package-summary.html", PackageSummaryTemplate(model, p))
|
||||
//run("${p.nameAsPath}/package-tree.html", PackageTreeTemplate(model, p))
|
||||
//run("${p.nameAsPath}/package-use.html", PackageUseTemplate(model, p))
|
||||
for (c in p.classes) {
|
||||
run("${c.nameAsPath}.html", ClassTemplate(model, p, c))
|
||||
}
|
||||
|
||||
generateExtensionFunctions(p)
|
||||
}
|
||||
}
|
||||
|
||||
protected fun log(text: String) {
|
||||
println(text)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package org.jetbrains.kotlin.doc
|
||||
|
||||
import kotlin.*
|
||||
import kotlin.util.*
|
||||
|
||||
import org.jetbrains.kotlin.doc.templates.*
|
||||
import org.jetbrains.kotlin.template.TextTemplate
|
||||
import org.jetbrains.kotlin.doc.model.*
|
||||
|
||||
import java.io.File
|
||||
import java.util.List
|
||||
import java.util.HashSet
|
||||
import java.util.Collection
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext.*
|
||||
import org.jetbrains.jet.compiler.CompilerPlugin
|
||||
import org.jetbrains.jet.lang.psi.JetFile
|
||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor
|
||||
import org.jetbrains.jet.lexer.JetTokens
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor
|
||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor
|
||||
import org.jetbrains.jet.lang.types.JetType
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.jet.lang.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.jet.lang.resolve.java.JavaNamespaceDescriptor
|
||||
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ExtensionReceiver
|
||||
import org.jetbrains.jet.util.slicedmap.WritableSlice
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils
|
||||
|
||||
/** Generates the Kotlin Documentation for the model */
|
||||
class KDoc(val outputDir: File) : KModelCompilerPlugin() {
|
||||
|
||||
override fun processModel(model: KModel) {
|
||||
// TODO allow this to be configured; maybe we use configuration on the KotlinModule
|
||||
// to define what doclets to use?
|
||||
val generator = JavadocStyleHtmlDoclet()
|
||||
generator.generate(model, outputDir)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package org.jetbrains.kotlin.doc
|
||||
|
||||
import kotlin.*
|
||||
import kotlin.util.*
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* The configuration used with KDoc
|
||||
*/
|
||||
class KDocConfig() {
|
||||
|
||||
/**
|
||||
* Returns the name of the documentation set
|
||||
*/
|
||||
public var title: String = "Documentation"
|
||||
|
||||
/**
|
||||
* Returns a map of the package prefix to the URLs to use to link to it in the documentation
|
||||
*/
|
||||
public val packagePrefixToUrls: Map<String, String> = TreeMap<String, String>(LongestFirstStringComparator())
|
||||
|
||||
/**
|
||||
* Returns true if a warning should be generated if there are no comments
|
||||
* on documented function or property
|
||||
*/
|
||||
public var warnNoComments: Boolean = true
|
||||
|
||||
/**
|
||||
* Returns true if protected functions and properties should be documented
|
||||
*/
|
||||
public var includeProtected: Boolean = true
|
||||
|
||||
{
|
||||
// add some common defaults
|
||||
addPackageLink("http://docs.oracle.com/javase/6/docs/api/", "java", "org.w3c.dom", "org.xml.sax", "org.omg", "org.ietf.jgss")
|
||||
addPackageLink("http://kentbeck.github.com/junit/javadoc/latest/", "org.junit", "junit")
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set of all the package which have been warned that were missing an external URL
|
||||
*/
|
||||
public val missingPackageUrls: Set<String> = TreeSet<String>()
|
||||
|
||||
/**
|
||||
* Adds one or more package prefixes to the given javadoc URL
|
||||
*/
|
||||
fun addPackageLink(url: String, vararg packagePrefixes: String): Unit {
|
||||
for (p in packagePrefixes) {
|
||||
packagePrefixToUrls.put(p, url)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves a link to the given class name
|
||||
*/
|
||||
fun resolveLink(packageName: String): String {
|
||||
// TODO should be able to do something like
|
||||
// for (e in packageUrls.filterNulls()) {
|
||||
val entrySet = packagePrefixToUrls.entrySet()
|
||||
if (entrySet != null) {
|
||||
for (e in entrySet) {
|
||||
val p = e?.getKey()
|
||||
val url = e?.getValue()
|
||||
if (p != null && url != null) {
|
||||
if (packageName.startsWith(p)) {
|
||||
return url
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (missingPackageUrls.add(packageName)) {
|
||||
println("Warning: could not find external link to package: $packageName")
|
||||
}
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
protected class LongestFirstStringComparator() : Comparator<String> {
|
||||
override fun compare(s1: String, s2: String): Int {
|
||||
var answer = s1.length() - s2.length()
|
||||
if (answer == 0) {
|
||||
answer = s1.compareTo(s2)
|
||||
}
|
||||
return answer
|
||||
}
|
||||
|
||||
override fun equals(obj : Any?) : Boolean {
|
||||
return obj is LongestFirstStringComparator
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package org.jetbrains.kotlin.doc.model
|
||||
|
||||
import kotlin.*
|
||||
import kotlin.util.*
|
||||
|
||||
import org.jetbrains.kotlin.doc.KDocConfig
|
||||
import org.jetbrains.kotlin.doc.templates.*
|
||||
import org.jetbrains.kotlin.template.TextTemplate
|
||||
|
||||
import java.io.File
|
||||
import java.util.List
|
||||
import java.util.HashSet
|
||||
import java.util.Collection
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext.*
|
||||
import org.jetbrains.jet.compiler.CompilerPlugin
|
||||
import org.jetbrains.jet.lang.psi.JetFile
|
||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor
|
||||
import org.jetbrains.jet.lexer.JetTokens
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor
|
||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor
|
||||
import org.jetbrains.jet.lang.types.JetType
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.jet.lang.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.jet.lang.resolve.java.JavaNamespaceDescriptor
|
||||
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ExtensionReceiver
|
||||
import org.jetbrains.jet.util.slicedmap.WritableSlice
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils
|
||||
|
||||
|
||||
/** Base class for any compiler plugin which needs to process a KModel */
|
||||
abstract class KModelCompilerPlugin : CompilerPlugin {
|
||||
|
||||
public open var config: KDocConfig = KDocConfig()
|
||||
|
||||
override fun processFiles(context: BindingContext?, sources: List<JetFile?>?) {
|
||||
if (context != null && sources != null) {
|
||||
val model = KModel(context, config)
|
||||
model.load(sources)
|
||||
|
||||
processModel(model)
|
||||
}
|
||||
}
|
||||
|
||||
abstract fun processModel(model: KModel): Unit
|
||||
}
|
||||
@@ -0,0 +1,652 @@
|
||||
package org.jetbrains.kotlin.doc.model
|
||||
|
||||
import kotlin.*
|
||||
import kotlin.util.*
|
||||
|
||||
import org.jetbrains.kotlin.doc.KDocConfig
|
||||
|
||||
import java.util.*
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor
|
||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.jet.lang.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.jet.lang.resolve.java.JavaNamespaceDescriptor
|
||||
import org.jetbrains.jet.lang.types.JetType
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils
|
||||
import org.jetbrains.jet.lexer.JetTokens
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope
|
||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ExtensionReceiver
|
||||
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor
|
||||
import org.jetbrains.jet.lang.psi.JetFile
|
||||
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor
|
||||
import org.pegdown.PegDownProcessor
|
||||
import org.pegdown.LinkRenderer
|
||||
import org.pegdown.ast.WikiLinkNode
|
||||
import org.pegdown.LinkRenderer.Rendering
|
||||
import org.pegdown.ast.RefLinkNode
|
||||
import org.pegdown.ast.AutoLinkNode
|
||||
import org.pegdown.ast.ExpLinkNode
|
||||
import org.pegdown.Extensions
|
||||
|
||||
fun containerName(descriptor: DeclarationDescriptor): String = qualifiedName(descriptor.getContainingDeclaration())
|
||||
|
||||
fun qualifiedName(descriptor: DeclarationDescriptor?): String {
|
||||
if (descriptor == null || descriptor is ModuleDescriptor) {
|
||||
return ""
|
||||
} else {
|
||||
val parent = containerName(descriptor)
|
||||
var name = descriptor.getName() ?: ""
|
||||
if (name.startsWith("<")) {
|
||||
name = ""
|
||||
}
|
||||
val answer = if (parent.length() > 0) parent + "." + name else name
|
||||
return if (answer.startsWith(".")) answer.substring(1) else answer
|
||||
}
|
||||
}
|
||||
|
||||
// TODO for some reason the SortedMap causes kotlin to freak out a little :)
|
||||
fun inheritedExtensionFunctions(functions: Collection<KFunction>): Map<KClass, SortedSet<KFunction>> {
|
||||
//fun inheritedExtensionFunctions(functions: Collection<KFunction>): SortedMap<KClass, SortedSet<KFunction>> {
|
||||
val map = extensionFunctions(functions)
|
||||
// for each class, lets walk its base classes and add any other extension functions from base classes
|
||||
val answer = TreeMap<KClass, SortedSet<KFunction>>()
|
||||
for (c in map.keySet()) {
|
||||
val allFunctions = map.get(c).orEmpty().toSortedSet()
|
||||
answer.put(c, allFunctions)
|
||||
val des = c.descendants()
|
||||
for (b in des) {
|
||||
val list = map.get(b)
|
||||
if (list != null) {
|
||||
if (allFunctions != null) {
|
||||
for (f in list) {
|
||||
if (f != null) {
|
||||
// add the methods from the base class if we don't have a matching method
|
||||
if (!allFunctions.any{ it.name == f.name && it.parameterTypeText == f.parameterTypeText}) {
|
||||
allFunctions.add(f)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return answer
|
||||
}
|
||||
|
||||
// TODO for some reason the SortedMap causes kotlin to freak out a little :)
|
||||
fun inheritedExtensionProperties(properties: Collection<KProperty>): Map<KClass, SortedSet<KProperty>> {
|
||||
val map = extensionProperties(properties)
|
||||
// for each class, lets walk its base classes and add any other extension properties from base classes
|
||||
val answer = TreeMap<KClass, SortedSet<KProperty>>()
|
||||
for (c in map.keySet()) {
|
||||
val allProperties = map.get(c).orEmpty().toSortedSet()
|
||||
answer.put(c, allProperties)
|
||||
val des = c.descendants()
|
||||
for (b in des) {
|
||||
val list = map.get(b)
|
||||
if (list != null) {
|
||||
if (allProperties != null) {
|
||||
for (f in list) {
|
||||
if (f != null) {
|
||||
// add the proeprties from the base class if we don't have a matching method
|
||||
if (!allProperties.any{ it.name == f.name}) {
|
||||
allProperties.add(f)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return answer
|
||||
}
|
||||
|
||||
|
||||
// TODO for some reason the SortedMap causes kotlin to freak out a little :)
|
||||
fun extensionFunctions(functions: Collection<KFunction>): Map<KClass, List<KFunction>> {
|
||||
val map = TreeMap<KClass, List<KFunction>>()
|
||||
functions.filter{ it.extensionClass != null }.groupBy(map){ it.extensionClass.sure() }
|
||||
return map
|
||||
}
|
||||
|
||||
// TODO for some reason the SortedMap causes kotlin to freak out a little :)
|
||||
fun extensionProperties(properties: Collection<KProperty>): Map<KClass, List<KProperty>> {
|
||||
val map = TreeMap<KClass, List<KProperty>>()
|
||||
properties.filter{ it.extensionClass != null }.groupBy(map){ it.extensionClass.sure() }
|
||||
return map
|
||||
}
|
||||
|
||||
abstract class KClassOrPackage : KAnnotated() {
|
||||
|
||||
public open val functions: SortedSet<KFunction> = TreeSet<KFunction>()
|
||||
|
||||
public open val properties: SortedSet<KProperty> = TreeSet<KProperty>()
|
||||
}
|
||||
|
||||
class KModel(var context: BindingContext, val config: KDocConfig, var title: String = "Documentation", var version: String = "TODO") {
|
||||
// TODO generates java.lang.NoSuchMethodError: kotlin.util.namespace.hashMap(Ljet/TypeInfo;Ljet/TypeInfo;)Ljava/util/HashMap;
|
||||
//val packages = sortedMap<String,KPackage>()
|
||||
public val packageMap: SortedMap<String, KPackage> = TreeMap<String, KPackage>()
|
||||
|
||||
public val allPackages: Collection<KPackage>
|
||||
get() = packageMap.values().sure()
|
||||
|
||||
/** Returns the local packages */
|
||||
public val packages: Collection<KPackage>
|
||||
get() = allPackages.filter{ it.local }
|
||||
|
||||
public val classes: Collection<KClass>
|
||||
get() = packages.flatMap{ it.classes }
|
||||
|
||||
public var markdownProcessor: PegDownProcessor = PegDownProcessor(Extensions.ALL)
|
||||
|
||||
/** Loads the model from the given set of source files */
|
||||
fun load(sources: List<JetFile?>): Unit {
|
||||
val allNamespaces = HashSet<NamespaceDescriptor>()
|
||||
for (source in sources) {
|
||||
if (source != null) {
|
||||
// We retrieve a descriptor by a PSI element from the context
|
||||
val namespaceDescriptor = BindingContextUtils.namespaceDescriptor(context, source)
|
||||
if (namespaceDescriptor != null) {
|
||||
allNamespaces.add(namespaceDescriptor);
|
||||
}
|
||||
}
|
||||
}
|
||||
val allClasses = HashSet<KClass>()
|
||||
for (namespace in allNamespaces) {
|
||||
getPackage(namespace)
|
||||
for (descriptor in namespace.getMemberScope().getAllDescriptors()) {
|
||||
if (descriptor is ClassDescriptor) {
|
||||
val klass = getClass(descriptor)
|
||||
if (klass != null) {
|
||||
allClasses.add(klass)
|
||||
}
|
||||
} else if (descriptor is NamespaceDescriptor) {
|
||||
getPackage(descriptor)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Returns the package for the given name or null if it does not exist */
|
||||
fun getPackage(name: String): KPackage? = packageMap.get(name)
|
||||
|
||||
/** Returns the package for the given descriptor, creating one if its not available */
|
||||
fun getPackage(descriptor: NamespaceDescriptor): KPackage {
|
||||
val name = qualifiedName(descriptor)
|
||||
var created = false
|
||||
val pkg = packageMap.getOrPut(name) {
|
||||
created = true
|
||||
KPackage(this, descriptor, name)
|
||||
}
|
||||
if (created) {
|
||||
pkg.description = commentsFor(descriptor)
|
||||
val scope = descriptor.getMemberScope()
|
||||
addFunctions(pkg, scope)
|
||||
pkg.local = isLocal(descriptor)
|
||||
}
|
||||
return pkg;
|
||||
}
|
||||
|
||||
protected fun isLocal(descriptor: DeclarationDescriptor): Boolean {
|
||||
return if (descriptor is ModuleDescriptor) {
|
||||
true
|
||||
} else {
|
||||
val parent = descriptor.getContainingDeclaration()
|
||||
if (parent != null) {
|
||||
isLocal(parent)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected fun addFunctions(owner: KClassOrPackage, scope: JetScope): Unit {
|
||||
try {
|
||||
val descriptors = scope.getAllDescriptors()
|
||||
for (descriptor in descriptors) {
|
||||
if (descriptor is PropertyDescriptor) {
|
||||
val name = descriptor.getName()
|
||||
val returnType = getType(descriptor.getReturnType())
|
||||
if (returnType != null) {
|
||||
val receiver = descriptor.getReceiverParameter()
|
||||
val extensionClass = if (receiver is ExtensionReceiver) {
|
||||
getType(receiver.getType())
|
||||
} else null
|
||||
|
||||
val property = KProperty(owner, descriptor, name, returnType, extensionClass?.klass)
|
||||
owner.properties.add(property)
|
||||
}
|
||||
} else if (descriptor is CallableDescriptor) {
|
||||
val function = createFunction(owner, descriptor)
|
||||
if (function != null) {
|
||||
owner.functions.add(function)
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e: Throwable) {
|
||||
println("Caught exception finding function declarations on $owner")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected fun createFunction(owner: KClassOrPackage, descriptor: CallableDescriptor): KFunction? {
|
||||
val returnType = getType(descriptor.getReturnType())
|
||||
if (returnType != null) {
|
||||
val name = descriptor.getName() ?: "null"
|
||||
val parameters = ArrayList<KParameter>()
|
||||
val params = descriptor.getValueParameters()
|
||||
for (param in params) {
|
||||
if (param != null) {
|
||||
val p = createParameter(param)
|
||||
if (p != null) {
|
||||
parameters.add(p)
|
||||
}
|
||||
}
|
||||
}
|
||||
val function = KFunction(descriptor, owner, name, returnType, parameters)
|
||||
addTypeParameters(function.typeParameters, descriptor.getTypeParameters())
|
||||
function.description = commentsFor(descriptor)
|
||||
val receiver = descriptor.getReceiverParameter()
|
||||
if (receiver is ExtensionReceiver) {
|
||||
function.extensionClass = getType(receiver.getType())?.klass
|
||||
}
|
||||
return function
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
protected fun addTypeParameters(answer: List<KTypeParameter>, descriptors: List<TypeParameterDescriptor?>): Unit {
|
||||
for (typeParam in descriptors) {
|
||||
if (typeParam != null) {
|
||||
val p = createTypeParameter(typeParam)
|
||||
if (p != null){
|
||||
answer.add(p)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected fun createTypeParameter(descriptor: TypeParameterDescriptor): KTypeParameter? {
|
||||
val name = descriptor.getName()
|
||||
val answer = KTypeParameter(name, descriptor)
|
||||
answer.description = commentsFor(descriptor)
|
||||
return answer
|
||||
}
|
||||
|
||||
protected fun createParameter(descriptor: ValueParameterDescriptor): KParameter? {
|
||||
val returnType = getType(descriptor.getReturnType())
|
||||
if (returnType != null) {
|
||||
val name = descriptor.getName()
|
||||
val answer = KParameter(name, returnType)
|
||||
answer.description = commentsFor(descriptor)
|
||||
return answer
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
fun commentsFor(descriptor: DeclarationDescriptor): String {
|
||||
val psiElement = try {
|
||||
BindingContextUtils.descriptorToDeclaration(context, descriptor)
|
||||
} catch (e: Throwable) {
|
||||
// ignore exceptions on fake descriptors
|
||||
null
|
||||
}
|
||||
|
||||
// This method is a hack. Doc comments should be easily accessible, but they aren't for now.
|
||||
if (psiElement != null) {
|
||||
var node = psiElement.getNode()?.getTreePrev()
|
||||
while (node != null && (node?.getElementType() == JetTokens.WHITE_SPACE || node?.getElementType() == JetTokens.BLOCK_COMMENT)) {
|
||||
node = node?.getTreePrev()
|
||||
}
|
||||
if (node == null) return ""
|
||||
if (node?.getElementType() != JetTokens.DOC_COMMENT) return ""
|
||||
var text = node?.getText() ?: ""
|
||||
// lets remove the comment tokens
|
||||
val lines = text.trim().split("\\n")
|
||||
if (lines != null) {
|
||||
// lets remove the /** ... * ... */ tokens
|
||||
val buffer = StringBuilder()
|
||||
val last = lines.size - 1
|
||||
for (i in 0.upto(last)) {
|
||||
var text = lines[i] ?: ""
|
||||
text = text.trim()
|
||||
if (i == 0) {
|
||||
text = text.trimLeading("/**").trimLeading("/*")
|
||||
} else {
|
||||
buffer.append("\n")
|
||||
}
|
||||
if (i >= last) {
|
||||
text = text.trimTrailing("*/")
|
||||
} else if (i > 0) {
|
||||
text = text.trimLeading("* ")
|
||||
if (text == "*") text = ""
|
||||
}
|
||||
buffer.append(text)
|
||||
}
|
||||
val linkRenderer = CustomLinkRenderer(descriptor)
|
||||
return wikiConvert(buffer.toString() ?: "", linkRenderer)
|
||||
} else {
|
||||
return text
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
fun wikiConvert(text: String, linkRenderer: LinkRenderer): String {
|
||||
return markdownProcessor.markdownToHtml(text, linkRenderer).sure()
|
||||
}
|
||||
|
||||
fun getType(aType: JetType?): KType? {
|
||||
if (aType != null) {
|
||||
val classifierDescriptor = aType.getConstructor().getDeclarationDescriptor()
|
||||
val klass = if (classifierDescriptor is ClassDescriptor) {
|
||||
getClass(classifierDescriptor)
|
||||
} else null
|
||||
return KType(aType, this, klass)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
fun getClass(classElement: ClassDescriptor): KClass? {
|
||||
val name = classElement.getName()
|
||||
val container = classElement.getContainingDeclaration()
|
||||
if (name != null && container is NamespaceDescriptor) {
|
||||
val pkg = getPackage(container)
|
||||
return pkg.getClass(name, classElement)
|
||||
} else {
|
||||
println("No package found for $container and class $name")
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
fun previous(pkg: KPackage): KPackage? {
|
||||
// TODO
|
||||
return null
|
||||
}
|
||||
|
||||
fun next(pkg: KPackage): KPackage? {
|
||||
// TODO
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
class CustomLinkRenderer(descriptor: DeclarationDescriptor) : LinkRenderer() {
|
||||
|
||||
override fun render(node : WikiLinkNode?) : Rendering? {
|
||||
println("LinkRenderer.render(WikiLinkNode): $node")
|
||||
// TODO translate the wiki link to a Class/function/property/extensionFunction etc
|
||||
return super.render(node)
|
||||
}
|
||||
|
||||
override fun render(node : RefLinkNode?, url : String?, title : String?, text : String?) : Rendering? {
|
||||
// println("LinkRenderer.render(RefLinkNode): $node url: $url title: $title text: $text")
|
||||
return super.render(node, url, title, text)
|
||||
}
|
||||
|
||||
override fun render(node : AutoLinkNode?) : Rendering? {
|
||||
// println("LinkRenderer.render(AutoLinkNode): $node")
|
||||
return super.render(node)
|
||||
}
|
||||
|
||||
override fun render(node : ExpLinkNode?, text : String?) : Rendering? {
|
||||
// println("LinkRenderer.render(ExpLinkNode): $node text: $text")
|
||||
return super.render(node, text)
|
||||
}
|
||||
}
|
||||
|
||||
abstract class KAnnotated {
|
||||
public open var description: String = ""
|
||||
|
||||
public open var detailedDescription: String = ""
|
||||
get() = if ($detailedDescription.notEmpty()) $detailedDescription else description
|
||||
|
||||
public open var deprecated: Boolean = false
|
||||
}
|
||||
|
||||
abstract class KNamed(val name: String) : KAnnotated(), Comparable<KNamed> {
|
||||
|
||||
override fun compareTo(other: KNamed): Int = name.compareTo(other.name)
|
||||
|
||||
open fun equals(other: KPackage) = name == other.name
|
||||
|
||||
open fun toString() = name
|
||||
}
|
||||
|
||||
|
||||
class KPackage(val model: KModel, val descriptor: NamespaceDescriptor,
|
||||
val name: String,
|
||||
var local: Boolean = false) : KClassOrPackage(), Comparable<KPackage> {
|
||||
|
||||
override fun compareTo(other: KPackage): Int = name.compareTo(other.name)
|
||||
|
||||
fun equals(other: KPackage) = name == other.name
|
||||
|
||||
fun toString() = "KPackage($name)"
|
||||
|
||||
fun getClass(name: String, descriptor: ClassDescriptor): KClass {
|
||||
var created = false
|
||||
val klass = classMap.getOrPut(name) {
|
||||
created = true
|
||||
KClass(this, descriptor, name)
|
||||
}
|
||||
if (created) {
|
||||
klass.description = model.commentsFor(descriptor)
|
||||
val typeConstructor = descriptor.getTypeConstructor()
|
||||
val superTypes = typeConstructor.getSupertypes()
|
||||
for (st in superTypes) {
|
||||
val sc = model.getType(st)
|
||||
if (sc != null) {
|
||||
klass.baseClasses.add(sc)
|
||||
}
|
||||
}
|
||||
val scope = descriptor.getDefaultType().getMemberScope()
|
||||
model.addFunctions(klass, scope)
|
||||
model.addTypeParameters(klass.typeParameters, typeConstructor.getParameters())
|
||||
}
|
||||
return klass
|
||||
}
|
||||
|
||||
/** Returns the name as a directory using '/' instead of '.' */
|
||||
public val nameAsPath: String
|
||||
get() = if (name.length() == 0) "." else name.replace('.', '/')
|
||||
|
||||
/** Returns a list of all the paths in the package name */
|
||||
public val namePaths: List<String>
|
||||
get() {
|
||||
val answer = ArrayList<String>()
|
||||
for (n in name.split("\\.")) {
|
||||
if (n != null) {
|
||||
answer.add(n)
|
||||
}
|
||||
}
|
||||
return answer;
|
||||
}
|
||||
|
||||
/** Returns a relative path like ../.. for each path in the name */
|
||||
public val nameAsRelativePath: String
|
||||
get() {
|
||||
val answer = namePaths.map{ ".." }.join("/")
|
||||
return if (answer.length == 0) "" else answer + "/"
|
||||
}
|
||||
|
||||
// TODO generates java.lang.NoSuchMethodError: kotlin.util.namespace.hashMap(Ljet/TypeInfo;Ljet/TypeInfo;)Ljava/util/HashMap;
|
||||
//val classes = sortedMap<String,KClass>()
|
||||
public val classMap: SortedMap<String, KClass> = TreeMap<String, KClass>()
|
||||
|
||||
public val classes: Collection<KClass> = classMap.values().sure()
|
||||
|
||||
public val annotations: Collection<KClass> = ArrayList<KClass>()
|
||||
|
||||
fun qualifiedName(simpleName: String): String {
|
||||
return if (name.length() > 0) {
|
||||
"${name}.${simpleName}"
|
||||
} else {
|
||||
simpleName
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun previous(pkg: KClass): KClass? {
|
||||
// TODO
|
||||
return null
|
||||
}
|
||||
|
||||
fun next(pkg: KClass): KClass? {
|
||||
// TODO
|
||||
return null
|
||||
}
|
||||
|
||||
fun groupClassMap(): Map<String, List<KClass>> {
|
||||
return classes.groupBy(TreeMap<String, List<KClass>>()){it.group}
|
||||
}
|
||||
|
||||
fun packageFunctions() = functions.filter{ it.extensionClass == null }
|
||||
}
|
||||
|
||||
class KType(val jetType: JetType, val model: KModel, val klass: KClass?, val arguments: List<KType> = ArrayList<KType>()) : KNamed(klass?.name ?: jetType.toString()) {
|
||||
{
|
||||
if (klass != null) {
|
||||
this.description = klass.description
|
||||
this.detailedDescription = klass.detailedDescription
|
||||
}
|
||||
for (arg in jetType.getArguments()) {
|
||||
if (arg != null) {
|
||||
val argJetType = arg.getType()
|
||||
val t = model.getType(argJetType)
|
||||
if (t != null) {
|
||||
$arguments.add(t)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun toString() = if (nullable) "$name?" else name
|
||||
|
||||
val nullable: Boolean
|
||||
get() = jetType.isNullable()
|
||||
}
|
||||
|
||||
class KClass(val pkg: KPackage, val descriptor: ClassDescriptor,
|
||||
val simpleName: String,
|
||||
var kind: String = "class", var group: String = "Other",
|
||||
var annotations: List<KAnnotation> = arrayList<KAnnotation>(),
|
||||
var typeParameters: List<KTypeParameter> = arrayList<KTypeParameter>(),
|
||||
var since: String = "",
|
||||
var authors: List<String> = arrayList<String>(),
|
||||
var baseClasses: List<KType> = arrayList<KType>(),
|
||||
var nestedClasses: List<KClass> = arrayList<KClass>(),
|
||||
var sourceLine: Int = 2) : KClassOrPackage(), Comparable<KClass> {
|
||||
|
||||
override fun compareTo(other: KClass): Int = name.compareTo(other.name)
|
||||
|
||||
fun equals(other: KClass) = name == other.name
|
||||
|
||||
fun toString() = "$kind($name)"
|
||||
|
||||
/** Link to the type which is relative if its a local type but could be a type in a different library or null if no link */
|
||||
public var url: String? = null
|
||||
get() {
|
||||
if ($url == null) $url = "${nameAsPath}.html"
|
||||
return $url
|
||||
}
|
||||
|
||||
public val name: String = pkg.qualifiedName(simpleName)
|
||||
|
||||
public val model: KModel = pkg.model
|
||||
|
||||
public val packageName: String = pkg.name
|
||||
|
||||
/** Returns the name as a directory using '/' instead of '.' */
|
||||
public val nameAsPath: String
|
||||
get() = name.replace('.', '/')
|
||||
|
||||
|
||||
fun isAnnotation() = kind == "annotation"
|
||||
fun isInterface() = kind == "interface"
|
||||
|
||||
/** Returns all of the base classes and all of their descendants */
|
||||
fun descendants(answer: Set<KClass> = LinkedHashSet<KClass>()): Set<KClass> {
|
||||
for (b in baseClasses) {
|
||||
val c = b.klass
|
||||
if (c != null) {
|
||||
answer.add(c)
|
||||
c.descendants(answer)
|
||||
}
|
||||
}
|
||||
return answer
|
||||
}
|
||||
}
|
||||
|
||||
class KFunction(val descriptor: CallableDescriptor, val owner: KClassOrPackage, val name: String,
|
||||
var returnType: KType,
|
||||
var parameters: List<KParameter>,
|
||||
var extensionClass: KClass? = null,
|
||||
var modifiers: List<String> = arrayList<String>(),
|
||||
var typeParameters: List<KTypeParameter> = arrayList<KTypeParameter>(),
|
||||
var exceptions: List<KClass> = arrayList<KClass>(),
|
||||
var annotations: List<KAnnotation> = arrayList<KAnnotation>(),
|
||||
var sourceLine: Int = 2) : KAnnotated(), Comparable<KFunction> {
|
||||
|
||||
public val parameterTypeText: String = parameters.map{ it.aType.name }.join(", ")
|
||||
|
||||
override fun compareTo(other: KFunction): Int {
|
||||
var answer = name.compareTo(other.name)
|
||||
if (answer == 0) {
|
||||
answer = parameterTypeText.compareTo(other.parameterTypeText)
|
||||
if (answer == 0) {
|
||||
val ec1 = extensionClass?.name ?: ""
|
||||
val ec2 = other.extensionClass?.name ?: ""
|
||||
answer = ec1.compareTo(ec2)
|
||||
}
|
||||
}
|
||||
return answer
|
||||
}
|
||||
|
||||
fun equals(other: KFunction) = name == other.name && this.parameterTypeText == other.parameterTypeText &&
|
||||
this.extensionClass == other.extensionClass && this.owner == other.owner
|
||||
|
||||
fun toString() = "fun $name($parameterTypeText): $returnType"
|
||||
|
||||
public val link: String = "$name($parameterTypeText)"
|
||||
|
||||
/** Returns a list of generic type parameter names kinds like "A, I" */
|
||||
public val typeParametersText: String
|
||||
get() = typeParameters.map{ it.name }.join(", ")
|
||||
}
|
||||
|
||||
class KProperty(val owner: KClassOrPackage, val descriptor: PropertyDescriptor, val name: String,
|
||||
val returnType: KType, val extensionClass: KClass?) : KAnnotated(), Comparable<KProperty> {
|
||||
|
||||
override fun compareTo(other: KProperty): Int = name.compareTo(other.name)
|
||||
|
||||
public val link: String = "$name"
|
||||
|
||||
fun equals(other: KFunction) = name == other.name
|
||||
|
||||
fun toString() = "property $name"
|
||||
}
|
||||
|
||||
class KParameter(val name: String,
|
||||
var aType: KType) : KAnnotated() {
|
||||
|
||||
fun toString() = "$name: ${aType.name}"
|
||||
}
|
||||
|
||||
class KTypeParameter(val name: String,
|
||||
val descriptor: TypeParameterDescriptor,
|
||||
var extends: List<KClass> = arrayList<KClass>()) : KAnnotated() {
|
||||
|
||||
fun toString() = "$name"
|
||||
}
|
||||
|
||||
class KAnnotation(var klass: KClass) : KAnnotated() {
|
||||
|
||||
// TODO add some parameter values?
|
||||
|
||||
fun toString() = "@$klass.simpleName"
|
||||
}
|
||||
Vendored
+45
@@ -0,0 +1,45 @@
|
||||
package org.jetbrains.kotlin.doc.templates
|
||||
|
||||
import kotlin.*
|
||||
import org.jetbrains.kotlin.template.*
|
||||
import kotlin.io.*
|
||||
import kotlin.util.*
|
||||
import java.util.*
|
||||
import org.jetbrains.kotlin.doc.model.KModel
|
||||
|
||||
class AllClassesFrameTemplate(val model: KModel, val classAttributes: String = "") : KDocTemplate() {
|
||||
override fun render() {
|
||||
println("""<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<!--NewPage-->
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<!-- Generated by kdoc (${model.version}) on ${Date()} -->
|
||||
<META http-equiv="Content-Type"
|
||||
content="text/html; charset=UTF-8">
|
||||
<TITLE>
|
||||
All Classes (${model.title})</TITLE>
|
||||
|
||||
<META NAME="date" CONTENT="2012-01-09">
|
||||
<LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">
|
||||
</HEAD>
|
||||
|
||||
<BODY BGCOLOR="white">
|
||||
<FONT size="+1" CLASS="FrameHeadingFont">
|
||||
<B>All Classes</B></FONT>
|
||||
<BR>
|
||||
|
||||
<TABLE BORDER="0" WIDTH="100%" SUMMARY="">
|
||||
<TR>
|
||||
<TD NOWRAP><FONT CLASS="FrameItemFont">""")
|
||||
for (c in model.classes) {
|
||||
println("""<A HREF="${c.nameAsPath}.html" title="class in ${c.packageName}"$classAttributes>${c.simpleName}</A>
|
||||
<BR>""")
|
||||
}
|
||||
println("""</FONT></TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</BODY>
|
||||
</HTML>
|
||||
""")
|
||||
}
|
||||
}
|
||||
Vendored
+46
@@ -0,0 +1,46 @@
|
||||
package org.jetbrains.kotlin.doc.templates
|
||||
|
||||
import kotlin.*
|
||||
import org.jetbrains.kotlin.template.*
|
||||
import kotlin.io.*
|
||||
import kotlin.util.*
|
||||
import java.util.*
|
||||
import org.jetbrains.kotlin.doc.model.KModel
|
||||
import org.jetbrains.kotlin.doc.model.KPackage
|
||||
import org.jetbrains.kotlin.doc.model.KClass
|
||||
import org.jetbrains.kotlin.doc.model.KFunction
|
||||
import org.jetbrains.kotlin.doc.model.KAnnotation
|
||||
import org.jetbrains.kotlin.doc.model.KProperty
|
||||
|
||||
class ClassExtensionsTemplate(m: KModel, p: KPackage, k: KClass,
|
||||
val functions: Collection<KFunction>, val properties: Collection<KProperty>) : ClassTemplate(m, p, k) {
|
||||
|
||||
override fun pageTitle(): String = "${klass.name} Extensions fom ${pkg.name} (${model.title})"
|
||||
|
||||
override fun printBody(): Unit {
|
||||
println("""<HR>
|
||||
<!-- ======== START OF CLASS EXTENSIONS DATA ======== -->
|
||||
<H2>
|
||||
<FONT SIZE="-1">
|
||||
${pkg.name}</FONT>
|
||||
<BR>
|
||||
Extensions on ${klass.name}</H2>
|
||||
<DL>
|
||||
<DT>
|
||||
extension functions on class <A HREF="${sourceHref(klass)}"><B>${klass.name}</B></A><DT>
|
||||
from package ${link(pkg)}
|
||||
</DL>
|
||||
</PRE>
|
||||
|
||||
<P>""")
|
||||
printPropertySummary(properties)
|
||||
printFunctionSummary(functions)
|
||||
printFunctionDetail(functions)
|
||||
println("""<!-- ========= END OF CLASS EXTENSIONS DATA ========= -->
|
||||
<HR>
|
||||
""")
|
||||
}
|
||||
|
||||
override fun href(f: KFunction): String = "#${f.link}"
|
||||
|
||||
}
|
||||
+263
@@ -0,0 +1,263 @@
|
||||
package org.jetbrains.kotlin.doc.templates
|
||||
|
||||
import kotlin.*
|
||||
import org.jetbrains.kotlin.template.*
|
||||
import kotlin.io.*
|
||||
import kotlin.util.*
|
||||
import java.util.*
|
||||
import org.jetbrains.kotlin.doc.model.KModel
|
||||
import org.jetbrains.kotlin.doc.model.KPackage
|
||||
import org.jetbrains.kotlin.doc.model.KClass
|
||||
import org.jetbrains.kotlin.doc.model.KFunction
|
||||
import org.jetbrains.kotlin.doc.model.KAnnotation
|
||||
|
||||
open class ClassTemplate(open val model: KModel, pkg: KPackage, open val klass: KClass) : PackageTemplateSupport(pkg) {
|
||||
|
||||
open fun pageTitle(): String = "${klass.name} (${model.title})"
|
||||
|
||||
override fun render() {
|
||||
println("""<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<!--NewPage-->
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<!-- Generated by kdoc (${model.version}) on ${Date()} -->
|
||||
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<TITLE>
|
||||
${pageTitle()}
|
||||
</TITLE>
|
||||
|
||||
<META NAME="date" CONTENT="2012-01-09">
|
||||
<META NAME="date" CONTENT="2012-01-09">
|
||||
<LINK REL="stylesheet" TYPE="text/css" HREF="${pkg.nameAsRelativePath}stylesheet.css" TITLE="Style">
|
||||
|
||||
<SCRIPT type="text/javascript">
|
||||
function windowTitle()
|
||||
{
|
||||
if (location.href.indexOf('is-external=true') == -1) {
|
||||
parent.document.title="${klass.name} (${model.title})";
|
||||
}
|
||||
}
|
||||
</SCRIPT>
|
||||
<NOSCRIPT>
|
||||
</NOSCRIPT>
|
||||
|
||||
</HEAD>
|
||||
|
||||
<BODY BGCOLOR="white" onload="windowTitle();">
|
||||
<HR>
|
||||
|
||||
|
||||
<!-- ========= START OF TOP NAVBAR ======= -->
|
||||
<A NAME="navbar_top"><!-- --></A>
|
||||
<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
|
||||
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
|
||||
<TR>
|
||||
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
|
||||
<A NAME="navbar_top_firstrow"><!-- --></A>
|
||||
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
|
||||
<TR ALIGN="center" VALIGN="top">
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="${pkg.nameAsRelativePath}overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/${klass.simpleName}.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="${pkg.nameAsRelativePath}deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="${pkg.nameAsRelativePath}index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="${pkg.nameAsRelativePath}help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</TD>
|
||||
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
|
||||
</EM>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
""")
|
||||
|
||||
printPrevNextClass()
|
||||
println("""<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
|
||||
<A HREF="${pkg.nameAsRelativePath}index.html?${klass.nameAsPath}.html" target="_top"><B>FRAMES</B></A>
|
||||
<A HREF="${klass.simpleName}.html" target="_top"><B>NO FRAMES</B></A>
|
||||
<SCRIPT type="text/javascript">
|
||||
<!--
|
||||
if(window==top) {
|
||||
document.writeln('<A HREF="${pkg.nameAsRelativePath}allclasses-noframe.html"><B>All Classes</B></A>');
|
||||
}
|
||||
//-->
|
||||
</SCRIPT>
|
||||
<NOSCRIPT>
|
||||
<A HREF="${pkg.nameAsRelativePath}allclasses-noframe.html"><B>All Classes</B></A>
|
||||
</NOSCRIPT>
|
||||
|
||||
|
||||
</FONT></TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
|
||||
SUMMARY: <A HREF="#nested_class_summary">NESTED</A> | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD>
|
||||
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
|
||||
DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
<A NAME="skip-navbar_top"></A>
|
||||
<!-- ========= END OF TOP NAVBAR ========= -->
|
||||
""")
|
||||
|
||||
printBody()
|
||||
|
||||
println("""<!-- ======= START OF BOTTOM NAVBAR ====== -->
|
||||
<A NAME="navbar_bottom"><!-- --></A>
|
||||
<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
|
||||
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
|
||||
<TR>
|
||||
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
|
||||
<A NAME="navbar_bottom_firstrow"><!-- --></A>
|
||||
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
|
||||
<TR ALIGN="center" VALIGN="top">
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="${pkg.nameAsRelativePath}overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
|
||||
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/${klass.simpleName}.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="${pkg.nameAsRelativePath}deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="${pkg.nameAsRelativePath}index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="${pkg.nameAsRelativePath}help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</TD>
|
||||
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
|
||||
</EM>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR>""")
|
||||
printPrevNextClass()
|
||||
println("""<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
|
||||
<A HREF="${pkg.nameAsRelativePath}index.html?${klass.nameAsPath}.html" target="_top"><B>FRAMES</B></A>
|
||||
<A HREF="${klass.simpleName}.html" target="_top"><B>NO FRAMES</B></A>
|
||||
<SCRIPT type="text/javascript">
|
||||
<!--
|
||||
if(window==top) {
|
||||
document.writeln('<A HREF="${pkg.nameAsRelativePath}allclasses-noframe.html"><B>All Classes</B></A>');
|
||||
}
|
||||
//-->
|
||||
</SCRIPT>
|
||||
<NOSCRIPT>${pkg.nameAsRelativePath}allclasses-noframe.html"><B>All Classes</B></A>
|
||||
</NOSCRIPT>
|
||||
|
||||
|
||||
</FONT></TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
|
||||
SUMMARY: <A HREF="#nested_class_summary">NESTED</A> | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD>
|
||||
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
|
||||
DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
<A NAME="skip-navbar_bottom"></A>
|
||||
<!-- ======== END OF BOTTOM NAVBAR ======= -->
|
||||
|
||||
<HR>
|
||||
Copyright © 2010-2012. All Rights Reserved.
|
||||
</BODY>
|
||||
</HTML>""")
|
||||
}
|
||||
|
||||
open fun printBody(): Unit {
|
||||
println("""<HR>
|
||||
<!-- ======== START OF CLASS DATA ======== -->
|
||||
<H2>
|
||||
<FONT SIZE="-1">
|
||||
${pkg.name}</FONT>
|
||||
<BR>
|
||||
Class ${klass.simpleName}</H2>
|
||||
<PRE>""")
|
||||
|
||||
for (bc in klass.baseClasses) {
|
||||
println(link(bc, true))
|
||||
}
|
||||
println(""" <IMG SRC="${pkg.nameAsRelativePath}resources/inherit.gif" ALT="extended by "><B>${klass.name}</B>
|
||||
</PRE>
|
||||
<HR>
|
||||
<DL>
|
||||
<DT><PRE><FONT SIZE="-1">""")
|
||||
printAnnotations(klass.annotations)
|
||||
print("""</FONT>public class <A HREF="${sourceHref(klass)}"><B>${klass.simpleName}</B></A><DT>""")
|
||||
if (!klass.baseClasses.isEmpty()) {
|
||||
print("""extends """)
|
||||
for (bc in klass.baseClasses) {
|
||||
println(link(bc))
|
||||
}
|
||||
}
|
||||
println("""</DL>
|
||||
</PRE>
|
||||
|
||||
<P>""")
|
||||
println(klass.detailedDescription)
|
||||
if (klass.since.size > 0 || klass.authors.size > 0) {
|
||||
println("""<P>
|
||||
<DL>""")
|
||||
if (klass.since.size > 0) {
|
||||
println("""<DT><B>Since:</B></DT>
|
||||
<DD>${klass.since}</DD>""")
|
||||
}
|
||||
for (author in klass.authors) {
|
||||
println("""<DT><B>Author:</B></DT>
|
||||
<DD>${author}</DD>""")
|
||||
}
|
||||
println("""</DL>""")
|
||||
}
|
||||
|
||||
println("""<HR>
|
||||
|
||||
<P>""")
|
||||
val nestedClasses = klass.nestedClasses
|
||||
if (!nestedClasses.isEmpty()) {
|
||||
println("""<!-- ======== NESTED CLASS SUMMARY ======== -->
|
||||
|
||||
<A NAME="nested_class_summary"><!-- --></A>
|
||||
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
|
||||
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
|
||||
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
|
||||
<B>Nested Class Summary</B></FONT></TH>
|
||||
</TR>""")
|
||||
for (nc in nestedClasses) {
|
||||
println("""<TR BGCOLOR="white" CLASS="TableRowColor">
|
||||
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||||
<CODE>static class</CODE></FONT></TD>
|
||||
<TD><CODE><B><A HREF="${pkg.nameAsRelativePath}${nc.nameAsPath}.html" title="class in ${nc.packageName}">${klass.simpleName}.${nc.simpleName}</A></B></CODE>
|
||||
<BR>
|
||||
${nc.description}
|
||||
</TD>""")
|
||||
}
|
||||
println("""</TR>
|
||||
</TABLE>
|
||||
""")
|
||||
}
|
||||
|
||||
printPropertySummary(klass.properties)
|
||||
printFunctionSummary(klass.functions)
|
||||
printFunctionDetail(klass.functions)
|
||||
|
||||
println("""<!-- ========= END OF CLASS DATA ========= -->
|
||||
<HR>
|
||||
""")
|
||||
}
|
||||
|
||||
open fun printPrevNextClass(): Unit {
|
||||
println("""<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">""")
|
||||
val prev = pkg.previous(klass)
|
||||
if (prev != null) {
|
||||
println(""" <A HREF="${pkg.nameAsRelativePath}${prev.nameAsPath}.html" title="class in ${prev.packageName}"><B>PREV CLASS</B></A> """)
|
||||
|
||||
}
|
||||
val next = pkg.next(klass)
|
||||
if (next != null) {
|
||||
println(""" <A HREF="${pkg.nameAsRelativePath}${next.nameAsPath}.html" title="class in ${next.packageName}"><B>NEXT CLASS</B></A>""")
|
||||
}
|
||||
println("""</FONT></TD>""")
|
||||
}
|
||||
|
||||
}
|
||||
+237
@@ -0,0 +1,237 @@
|
||||
package org.jetbrains.kotlin.doc.templates
|
||||
|
||||
import kotlin.*
|
||||
import org.jetbrains.kotlin.template.*
|
||||
import kotlin.io.*
|
||||
import kotlin.util.*
|
||||
import java.util.*
|
||||
import org.jetbrains.kotlin.doc.model.KModel
|
||||
|
||||
class HelpDocTemplate(val model: KModel) : KDocTemplate() {
|
||||
override fun render() {
|
||||
println("""<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
|
||||
<!--NewPage-->
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<!-- Generated by javadoc on Mon Jan 09 13:32:00 EST 2012-->
|
||||
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<TITLE>
|
||||
API Help (${model.title})
|
||||
</TITLE>
|
||||
|
||||
<META NAME="date" CONTENT="2012-01-09">
|
||||
|
||||
<LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">
|
||||
|
||||
<SCRIPT type="text/javascript">
|
||||
function windowTitle()
|
||||
{
|
||||
if (location.href.indexOf('is-external=true') == -1) {
|
||||
parent.document.title="API Help (${model.title})";
|
||||
}
|
||||
}
|
||||
</SCRIPT>
|
||||
<NOSCRIPT>
|
||||
</NOSCRIPT>
|
||||
|
||||
</HEAD>
|
||||
|
||||
<BODY BGCOLOR="white" onload="windowTitle();">
|
||||
<HR>
|
||||
|
||||
|
||||
<!-- ========= START OF TOP NAVBAR ======= -->
|
||||
<A NAME="navbar_top"><!-- --></A>
|
||||
<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
|
||||
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
|
||||
<TR>
|
||||
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
|
||||
<A NAME="navbar_top_firstrow"><!-- --></A>
|
||||
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
|
||||
<TR ALIGN="center" VALIGN="top">
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Package</FONT> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Class</FONT> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Use</FONT> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="overview-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
|
||||
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Help</B></FONT> </TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</TD>
|
||||
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
|
||||
</EM>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
|
||||
PREV
|
||||
NEXT</FONT></TD>
|
||||
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
|
||||
<A HREF="index.html?help-doc.html" target="_top"><B>FRAMES</B></A>
|
||||
<A HREF="help-doc.html" target="_top"><B>NO FRAMES</B></A>
|
||||
<SCRIPT type="text/javascript">
|
||||
<!--
|
||||
if(window==top) {
|
||||
document.writeln('<A HREF="allclasses-noframe.html"><B>All Classes</B></A>');
|
||||
}
|
||||
//-->
|
||||
</SCRIPT>
|
||||
<NOSCRIPT>
|
||||
<A HREF="allclasses-noframe.html"><B>All Classes</B></A>
|
||||
</NOSCRIPT>
|
||||
|
||||
|
||||
</FONT></TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
<A NAME="skip-navbar_top"></A>
|
||||
<!-- ========= END OF TOP NAVBAR ========= -->
|
||||
|
||||
<HR>
|
||||
<CENTER>
|
||||
<H1>
|
||||
How This API Document Is Organized</H1>
|
||||
</CENTER>
|
||||
This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.<H3>
|
||||
Overview</H3>
|
||||
<BLOCKQUOTE>
|
||||
|
||||
<P>
|
||||
The <A HREF="overview-summary.html">Overview</A> page is the front page of this API document and provides a list of all packages with a summary for each. This page can also contain an overall description of the set of packages.</BLOCKQUOTE>
|
||||
<H3>
|
||||
Package</H3>
|
||||
<BLOCKQUOTE>
|
||||
|
||||
<P>
|
||||
Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain four categories:<UL>
|
||||
<LI>Interfaces (italic)<LI>Classes<LI>Enums<LI>Exceptions<LI>Errors<LI>Annotation Types</UL>
|
||||
</BLOCKQUOTE>
|
||||
<H3>
|
||||
Class/Interface</H3>
|
||||
<BLOCKQUOTE>
|
||||
|
||||
<P>
|
||||
Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:<UL>
|
||||
<LI>Class inheritance diagram<LI>Direct Subclasses<LI>All Known Subinterfaces<LI>All Known Implementing Classes<LI>Class/interface declaration<LI>Class/interface description
|
||||
<P>
|
||||
<LI>Nested Class Summary<LI>Field Summary<LI>Constructor Summary<LI>Method Summary
|
||||
<P>
|
||||
<LI>Field Detail<LI>Constructor Detail<LI>Method Detail</UL>
|
||||
Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.</BLOCKQUOTE>
|
||||
</BLOCKQUOTE>
|
||||
<H3>
|
||||
Annotation Type</H3>
|
||||
<BLOCKQUOTE>
|
||||
|
||||
<P>
|
||||
Each annotation type has its own separate page with the following sections:<UL>
|
||||
<LI>Annotation Type declaration<LI>Annotation Type description<LI>Required Element Summary<LI>Optional Element Summary<LI>Element Detail</UL>
|
||||
</BLOCKQUOTE>
|
||||
</BLOCKQUOTE>
|
||||
<H3>
|
||||
Enum</H3>
|
||||
<BLOCKQUOTE>
|
||||
|
||||
<P>
|
||||
Each enum has its own separate page with the following sections:<UL>
|
||||
<LI>Enum declaration<LI>Enum description<LI>Enum Constant Summary<LI>Enum Constant Detail</UL>
|
||||
</BLOCKQUOTE>
|
||||
<H3>
|
||||
Use</H3>
|
||||
<BLOCKQUOTE>
|
||||
Each documented package, class and interface has its own Use page. This page describes what packages, classes, methods, constructors and fields use any part of the given class or package. Given a class or interface A, its Use page includes subclasses of A, fields declared as A, methods that return A, and methods and constructors with parameters of type A. You can access this page by first going to the package, class or interface, then clicking on the "Use" link in the navigation bar.</BLOCKQUOTE>
|
||||
<H3>
|
||||
Tree (Class Hierarchy)</H3>
|
||||
<BLOCKQUOTE>
|
||||
There is a <A HREF="overview-tree.html">Class Hierarchy</A> page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with <code>java.lang.Object</code>. The interfaces do not inherit from <code>java.lang.Object</code>.<UL>
|
||||
<LI>When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.<LI>When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.</UL>
|
||||
</BLOCKQUOTE>
|
||||
<H3>
|
||||
Deprecated API</H3>
|
||||
<BLOCKQUOTE>
|
||||
The <A HREF="deprecated-list.html">Deprecated API</A> page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.</BLOCKQUOTE>
|
||||
<H3>
|
||||
Index</H3>
|
||||
<BLOCKQUOTE>
|
||||
The <A HREF="index-all.html">Index</A> contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.</BLOCKQUOTE>
|
||||
<H3>
|
||||
Prev/Next</H3>
|
||||
These links take you to the next or previous class, interface, package, or related page.<H3>
|
||||
Frames/No Frames</H3>
|
||||
These links show and hide the HTML frames. All pages are available with or without frames.
|
||||
<P>
|
||||
<H3>
|
||||
Serialized Form</H3>
|
||||
Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.
|
||||
<P>
|
||||
<H3>
|
||||
Constant Field Values</H3>
|
||||
The <a href="constant-values.html">Constant Field Values</a> page lists the static final fields and their values.
|
||||
<P>
|
||||
<FONT SIZE="-1">
|
||||
<EM>
|
||||
This help file applies to API documentation generated using the standard doclet.</EM>
|
||||
</FONT>
|
||||
<BR>
|
||||
<HR>
|
||||
|
||||
|
||||
<!-- ======= START OF BOTTOM NAVBAR ====== -->
|
||||
<A NAME="navbar_bottom"><!-- --></A>
|
||||
<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
|
||||
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
|
||||
<TR>
|
||||
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
|
||||
<A NAME="navbar_bottom_firstrow"><!-- --></A>
|
||||
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
|
||||
<TR ALIGN="center" VALIGN="top">
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Package</FONT> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Class</FONT> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Use</FONT> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="overview-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
|
||||
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Help</B></FONT> </TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</TD>
|
||||
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
|
||||
</EM>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
|
||||
PREV
|
||||
NEXT</FONT></TD>
|
||||
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
|
||||
<A HREF="index.html?help-doc.html" target="_top"><B>FRAMES</B></A>
|
||||
<A HREF="help-doc.html" target="_top"><B>NO FRAMES</B></A>
|
||||
<SCRIPT type="text/javascript">
|
||||
<!--
|
||||
if(window==top) {
|
||||
document.writeln('<A HREF="allclasses-noframe.html"><B>All Classes</B></A>');
|
||||
}
|
||||
//-->
|
||||
</SCRIPT>
|
||||
<NOSCRIPT>
|
||||
<A HREF="allclasses-noframe.html"><B>All Classes</B></A>
|
||||
</NOSCRIPT>
|
||||
|
||||
|
||||
</FONT></TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
<A NAME="skip-navbar_bottom"></A>
|
||||
<!-- ======== END OF BOTTOM NAVBAR ======= -->
|
||||
|
||||
<HR>
|
||||
Copyright © 2012. All Rights Reserved.
|
||||
</BODY>
|
||||
</HTML>""")
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
package org.jetbrains.kotlin.doc.templates
|
||||
|
||||
import kotlin.*
|
||||
import org.jetbrains.kotlin.template.*
|
||||
import kotlin.io.*
|
||||
import kotlin.util.*
|
||||
import java.util.*
|
||||
import org.jetbrains.kotlin.doc.model.KModel
|
||||
|
||||
class IndexTemplate(val model: KModel) : KDocTemplate() {
|
||||
override fun render() {
|
||||
print("""<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
|
||||
<!--NewPage-->
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<!-- Generated by javadoc on Mon Jan 09 13:32:00 EST 2012-->
|
||||
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<TITLE>
|
||||
${model.title}
|
||||
</TITLE>
|
||||
<SCRIPT type="text/javascript">
|
||||
targetPage = "" + window.location.search;
|
||||
if (targetPage != "" && targetPage != "undefined")
|
||||
targetPage = targetPage.substring(1);
|
||||
if (targetPage.indexOf(":") != -1)
|
||||
targetPage = "undefined";
|
||||
function loadFrames() {
|
||||
if (targetPage != "" && targetPage != "undefined")
|
||||
top.classFrame.location = top.targetPage;
|
||||
}
|
||||
</SCRIPT>
|
||||
<NOSCRIPT>
|
||||
</NOSCRIPT>
|
||||
</HEAD>
|
||||
<FRAMESET cols="20%,80%" title="" onLoad="top.loadFrames()">
|
||||
<FRAMESET rows="30%,70%" title="" onLoad="top.loadFrames()">
|
||||
<FRAME src="overview-frame.html" name="packageListFrame" title="All Packages">
|
||||
<FRAME src="allclasses-frame.html" name="packageFrame" title="All classes and interfaces (except non-static nested types)">
|
||||
</FRAMESET>
|
||||
<FRAME src="overview-summary.html" name="classFrame" title="Package, class and interface descriptions" scrolling="yes">
|
||||
<NOFRAMES>
|
||||
<H2>
|
||||
Frame Alert</H2>
|
||||
|
||||
<P>
|
||||
This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client.
|
||||
<BR>
|
||||
Link to<A HREF="overview-summary.html">Non-frame version.</A>
|
||||
</NOFRAMES>
|
||||
</FRAMESET>
|
||||
</HTML>
|
||||
""")
|
||||
}
|
||||
}
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
package org.jetbrains.kotlin.doc.templates
|
||||
|
||||
import kotlin.*
|
||||
import kotlin.util.*
|
||||
import org.jetbrains.kotlin.doc.model.KClass
|
||||
import org.jetbrains.kotlin.doc.model.KAnnotation
|
||||
import org.jetbrains.kotlin.doc.model.KPackage
|
||||
import org.jetbrains.kotlin.template.TextTemplate
|
||||
import org.jetbrains.kotlin.doc.model.KFunction
|
||||
import java.util.Collection
|
||||
import org.jetbrains.kotlin.doc.model.KProperty
|
||||
import org.jetbrains.kotlin.doc.model.KType
|
||||
import java.util.List
|
||||
|
||||
abstract class KDocTemplate() : TextTemplate() {
|
||||
open fun rootHref(pkg: KPackage): String {
|
||||
return if (pkg.local)
|
||||
relativePrefix()
|
||||
else
|
||||
pkg.model.config.resolveLink(pkg.name)
|
||||
}
|
||||
|
||||
open fun href(p: KPackage): String
|
||||
= "${rootHref(p)}${p.nameAsPath}/package-summary.html"
|
||||
|
||||
open fun href(c: KClass): String {
|
||||
val postfix = if (c.pkg.local) "" else "?is-external=true"
|
||||
return "${rootHref(c.pkg)}${c.nameAsPath}.html$postfix"
|
||||
}
|
||||
|
||||
open fun href(f: KFunction): String {
|
||||
return if (f.owner is KClass) {
|
||||
"${href(f.owner)}#${f.link}"
|
||||
} else {
|
||||
"package-summary.html#${f.link}"
|
||||
}
|
||||
}
|
||||
|
||||
open fun href(f: KProperty): String {
|
||||
return if (f.owner is KClass) {
|
||||
"${href(f.owner)}#${f.link}"
|
||||
} else {
|
||||
"package-summary.html#${f.link}"
|
||||
}
|
||||
}
|
||||
|
||||
open fun extensionsHref(pkg: KPackage, c: KClass): String {
|
||||
// is inside the pkg so no need to use it...
|
||||
return "${c.nameAsPath}-extensions.html"
|
||||
}
|
||||
|
||||
open fun extensionsHref(pkg: KPackage, c: KClass, f: KFunction): String {
|
||||
return "${extensionsHref(pkg, c)}#${f.link}"
|
||||
}
|
||||
|
||||
open fun sourceHref(klass: KClass): String {
|
||||
val pkg = klass.pkg
|
||||
return if (pkg.local) {
|
||||
"${pkg.nameAsRelativePath}src-html/${klass.nameAsPath}.html#line.${klass.sourceLine}"
|
||||
} else {
|
||||
href(klass)
|
||||
}
|
||||
}
|
||||
open fun sourceHref(f: KFunction): String {
|
||||
val owner = f.owner
|
||||
return if (owner is KClass) {
|
||||
val pkg = owner.pkg
|
||||
if (pkg.local) {
|
||||
"${rootHref(pkg)}src-html/${owner.simpleName}.html#line.${f.sourceLine}"
|
||||
} else {
|
||||
href(f)
|
||||
}
|
||||
} else if (owner is KPackage) {
|
||||
if (owner.local) {
|
||||
// TODO how to find the function in a package???
|
||||
"${rootHref(owner)}src-html/namespace.html#line.${f.sourceLine}"
|
||||
} else {
|
||||
href(owner)
|
||||
}
|
||||
} else href(f)
|
||||
}
|
||||
|
||||
open fun link(c: KClass, fullName: Boolean = false): String {
|
||||
val prefix = if (c.isAnnotation()) "@" else ""
|
||||
val name = if (fullName) c.name else c.simpleName
|
||||
return "<A HREF=\"${href(c)}\" title=\"${c.kind} in ${c.packageName}\">$prefix$name</A>"
|
||||
}
|
||||
|
||||
open fun link(t: KType, fullName: Boolean = false): String {
|
||||
val c = t.klass
|
||||
val arguments = t.arguments
|
||||
return if (c != null) {
|
||||
val prefix = if (c.isAnnotation()) "@" else ""
|
||||
val cname = c.name
|
||||
if ((cname.startsWith("jet.Function") || cname.startsWith("jet.ExtensionFunction")) && arguments.notEmpty()) {
|
||||
val rt = arguments.last()
|
||||
// TODO use drop()
|
||||
val rest = arguments.subList(0, arguments.size - 1).orEmpty()
|
||||
"${typeArguments(rest, "(", ")", "()")} <A HREF=\"${href(c)}\" title=\"${c.kind} in ${c.packageName}\">-></a> ${link(rt)}"
|
||||
} else if (cname.startsWith("jet.Tuple")) {
|
||||
if (arguments.isEmpty()) {
|
||||
"Unit"
|
||||
} else {
|
||||
"<A HREF=\"${href(c)}\" title=\"${c.kind} in ${c.packageName}\">#</a>${typeArguments(arguments, "(", ")", "()")}"
|
||||
}
|
||||
} else {
|
||||
val name = if (fullName) cname else c.simpleName
|
||||
"<A HREF=\"${href(c)}\" title=\"${c.kind} in ${c.packageName}\">$prefix$name</A>${typeArguments(arguments)}"
|
||||
}
|
||||
} else {
|
||||
"${t.name}${typeArguments(arguments)}"
|
||||
}
|
||||
}
|
||||
|
||||
open fun typeArguments(arguments: List<KType>, val prefix: String = "<", val postfix: String = ">", val empty: String = ""): String {
|
||||
val text = arguments.map<KType, String>() { link(it) }.join(", ")
|
||||
return if (text.length() == 0) empty else "$prefix$text$postfix"
|
||||
}
|
||||
|
||||
open fun link(p: KPackage): String {
|
||||
return "<A HREF=\"${href(p)}\" title=\"package ${p.name}}\">${p.name}</A>"
|
||||
}
|
||||
|
||||
open fun link(a: KAnnotation): String {
|
||||
val c = a.klass
|
||||
return "<A HREF=\"${href(c)}\" title=\"annotation in ${c.packageName}\">@${c.simpleName}</A>"
|
||||
}
|
||||
|
||||
protected open fun relativePrefix(): String = ""
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
package org.jetbrains.kotlin.doc.templates
|
||||
|
||||
import kotlin.*
|
||||
import org.jetbrains.kotlin.template.*
|
||||
import kotlin.io.*
|
||||
import kotlin.util.*
|
||||
import java.util.*
|
||||
import org.jetbrains.kotlin.doc.model.KModel
|
||||
|
||||
class OverviewFrameTemplate(val model: KModel) : KDocTemplate() {
|
||||
override fun render() {
|
||||
println("""<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<!--NewPage-->
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<!-- Generated by kdoc (${model.version}) on ${Date()} -->
|
||||
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<TITLE>
|
||||
Overview List (${model.title})
|
||||
</TITLE>
|
||||
|
||||
<META NAME="date" CONTENT="2012-01-09">
|
||||
<LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">
|
||||
</HEAD>
|
||||
|
||||
<BODY BGCOLOR="white">
|
||||
|
||||
<TABLE BORDER="0" WIDTH="100%" SUMMARY="">
|
||||
<TR>
|
||||
<TH ALIGN="left" NOWRAP><FONT size="+1" CLASS="FrameTitleFont">
|
||||
<B></B></FONT></TH>
|
||||
</TR>
|
||||
</TABLE>
|
||||
|
||||
<TABLE BORDER="0" WIDTH="100%" SUMMARY="">
|
||||
<TR>
|
||||
<TD NOWRAP><FONT CLASS="FrameItemFont"><A HREF="allclasses-frame.html" target="packageFrame">All Classes</A></FONT>
|
||||
<P>
|
||||
<FONT size="+1" CLASS="FrameHeadingFont">
|
||||
Packages</FONT>
|
||||
<BR>""")
|
||||
for (p in model.packages) {
|
||||
println("""<FONT CLASS="FrameItemFont"><A HREF="${p.nameAsPath}/package-frame.html" target="packageFrame">${p.name}</A></FONT>
|
||||
<BR>""")
|
||||
}
|
||||
println("""</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
|
||||
<P>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
""")
|
||||
}
|
||||
}
|
||||
Vendored
+172
@@ -0,0 +1,172 @@
|
||||
package org.jetbrains.kotlin.doc.templates
|
||||
|
||||
import kotlin.*
|
||||
import org.jetbrains.kotlin.template.*
|
||||
import kotlin.io.*
|
||||
import kotlin.util.*
|
||||
import java.util.*
|
||||
import org.jetbrains.kotlin.doc.model.KModel
|
||||
|
||||
class OverviewSummaryTemplate(val model: KModel) : KDocTemplate() {
|
||||
override fun render() {
|
||||
println("""<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
|
||||
<!--NewPage-->
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<!-- Generated by javadoc on Mon Jan 09 13:32:00 EST 2012-->
|
||||
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<TITLE>
|
||||
Overview (${model.title})
|
||||
</TITLE>
|
||||
|
||||
<META NAME="date" CONTENT="2012-01-09">
|
||||
|
||||
<LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">
|
||||
|
||||
<SCRIPT type="text/javascript">
|
||||
function windowTitle()
|
||||
{
|
||||
if (location.href.indexOf('is-external=true') == -1) {
|
||||
parent.document.title="Overview (${model.title})";
|
||||
}
|
||||
}
|
||||
</SCRIPT>
|
||||
<NOSCRIPT>
|
||||
</NOSCRIPT>
|
||||
|
||||
</HEAD>
|
||||
|
||||
<BODY BGCOLOR="white" onload="windowTitle();">
|
||||
<HR>
|
||||
|
||||
|
||||
<!-- ========= START OF TOP NAVBAR ======= -->
|
||||
<A NAME="navbar_top"><!-- --></A>
|
||||
<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
|
||||
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
|
||||
<TR>
|
||||
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
|
||||
<A NAME="navbar_top_firstrow"><!-- --></A>
|
||||
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
|
||||
<TR ALIGN="center" VALIGN="top">
|
||||
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Overview</B></FONT> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Package</FONT> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Class</FONT> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Use</FONT> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="overview-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</TD>
|
||||
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
|
||||
</EM>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
|
||||
PREV
|
||||
NEXT</FONT></TD>
|
||||
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
|
||||
<A HREF="index.html?overview-summary.html" target="_top"><B>FRAMES</B></A>
|
||||
<A HREF="overview-summary.html" target="_top"><B>NO FRAMES</B></A>
|
||||
<SCRIPT type="text/javascript">
|
||||
<!--
|
||||
if(window==top) {
|
||||
document.writeln('<A HREF="allclasses-noframe.html"><B>All Classes</B></A>');
|
||||
}
|
||||
//-->
|
||||
</SCRIPT>
|
||||
<NOSCRIPT>
|
||||
<A HREF="allclasses-noframe.html"><B>All Classes</B></A>
|
||||
</NOSCRIPT>
|
||||
|
||||
|
||||
</FONT></TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
<A NAME="skip-navbar_top"></A>
|
||||
<!-- ========= END OF TOP NAVBAR ========= -->
|
||||
|
||||
<HR>
|
||||
<CENTER>
|
||||
<H1>
|
||||
${model.title}
|
||||
</H1>
|
||||
</CENTER>
|
||||
|
||||
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
|
||||
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
|
||||
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
|
||||
<B>Packages</B></FONT></TH>
|
||||
</TR>""")
|
||||
for (p in model.packages) {
|
||||
println("""<TR BGCOLOR="white" CLASS="TableRowColor">
|
||||
<TD WIDTH="20%"><B><A HREF="${p.nameAsPath}/package-summary.html">${p.name}</A></B></TD>
|
||||
<TD>${p.description}</TD>
|
||||
</TR>""")
|
||||
}
|
||||
println("""</TABLE>
|
||||
|
||||
<P>
|
||||
<HR>
|
||||
|
||||
|
||||
<!-- ======= START OF BOTTOM NAVBAR ====== -->
|
||||
<A NAME="navbar_bottom"><!-- --></A>
|
||||
<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
|
||||
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
|
||||
<TR>
|
||||
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
|
||||
<A NAME="navbar_bottom_firstrow"><!-- --></A>
|
||||
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
|
||||
<TR ALIGN="center" VALIGN="top">
|
||||
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Overview</B></FONT> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Package</FONT> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Class</FONT> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Use</FONT> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="overview-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</TD>
|
||||
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
|
||||
</EM>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
|
||||
PREV
|
||||
NEXT</FONT></TD>
|
||||
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
|
||||
<A HREF="index.html?overview-summary.html" target="_top"><B>FRAMES</B></A>
|
||||
<A HREF="overview-summary.html" target="_top"><B>NO FRAMES</B></A>
|
||||
<SCRIPT type="text/javascript">
|
||||
<!--
|
||||
if(window==top) {
|
||||
document.writeln('<A HREF="allclasses-noframe.html"><B>All Classes</B></A>');
|
||||
}
|
||||
//-->
|
||||
</SCRIPT>
|
||||
<NOSCRIPT>
|
||||
<A HREF="allclasses-noframe.html"><B>All Classes</B></A>
|
||||
</NOSCRIPT>
|
||||
|
||||
|
||||
</FONT></TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
<A NAME="skip-navbar_bottom"></A>
|
||||
<!-- ======== END OF BOTTOM NAVBAR ======= -->
|
||||
|
||||
<HR>
|
||||
Copyright © 2010-2012. All Rights Reserved.
|
||||
</BODY>
|
||||
</HTML>""")
|
||||
}
|
||||
}
|
||||
+194
@@ -0,0 +1,194 @@
|
||||
package org.jetbrains.kotlin.doc.templates
|
||||
|
||||
import kotlin.*
|
||||
import org.jetbrains.kotlin.template.*
|
||||
import kotlin.io.*
|
||||
import kotlin.util.*
|
||||
import java.util.*
|
||||
import org.jetbrains.kotlin.doc.model.KModel
|
||||
|
||||
class OverviewTreeTemplate(val model: KModel) : KDocTemplate() {
|
||||
override fun render() {
|
||||
println("""<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
|
||||
<!--NewPage-->
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<!-- Generated by javadoc on Mon Jan 09 13:32:00 EST 2012-->
|
||||
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<TITLE>
|
||||
Class Hierarchy (${model.title})
|
||||
</TITLE>
|
||||
|
||||
<META NAME="date" CONTENT="2012-01-09">
|
||||
|
||||
<LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">
|
||||
|
||||
<SCRIPT type="text/javascript">
|
||||
function windowTitle()
|
||||
{
|
||||
if (location.href.indexOf('is-external=true') == -1) {
|
||||
parent.document.title="Class Hierarchy (${model.title})";
|
||||
}
|
||||
}
|
||||
</SCRIPT>
|
||||
<NOSCRIPT>
|
||||
</NOSCRIPT>
|
||||
|
||||
</HEAD>
|
||||
|
||||
<BODY BGCOLOR="white" onload="windowTitle();">
|
||||
<HR>
|
||||
|
||||
|
||||
<!-- ========= START OF TOP NAVBAR ======= -->
|
||||
<A NAME="navbar_top"><!-- --></A>
|
||||
<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
|
||||
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
|
||||
<TR>
|
||||
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
|
||||
<A NAME="navbar_top_firstrow"><!-- --></A>
|
||||
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
|
||||
<TR ALIGN="center" VALIGN="top">
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Package</FONT> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Class</FONT> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Use</FONT> </TD>
|
||||
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Tree</B></FONT> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</TD>
|
||||
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
|
||||
</EM>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
|
||||
PREV
|
||||
NEXT</FONT></TD>
|
||||
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
|
||||
<A HREF="index.html?overview-tree.html" target="_top"><B>FRAMES</B></A>
|
||||
<A HREF="overview-tree.html" target="_top"><B>NO FRAMES</B></A>
|
||||
<SCRIPT type="text/javascript">
|
||||
<!--
|
||||
if(window==top) {
|
||||
document.writeln('<A HREF="allclasses-noframe.html"><B>All Classes</B></A>');
|
||||
}
|
||||
//-->
|
||||
</SCRIPT>
|
||||
<NOSCRIPT>
|
||||
<A HREF="allclasses-noframe.html"><B>All Classes</B></A>
|
||||
</NOSCRIPT>
|
||||
|
||||
|
||||
</FONT></TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
<A NAME="skip-navbar_top"></A>
|
||||
<!-- ========= END OF TOP NAVBAR ========= -->
|
||||
|
||||
<HR>
|
||||
<CENTER>
|
||||
<H2>
|
||||
Hierarchy For All Packages</H2>
|
||||
</CENTER>
|
||||
<DL>
|
||||
<DT><B>Package Hierarchies:</B><DD>""")
|
||||
|
||||
var first = true
|
||||
for (p in model.packages) {
|
||||
if (first) {
|
||||
first = false
|
||||
} else {
|
||||
print(""",
|
||||
<A HREF="${p.nameAsPath}/package-tree.html">${p.nameAsPath}</A>""")
|
||||
}
|
||||
}
|
||||
println("""</DL>
|
||||
<HR>
|
||||
<H2>
|
||||
Class Hierarchy
|
||||
</H2>""")
|
||||
|
||||
// TODO walk the hierarchy...
|
||||
/*
|
||||
<UL>
|
||||
<LI TYPE="circle">java.util.<A HREF="http://download.oracle.com/javase/1.5.0/docs/api/java/util/AbstractQueue.html?is-external=true" title="class or interface in java.util"><B>AbstractQueue</B></A><E> (implements java.util.<A HREF="http://download.oracle.com/javase/1.5.0/docs/api/java/util/Queue.html?is-external=true" title="class or interface in java.util">Queue</A><E>)
|
||||
<UL>
|
||||
*/
|
||||
|
||||
println("""<H2>
|
||||
Interface Hierarchy
|
||||
</H2>""")
|
||||
|
||||
// TODO
|
||||
println("""<H2>
|
||||
Annotation Type Hierarchy
|
||||
</H2>""")
|
||||
|
||||
// TODO
|
||||
println("""<H2>
|
||||
Enum Hierarchy
|
||||
</H2>
|
||||
<HR>
|
||||
|
||||
|
||||
<!-- ======= START OF BOTTOM NAVBAR ====== -->
|
||||
<A NAME="navbar_bottom"><!-- --></A>
|
||||
<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
|
||||
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
|
||||
<TR>
|
||||
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
|
||||
<A NAME="navbar_bottom_firstrow"><!-- --></A>
|
||||
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
|
||||
<TR ALIGN="center" VALIGN="top">
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Package</FONT> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Class</FONT> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Use</FONT> </TD>
|
||||
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Tree</B></FONT> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</TD>
|
||||
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
|
||||
</EM>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
|
||||
PREV
|
||||
NEXT</FONT></TD>
|
||||
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
|
||||
<A HREF="index.html?overview-tree.html" target="_top"><B>FRAMES</B></A>
|
||||
<A HREF="overview-tree.html" target="_top"><B>NO FRAMES</B></A>
|
||||
<SCRIPT type="text/javascript">
|
||||
<!--
|
||||
if(window==top) {
|
||||
document.writeln('<A HREF="allclasses-noframe.html"><B>All Classes</B></A>');
|
||||
}
|
||||
//-->
|
||||
</SCRIPT>
|
||||
<NOSCRIPT>
|
||||
<A HREF="allclasses-noframe.html"><B>All Classes</B></A>
|
||||
</NOSCRIPT>
|
||||
|
||||
|
||||
</FONT></TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
<A NAME="skip-navbar_bottom"></A>
|
||||
<!-- ======== END OF BOTTOM NAVBAR ======= -->
|
||||
|
||||
<HR>
|
||||
Copyright © 2010-2012. All Rights Reserved.
|
||||
</BODY>
|
||||
</HTML>""")
|
||||
}
|
||||
}
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
package org.jetbrains.kotlin.doc.templates
|
||||
|
||||
import kotlin.*
|
||||
import org.jetbrains.kotlin.template.*
|
||||
import kotlin.io.*
|
||||
import kotlin.util.*
|
||||
import java.util.*
|
||||
import org.jetbrains.kotlin.doc.model.KModel
|
||||
import org.jetbrains.kotlin.doc.model.KPackage
|
||||
import org.jetbrains.kotlin.doc.model.KClass
|
||||
import org.jetbrains.kotlin.doc.model.KFunction
|
||||
import org.jetbrains.kotlin.doc.model.extensionFunctions
|
||||
|
||||
class PackageFrameTemplate(val model: KModel, p: KPackage) : PackageTemplateSupport(p) {
|
||||
override fun render() {
|
||||
println("""<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<!--NewPage-->
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<!-- Generated by kdoc (${model.version}) on ${Date()} -->
|
||||
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<TITLE>
|
||||
${pkg.name} (${model.title})
|
||||
</TITLE>
|
||||
|
||||
<META NAME="date" CONTENT="2012-01-09">
|
||||
<LINK REL ="stylesheet" TYPE="text/css" HREF="${pkg.nameAsRelativePath}stylesheet.css" TITLE="Style">
|
||||
|
||||
</HEAD>
|
||||
|
||||
<BODY BGCOLOR="white">
|
||||
<FONT size="+1" CLASS="FrameTitleFont">
|
||||
<A HREF="${pkg.nameAsRelativePath}${pkg.nameAsPath}/package-summary.html" target="classFrame">${pkg.name}</A></FONT>""")
|
||||
|
||||
printClasses("interface", "Interfaces")
|
||||
printClasses("class", "Classes")
|
||||
printClasses("enum", "Enums")
|
||||
printClasses("annotation", "Annotations")
|
||||
printClasses("exception", "Exceptions")
|
||||
printFunctions()
|
||||
printExtensionFunctions()
|
||||
|
||||
println("""</BODY>
|
||||
</HTML>""")
|
||||
}
|
||||
|
||||
protected fun printClasses(kind: String, description: String): Unit {
|
||||
val classes = pkg.classes.filter{ it.kind == kind }
|
||||
if (! classes.isEmpty()) {
|
||||
println("""<TABLE BORDER="0" WIDTH="100%" SUMMARY="">
|
||||
<TR>
|
||||
<TD NOWRAP><FONT size="+1" CLASS="FrameHeadingFont">""")
|
||||
print(description)
|
||||
println("""</FONT>
|
||||
<FONT CLASS="FrameItemFont">
|
||||
<BR>""")
|
||||
for (c in classes) {
|
||||
val formatted = if (kind == "interface") "<I>${c.simpleName}</I>" else c.simpleName
|
||||
println("""<A HREF="${c.simpleName}.html" title="$kind in ${pkg.name}" target="classFrame">$formatted</A>
|
||||
<BR>""")
|
||||
}
|
||||
println("""</TR>
|
||||
</TABLE>""")
|
||||
}
|
||||
}
|
||||
|
||||
protected fun printFunctions(): Unit {
|
||||
val functions = pkg.packageFunctions()
|
||||
if (! functions.isEmpty()) {
|
||||
println("""<TABLE BORDER="0" WIDTH="100%" SUMMARY="">
|
||||
<TR>
|
||||
<TD NOWRAP><FONT size="+1" CLASS="FrameHeadingFont">Functions</FONT>
|
||||
<FONT CLASS="FrameItemFont">
|
||||
<BR>""")
|
||||
for (c in functions) {
|
||||
println("""<A HREF="${href(c)}" title="function in ${pkg.name}" target="classFrame"><I>${c.name}</I></A>
|
||||
<BR>""")
|
||||
}
|
||||
println("""</TR>
|
||||
</TABLE>""")
|
||||
}
|
||||
}
|
||||
|
||||
protected fun printExtensionFunctions(): Unit {
|
||||
val map = extensionFunctions(pkg.functions)
|
||||
if (! map.isEmpty()) {
|
||||
println("""<TABLE BORDER="0" WIDTH="100%" SUMMARY="">
|
||||
<TR>
|
||||
<TD NOWRAP><FONT size="+1" CLASS="FrameHeadingFont">Extensions</FONT>
|
||||
<FONT CLASS="FrameItemFont">
|
||||
<BR>""")
|
||||
for (e in map.entrySet()) {
|
||||
val c = e?.getKey()
|
||||
if (c != null) {
|
||||
println("""<A HREF="${extensionsHref(pkg, c)}" title="extensions functions on class ${c.name} from ${pkg.name}" target="classFrame"><I>${c.name}</I></A>
|
||||
<BR>""")
|
||||
}
|
||||
}
|
||||
println("""</TR>
|
||||
</TABLE>""")
|
||||
}
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package org.jetbrains.kotlin.doc.templates
|
||||
|
||||
import kotlin.*
|
||||
import org.jetbrains.kotlin.template.*
|
||||
import kotlin.io.*
|
||||
import kotlin.util.*
|
||||
import java.util.*
|
||||
import org.jetbrains.kotlin.doc.model.KModel
|
||||
|
||||
class PackageListTemplate(val model: KModel) : KDocTemplate() {
|
||||
override fun render() {
|
||||
for (p in model.packages) {
|
||||
println(p.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
Vendored
+313
@@ -0,0 +1,313 @@
|
||||
package org.jetbrains.kotlin.doc.templates
|
||||
|
||||
import kotlin.*
|
||||
import org.jetbrains.kotlin.template.*
|
||||
import kotlin.io.*
|
||||
import kotlin.util.*
|
||||
import java.util.*
|
||||
import org.jetbrains.kotlin.doc.model.KModel
|
||||
import org.jetbrains.kotlin.doc.model.KPackage
|
||||
import org.jetbrains.kotlin.doc.model.KClass
|
||||
import org.jetbrains.kotlin.doc.model.extensionFunctions
|
||||
import org.jetbrains.kotlin.doc.model.inheritedExtensionFunctions
|
||||
|
||||
class PackageSummaryTemplate(val model: KModel, pkg: KPackage) : PackageTemplateSupport(pkg) {
|
||||
override fun render() {
|
||||
println("""<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<!--NewPage-->
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<!-- Generated by kdoc (${model.version}) on ${Date()} -->
|
||||
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<TITLE>
|
||||
${pkg.name} (${model.title})
|
||||
</TITLE>
|
||||
|
||||
<META NAME="date" CONTENT="2012-01-09">
|
||||
<META NAME="date" CONTENT="2012-01-09">
|
||||
<LINK REL="stylesheet" TYPE="text/css" HREF="${pkg.nameAsRelativePath}stylesheet.css" TITLE="Style">
|
||||
|
||||
<SCRIPT type="text/javascript">
|
||||
function windowTitle()
|
||||
{
|
||||
if (location.href.indexOf('is-external=true') == -1) {
|
||||
parent.document.title="${pkg.name} (${model.title})";
|
||||
}
|
||||
}
|
||||
</SCRIPT>
|
||||
<NOSCRIPT>
|
||||
</NOSCRIPT>
|
||||
|
||||
</HEAD>
|
||||
|
||||
<BODY BGCOLOR="white" onload="windowTitle();">
|
||||
<HR>
|
||||
|
||||
|
||||
<!-- ========= START OF TOP NAVBAR ======= -->
|
||||
<A NAME="navbar_top"><!-- --></A>
|
||||
<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
|
||||
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
|
||||
<TR>
|
||||
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
|
||||
<A NAME="navbar_top_firstrow"><!-- --></A>
|
||||
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
|
||||
<TR ALIGN="center" VALIGN="top">
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="${pkg.nameAsRelativePath}overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
|
||||
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Package</B></FONT> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Class</FONT> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-use.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="${pkg.nameAsRelativePath}deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="${pkg.nameAsRelativePath}index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="${pkg.nameAsRelativePath}help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</TD>
|
||||
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
|
||||
</EM>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR>""")
|
||||
|
||||
printNextPrevPackages()
|
||||
println("""<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
|
||||
<A HREF="${pkg.nameAsRelativePath}index.html?${pkg.nameAsPath}/package-summary.html" target="_top"><B>FRAMES</B></A>
|
||||
<A HREF="package-summary.html" target="_top"><B>NO FRAMES</B></A>
|
||||
<SCRIPT type="text/javascript">
|
||||
<!--
|
||||
if(window==top) {
|
||||
document.writeln('<A HREF="${pkg.nameAsRelativePath}allclasses-noframe.html"><B>All Classes</B></A>');
|
||||
}
|
||||
//-->
|
||||
</SCRIPT>
|
||||
<NOSCRIPT>
|
||||
<A HREF="${pkg.nameAsRelativePath}allclasses-noframe.html"><B>All Classes</B></A>
|
||||
</NOSCRIPT>
|
||||
|
||||
|
||||
</FONT></TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
<A NAME="skip-navbar_top"></A>
|
||||
<!-- ========= END OF TOP NAVBAR ========= -->
|
||||
|
||||
<HR>
|
||||
<FONT SIZE="-1">""")
|
||||
|
||||
for (a in pkg.annotations) {
|
||||
val url = a.url
|
||||
if (url != null) {
|
||||
println("""<A HREF="$url?is-external=true" title="class or interface in ${a.packageName}">@${a.simpleName}</A>""")
|
||||
}
|
||||
}
|
||||
println("""</FONT><H2>
|
||||
Package ${pkg.name}
|
||||
</H2>
|
||||
${pkg.description}
|
||||
<P>
|
||||
<B>See:</B>
|
||||
<BR>
|
||||
<A HREF="#package_description"><B>Description</B></A>
|
||||
<P>
|
||||
""")
|
||||
|
||||
printClasses("interface", "Interfaces")
|
||||
printClasses("class", "Classes")
|
||||
printClasses("enum", "Enums")
|
||||
printClasses("annotation", "Annotations")
|
||||
printClasses("exception", "Exceptions")
|
||||
|
||||
printFunctions()
|
||||
printExtensionFunctions()
|
||||
|
||||
println("""<A NAME="package_description"><!-- --></A><H2>
|
||||
Package ${pkg.name} Description
|
||||
</H2>
|
||||
|
||||
<P>
|
||||
${pkg.detailedDescription}
|
||||
|
||||
<h2>Contents</h2>
|
||||
|
||||
""")
|
||||
|
||||
val groupMap = pkg.groupClassMap()
|
||||
for (e in groupMap.entrySet()) {
|
||||
val group = e?.getKey() ?: "Other"
|
||||
val list = e?.getValue()
|
||||
if (list != null) {
|
||||
println(""" <h3>$group</h3>
|
||||
|
||||
<ul>""")
|
||||
for (c in list) {
|
||||
println(""" <li><A HREF="${pkg.nameAsRelativePath}${c.nameAsPath}.html" title="class in ${pkg.name}"><CODE>${c.simpleName}</CODE></A>""")
|
||||
}
|
||||
println("""
|
||||
</ul>""")
|
||||
}
|
||||
}
|
||||
println("""<P>""")
|
||||
|
||||
printFunctionDetail(pkg.packageFunctions())
|
||||
|
||||
println("""
|
||||
|
||||
<P>
|
||||
<DL>
|
||||
</DL>
|
||||
<HR>
|
||||
|
||||
|
||||
<!-- ======= START OF BOTTOM NAVBAR ====== -->
|
||||
<A NAME="navbar_bottom"><!-- --></A>
|
||||
<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
|
||||
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
|
||||
<TR>
|
||||
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
|
||||
<A NAME="navbar_bottom_firstrow"><!-- --></A>
|
||||
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
|
||||
<TR ALIGN="center" VALIGN="top">
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="${pkg.nameAsRelativePath}overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
|
||||
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Package</B></FONT> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Class</FONT> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-use.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="${pkg.nameAsRelativePath}deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="${pkg.nameAsRelativePath}index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
|
||||
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="${pkg.nameAsRelativePath}help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</TD>
|
||||
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
|
||||
</EM>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR>""")
|
||||
|
||||
printNextPrevPackages()
|
||||
|
||||
println("""<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
|
||||
) <A HREF="${pkg.nameAsRelativePath}index.html?${pkg.nameAsPath}/package-summary.html" target="_top"><B>FRAMES</B></A>
|
||||
<A HREF="package-summary.html" target="_top"><B>NO FRAMES</B></A>
|
||||
<SCRIPT type="text/javascript">
|
||||
<!--
|
||||
if(window==top) {
|
||||
document.writeln('<A HREF="${pkg.nameAsRelativePath}allclasses-noframe.html"><B>All Classes</B></A>');
|
||||
}
|
||||
//-->
|
||||
</SCRIPT>
|
||||
<NOSCRIPT>
|
||||
<A HREF="${pkg.nameAsRelativePath}allclasses-noframe.html"><B>All Classes</B></A>
|
||||
</NOSCRIPT>
|
||||
|
||||
|
||||
</FONT></TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
<A NAME="skip-navbar_bottom"></A>
|
||||
<!-- ======== END OF BOTTOM NAVBAR ======= -->
|
||||
|
||||
<HR>
|
||||
Copyright © 2010-2012. All Rights Reserved.
|
||||
</BODY>
|
||||
</HTML>""")
|
||||
}
|
||||
|
||||
|
||||
protected fun printClasses(kind: String, description: String): Unit {
|
||||
val classes = pkg.classes.filter{ it.kind == kind }
|
||||
if (! classes.isEmpty()) {
|
||||
print("""<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
|
||||
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
|
||||
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
|
||||
<B>$description Summary</B></FONT></TH>
|
||||
</TR>""")
|
||||
|
||||
for (c in classes) {
|
||||
println("""<TR BGCOLOR="white" CLASS="TableRowColor">
|
||||
<TD WIDTH="15%"><B><A HREF="${pkg.nameAsRelativePath}${c.nameAsPath}.html" title="$kind in ${pkg.name}">${c.simpleName}</A></B></TD>
|
||||
<TD>${c.description}</TD>
|
||||
</TR>""")
|
||||
}
|
||||
println("""</TABLE>
|
||||
|
||||
|
||||
<P>
|
||||
""")
|
||||
}
|
||||
}
|
||||
|
||||
protected fun printFunctions(): Unit {
|
||||
val functions = pkg.functions.filter{ it.extensionClass == null }
|
||||
if (! functions.isEmpty()) {
|
||||
print("""<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
|
||||
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
|
||||
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
|
||||
<B>Functions Summary</B></FONT></TH>
|
||||
</TR>""")
|
||||
|
||||
for (f in functions) {
|
||||
println("""<TR BGCOLOR="white" CLASS="TableRowColor">
|
||||
<TD WIDTH="15%"><B><A HREF="${href(f)}" title="function in ${pkg.name}">${f.name}</A></B></TD>
|
||||
<TD>${f.description}</TD>
|
||||
</TR>""")
|
||||
}
|
||||
println("""</TABLE>
|
||||
|
||||
|
||||
<P>
|
||||
""")
|
||||
}
|
||||
}
|
||||
|
||||
protected fun printExtensionFunctions(): Unit {
|
||||
val map = inheritedExtensionFunctions(pkg.functions)
|
||||
if (! map.isEmpty()) {
|
||||
print("""<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
|
||||
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
|
||||
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
|
||||
<B>Extensions Summary</B></FONT></TH>
|
||||
</TR>""")
|
||||
|
||||
for (e in map.entrySet()) {
|
||||
val c = e?.getKey()
|
||||
if (c != null) {
|
||||
println("""<TR BGCOLOR="white" CLASS="TableRowColor">
|
||||
<TD WIDTH="15%"><B><A HREF="${extensionsHref(pkg, c)}" title="extensions on ${pkg.name}">${c.name}</A></B></TD>
|
||||
<TD>""")
|
||||
val list = e?.getValue()
|
||||
if (list != null) {
|
||||
for (f in list) {
|
||||
println("""<A HREF="${extensionsHref(pkg, c, f)}">${f.name}<A> """)
|
||||
}
|
||||
}
|
||||
println("""</TD>
|
||||
</TR>""")
|
||||
}
|
||||
}
|
||||
println("""</TABLE>
|
||||
|
||||
|
||||
<P>
|
||||
""")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected fun printNextPrevPackages(): Unit {
|
||||
println("""<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">""")
|
||||
val prev = model.previous(pkg)
|
||||
if (prev != null) {
|
||||
println(""" <A HREF="${prev.nameAsRelativePath}${prev.nameAsPath}/package-summary.html"><B>PREV PACKAGE</B></A> """)
|
||||
}
|
||||
val next = model.next(pkg)
|
||||
if (next != null) {
|
||||
println(""" <A HREF="${next.nameAsRelativePath}${next.nameAsPath}/package-summary.html"><B>NEXT PACKAGE</B></A>""")
|
||||
}
|
||||
println("""</FONT></TD>""")
|
||||
|
||||
}
|
||||
}
|
||||
Vendored
+236
@@ -0,0 +1,236 @@
|
||||
package org.jetbrains.kotlin.doc.templates
|
||||
|
||||
import kotlin.*
|
||||
import kotlin.io.*
|
||||
import kotlin.util.*
|
||||
import java.util.*
|
||||
import org.jetbrains.kotlin.template.*
|
||||
import org.jetbrains.kotlin.doc.model.KModel
|
||||
import org.jetbrains.kotlin.doc.model.KPackage
|
||||
import org.jetbrains.kotlin.doc.model.KClass
|
||||
import org.jetbrains.kotlin.doc.model.KFunction
|
||||
import org.jetbrains.kotlin.doc.model.KAnnotation
|
||||
import org.jetbrains.kotlin.doc.model.KProperty
|
||||
import org.jetbrains.kotlin.doc.model.KTypeParameter
|
||||
|
||||
|
||||
abstract class PackageTemplateSupport(open val pkg: KPackage) : KDocTemplate() {
|
||||
|
||||
protected override fun relativePrefix(): String = pkg.nameAsRelativePath
|
||||
|
||||
|
||||
fun printFunctionSummary(functions: Collection<KFunction>): Unit {
|
||||
if (functions.notEmpty()) {
|
||||
println("""<!-- ========== FUNCTION SUMMARY =========== -->
|
||||
|
||||
<A NAME="method_summary"><!-- --></A>
|
||||
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
|
||||
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
|
||||
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
|
||||
<B>Function Summary</B></FONT></TH>
|
||||
</TR>""")
|
||||
|
||||
for (f in functions) {
|
||||
printFunctionSummary(f)
|
||||
}
|
||||
println("""</TABLE>
|
||||
|
||||
<P>
|
||||
""")
|
||||
}
|
||||
}
|
||||
|
||||
fun printFunctionSummary(function: KFunction): Unit {
|
||||
val deprecated = if (function.deprecated) "<B>Deprecated.</B>" else ""
|
||||
print("""<TR BGCOLOR="white" CLASS="TableRowColor">
|
||||
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||||
<CODE>""")
|
||||
if (!function.typeParameters.isEmpty()) {
|
||||
println("""<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY="">
|
||||
<TR ALIGN="right" VALIGN="">
|
||||
<TD NOWRAP><FONT SIZE="-1">
|
||||
<CODE>""")
|
||||
printTypeParameters(function)
|
||||
println("""<BR>""")
|
||||
print(link(function.returnType))
|
||||
println("""</CODE></FONT></TD>
|
||||
</TR>
|
||||
</TABLE>""")
|
||||
} else {
|
||||
print(link(function.returnType))
|
||||
}
|
||||
println("""</CODE></FONT></TD>""")
|
||||
print("""<TD><CODE><B><A HREF="${href(function)}">${function.name}</A></B>""")
|
||||
printParameters(function)
|
||||
println("""</CODE>""")
|
||||
println("")
|
||||
if (true) {
|
||||
val detail = function.detailedDescription
|
||||
println("""${detail}""")
|
||||
} else {
|
||||
println("""<BR>""")
|
||||
println(""" ${deprecated} ${function.detailedDescription}</TD>""")
|
||||
}
|
||||
println("""</TD>""")
|
||||
println("""</TR>""")
|
||||
}
|
||||
|
||||
fun printFunctionDetail(functions: Collection<KFunction>): Unit {
|
||||
if (functions.notEmpty()) {
|
||||
println("""
|
||||
|
||||
<!-- ============ FUNCTION DETAIL ========== -->
|
||||
|
||||
<A NAME="method_detail"><!-- --></A>
|
||||
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
|
||||
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
|
||||
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
|
||||
<B>Function Detail</B></FONT></TH>
|
||||
</TR>
|
||||
</TABLE>
|
||||
""")
|
||||
|
||||
for (f in functions) {
|
||||
printFunctionDetail(f)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun printFunctionDetail(function: KFunction): Unit {
|
||||
println("""<A NAME="${function.name}{${function.parameterTypeText}}"><!-- --></A><A NAME="${function.link}"><!-- --></A><H3>""")
|
||||
println("""${function.name}</H3>""")
|
||||
println("""<PRE>""")
|
||||
println("""<FONT SIZE="-1">""")
|
||||
printAnnotations(function.annotations)
|
||||
print("""</FONT>${function.modifiers.join(" ")} """)
|
||||
|
||||
printTypeParameters(function)
|
||||
print(link(function.returnType))
|
||||
|
||||
print(""" <A HREF="${sourceHref(function)}"><B>${function.name}</B></A>""")
|
||||
printParameters(function)
|
||||
val exlist = function.exceptions
|
||||
var first = true
|
||||
if (!exlist.isEmpty()) {
|
||||
println(""" throws """);
|
||||
for (ex in exlist) {
|
||||
if (first) first = false else print(", ")
|
||||
print(link(ex))
|
||||
}
|
||||
}
|
||||
println("""</PRE>""")
|
||||
|
||||
println(function.detailedDescription)
|
||||
/* TODO
|
||||
println("""<DL>
|
||||
<DD><B>Deprecated.</B> TODO text
|
||||
<P>
|
||||
<DD><b>Deprecated.</b>
|
||||
<P>
|
||||
<DD>
|
||||
<DL>
|
||||
<DT><B>Throws:</B>
|
||||
<DD><CODE>${link(ex}</CODE><DT><B>Since:</B></DT>
|
||||
<DD>${since}</DD>
|
||||
</DL>
|
||||
</DD>
|
||||
</DL>
|
||||
*/
|
||||
println("""<HR>""")
|
||||
}
|
||||
|
||||
fun printPropertySummary(properties: Collection<KProperty>): Unit {
|
||||
if (properties.notEmpty()) {
|
||||
println("""<!-- ========== PROPERTY SUMMARY =========== -->
|
||||
|
||||
<A NAME="method_summary"><!-- --></A>
|
||||
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
|
||||
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
|
||||
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
|
||||
<B>Property Summary</B></FONT></TH>
|
||||
</TR>""")
|
||||
|
||||
for (f in properties) {
|
||||
printPropertySummary(f)
|
||||
}
|
||||
println("""</TABLE>
|
||||
|
||||
<P>
|
||||
""")
|
||||
}
|
||||
}
|
||||
|
||||
fun printPropertySummary(property: KProperty): Unit {
|
||||
val deprecated = if (property.deprecated) "<B>Deprecated.</B>" else ""
|
||||
print("""<TR BGCOLOR="white" CLASS="TableRowColor">
|
||||
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||||
<CODE>""")
|
||||
/*
|
||||
if (!property.typeParameters.isEmpty()) {
|
||||
println("""<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY="">
|
||||
<TR ALIGN="right" VALIGN="">
|
||||
<TD NOWRAP><FONT SIZE="-1">
|
||||
<CODE>""")
|
||||
printTypeParameters(property)
|
||||
println("""<BR>""")
|
||||
print(link(property.returnType))
|
||||
println("""</CODE></FONT></TD>
|
||||
</TR>
|
||||
</TABLE>""")
|
||||
} else {
|
||||
print(link(property.returnType))
|
||||
}
|
||||
*/
|
||||
print(link(property.returnType))
|
||||
println("""</CODE></FONT></TD>""")
|
||||
print("""<TD><CODE><B><A HREF="${href(property)}">${property.name}</A></B>""")
|
||||
//printParameters(property)
|
||||
println("""</CODE>""")
|
||||
println("""""")
|
||||
println("""<BR>""")
|
||||
println(""" ${deprecated} ${property.detailedDescription}</TD>""")
|
||||
println("""</TR>""")
|
||||
}
|
||||
|
||||
fun printTypeParameters(method: KFunction): Unit {
|
||||
val typeParameters = method.typeParameters
|
||||
if (!typeParameters.isEmpty()) {
|
||||
print("<")
|
||||
var separator = ""
|
||||
for (t in typeParameters) {
|
||||
print(separator)
|
||||
separator = ", "
|
||||
print(t.name)
|
||||
val elist = t.extends
|
||||
if (!elist.isEmpty()) {
|
||||
print(" extends ")
|
||||
var esep = ""
|
||||
for (e in elist) {
|
||||
print(esep)
|
||||
esep = " & "
|
||||
print(link(e))
|
||||
}
|
||||
}
|
||||
}
|
||||
print("> ")
|
||||
}
|
||||
}
|
||||
|
||||
fun printParameters(method: KFunction): Unit {
|
||||
print("(")
|
||||
var first = true
|
||||
for (p in method.parameters) {
|
||||
if (first) first = false else print(", ")
|
||||
print("${p.name}: ")
|
||||
print(link(p.aType))
|
||||
}
|
||||
print(")")
|
||||
}
|
||||
|
||||
|
||||
fun printAnnotations(annotations: Collection<KAnnotation>): Unit {
|
||||
for (a in annotations) {
|
||||
println(link(a))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package org.jetbrains.kotlin.template
|
||||
|
||||
import kotlin.io.*
|
||||
import java.io.Writer
|
||||
import java.io.StringWriter
|
||||
import java.io.OutputStream
|
||||
import java.io.OutputStreamWriter
|
||||
import java.io.FileWriter
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* Represents a generic API to templates which should be usable
|
||||
* in JavaScript in a browser or on the server side stand alone or in a web app etc.
|
||||
*
|
||||
* To make things easier to implement in JS this namespace won't refer to any java.io or servlet
|
||||
* stuff
|
||||
*/
|
||||
trait Template {
|
||||
|
||||
/** Renders the template to the output printer */
|
||||
fun render(): Unit
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the output of a template which is a stream of objects
|
||||
* usually strings which then write to some underlying output stream
|
||||
* such as a java.io.Writer on the server side.
|
||||
*
|
||||
* We abstract away java.io.* APIs here to make the JS implementation simpler
|
||||
*/
|
||||
trait Printer {
|
||||
fun print(value: Any): Unit
|
||||
//fun print(text: String): Unit
|
||||
|
||||
}
|
||||
|
||||
|
||||
class NullPrinter() : Printer {
|
||||
override fun print(value: Any) {
|
||||
throw UnsupportedOperationException("No Printer defined on the Template")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Base class for template implementations to hold any helpful behaviour
|
||||
*/
|
||||
abstract class TemplateSupport : Template {
|
||||
}
|
||||
|
||||
val newline: String = System.getProperty("line.separator") ?: "\n"
|
||||
|
||||
/**
|
||||
* Base class for templates generating text output
|
||||
* by printing values to some underlying Printer which
|
||||
* will typically output to a String, File, stream etc.
|
||||
*/
|
||||
abstract class TextTemplate() : TemplateSupport(), Printer {
|
||||
public var printer: Printer = NullPrinter()
|
||||
|
||||
fun String.plus(): Unit {
|
||||
printer.print(this)
|
||||
}
|
||||
|
||||
override fun print(value: Any) = printer.print(value)
|
||||
|
||||
fun println(value: Any) {
|
||||
print(value)
|
||||
print(newline)
|
||||
}
|
||||
|
||||
fun renderToText(): String {
|
||||
val buffer = StringWriter()
|
||||
renderTo(buffer)
|
||||
return buffer.toString().sure()
|
||||
}
|
||||
|
||||
fun renderTo(writer: Writer): Unit {
|
||||
this.printer = WriterPrinter(writer)
|
||||
this.render()
|
||||
}
|
||||
|
||||
fun renderTo(os: OutputStream): Unit {
|
||||
// TODO compiler error
|
||||
//OutputStreamWriter(os).foreach{ renderTo(it) }
|
||||
val s = OutputStreamWriter(os)
|
||||
renderTo(s)
|
||||
s.close()
|
||||
}
|
||||
|
||||
fun renderTo(file: File): Unit {
|
||||
// TODO compiler error
|
||||
//FileWriter(file).foreach{ s -> renderTo(s) }
|
||||
val s = FileWriter(file)
|
||||
renderTo(s)
|
||||
s.close()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A Printer implementation which uses a Writer
|
||||
*/
|
||||
class WriterPrinter(val writer: Writer) : Printer {
|
||||
|
||||
override fun print(value: Any) {
|
||||
// TODO should be using a formatter to do the conversion
|
||||
writer.write(value.toString())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<ivysettings>
|
||||
<property name='ivy.checksums' value=''/>
|
||||
<caches defaultCache="${user.home}/.ivy/cache"/>
|
||||
<settings defaultResolver="jetbrains-repo"/>
|
||||
<statuses>
|
||||
<status name='integration' integration='true'/>
|
||||
</statuses>
|
||||
<resolvers>
|
||||
<url name='jetbrains-repo' alwaysCheckExactRevision='yes' checkmodified='true'>
|
||||
<ivy pattern='http://teamcity.jetbrains.com/guestAuth/repository/download/[module]/[revision]/teamcity-ivy.xml'/>
|
||||
<artifact pattern='http://teamcity.jetbrains.com/guestAuth/repository/download/[module]/[revision]/[artifact](.[ext])'/>
|
||||
</url>
|
||||
</resolvers>
|
||||
<modules>
|
||||
<module organisation='org' name='bt343' matcher='regexp' resolver='jetbrains-repo'/>
|
||||
<module organisation='org' name='bt344' matcher='regexp' resolver='jetbrains-repo'/>
|
||||
</modules>
|
||||
</ivysettings>
|
||||
@@ -0,0 +1,54 @@
|
||||
package test.pegdown
|
||||
|
||||
import kotlin.*
|
||||
import kotlin.util.*
|
||||
import kotlin.test.*
|
||||
|
||||
import junit.framework.TestCase
|
||||
import org.pegdown.*
|
||||
import org.pegdown.ast.*
|
||||
import org.pegdown.LinkRenderer.Rendering
|
||||
|
||||
class PegdownTest() : TestCase() {
|
||||
var markdownProcessor = PegDownProcessor(Extensions.ALL)
|
||||
var linkRenderer = CustomLinkRenderer()
|
||||
|
||||
fun testPegDown() {
|
||||
val markups = arrayList(
|
||||
"hello **there **",
|
||||
"a [[WikiLink]] blah",
|
||||
"a [[WikiLink someText]] blah",
|
||||
"a [[SomeClass.property]] blah",
|
||||
"a [[SomeClass.method()]] blah",
|
||||
"a [Link](somewhere) blah")
|
||||
|
||||
for (text in markups) {
|
||||
val answer = markdownProcessor.markdownToHtml(text, linkRenderer).sure()
|
||||
println("$text = $answer")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class CustomLinkRenderer() : LinkRenderer() {
|
||||
|
||||
override fun render(node : WikiLinkNode?) : Rendering? {
|
||||
println("LinkRenderer.render(WikiLinkNode): $node")
|
||||
return super.render(node)
|
||||
}
|
||||
|
||||
override fun render(node : RefLinkNode?, url : String?, title : String?, text : String?) : Rendering? {
|
||||
println("LinkRenderer.render(RefLinkNode): $node url: $url title: $title text: $text")
|
||||
return super.render(node, url, title, text)
|
||||
}
|
||||
|
||||
override fun render(node : AutoLinkNode?) : Rendering? {
|
||||
println("LinkRenderer.render(AutoLinkNode): $node")
|
||||
return super.render(node)
|
||||
}
|
||||
|
||||
override fun render(node : ExpLinkNode?, text : String?) : Rendering? {
|
||||
println("LinkRenderer.render(ExpLinkNode): $node text: $text")
|
||||
return super.render(node, text)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package test.kotlin.template
|
||||
|
||||
import kotlin.*
|
||||
import org.jetbrains.kotlin.template.*
|
||||
import kotlin.io.*
|
||||
import kotlin.util.*
|
||||
import java.util.*
|
||||
|
||||
import junit.framework.TestCase
|
||||
import junit.framework.Assert.*
|
||||
|
||||
class EmailTemplate(var name: String = "James", var time: Date = Date()) : TextTemplate() {
|
||||
override fun render() {
|
||||
print("Hello there $name and how are you? Today is $time. Kotlin rocks")
|
||||
}
|
||||
}
|
||||
|
||||
class MoreDryTemplate(var name: String = "James", var time: Date = Date()) : TextTemplate() {
|
||||
override fun render() {
|
||||
+"Hey there $name and how are you? Today is $time. Kotlin rocks"
|
||||
}
|
||||
}
|
||||
|
||||
class TemplateCoreTest() : TestCase() {
|
||||
fun testDefaultValues() {
|
||||
val text = EmailTemplate().renderToText()
|
||||
assertTrue(
|
||||
text.startsWith("Hello there James")
|
||||
)
|
||||
}
|
||||
|
||||
fun testDifferentValues() {
|
||||
val text = EmailTemplate("Andrey").renderToText()
|
||||
assertTrue(
|
||||
text.startsWith("Hello there Andrey")
|
||||
)
|
||||
}
|
||||
|
||||
fun testMoreDryTemplate() {
|
||||
val text = MoreDryTemplate("Alex").renderToText()
|
||||
assertTrue(
|
||||
text.startsWith("Hey there Alex")
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user