kdoc: constants for names

This commit is contained in:
Stepan Koltsov
2012-06-25 23:55:30 +04:00
parent be1b9a011b
commit 8d2bd30585
3 changed files with 18 additions and 6 deletions
@@ -0,0 +1,10 @@
package org.jetbrains.kotlin.doc
object names {
val htmlSourceDirName = "src-html"
fun lineNumberLinkHref(lineNumber: Int) = "L$lineNumber"
}
@@ -19,6 +19,7 @@ import org.jetbrains.kotlin.doc.Doclet
import org.jetbrains.kotlin.doc.model.KModel
import org.jetbrains.jet.lang.psi.JetFile
import org.jetbrains.kotlin.doc.model.SourceInfo
import org.jetbrains.kotlin.doc.*
class Html2CompilerPlugin(private val compilerArguments: KDocArguments) : Doclet {
@@ -32,7 +33,7 @@ class Html2CompilerPlugin(private val compilerArguments: KDocArguments) : Doclet
docOutputRoot = File(docOutputDir)
}
private val srcOutputRoot = File(docOutputRoot, "src-html")
private val srcOutputRoot = File(docOutputRoot, names.htmlSourceDirName)
private val sourceDirs: List<File> =
compilerArguments
@@ -7,6 +7,7 @@ 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 org.jetbrains.kotlin.doc.*
import java.util.Collection
import org.jetbrains.kotlin.doc.model.KProperty
import org.jetbrains.kotlin.doc.model.KType
@@ -73,7 +74,7 @@ abstract class KDocTemplate() : TextTemplate() {
} else {
val pkg = klass.pkg
return if (klass.sourceInfo != null) {
"${pkg.nameAsRelativePath}src-html/${klass.sourceInfo.htmlPath}.html#line.${klass.sourceLine}"
"${pkg.nameAsRelativePath}${names.htmlSourceDirName}/${klass.sourceInfo.htmlPath}.html#${names.lineNumberLinkHref(klass.sourceLine)}"
} else {
href(klass)
}
@@ -87,14 +88,14 @@ abstract class KDocTemplate() : TextTemplate() {
return if (owner is KClass) {
val pkg = owner.pkg
if (owner.sourceInfo != null) {
"${rootHref(pkg)}src-html/${owner.sourceInfo.htmlPath}.html#line.${f.sourceLine}"
"${rootHref(pkg)}${names.htmlSourceDirName}/${owner.sourceInfo.htmlPath}.html#${names.lineNumberLinkHref(f.sourceLine)}"
} else {
href(f)
}
} else if (owner is KPackage) {
if (!owner.useExternalLink) {
// TODO how to find the function in a package???
"${rootHref(owner)}src-html/namespace.html#line.${f.sourceLine}"
"${rootHref(owner)}${names.htmlSourceDirName}/namespace.html#${names.lineNumberLinkHref(f.sourceLine)}"
} else {
href(owner)
}
@@ -110,14 +111,14 @@ abstract class KDocTemplate() : TextTemplate() {
return if (owner is KClass) {
val pkg = owner.pkg
if (owner.sourceInfo != null) {
"${rootHref(pkg)}src-html/${owner.sourceInfo.htmlPath}#line.${f.sourceLine}"
"${rootHref(pkg)}${names.htmlSourceDirName}/${owner.sourceInfo.htmlPath}#${names.lineNumberLinkHref(f.sourceLine)}"
} else {
href(f)
}
} else if (owner is KPackage) {
if (!owner.useExternalLink) {
// TODO how to find the function in a package???
"${rootHref(owner)}src-html/namespace.html#line.${f.sourceLine}"
"${rootHref(owner)}${names.htmlSourceDirName}/namespace.html#${names.lineNumberLinkHref(f.sourceLine)}"
} else {
href(owner)
}