diff options
author | Andrzej Ratajczak <andrzej.ratajczak98@gmail.com> | 2020-07-02 11:33:52 +0200 |
---|---|---|
committer | Paweł Marks <Kordyjan@users.noreply.github.com> | 2020-07-08 11:48:29 +0200 |
commit | f80d5938ccafcf5bd41d73f98bebe2d9699faa95 (patch) | |
tree | 8d0df46b4f806bdcc092c2f38af5face44e026bb /plugins/base/src/main/kotlin | |
parent | 5647b4221604a9084194949d9c582a57da920220 (diff) | |
download | dokka-f80d5938ccafcf5bd41d73f98bebe2d9699faa95.tar.gz dokka-f80d5938ccafcf5bd41d73f98bebe2d9699faa95.tar.bz2 dokka-f80d5938ccafcf5bd41d73f98bebe2d9699faa95.zip |
Add GFM renderer tests
Diffstat (limited to 'plugins/base/src/main/kotlin')
-rw-r--r-- | plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt | 19 | ||||
-rw-r--r-- | plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt | 33 |
2 files changed, 32 insertions, 20 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt b/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt index f2fce191..57a3d8d1 100644 --- a/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt @@ -170,6 +170,23 @@ abstract class DefaultRenderer<T>( renderPages(newRoot) } } + + protected fun ContentDivergentGroup.groupDivergentInstances( + pageContext: ContentPage, + beforeTransformer: (ContentDivergentInstance, ContentPage, DokkaSourceSet) -> String, + afterTransformer: (ContentDivergentInstance, ContentPage, DokkaSourceSet) -> String + ): Map<Pair<String, String>, List<Pair<ContentDivergentInstance, DokkaSourceSet>>> = + children.flatMap { instance -> + instance.sourceSets.map { sourceSet -> + Pair(instance, sourceSet) to Pair( + beforeTransformer(instance, pageContext, sourceSet), + afterTransformer(instance, pageContext, sourceSet) + ) + } + }.groupBy( + Pair<Pair<ContentDivergentInstance, DokkaSourceSet>, Pair<String, String>>::second, + Pair<Pair<ContentDivergentInstance, DokkaSourceSet>, Pair<String, String>>::first + ) } -fun ContentPage.sourceSets() = this.content.sourceSets +fun ContentPage.sourceSets() = this.content.sourceSets
\ No newline at end of file diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt index a950667f..595dc8d2 100644 --- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt @@ -222,26 +222,21 @@ open class HtmlRenderer( } override fun FlowContent.buildDivergent(node: ContentDivergentGroup, pageContext: ContentPage) { + val distinct = - node.children.flatMap { instance -> - instance.sourceSets.map { sourceSet -> - Pair(instance, sourceSet) to Pair( - createHTML(prettyPrint = false).div { - instance.before?.let { before -> - buildContentNode(before, pageContext, setOf(sourceSet)) - } - }.stripDiv(), - createHTML(prettyPrint = false).div { - instance.after?.let { after -> - buildContentNode(after, pageContext, setOf(sourceSet)) - } - }.stripDiv() - ) - } - }.groupBy( - Pair<Pair<ContentDivergentInstance, DokkaSourceSet>, Pair<String, String>>::second, - Pair<Pair<ContentDivergentInstance, DokkaSourceSet>, Pair<String, String>>::first - ) + node.groupDivergentInstances(pageContext, { instance, contentPage, sourceSet -> + createHTML(prettyPrint = false).div { + instance.before?.let { before -> + buildContentNode(before, pageContext, setOf(sourceSet)) + } + }.stripDiv() + }, { instance, contentPage, sourceSet -> + createHTML(prettyPrint = false).div { + instance.after?.let { after -> + buildContentNode(after, pageContext, setOf(sourceSet)) + } + }.stripDiv() + }) distinct.forEach { val groupedDivergent = it.value.groupBy { it.second } |