diff options
Diffstat (limited to 'core/src/main/kotlin/Model')
-rw-r--r-- | core/src/main/kotlin/Model/Content.kt | 10 | ||||
-rw-r--r-- | core/src/main/kotlin/Model/DocumentationNode.kt | 2 | ||||
-rw-r--r-- | core/src/main/kotlin/Model/DocumentationReference.kt | 12 |
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() } |