aboutsummaryrefslogtreecommitdiff
path: root/src/Kotlin/DocumentationBuilder.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/Kotlin/DocumentationBuilder.kt')
-rw-r--r--src/Kotlin/DocumentationBuilder.kt33
1 files changed, 26 insertions, 7 deletions
diff --git a/src/Kotlin/DocumentationBuilder.kt b/src/Kotlin/DocumentationBuilder.kt
index 1680b407..c9c45214 100644
--- a/src/Kotlin/DocumentationBuilder.kt
+++ b/src/Kotlin/DocumentationBuilder.kt
@@ -51,13 +51,17 @@ class DocumentationBuilder(val session: ResolveSession, val options: Documentati
if (kdoc is KDocSection) {
val tags = kdoc.getTags()
tags.forEach {
- if (it.getName() == "sample") {
- content.append(functionBody(descriptor, it.getSubjectName()))
- } else {
- val section = content.addSection(displayName(it.getName()), it.getSubjectName())
- val sectionContent = it.getContent()
- val markdownNode = parseMarkdown(sectionContent)
- buildInlineContentTo(markdownNode, section)
+ when (it.getName()) {
+ "sample" ->
+ content.append(functionBody(descriptor, it.getSubjectName()))
+ "see" ->
+ content.addTagToSeeAlso(it)
+ else -> {
+ val section = content.addSection(displayName(it.getName()), it.getSubjectName())
+ val sectionContent = it.getContent()
+ val markdownNode = parseMarkdown(sectionContent)
+ buildInlineContentTo(markdownNode, section)
+ }
}
}
}
@@ -73,6 +77,18 @@ class DocumentationBuilder(val session: ResolveSession, val options: Documentati
else -> sectionName?.capitalize()
}
+ private fun Content.addTagToSeeAlso(seeTag: KDocTag) {
+ val subjectName = seeTag.getSubjectName()
+ if (subjectName != null) {
+ val seeSection = findSectionByTag("See Also") ?: addSection("See Also", null)
+ val link = ContentExternalLink(subjectName)
+ link.append(ContentText(subjectName))
+ val para = ContentParagraph()
+ para.append(link)
+ seeSection.append(para)
+ }
+ }
+
fun link(node: DocumentationNode, descriptor: DeclarationDescriptor) {
links.put(node, descriptor)
}
@@ -505,6 +521,9 @@ class DocumentationBuilder(val session: ResolveSession, val options: Documentati
}
resolveContentLinks(node, node.content)
+ for (section in node.content.sections) {
+ resolveContentLinks(node, section)
+ }
for (child in node.members) {
resolveReferences(child)