diff options
author | Filip Zybała <fzybala@virtuslab.com> | 2020-04-01 17:20:44 +0200 |
---|---|---|
committer | Paweł Marks <Kordyjan@users.noreply.github.com> | 2020-04-06 14:23:54 +0200 |
commit | 2b921897aa90216d78e05165d5ce122814ead74c (patch) | |
tree | f89765c4bd17a1af3651596c377b84e3f0d146c6 | |
parent | a1866dd98d291a6a2a538e88348c53ff08c812eb (diff) | |
download | dokka-2b921897aa90216d78e05165d5ce122814ead74c.tar.gz dokka-2b921897aa90216d78e05165d5ce122814ead74c.tar.bz2 dokka-2b921897aa90216d78e05165d5ce122814ead74c.zip |
Changed see also parsing, added see also section to pages
4 files changed, 34 insertions, 3 deletions
diff --git a/core/src/main/kotlin/model/doc/TagWrapper.kt b/core/src/main/kotlin/model/doc/TagWrapper.kt index 9dda7c8f..6652f5a1 100644 --- a/core/src/main/kotlin/model/doc/TagWrapper.kt +++ b/core/src/main/kotlin/model/doc/TagWrapper.kt @@ -1,5 +1,7 @@ package org.jetbrains.dokka.model.doc +import org.jetbrains.dokka.links.DRI + sealed class TagWrapper(val root: DocTag) { override fun equals(other: Any?): Boolean = @@ -20,7 +22,7 @@ class Description(root: DocTag) : TagWrapper(root) class Author(root: DocTag) : TagWrapper(root) class Version(root: DocTag) : TagWrapper(root) class Since(root: DocTag) : TagWrapper(root) -class See(root: DocTag, name: String) : NamedTagWrapper(root, name) +class See(root: DocTag, name: String, val address: DRI?) : NamedTagWrapper(root, name) class Param(root: DocTag, name: String) : NamedTagWrapper(root, name) class Return(root: DocTag) : TagWrapper(root) class Receiver(root: DocTag) : TagWrapper(root) diff --git a/core/src/main/kotlin/parsers/MarkdownParser.kt b/core/src/main/kotlin/parsers/MarkdownParser.kt index 617d351b..782a6504 100644 --- a/core/src/main/kotlin/parsers/MarkdownParser.kt +++ b/core/src/main/kotlin/parsers/MarkdownParser.kt @@ -361,7 +361,15 @@ class MarkdownParser( ) KDocKnownTag.RECEIVER -> Receiver(parseStringToDocNode(it.getContent())) KDocKnownTag.RETURN -> Return(parseStringToDocNode(it.getContent())) - KDocKnownTag.SEE -> See(parseStringToDocNode(it.getContent()), it.getSubjectName().orEmpty()) + KDocKnownTag.SEE -> See( + parseStringToDocNode(it.getContent()), + it.getSubjectName().orEmpty(), + parseStringToDocNode("[${it.getSubjectName()}]") + .let { + if(it is DocumentationLink) it.dri + else null + } + ) KDocKnownTag.SINCE -> Since(parseStringToDocNode(it.getContent())) KDocKnownTag.CONSTRUCTOR -> Constructor(parseStringToDocNode(it.getContent())) KDocKnownTag.PROPERTY -> Property( diff --git a/core/src/main/kotlin/parsers/Parser.kt b/core/src/main/kotlin/parsers/Parser.kt index f03e57be..11dcafb0 100644 --- a/core/src/main/kotlin/parsers/Parser.kt +++ b/core/src/main/kotlin/parsers/Parser.kt @@ -17,7 +17,7 @@ abstract class Parser { "author" -> Author(parseStringToDocNode(it.second)) "version" -> Version(parseStringToDocNode(it.second)) "since" -> Since(parseStringToDocNode(it.second)) - "see" -> See(parseStringToDocNode(it.second.substringAfter(' ')), it.second.substringBefore(' ')) + "see" -> See(parseStringToDocNode(it.second.substringAfter(' ')), it.second.substringBefore(' '), null) "param" -> Param(parseStringToDocNode(it.second.substringAfter(' ')), it.second.substringBefore(' ')) "property" -> Property(parseStringToDocNode(it.second.substringAfter(' ')), it.second.substringBefore(' ')) "return" -> Return(parseStringToDocNode(it.second)) diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt index 177d5021..e8cdb2cf 100644 --- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt +++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt @@ -245,6 +245,26 @@ open class DefaultPageCreator( } } + fun DocumentableContentBuilder.contentForSeeAlso() { + val seeAlsoTags = tags.withTypeNamed<See>() + if(seeAlsoTags.isNotEmpty()) { + header(4, kind = ContentKind.Comment) { text("See also") } + table(kind = ContentKind.Comment) { + platforms.flatMap { platform -> + seeAlsoTags.mapNotNull { (_, see) -> + see.getOrExpect(platform)?.let { + buildGroup { + if (it.address != null) link(it.name, it.address!!) + else text(it.name) + comment(it.root) + } + } + } + } + } + } + } + fun DocumentableContentBuilder.contentForUnnamedTags() { val unnamedTags: List<PlatformDependent<TagWrapper>> = tags.filterNot { (k, _) -> k.isSubclassOf(NamedTagWrapper::class) || k in specialTags } @@ -268,6 +288,7 @@ open class DefaultPageCreator( contentForDescription() contentForParams() contentForUnnamedTags() + contentForSeeAlso() } } }.children |