From a923eee175f80ab59297f89fca9d8f915c5771e5 Mon Sep 17 00:00:00 2001 From: James Strachan Date: Fri, 24 Feb 2012 11:04:50 +0000 Subject: [PATCH] added links to the extension functions from the summary page table and fixed up the detail extension function docs (also made nice use of the multi line treble quoted strings with templates, yay! :) --- .../doc/templates/ClassExtensionsTemplate.kt | 2 ++ .../kotlin/doc/templates/KDocTemplate.kt | 24 +++++++++++-------- .../doc/templates/PackageSummaryTemplate.kt | 9 ++++++- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/templates/ClassExtensionsTemplate.kt b/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/templates/ClassExtensionsTemplate.kt index 6e28887791c..9ed434a2e25 100644 --- a/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/templates/ClassExtensionsTemplate.kt +++ b/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/templates/ClassExtensionsTemplate.kt @@ -42,4 +42,6 @@ class ClassExtensionsTemplate(m: KModel, p: KPackage, k: KClass, var functions: """) } + override fun href(f: KFunction): String = "#${f.link}" + } diff --git a/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/templates/KDocTemplate.kt b/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/templates/KDocTemplate.kt index 7ccd1dcc157..45a9899dabb 100644 --- a/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/templates/KDocTemplate.kt +++ b/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/templates/KDocTemplate.kt @@ -9,22 +9,22 @@ import java.util.Collection import org.jetbrains.kotlin.model.KProperty abstract class KDocTemplate() : TextTemplate() { - fun rootHref(pkg: KPackage): String { + open fun rootHref(pkg: KPackage): String { return if (pkg.external) { // TODO deal with external classes "" } else relativePrefix() } - fun href(p: KPackage): String + open fun href(p: KPackage): String = "${rootHref(p)}${p.nameAsPath}/package-summary.html" - fun href(c: KClass): String { + open fun href(c: KClass): String { val postfix = if (c.pkg.external) "?is-external=true" else "" return "${rootHref(c.pkg)}${c.nameAsPath}.html$postfix" } - fun href(f: KFunction): String { + open fun href(f: KFunction): String { return if (f.owner is KClass) { "${href(f.owner)}#${f.link}" } else { @@ -32,7 +32,7 @@ abstract class KDocTemplate() : TextTemplate() { } } - fun href(f: KProperty): String { + open fun href(f: KProperty): String { return if (f.owner is KClass) { "${href(f.owner)}#${f.link}" } else { @@ -40,12 +40,16 @@ abstract class KDocTemplate() : TextTemplate() { } } - fun extensionsHref(pkg: KPackage, c: KClass): String { + open fun extensionsHref(pkg: KPackage, c: KClass): String { // is inside the pkg so no need to use it... return "${c.nameAsPath}-extensions.html" } - fun sourceHref(f: KFunction): String { + open fun extensionsHref(pkg: KPackage, c: KClass, f: KFunction): String { + return "${extensionsHref(pkg, c)}#${f.link}" + } + + open fun sourceHref(f: KFunction): String { return if (f.owner is KClass) { "${rootHref(f.owner.pkg)}src-html/${f.owner.simpleName}.html#line.${f.sourceLine}" } else { @@ -54,18 +58,18 @@ abstract class KDocTemplate() : TextTemplate() { } } - fun link(c: KClass, fullName: Boolean = false): String { + open fun link(c: KClass, fullName: Boolean = false): String { // TODO if a class is a generic type parameter, just return the name... val prefix = if (c.isAnnotation()) "@" else "" val name = if (fullName) c.name else c.simpleName return "$prefix$name" } - fun link(p: KPackage): String { + open fun link(p: KPackage): String { return "${p.name}" } - fun link(a: KAnnotation): String { + open fun link(a: KAnnotation): String { val c = a.klass return "@${c.simpleName}" } diff --git a/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/templates/PackageSummaryTemplate.kt b/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/templates/PackageSummaryTemplate.kt index 837271838b4..46a6af73f30 100644 --- a/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/templates/PackageSummaryTemplate.kt +++ b/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/templates/PackageSummaryTemplate.kt @@ -282,7 +282,14 @@ Copyright © 2010-2012. All Rights Reserved. if (c != null) { println("""""") println("${c.name}") - println("${c.description}") + print("") + val list = e?.getValue() + if (list != null) { + for (f in list) { + println("""${f.name} """) + } + } + println("") println("") } }