aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/Model
diff options
context:
space:
mode:
authorDmitry Jemerov <yole@jetbrains.com>2016-01-12 16:14:21 +0100
committerDmitry Jemerov <yole@jetbrains.com>2016-01-12 16:14:21 +0100
commita3ec2e2afd6f4140ac78f7630fa9c2ca1f8ca8af (patch)
treec0a87789124c2fff312c5b32f1a4e6815129abca /core/src/main/kotlin/Model
parent99b6196bde4773fd26bd733ecf5e3984ce0a4c63 (diff)
downloaddokka-a3ec2e2afd6f4140ac78f7630fa9c2ca1f8ca8af.tar.gz
dokka-a3ec2e2afd6f4140ac78f7630fa9c2ca1f8ca8af.tar.bz2
dokka-a3ec2e2afd6f4140ac78f7630fa9c2ca1f8ca8af.zip
generate signature-based anchors for overloads; use signature instead of name as an anchor for in-page links
Diffstat (limited to 'core/src/main/kotlin/Model')
-rw-r--r--core/src/main/kotlin/Model/Content.kt10
-rw-r--r--core/src/main/kotlin/Model/DocumentationNode.kt2
-rw-r--r--core/src/main/kotlin/Model/DocumentationReference.kt12
3 files changed, 20 insertions, 4 deletions
diff --git a/core/src/main/kotlin/Model/Content.kt b/core/src/main/kotlin/Model/Content.kt
index 4c69f6cb..0a38a524 100644
--- a/core/src/main/kotlin/Model/Content.kt
+++ b/core/src/main/kotlin/Model/Content.kt
@@ -45,7 +45,9 @@ data class ContentKeyword(val text: String) : ContentNode {
get() = text.length
}
-data class ContentIdentifier(val text: String, val kind: IdentifierKind = IdentifierKind.Other) : ContentNode {
+data class ContentIdentifier(val text: String,
+ val kind: IdentifierKind = IdentifierKind.Other,
+ val signature: String? = null) : ContentNode {
override val textLength: Int
get() = text.length
}
@@ -140,7 +142,11 @@ fun content(body: ContentBlock.() -> Unit): ContentBlock {
fun ContentBlock.text(value: String) = append(ContentText(value))
fun ContentBlock.keyword(value: String) = append(ContentKeyword(value))
fun ContentBlock.symbol(value: String) = append(ContentSymbol(value))
-fun ContentBlock.identifier(value: String, kind: IdentifierKind = IdentifierKind.Other) = append(ContentIdentifier(value, kind))
+
+fun ContentBlock.identifier(value: String, kind: IdentifierKind = IdentifierKind.Other, signature: String? = null) {
+ append(ContentIdentifier(value, kind, signature))
+}
+
fun ContentBlock.nbsp() = append(ContentNonBreakingSpace)
fun ContentBlock.softLineBreak() = append(ContentSoftLineBreak)
fun ContentBlock.indentedSoftLineBreak() = append(ContentIndentedSoftLineBreak)
diff --git a/core/src/main/kotlin/Model/DocumentationNode.kt b/core/src/main/kotlin/Model/DocumentationNode.kt
index 3cedb8e6..f7e935b2 100644
--- a/core/src/main/kotlin/Model/DocumentationNode.kt
+++ b/core/src/main/kotlin/Model/DocumentationNode.kt
@@ -42,6 +42,7 @@ enum class NodeKind {
SourceUrl,
SourcePosition,
+ Signature,
ExternalLink,
@@ -115,6 +116,7 @@ open class DocumentationNode(val name: String,
fun links(kind: NodeKind): List<DocumentationNode> = links.filter { it.kind == kind }
fun detail(kind: NodeKind): DocumentationNode = details.filter { it.kind == kind }.single()
+ fun detailOrNull(kind: NodeKind): DocumentationNode? = details.filter { it.kind == kind }.singleOrNull()
fun member(kind: NodeKind): DocumentationNode = members.filter { it.kind == kind }.single()
fun link(kind: NodeKind): DocumentationNode = links.filter { it.kind == kind }.single()
diff --git a/core/src/main/kotlin/Model/DocumentationReference.kt b/core/src/main/kotlin/Model/DocumentationReference.kt
index 0b40e83a..0c87d719 100644
--- a/core/src/main/kotlin/Model/DocumentationReference.kt
+++ b/core/src/main/kotlin/Model/DocumentationReference.kt
@@ -1,5 +1,6 @@
package org.jetbrains.dokka
+import com.google.inject.Inject
import com.google.inject.Singleton
enum class RefKind {
@@ -35,7 +36,8 @@ class PendingDocumentationReference(val lazyNodeFrom: () -> DocumentationNode?,
}
@Singleton
-class NodeReferenceGraph() {
+class NodeReferenceGraph
+ @Inject constructor(val logger: DokkaLogger) {
private val nodeMap = hashMapOf<String, DocumentationNode>()
val references = arrayListOf<PendingDocumentationReference>()
@@ -55,7 +57,13 @@ class NodeReferenceGraph() {
references.add(PendingDocumentationReference({ -> nodeMap[fromSignature]}, { -> nodeMap[toSignature]}, kind))
}
- fun lookup(signature: String): DocumentationNode? = nodeMap[signature]
+ fun lookup(signature: String): DocumentationNode? {
+ val result = nodeMap[signature]
+ if (result == null) {
+ logger.warn("Can't find node by signature $signature")
+ }
+ return result
+ }
fun resolveReferences() {
references.forEach { it.resolve() }