diff options
author | Andrzej Ratajczak <andrzej.ratajczak98@gmail.com> | 2020-05-18 13:57:41 +0200 |
---|---|---|
committer | Paweł Marks <Kordyjan@users.noreply.github.com> | 2020-05-19 09:56:32 +0200 |
commit | 9a77287304af906d3d8f14bf6852bf3bc3b759d6 (patch) | |
tree | 89f11ced3d8f8148e9b37a298177405174228a32 | |
parent | 65e69a8d204f873a4034810436649c3f02de3ad0 (diff) | |
download | dokka-9a77287304af906d3d8f14bf6852bf3bc3b759d6.tar.gz dokka-9a77287304af906d3d8f14bf6852bf3bc3b759d6.tar.bz2 dokka-9a77287304af906d3d8f14bf6852bf3bc3b759d6.zip |
Samples fix
-rw-r--r-- | plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt | 28 | ||||
-rw-r--r-- | plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt | 2 |
2 files changed, 15 insertions, 15 deletions
diff --git a/plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt b/plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt index 9b04af40..57655a9d 100644 --- a/plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt @@ -20,7 +20,6 @@ import org.jetbrains.kotlin.utils.PathUtil import org.jetbrains.kotlin.idea.kdoc.resolveKDocSampleLink import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils -import org.jetbrains.kotlin.utils.addToStdlib.safeAs import java.io.File abstract class SamplesTransformer(val context: DokkaContext) : PageTransformer { @@ -67,22 +66,25 @@ abstract class SamplesTransformer(val context: DokkaContext) : PageTransformer { val body = processBody(psiElement) val node = contentCode(contentPage.platforms(), contentPage.dri, body, "kotlin") - return bfs(fqName, node) + return dfs(fqName, node) } - private fun ContentNode.bfs(fqName: String, node: ContentCode): ContentNode { + private fun ContentNode.dfs(fqName: String, node: ContentCode): ContentNode { return when(this) { - is ContentHeader -> copy(children.map { it.bfs(fqName, node) }) - is ContentCode -> copy(children.map { it.bfs(fqName, node) }) - is ContentDRILink -> copy(children.map { it.bfs(fqName, node) }) - is ContentResolvedLink -> copy(children.map { it.bfs(fqName, node) }) - is ContentEmbeddedResource -> copy(children.map { it.bfs(fqName, node) }) - is ContentTable -> copy(children = children.map { it.bfs(fqName, node) as ContentGroup }) - is ContentList -> copy(children.map { it.bfs(fqName, node) }) - is ContentGroup -> copy(children.map { it.bfs(fqName, node) }) - is PlatformHintedContent -> copy(inner.bfs(fqName, node)) + is ContentHeader -> copy(children.map { it.dfs(fqName, node) }) + is ContentDivergentGroup -> copy(children.map { it.dfs(fqName, node) } as List<ContentDivergentInstance>) + is ContentDivergentInstance -> copy(before.let { it?.dfs(fqName, node) }, divergent.let { it.dfs(fqName, node) }, after.let { it?.dfs(fqName, node) }) + is ContentCode -> copy(children.map { it.dfs(fqName, node) }) + is ContentDRILink -> copy(children.map { it.dfs(fqName, node) }) + is ContentResolvedLink -> copy(children.map { it.dfs(fqName, node) }) + is ContentEmbeddedResource -> copy(children.map { it.dfs(fqName, node) }) + is ContentTable -> copy(children = children.map { it.dfs(fqName, node) as ContentGroup }) + is ContentList -> copy(children.map { it.dfs(fqName, node) }) + is ContentGroup -> copy(children.map { it.dfs(fqName, node) }) + is PlatformHintedContent -> copy(inner.dfs(fqName, node)) is ContentText -> if (text == fqName) node else this - else -> this + is ContentBreakLine -> this + else -> this.also { context.logger.error("Could not recognize $this ContentNode in SamplesTransformer") } } } diff --git a/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt b/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt index 8f60eecb..e7883bc1 100644 --- a/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt +++ b/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt @@ -123,8 +123,6 @@ class LinkableContentTest : AbstractCoreTest() { } } - // TODO: enable after fixing SampleTransformer - @Disabled @Test fun `Samples multiplatform documentation`() { |