aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/base/src')
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt26
-rw-r--r--plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt11
-rw-r--r--plugins/base/src/main/kotlin/transformers/documentables/InheritorsExtractorTransformer.kt2
-rw-r--r--plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt62
-rw-r--r--plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt22
5 files changed, 67 insertions, 56 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
index 1365fecb..e1025ed4 100644
--- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
@@ -29,9 +29,13 @@ open class HtmlRenderer(
) {
val additionalClasses = node.style.joinToString(" ") { it.toString().toLowerCase() }
return when {
- ContentKind.shouldBePlatformTagged(node.dci.kind) -> wrapPlatformTagged(node, pageContext) { childrenCallback() }
+ ContentKind.shouldBePlatformTagged(node.dci.kind) -> wrapPlatformTagged(
+ node,
+ pageContext
+ ) { childrenCallback() }
node.dci.kind == ContentKind.Symbol -> div("symbol $additionalClasses") { childrenCallback() }
node.dci.kind == ContentKind.BriefComment -> div("brief $additionalClasses") { childrenCallback() }
+ node.dci.kind == ContentKind.Cover -> div("cover $additionalClasses") { childrenCallback() }
node.style.contains(TextStyle.Paragraph) -> p(additionalClasses) { childrenCallback() }
node.style.contains(TextStyle.Block) -> div(additionalClasses) { childrenCallback() }
else -> childrenCallback()
@@ -43,13 +47,13 @@ open class HtmlRenderer(
pageContext: ContentPage,
childrenCallback: FlowContent.() -> Unit
) {
- div("platform-tagged"){
+ div("platform-tagged") {
node.platforms.forEach {
- div("platform-tag ${it.platformType.name}"){
+ div("platform-tag ${it.platformType.name}") {
text(it.platformType.key.toUpperCase())
}
}
- div("content"){
+ div("content") {
childrenCallback()
}
}
@@ -176,7 +180,7 @@ open class HtmlRenderer(
}
}
tbody {
- if(ContentKind.shouldBePlatformTagged(node.dci.kind)) {
+ if (ContentKind.shouldBePlatformTagged(node.dci.kind)) {
buildPlatformTaggedRow(node, pageContext, platformRestriction)
} else {
buildRow(node, pageContext, platformRestriction)
@@ -198,10 +202,12 @@ open class HtmlRenderer(
}
override fun FlowContent.buildNavigation(page: PageNode) =
- locationProvider.ancestors(page).asReversed().forEach { node ->
- text("/")
- if (node.isNavigable) buildLink(node, page)
- else text(node.name)
+ div(classes = "breadcrumbs") {
+ locationProvider.ancestors(page).asReversed().forEach { node ->
+ text("/")
+ if (node.isNavigable) buildLink(node, page)
+ else text(node.name)
+ }
}
private fun FlowContent.buildLink(to: PageNode, from: PageNode) =
@@ -257,7 +263,7 @@ open class HtmlRenderer(
}
override fun FlowContent.buildText(textNode: ContentText) {
- when{
+ when {
textNode.style.contains(TextStyle.Indented) -> consumer.onTagContentEntity(Entities.nbsp)
}
text(textNode.text)
diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
index ef557eaf..7b35c455 100644
--- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
+++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
@@ -55,9 +55,9 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
private fun regularSignature(c: DClasslike, platformData: Set<PlatformData> = c.platformData.toSet()) =
contentBuilder.contentFor(c, ContentKind.Symbol, setOf(TextStyle.Monospace), platformData = platformData) {
- platformText(c.visibility) { (it.takeIf { it !in ignoredVisibilities }?.name ?: "") + " " }
+ platformText(c.visibility, platformData) { (it.takeIf { it !in ignoredVisibilities }?.name ?: "") + " " }
if (c is DClass) {
- platformText(c.modifier) {
+ platformText(c.modifier, platformData) {
if (c.extra[AdditionalModifiers]?.content?.contains(ExtraModifiers.DATA) == true && it.name == "final") "data "
else it.name + " "
}
@@ -71,16 +71,15 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
}
link(c.name!!, c.dri)
if (c is DClass) {
- val pConstructor = c.constructors.singleOrNull() { it.extra[PrimaryConstructorExtra] != null }
+ val pConstructor = c.constructors.singleOrNull { it.extra[PrimaryConstructorExtra] != null }
list(pConstructor?.parameters.orEmpty(), "(", ")", ",", pConstructor?.platformData.orEmpty().toSet()) {
- breakLine()
text(it.name ?: "", styles = mainStyles.plus(TextStyle.Bold).plus(TextStyle.Indented))
text(": ")
signatureForProjection(it.type)
}
}
if (c is WithSupertypes) {
- c.supertypes.map { (p, dris) ->
+ c.supertypes.filter { it.key in platformData }.map { (p, dris) ->
list(dris, prefix = " : ", platformData = setOf(p)) {
link(it.sureClassNames, it, platformData = setOf(p))
}
@@ -128,7 +127,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
}
private fun signature(t: DTypeAlias) =
- contentBuilder.contentFor(t, ContentKind.Symbol, setOf(TextStyle.Monospace)) {
+ contentBuilder.contentFor(t) {
t.underlyingType.entries.groupBy({ it.value }, { it.key }).map { (type, platforms) ->
+contentBuilder.contentFor(
t,
diff --git a/plugins/base/src/main/kotlin/transformers/documentables/InheritorsExtractorTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/InheritorsExtractorTransformer.kt
index e372ad9c..8c014a29 100644
--- a/plugins/base/src/main/kotlin/transformers/documentables/InheritorsExtractorTransformer.kt
+++ b/plugins/base/src/main/kotlin/transformers/documentables/InheritorsExtractorTransformer.kt
@@ -42,7 +42,7 @@ class InheritorsExtractorTransformer : DocumentableTransformer {
.map { (k, v) ->
k to v.flatMap { p -> p.groupBy({ it.first }) { it.second }.toList() }
.groupBy({ it.first }) { it.second }.map { (k2, v2) -> k2 to v2.flatten() }.toMap()
- }.toMap()
+ }.filter{ it.second.values.isEmpty() }.toMap()
private fun <T : Documentable> T.getInheritanceEntriesRec(): List<Pair<PlatformData, List<Pair<DRI, DRI>>>> =
this.toInheritanceEntries() + children.flatMap { it.getInheritanceEntriesRec() }
diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
index 312c7a5a..e1bce565 100644
--- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
+++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
@@ -1,13 +1,11 @@
package org.jetbrains.dokka.base.translators.documentables
import org.jetbrains.dokka.base.signatures.SignatureProvider
-import org.jetbrains.dokka.base.transformers.documentables.InheritorsInfo
import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentConverter
import org.jetbrains.dokka.base.translators.documentables.PageContentBuilder.DocumentableContentBuilder
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.model.*
import org.jetbrains.dokka.model.doc.*
-import org.jetbrains.dokka.model.properties.WithExtraProperties
import org.jetbrains.dokka.pages.*
import org.jetbrains.dokka.utilities.DokkaLogger
import kotlin.reflect.KClass
@@ -38,7 +36,7 @@ open class DefaultPageCreator(
open fun pageForEnumEntry(e: DEnumEntry): ClasslikePageNode =
ClasslikePageNode(
- e.name.orEmpty(), contentForEnumEntry(e), setOf(e.dri), e,
+ e.name, contentForEnumEntry(e), setOf(e.dri), e,
e.classlikes.map(::pageForClasslike) +
e.filteredFunctions.map(::pageForFunction)
)
@@ -63,7 +61,9 @@ open class DefaultPageCreator(
get() = functions.filter { it.extra[InheritedFunction]?.isInherited != true }
protected open fun contentForModule(m: DModule) = contentBuilder.contentFor(m) {
- header(1) { text(m.name) }
+ group(kind = ContentKind.Cover) {
+ header(1) { text(m.name) }
+ }
+contentForComments(m)
block("Packages", 2, ContentKind.Packages, m.packages, m.platformData.toSet()) {
link(it.name, it.dri)
@@ -73,7 +73,7 @@ open class DefaultPageCreator(
}
protected open fun contentForPackage(p: DPackage) = contentBuilder.contentFor(p) {
- group(p.dri, p.platformData.toSet(), ContentKind.Packages) {
+ group(kind = ContentKind.Cover) {
header(1) { text("Package ${p.name}") }
}
+contentForComments(p)
@@ -124,40 +124,49 @@ open class DefaultPageCreator(
platformDependentHint(it.dri, it.platformData.toSet()) {
+buildSignature(it)
}
- breakLine()
group(kind = ContentKind.BriefComment) {
text(it.briefDocumentation())
}
}
}
- (s as? WithExtraProperties<Documentable>)?.let { it.extra[InheritorsInfo] }?.let { inheritors ->
- val map = inheritors.value.map
- text("Subclasses:")
- platformDependentHint(dri = s.dri, platformData = map.keys) {
- map.keys.forEach { pd ->
- linkTable(map[pd].orEmpty(), ContentKind.Classlikes, setOf(pd))
- }
- }
- }
+ // TODO: Fix this after fixing InheritorsExtractorTransformer
+// (s as? WithExtraProperties<Documentable>)?.let { it.extra[InheritorsInfo] }?.let { inheritors ->
+// val map = inheritors.value.map
+// if (map.values.any()) {
+// header(2) { text("Subtypes") }
+// +ContentTable(
+// emptyList(),
+// map.entries.groupBy({ it.value }, { it.key }).map { (types, platforms) ->
+// buildGroup(dri, platforms.toSet(), ContentKind.Subtypes) {
+// types.map {
+// link(it.toString(), it)
+// }
+// }
+// },
+// DCI(setOf(dri), ContentKind.Subtypes),
+// platformData.toSet(),
+// style = emptySet()
+// )
+// }
+// }
}
protected open fun contentForEnumEntry(e: DEnumEntry) = contentBuilder.contentFor(e) {
- header(1) { text(e.name.orEmpty()) }
- +buildSignature(e)
-
+ group(kind = ContentKind.Cover) {
+ header(1) { text(e.name) }
+ +buildSignature(e)
+ }
+contentForComments(e)
-
+contentForScope(e, e.dri, e.platformData)
}
protected open fun contentForClasslike(c: DClasslike) = contentBuilder.contentFor(c) {
- group(c.dri, c.platformData.toSet(), ContentKind.Classlikes) {
+ group(kind = ContentKind.Cover) {
header(1) { text(c.name.orEmpty()) }
platformDependentHint(c.dri, c.platformData.toSet()) {
+buildSignature(c)
}
}
- breakLine()
+contentForComments(c)
if (c is WithConstructors) {
@@ -224,7 +233,6 @@ open class DefaultPageCreator(
description.getOrExpect(platform)?.also {
group(platformData = setOf(platform)) {
comment(it.root)
- breakLine()
}
}
}
@@ -263,7 +271,7 @@ open class DefaultPageCreator(
fun DocumentableContentBuilder.contentForSeeAlso() {
val seeAlsoTags = tags.withTypeNamed<See>()
- if(seeAlsoTags.isNotEmpty()) {
+ if (seeAlsoTags.isNotEmpty()) {
header(4, kind = ContentKind.Comment) { text("See also") }
table(kind = ContentKind.Comment) {
platforms.flatMap { platform ->
@@ -311,7 +319,7 @@ open class DefaultPageCreator(
}
protected open fun contentForFunction(f: DFunction) = contentBuilder.contentFor(f) {
- group(f.dri, f.platformData.toSet(), ContentKind.Functions) {
+ group(kind = ContentKind.Cover) {
header(1) { text(f.name) }
platformDependentHint(f.dri, f.platformData.toSet()) {
+buildSignature(f)
@@ -321,8 +329,10 @@ open class DefaultPageCreator(
}
protected open fun contentForTypeAlias(t: DTypeAlias) = contentBuilder.contentFor(t) {
- header(1) { text(t.name) }
- +buildSignature(t)
+ group(kind = ContentKind.Cover) {
+ header(1) { text(t.name) }
+ +buildSignature(t)
+ }
+contentForComments(t)
}
diff --git a/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt b/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt
index 74d0011f..d9a78d0d 100644
--- a/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt
+++ b/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt
@@ -39,7 +39,7 @@ open class PageContentBuilder(
): ContentGroup =
DocumentableContentBuilder(d.dri, platformData, styles, extra)
.apply(block)
- .build(d.platformData.toSet(), kind, styles, extra)
+ .build(platformData, kind, styles, extra)
@ContentBuilderMarker
open inner class DocumentableContentBuilder(
@@ -123,12 +123,12 @@ open class PageContentBuilder(
extra: PropertyContainer<ContentNode> = mainExtra,
operation: DocumentableContentBuilder.() -> List<ContentGroup>
) {
- contents += ContentTable(
- emptyList(),
- operation(),
- DCI(setOf(mainDRI), kind),
- platformData, styles, extra
- )
+ contents += ContentTable(
+ emptyList(),
+ operation(),
+ DCI(setOf(mainDRI), kind),
+ platformData, styles, extra
+ )
}
fun <T : Documentable> block(
@@ -148,7 +148,6 @@ open class PageContentBuilder(
emptyList(),
elements.map {
buildGroup(it.dri, it.platformData.toSet(), kind, styles, extra) {
- // TODO this will fail
operation(it)
}
},
@@ -244,10 +243,6 @@ open class PageContentBuilder(
block: DocumentableContentBuilder.() -> Unit
): ContentGroup = contentFor(dri, platformData, kind, styles, extra, block)
- fun breakLine(platformData: Set<PlatformData> = mainPlatformData) {
- contents += ContentBreakLine(platformData)
- }
-
fun platformDependentHint(
dri: DRI = mainDRI,
platformData: Set<PlatformData> = mainPlatformData,
@@ -273,8 +268,9 @@ open class PageContentBuilder(
fun <T> platformText(
value: PlatformDependent<T>,
+ platforms: Set<PlatformData> = value.keys,
transform: (T) -> String
- ) = value.entries.forEach { (p, v) ->
+ ) = value.entries.filter { it.key in platforms }.forEach { (p, v) ->
transform(v).takeIf { it.isNotBlank() }?.also { text(it, platformData = setOf(p)) }
}
}