From 61a3587abeb35908b09e169bb55e2a9f1890c195 Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Tue, 27 Aug 2019 17:59:30 +0200 Subject: Fix for missing colon in links to external sites, https://github.com/Kotlin/dokka/issues/405 --- core/src/main/kotlin/Kotlin/ContentBuilder.kt | 2 +- core/src/test/kotlin/model/LinkTest.kt | 10 ++++++++++ core/testdata/links/linkToExternalSite.kt | 4 ++++ 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 core/testdata/links/linkToExternalSite.kt diff --git a/core/src/main/kotlin/Kotlin/ContentBuilder.kt b/core/src/main/kotlin/Kotlin/ContentBuilder.kt index c60625a4..573b41b6 100644 --- a/core/src/main/kotlin/Kotlin/ContentBuilder.kt +++ b/core/src/main/kotlin/Kotlin/ContentBuilder.kt @@ -168,7 +168,7 @@ fun buildContentTo(tree: MarkdownNode, target: ContentBlock, linkResolver: LinkR } } -private fun MarkdownNode.getLabelText() = children.filter { it.type == MarkdownTokenTypes.TEXT || it.type == MarkdownTokenTypes.EMPH }.joinToString("") { it.text } +private fun MarkdownNode.getLabelText() = children.filter { it.type == MarkdownTokenTypes.TEXT || it.type == MarkdownTokenTypes.EMPH || it.type == MarkdownTokenTypes.COLON }.joinToString("") { it.text } private fun keepEol(node: ContentNode) = node is ContentParagraph || node is ContentSection || node is ContentBlockCode private fun processingList(node: ContentNode) = node is ContentOrderedList || node is ContentUnorderedList diff --git a/core/src/test/kotlin/model/LinkTest.kt b/core/src/test/kotlin/model/LinkTest.kt index 9b2f9f0d..6526a4db 100644 --- a/core/src/test/kotlin/model/LinkTest.kt +++ b/core/src/test/kotlin/model/LinkTest.kt @@ -19,6 +19,16 @@ abstract class BaseLinkTest(val analysisPlatform: Platform) { } } + @Test fun linkToExternalSite() { + checkSourceExistsAndVerifyModel("testdata/links/linkToExternalSite.kt", defaultModelConfig) { model -> + with(model.members.single().members.single()) { + assertEquals("Foo", name) + assertEquals(NodeKind.Class, kind) + assertEquals("This is link to http://example.com/#example", content.summary.toTestString()) + } + } + } + @Test fun linkToMember() { checkSourceExistsAndVerifyModel("testdata/links/linkToMember.kt", defaultModelConfig) { model -> with(model.members.single().members.single()) { diff --git a/core/testdata/links/linkToExternalSite.kt b/core/testdata/links/linkToExternalSite.kt new file mode 100644 index 00000000..a3d8c5ef --- /dev/null +++ b/core/testdata/links/linkToExternalSite.kt @@ -0,0 +1,4 @@ +/** + * This is link to [http://example.com/#example] + */ +class Foo {} \ No newline at end of file -- cgit