kdoc: constants for names
This commit is contained in:
@@ -0,0 +1,10 @@
|
|||||||
|
package org.jetbrains.kotlin.doc
|
||||||
|
|
||||||
|
|
||||||
|
object names {
|
||||||
|
|
||||||
|
val htmlSourceDirName = "src-html"
|
||||||
|
|
||||||
|
fun lineNumberLinkHref(lineNumber: Int) = "L$lineNumber"
|
||||||
|
|
||||||
|
}
|
||||||
+2
-1
@@ -19,6 +19,7 @@ import org.jetbrains.kotlin.doc.Doclet
|
|||||||
import org.jetbrains.kotlin.doc.model.KModel
|
import org.jetbrains.kotlin.doc.model.KModel
|
||||||
import org.jetbrains.jet.lang.psi.JetFile
|
import org.jetbrains.jet.lang.psi.JetFile
|
||||||
import org.jetbrains.kotlin.doc.model.SourceInfo
|
import org.jetbrains.kotlin.doc.model.SourceInfo
|
||||||
|
import org.jetbrains.kotlin.doc.*
|
||||||
|
|
||||||
|
|
||||||
class Html2CompilerPlugin(private val compilerArguments: KDocArguments) : Doclet {
|
class Html2CompilerPlugin(private val compilerArguments: KDocArguments) : Doclet {
|
||||||
@@ -32,7 +33,7 @@ class Html2CompilerPlugin(private val compilerArguments: KDocArguments) : Doclet
|
|||||||
docOutputRoot = File(docOutputDir)
|
docOutputRoot = File(docOutputDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val srcOutputRoot = File(docOutputRoot, "src-html")
|
private val srcOutputRoot = File(docOutputRoot, names.htmlSourceDirName)
|
||||||
|
|
||||||
private val sourceDirs: List<File> =
|
private val sourceDirs: List<File> =
|
||||||
compilerArguments
|
compilerArguments
|
||||||
|
|||||||
+6
-5
@@ -7,6 +7,7 @@ import org.jetbrains.kotlin.doc.model.KAnnotation
|
|||||||
import org.jetbrains.kotlin.doc.model.KPackage
|
import org.jetbrains.kotlin.doc.model.KPackage
|
||||||
import org.jetbrains.kotlin.template.TextTemplate
|
import org.jetbrains.kotlin.template.TextTemplate
|
||||||
import org.jetbrains.kotlin.doc.model.KFunction
|
import org.jetbrains.kotlin.doc.model.KFunction
|
||||||
|
import org.jetbrains.kotlin.doc.*
|
||||||
import java.util.Collection
|
import java.util.Collection
|
||||||
import org.jetbrains.kotlin.doc.model.KProperty
|
import org.jetbrains.kotlin.doc.model.KProperty
|
||||||
import org.jetbrains.kotlin.doc.model.KType
|
import org.jetbrains.kotlin.doc.model.KType
|
||||||
@@ -73,7 +74,7 @@ abstract class KDocTemplate() : TextTemplate() {
|
|||||||
} else {
|
} else {
|
||||||
val pkg = klass.pkg
|
val pkg = klass.pkg
|
||||||
return if (klass.sourceInfo != null) {
|
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 {
|
} else {
|
||||||
href(klass)
|
href(klass)
|
||||||
}
|
}
|
||||||
@@ -87,14 +88,14 @@ abstract class KDocTemplate() : TextTemplate() {
|
|||||||
return if (owner is KClass) {
|
return if (owner is KClass) {
|
||||||
val pkg = owner.pkg
|
val pkg = owner.pkg
|
||||||
if (owner.sourceInfo != null) {
|
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 {
|
} else {
|
||||||
href(f)
|
href(f)
|
||||||
}
|
}
|
||||||
} else if (owner is KPackage) {
|
} else if (owner is KPackage) {
|
||||||
if (!owner.useExternalLink) {
|
if (!owner.useExternalLink) {
|
||||||
// TODO how to find the function in a package???
|
// 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 {
|
} else {
|
||||||
href(owner)
|
href(owner)
|
||||||
}
|
}
|
||||||
@@ -110,14 +111,14 @@ abstract class KDocTemplate() : TextTemplate() {
|
|||||||
return if (owner is KClass) {
|
return if (owner is KClass) {
|
||||||
val pkg = owner.pkg
|
val pkg = owner.pkg
|
||||||
if (owner.sourceInfo != null) {
|
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 {
|
} else {
|
||||||
href(f)
|
href(f)
|
||||||
}
|
}
|
||||||
} else if (owner is KPackage) {
|
} else if (owner is KPackage) {
|
||||||
if (!owner.useExternalLink) {
|
if (!owner.useExternalLink) {
|
||||||
// TODO how to find the function in a package???
|
// 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 {
|
} else {
|
||||||
href(owner)
|
href(owner)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user