diff options
Diffstat (limited to 'plugins/base/src/main/kotlin')
3 files changed, 27 insertions, 29 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() diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt index 00e3239c..128b9bd4 100644 --- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt @@ -500,14 +500,13 @@ private class DokkaDescriptorVisitor( .filter { it.kind == ClassKind.ENUM_ENTRY } .map { enumEntryDescriptor(it, parent) } - private fun DeclarationDescriptor.resolveDescriptorData(platformData: PlatformData?): PlatformDependent<DocumentationNode> { - val documentation = getDocumentation() - return if (documentation.children.isEmpty()) + private fun DeclarationDescriptor.resolveDescriptorData(platformData: PlatformData?): PlatformDependent<DocumentationNode> = getDocumentation().let { + if (it.children.isEmpty()) PlatformDependent.empty() else if (platformData != null) - PlatformDependent.from(platformData, documentation) + PlatformDependent.from(platformData, it) else - PlatformDependent.expectFrom(documentation) + PlatformDependent.expectFrom(it) } private fun ClassDescriptor.resolveClassDescriptionData(platformData: PlatformData?): ClassInfo { diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt index dd28b533..9c7abdd9 100644 --- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt +++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt @@ -268,7 +268,7 @@ open class DefaultPageCreator( platforms.forEach { header(4, kind = ContentKind.Comment, platformData = setOf(it)) { text("See also") } } - table(kind = ContentKind.Comment) { + table(kind = ContentKind.Sample) { platforms.flatMap { platform -> seeAlsoTags.mapNotNull { (_, see) -> see.getOrExpect(platform)?.let { |