Skip to content

Commit

Permalink
Handle multiple authors
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcinAman committed Oct 8, 2020
1 parent 58a76b4 commit a8df607
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -320,16 +320,18 @@ open class DefaultPageCreator(
}
}

val unnamedTags: List<SourceSetDependent<TagWrapper>> =
tags.filterNot { (k, _) -> k.isSubclassOf(NamedTagWrapper::class) || k in specialTags }
.map { (_, v) -> v.mapNotNull { (k, v) -> k?.let { it to v } }.toMap() }
val unnamedTags = tags.filterNot { (k, _) -> k.isSubclassOf(NamedTagWrapper::class) || k in specialTags }
.values.flatten().groupBy { it.first }.mapValues { it.value.map { it.second } }
if (unnamedTags.isNotEmpty()) {
platforms.forEach { platform ->
unnamedTags.forEach { pdTag ->
pdTag[platform]?.also { tag ->
group(sourceSets = setOf(platform), styles = emptySet()) {
header(4, tag.toHeaderString())
comment(tag.root)
unnamedTags[platform]?.let { tags ->
if(tags.isNotEmpty()){
tags.groupBy { it::class }.forEach {
(_, sameCategoryTags) ->
group(sourceSets = setOf(platform), styles = emptySet()) {
header(4, sameCategoryTags.first().toHeaderString())
sameCategoryTags.forEach { comment(it.root) }
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class ContentForParamsTest : AbstractCoreTest() {
|package test
| /**
| * @author Kordyjan
| * @author Woolfy
| * @since 0.11
| */
|fun function(abc: String) {
Expand Down Expand Up @@ -141,8 +142,15 @@ class ContentForParamsTest : AbstractCoreTest() {
)
}
after {
unnamedTag("Author") { group { +"Kordyjan" } }
unnamedTag("Since") { group { +"0.11" } }
unnamedTag("Author") {
comment {
+"Kordyjan"
}
comment {
+"Woolfy"
}
}
unnamedTag("Since") { comment { +"0.11" } }
}
}
}
Expand Down Expand Up @@ -189,8 +197,8 @@ class ContentForParamsTest : AbstractCoreTest() {
}
after {
group { pWrapped("comment to function") }
unnamedTag("Author") { group { +"Kordyjan" } }
unnamedTag("Since") { group { +"0.11" } }
unnamedTag("Author") { comment { +"Kordyjan" } }
unnamedTag("Since") { comment { +"0.11" } }
}
}
}
Expand Down Expand Up @@ -537,8 +545,8 @@ class ContentForParamsTest : AbstractCoreTest() {
}
after {
group { pWrapped("comment to function") }
unnamedTag("Author") { group { +"Kordyjan" } }
unnamedTag("Since") { group { +"0.11" } }
unnamedTag("Author") { comment { +"Kordyjan" } }
unnamedTag("Since") { comment { +"0.11" } }
header(2) { +"Parameters" }

group {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ import matchers.content.*
import org.jetbrains.dokka.pages.ContentPage
import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest
import org.junit.jupiter.api.Test
import utils.ParamAttributes
import utils.bareSignature
import utils.pWrapped
import utils.unnamedTag
import utils.*

class ContentForSeeAlsoTest : AbstractCoreTest() {
private val testConfiguration = dokkaConfiguration {
Expand Down Expand Up @@ -320,9 +317,9 @@ class ContentForSeeAlsoTest : AbstractCoreTest() {
)
}
after {
group { group { group { +"random comment"} } }
unnamedTag("Author") { group { +"pikinier20" } }
unnamedTag("Since") { group { +"0.11" } }
group { comment { +"random comment"} }
unnamedTag("Author") { comment { +"pikinier20" } }
unnamedTag("Since") { comment { +"0.11" } }

header(2) { +"See also" }
group {
Expand Down
9 changes: 8 additions & 1 deletion plugins/base/src/test/kotlin/utils/contentUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,14 @@ fun ContentMatcherBuilder<*>.pWrapped(text: String) =
fun ContentMatcherBuilder<*>.unnamedTag(tag: String, content: ContentMatcherBuilder<ContentGroup>.() -> Unit) =
group {
header(4) { +tag }
group { content() }
content()
}

fun ContentMatcherBuilder<*>.comment(content: ContentMatcherBuilder<ContentGroup>.() -> Unit) =
group {
group {
content()
}
}

fun ContentMatcherBuilder<*>.unwrapAnnotation(elem: Map.Entry<String, Set<String>>) {
Expand Down

0 comments on commit a8df607

Please sign in to comment.