aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIlya Ryzhenkov <orangy@jetbrains.com>2014-10-03 23:41:16 +0400
committerIlya Ryzhenkov <orangy@jetbrains.com>2014-10-03 23:41:16 +0400
commit10068c5b31a2e3df746638da8c440d325a32f67d (patch)
tree9f70d1ddd4d298ded93152f25ab545749b02fa2b /src
parent04135d13e4f1fc41893767b8719e9189cd41617a (diff)
downloaddokka-10068c5b31a2e3df746638da8c440d325a32f67d.tar.gz
dokka-10068c5b31a2e3df746638da8c440d325a32f67d.tar.bz2
dokka-10068c5b31a2e3df746638da8c440d325a32f67d.zip
Unify link resolution for short and full forms, remove ContentNameLink.
Diffstat (limited to 'src')
-rw-r--r--src/Kotlin/ContentBuilder.kt5
-rw-r--r--src/Kotlin/ResolveReferences.kt30
-rw-r--r--src/Languages/LanguageService.kt2
-rw-r--r--src/Model/Content.kt1
4 files changed, 14 insertions, 24 deletions
diff --git a/src/Kotlin/ContentBuilder.kt b/src/Kotlin/ContentBuilder.kt
index 389b2732..b7290b58 100644
--- a/src/Kotlin/ContentBuilder.kt
+++ b/src/Kotlin/ContentBuilder.kt
@@ -53,10 +53,7 @@ public fun MarkdownTree.toContent(): Content {
MarkdownElementTypes.LINK -> {
val target = findChildByType(node, MarkdownElementTypes.TARGET)?.let { getNodeText(it) } ?: ""
val href = findChildByType(node, MarkdownElementTypes.HREF)?.let { getNodeText(it) }
- val link = if (href != null)
- ContentExternalLink(href)
- else
- ContentNameLink(target)
+ val link = if (href != null) ContentExternalLink(href) else ContentExternalLink(target)
link.append(ContentText(target))
parent.append(link)
}
diff --git a/src/Kotlin/ResolveReferences.kt b/src/Kotlin/ResolveReferences.kt
index b14d3718..1349c69e 100644
--- a/src/Kotlin/ResolveReferences.kt
+++ b/src/Kotlin/ResolveReferences.kt
@@ -49,33 +49,27 @@ public fun DocumentationContext.resolveReferences(node: DocumentationNode) {
fun DocumentationContext.resolveContentLinks(node: DocumentationNode, content: ContentNode) {
val snapshot = content.children.toList()
for (child in snapshot) {
- val referenceText = when (child) {
- is ContentExternalLink -> child.href
- is ContentNameLink -> child.name
- else -> null
- }
+ if (child is ContentExternalLink) {
+ val referenceText = child.href
+ if (Name.isValidIdentifier(referenceText)) {
+ val scope = getResolutionScope(node)
+ val symbolName = Name.guess(referenceText)
+ val symbol = scope.getLocalVariable(symbolName) ?:
+ scope.getProperties(symbolName).firstOrNull() ?:
+ scope.getFunctions(symbolName).firstOrNull() ?:
+ scope.getClassifier(symbolName)
- if (referenceText != null && Name.isValidIdentifier(referenceText)) {
- val scope = getResolutionScope(node)
- val symbolName = Name.guess(referenceText)
- val symbol =
- scope.getLocalVariable(symbolName) ?:
- scope.getProperties(symbolName).firstOrNull() ?:
- scope.getFunctions(symbolName).firstOrNull() ?:
- scope.getClassifier(symbolName)
+ if (symbol != null) {
+ val targetNode = descriptorToNode[symbol]
+ val contentLink = if (targetNode != null) ContentNodeLink(targetNode) else ContentExternalLink("#")
- if (symbol != null) {
- val targetNode = descriptorToNode[symbol]
- if (targetNode != null) {
val index = content.children.indexOf(child)
content.children.remove(index)
- val contentLink = ContentNodeLink(targetNode)
contentLink.children.addAll(child.children)
content.children.add(index, contentLink)
}
}
}
-
resolveContentLinks(node, child)
}
} \ No newline at end of file
diff --git a/src/Languages/LanguageService.kt b/src/Languages/LanguageService.kt
index bf55ac2c..0f1a1d26 100644
--- a/src/Languages/LanguageService.kt
+++ b/src/Languages/LanguageService.kt
@@ -5,7 +5,7 @@ package org.jetbrains.dokka
*/
trait LanguageService {
/**
- * Renders [node] as a class, function, property or other signature
+ * Renders a [node](DocumentationNode) as a class, function, property or other signature in a target language.
* $node: A [DocumentationNode] to render
* $returns: [ContentNode] which is a root for a rich content tree suitable for formatting with [FormatService]
*/
diff --git a/src/Model/Content.kt b/src/Model/Content.kt
index 27adfe59..ce438835 100644
--- a/src/Model/Content.kt
+++ b/src/Model/Content.kt
@@ -25,7 +25,6 @@ public class ContentIdentifier(val text: String) : ContentNode()
public class ContentSymbol(val text: String) : ContentNode()
public class ContentEmphasis() : ContentBlock()
public class ContentNodeLink(val node : DocumentationNode) : ContentBlock()
-public class ContentNameLink(val name : String) : ContentBlock()
public class ContentExternalLink(val href : String) : ContentBlock()
public class ContentStrong() : ContentBlock()
public class ContentList() : ContentBlock()