aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin/transformers
diff options
context:
space:
mode:
authorAndrzej Ratajczak <andrzej.ratajczak98@gmail.com>2020-05-05 15:07:55 +0200
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-05-13 10:03:48 +0200
commitabc0d2791a47635e4ce909041e7705de4121bb05 (patch)
tree6f8c90b15d54b6fa9a00a7bc334b2c70e5e8896d /plugins/base/src/main/kotlin/transformers
parentbbfb105c1e697eb792301b9fa9d9823344734aeb (diff)
downloaddokka-abc0d2791a47635e4ce909041e7705de4121bb05.tar.gz
dokka-abc0d2791a47635e4ce909041e7705de4121bb05.tar.bz2
dokka-abc0d2791a47635e4ce909041e7705de4121bb05.zip
Introduce requested changes
Diffstat (limited to 'plugins/base/src/main/kotlin/transformers')
-rw-r--r--plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt45
1 files changed, 22 insertions, 23 deletions
diff --git a/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt b/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt
index 58e52c43..fa73e757 100644
--- a/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt
+++ b/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt
@@ -17,13 +17,12 @@ import org.jetbrains.kotlin.utils.addToStdlib.cast
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
class SourceLinksTransformer(val context: DokkaContext, val builder: PageContentBuilder) : PageTransformer {
- private val sourceLinks = getSourceLinks()
override fun invoke(input: RootPageNode) =
input.transformContentPagesTree { node ->
- when(val documentable = node.documentable){
+ when (val documentable = node.documentable) {
is WithExpectActual -> resolveSources(documentable)
- .takeIf{ it.isNotEmpty() }
+ .takeIf { it.isNotEmpty() }
?.let { node.addSourcesContent(it) }
?: node
else -> node
@@ -33,9 +32,9 @@ class SourceLinksTransformer(val context: DokkaContext, val builder: PageContent
private fun getSourceLinks() = context.configuration.passesConfigurations
.flatMap { it.sourceLinks.map { sl -> SourceLink(sl, it.platformData) } }
- private fun resolveSources(documentable: WithExpectActual) = documentable.sources.map.entries
+ private fun resolveSources(documentable: WithExpectActual) = documentable.sources
.mapNotNull { entry ->
- sourceLinks.find { entry.value.path.contains(it.path) && it.platformData == entry.key }?.let {
+ getSourceLinks().find { entry.value.path.contains(it.path) && it.platformData == entry.key }?.let {
Pair(
entry.key,
entry.value.toLink(it)
@@ -53,27 +52,27 @@ class SourceLinksTransformer(val context: DokkaContext, val builder: PageContent
private fun PageContentBuilder.buildSourcesContent(
node: ContentPage,
- sources: List<Pair<PlatformData,String>>
+ sources: List<Pair<PlatformData, String>>
) = contentFor(
- node.dri.first(),
- node.documentable!!.platformData.toSet()
- ) {
- header(2) { text("Sources") }
- +ContentTable(
- emptyList(),
- sources.map {
- buildGroup(node.dri.first(), setOf(it.first)) {
- +link("(source)", it.second)
- }
- },
- DCI(node.dri, ContentKind.Source),
- node.documentable!!.platformData.toSet(),
- style = emptySet()
- )
- }
+ node.dri.first(),
+ node.documentable!!.platformData.toSet()
+ ) {
+ header(2) { text("Sources") }
+ +ContentTable(
+ emptyList(),
+ sources.map {
+ buildGroup(node.dri.first(), setOf(it.first)) {
+ +link("(source)", it.second)
+ }
+ },
+ DCI(node.dri, ContentKind.Source),
+ node.documentable!!.platformData.toSet(),
+ style = emptySet()
+ )
+ }
private fun DocumentableSource.toLink(sourceLink: SourceLink): String {
- val lineNumber = when(this){
+ val lineNumber = when (this) {
is DescriptorDocumentableSource -> this.descriptor
.cast<DeclarationDescriptorWithSource>()
.source.getPsi()