org.jetbrains.kotlin.doc.templates.PackageSummaryTemplate.kt Maven / Gradle / Ivy
package org.jetbrains.kotlin.doc.templates
import org.jetbrains.kotlin.doc.model.KModel
import org.jetbrains.kotlin.doc.model.KPackage
import org.jetbrains.kotlin.doc.model.filterDuplicateNames
import org.jetbrains.kotlin.doc.model.inheritedExtensionFunctions
class PackageSummaryTemplate(val model: KModel, pkg: KPackage) : PackageTemplateSupport(pkg) {
override fun render() {
println("""
$generatedComment
${pkg.name} (${model.title})
${stylesheets()}
Overview
Package
Class
Use
Tree
Deprecated
Index
Help
${searchBox()}
""")
printNextPrevPackages()
println("""
FRAMES
NO FRAMES
""")
for (a in pkg.annotations) {
val url = a.url
if (url != null) {
println("""@${a.simpleName}""")
}
}
println("""
Package ${pkg.name}
${pkg.description(this)}
See:
Description
""")
printClasses("trait", "Traits")
printClasses("class", "Classes")
printClasses("enum", "Enums")
printClasses("annotation", "Annotations")
printClasses("exception", "Exceptions")
printPropertySummary(pkg.packageProperties())
printFunctionSummary(pkg.packageFunctions())
printExtensionFunctions()
println("""
Package ${pkg.name} Description
${pkg.detailedDescription(this)}
Contents
""")
val groupMap = pkg.groupClassMap()
for (e in groupMap) {
val group = e.key ?: "Other"
val list = e.value
if (list != null) {
println(""" $group
""")
for (c in list) {
println(""" ${c.simpleName}
""")
}
println("""
""")
}
}
println("""""")
printFunctionDetail(pkg.packageFunctions())
println("""
Overview
Package
Class
Use
Tree
Deprecated
Index
Help
""")
printNextPrevPackages()
println("""
FRAMES
NO FRAMES
Copyright © 2010-2012. All Rights Reserved.
""")
}
protected fun printClasses(kind: String, description: String): Unit {
val classes = pkg.classes.filter{ it.kind == kind }
if (! classes.isEmpty()) {
print("""
$description Summary
""")
for (c in classes) {
println("""
${c.simpleName}
${c.description(this)}
""")
}
println("""
""")
}
}
// TODO delete
protected fun printFunctions(): Unit {
val functions = pkg.functions.filter{ it.extensionClass == null }
if (! functions.isEmpty()) {
print("""
Functions Summary
""")
for (f in functions) {
println("""
${f.name}
${f.description(this)}
""")
}
println("""
""")
}
}
protected fun printExtensionFunctions(): Unit {
val map = inheritedExtensionFunctions(pkg.functions)
if (! map.isEmpty()) {
print("""
Extensions Summary
""")
for (e in map) {
val c = e.key
if (c != null) {
println("""
${c.name}
""")
val list = e.value
if (list != null) {
val functions = filterDuplicateNames(list)
for (f in functions) {
println("""${f.name} """)
}
}
println("""
""")
}
}
println("""
""")
}
}
protected fun printNextPrevPackages(): Unit {
println("""
""")
val prev = model.previous(pkg)
if (prev != null) {
println(""" PREV PACKAGE """)
} else {
println(""" PREV PACKAGE """ )
}
val next = model.next(pkg)
if (next != null) {
println(""" NEXT PACKAGE""")
} else {
println(""" NEXT PACKAGE""" )
}
println(""" """)
}
}