+This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.
+Overview
+
+
+
+The Overview 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.
+
+Package
+
+
+
+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:
+
Interfaces (italic)
Classes
Enums
Exceptions
Errors
Annotation Types
+
+
+Class/Interface
+
+
+
+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:
+
Class inheritance diagram
Direct Subclasses
All Known Subinterfaces
All Known Implementing Classes
Class/interface declaration
Class/interface description
+
+
Nested Class Summary
Field Summary
Constructor Summary
Method Summary
+
+
Field Detail
Constructor Detail
Method Detail
+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.
+
+
+Annotation Type
+
+
+
+Each annotation type has its own separate page with the following sections:
+
Annotation Type declaration
Annotation Type description
Required Element Summary
Optional Element Summary
Element Detail
+
+
+
+Enum
+
+
+
+Each enum has its own separate page with the following sections:
+
Enum declaration
Enum description
Enum Constant Summary
Enum Constant Detail
+
+
+Use
+
+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.
+
+Tree (Class Hierarchy)
+
+There is a Class Hierarchy 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 java.lang.Object. The interfaces do not inherit from java.lang.Object.
+
When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.
+
+
+Deprecated API
+
+The Deprecated API 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.
+
+Index
+
+The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.
+
+Prev/Next
+These links take you to the next or previous class, interface, package, or related page.
+Frames/No Frames
+These links show and hide the HTML frames. All pages are available with or without frames.
+
+
+Serialized Form
+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.
+
+
+""")
+
+ val groupMap = pkg.groupClassMap()
+ for (e in groupMap.entrySet()) {
+ val group = e?.getKey() ?: "Other"
+ val list = e?.getValue()
+ if (list != null) {
+ println("
+""")
+ }
+
+ }
+
+ protected fun printNextPrevPackages(): Unit {
+ println("""
""")
+ val prev = model.previous(pkg)
+ if (prev != null) {
+ println(" PREV PACKAGE ")
+ }
+ val next = model.next(pkg)
+ if (next != null) {
+ println(" NEXT PACKAGE")
+ }
+ println("""
""")
+
+ }
+}
diff --git a/kdoc/src/main/kotlin/org/jetbrains/kotlin/model/KotlinModel.kt b/kdoc/src/main/kotlin/org/jetbrains/kotlin/model/KotlinModel.kt
index 1acad7a725b..75c6e7aa7f1 100644
--- a/kdoc/src/main/kotlin/org/jetbrains/kotlin/model/KotlinModel.kt
+++ b/kdoc/src/main/kotlin/org/jetbrains/kotlin/model/KotlinModel.kt
@@ -6,13 +6,16 @@ import std.util.*
import java.util.*
-class KModel(var title: String = "Documentation") {
+class KModel(var title: String = "Documentation", var version: String = "TODO") {
// TODO generates java.lang.NoSuchMethodError: std.util.namespace.hashMap(Ljet/TypeInfo;Ljet/TypeInfo;)Ljava/util/HashMap;
//val packages = sortedMap()
public val packageMap: SortedMap = TreeMap()
public val packages: Collection = packageMap.values().sure()
+ public val classes: Collection
+ get() = packages.flatMap{ it.classes }
+
/* Returns the package for the given name, creating one if its not already been create yet */
fun getPackage(name: String): KPackage {
return packageMap.getOrPut(name){ KPackage(name) }
@@ -27,21 +30,52 @@ class KModel(var title: String = "Documentation") {
getPackage("").getClass(qualifiedName)
}
}
+
+ fun previous(pkg: KPackage): KPackage? {
+ return null
+ }
+
+ fun next(pkg: KPackage): KPackage? {
+ return null
+ }
}
-class KPackage(val name: String) : Comparable {
+class KPackage(val name: String, var description: String = "", var detailedDescription: String = "") : Comparable {
override fun compareTo(other: KPackage): Int = name.compareTo(other.name)
fun equals(other: KPackage) = name == other.name
fun toString() = "KPackage($name)"
+ /** Returns the name as a directory using '/' instead of '.' */
+ public val nameAsPath: String
+ get() = name.replace('.', '/')
+
+ /** Returns a list of all the paths in the package name */
+ public val namePaths: List
+ get() {
+ val answer = ArrayList()
+ 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() = namePaths.map{ ".." }.join("/")
+
// TODO generates java.lang.NoSuchMethodError: std.util.namespace.hashMap(Ljet/TypeInfo;Ljet/TypeInfo;)Ljava/util/HashMap;
//val classes = sortedMap()
public val classMap: SortedMap = TreeMap()
public val classes: Collection = classMap.values().sure()
+ public val annotations: Collection = ArrayList()
+
+
/* Returns the class for the given name, creating one if its not already been create yet */
fun getClass(simpleName: String): KClass {
return classMap.getOrPut(simpleName){ KClass(this, simpleName) }
@@ -55,16 +89,31 @@ class KPackage(val name: String) : Comparable {
}
}
+ fun groupClassMap(): Map> {
+ return classes.groupBy(TreeMap>()){it.group}
+ }
}
-class KClass(val kpackage: KPackage, val simpleName: String) : Comparable {
+class KClass(val kpackage: KPackage, val simpleName: String,
+ var kind: String = "class", var group: String = "Other", var description: String = "") : Comparable {
override fun compareTo(other: KClass): Int = name.compareTo(other.name)
fun equals(other: KClass) = name == other.name
- fun toString() = "KClass($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 = kpackage.qualifiedName(simpleName)
public val packageName: String = kpackage.name
+ /** Returns the name as a directory using '/' instead of '.' */
+ public val nameAsPath: String
+ get() = name.replace('.', '/')
+
}
\ No newline at end of file
diff --git a/kdoc/src/main/kotlin/std/template/TemplateCore.kt b/kdoc/src/main/kotlin/org/jetbrains/kotlin/template/TemplateCore.kt
similarity index 76%
rename from kdoc/src/main/kotlin/std/template/TemplateCore.kt
rename to kdoc/src/main/kotlin/org/jetbrains/kotlin/template/TemplateCore.kt
index 4dc0bce3642..12a8701ad58 100644
--- a/kdoc/src/main/kotlin/std/template/TemplateCore.kt
+++ b/kdoc/src/main/kotlin/org/jetbrains/kotlin/template/TemplateCore.kt
@@ -1,4 +1,4 @@
-package std.template
+package org.jetbrains.kotlin.template
import std.io.*
import java.io.Writer
@@ -16,7 +16,6 @@ import java.io.File
* stuff
*/
trait Template {
- var printer: Printer
/** Renders the template to the output printer */
fun render(): Unit
@@ -32,10 +31,11 @@ trait Template {
trait Printer {
fun print(value: Any): Unit
//fun print(text: String): Unit
+
}
+
class NullPrinter() : Printer {
- //override fun print(text: String) = none()
override fun print(value: Any) {
throw UnsupportedOperationException("No Printer defined on the Template")
}
@@ -47,22 +47,26 @@ class NullPrinter() : Printer {
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 {
- override var printer: Printer = NullPrinter()
+ public var printer: Printer = NullPrinter()
fun String.plus(): Unit {
printer.print(this)
}
- //override fun print(value: String) = printer.print(value)
-
override fun print(value: Any) = printer.print(value)
+ fun println(value: Any) {
+ print(value)
+ print(newline)
+ }
fun renderToText(): String {
val buffer = StringWriter()
@@ -75,9 +79,21 @@ abstract class TextTemplate() : TemplateSupport(), Printer {
this.render()
}
- fun renderTo(os: OutputStream): Unit = renderTo(OutputStreamWriter(os))
+ 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 = renderTo(FileWriter(file))
+ fun renderTo(file: File): Unit {
+ // TODO compiler error
+ //FileWriter(file).foreach{ s -> renderTo(s) }
+ val s = FileWriter(file)
+ renderTo(s)
+ s.close()
+ }
}
diff --git a/kdoc/src/test/kotlin/org/jetbrains/kotlin/doc/TestAll.java b/kdoc/src/test/kotlin/test/kotlin/doc/KDocTestAll.java
similarity index 88%
rename from kdoc/src/test/kotlin/org/jetbrains/kotlin/doc/TestAll.java
rename to kdoc/src/test/kotlin/test/kotlin/doc/KDocTestAll.java
index aee76f92ddd..e7a02770889 100644
--- a/kdoc/src/test/kotlin/org/jetbrains/kotlin/doc/TestAll.java
+++ b/kdoc/src/test/kotlin/test/kotlin/doc/KDocTestAll.java
@@ -15,14 +15,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.jetbrains.kotlin.doc;
+package test.kotlin.doc;
import junit.framework.TestSuite;
/**
*/
-public class TestAll {
+public class KDocTestAll {
public static TestSuite suite() {
- return TestSuite(ModelTest.class);
+ return new TestSuite("test.kotlin.doc.ModelTest");
}
}
diff --git a/kdoc/src/test/kotlin/org/jetbrains/kotlin/doc/ModelTest.kt b/kdoc/src/test/kotlin/test/kotlin/doc/ModelTest.kt
similarity index 98%
rename from kdoc/src/test/kotlin/org/jetbrains/kotlin/doc/ModelTest.kt
rename to kdoc/src/test/kotlin/test/kotlin/doc/ModelTest.kt
index 09e3efad24f..91d961c2357 100644
--- a/kdoc/src/test/kotlin/org/jetbrains/kotlin/doc/ModelTest.kt
+++ b/kdoc/src/test/kotlin/test/kotlin/doc/ModelTest.kt
@@ -1,4 +1,4 @@
-package test.model
+package test.kotlin.doc
import std.*
import std.util.*
diff --git a/kdoc/src/test/kotlin/org/jetbrains/kotlin/template/TemplateCoreTest.kt b/kdoc/src/test/kotlin/test/kotlin/template/TemplateCoreTest.kt
similarity index 93%
rename from kdoc/src/test/kotlin/org/jetbrains/kotlin/template/TemplateCoreTest.kt
rename to kdoc/src/test/kotlin/test/kotlin/template/TemplateCoreTest.kt
index 7ad8d9d3b21..d194dc5fb93 100644
--- a/kdoc/src/test/kotlin/org/jetbrains/kotlin/template/TemplateCoreTest.kt
+++ b/kdoc/src/test/kotlin/test/kotlin/template/TemplateCoreTest.kt
@@ -1,7 +1,7 @@
-package test.org.jetbrains.kotlin.template
+package test.kotlin.template
import std.*
-import std.template.*
+import org.jetbrains.kotlin.template.*
import std.io.*
import std.util.*
import java.util.*