aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin
diff options
context:
space:
mode:
authorMarcin Aman <maman@virtuslab.com>2020-05-13 16:20:44 +0200
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-05-14 11:33:06 +0200
commita440f0cb8756019131a2c15389e747aea3c585e7 (patch)
tree1c2e2b25464d540b8ce68fe8f14cd105c5268b27 /plugins/base/src/main/kotlin
parentd6bfd213a2f363f0581bdc85a68e11c170c93071 (diff)
downloaddokka-a440f0cb8756019131a2c15389e747aea3c585e7.tar.gz
dokka-a440f0cb8756019131a2c15389e747aea3c585e7.tar.bz2
dokka-a440f0cb8756019131a2c15389e747aea3c585e7.zip
Platform dependant comments
Diffstat (limited to 'plugins/base/src/main/kotlin')
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt26
-rw-r--r--plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt4
-rw-r--r--plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt69
3 files changed, 53 insertions, 46 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
index 4f0c1e55..c061cabf 100644
--- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
@@ -128,22 +128,32 @@ open class HtmlRenderer(
?.let {
div(classes = "table-row") {
it.filter { it.dci.kind != ContentKind.Symbol }.takeIf { it.isNotEmpty() }?.let {
- div("main-subrow") {
+ div("main-subrow ${node.style.joinToString { it.toString().decapitalize() }}") {
it.filter { platformRestriction == null || platformRestriction in it.platforms }
.forEach {
when(it.dci.kind){
- ContentKind.Main -> div("title") {
- it.build(this, pageContext, platformRestriction)
+ ContentKind.PlatformDependantHint -> {
+ div("platform-dependant-row keyValue"){
+ div()
+ div("title"){
+ it.build(this, pageContext, platformRestriction)
+ }
+ }
}
- ContentKind.BriefComment, ContentKind.Comment -> div("brief") {
- it.build(this, pageContext, platformRestriction)
+ ContentKind.Main -> {
+ div("title-row"){
+ it.build(this, pageContext, platformRestriction)
+ div()
+ if (ContentKind.shouldBePlatformTagged(node.dci.kind) && node.platforms.size == 1) {
+ createPlatformTags(node)
+ } else {
+ div()
+ }
+ }
}
else -> div { it.build(this, pageContext, platformRestriction) }
}
}
- if (ContentKind.shouldBePlatformTagged(node.dci.kind) && node.platforms.size == 1) {
- createPlatformTags(node)
- }
}
}
it.filter { it.dci.kind == ContentKind.Symbol }.takeIf { it.isNotEmpty() }?.let {
diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
index 30ec38bb..313973bf 100644
--- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
+++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
@@ -31,7 +31,9 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
)
}
- private fun signature(e: DEnumEntry) = contentBuilder.contentFor(e, ContentKind.Symbol, setOf(TextStyle.Monospace))
+ private fun signature(e: DEnumEntry) = contentBuilder.contentFor(e, ContentKind.Symbol, setOf(TextStyle.Monospace)){
+ link(e.name, e.dri)
+ }
private fun actualTypealiasedSignature(dri: DRI, name: String, aliasedTypes: PlatformDependent<Bound>) =
aliasedTypes.entries.groupBy({ it.value }, { it.key }).map { (bound, platforms) ->
diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
index 9c7abdd9..439da560 100644
--- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
+++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
@@ -83,11 +83,9 @@ open class DefaultPageCreator(
+contentForScope(p, p.dri, p.platformData)
block("Type aliases", 2, ContentKind.TypeAliases, p.typealiases, p.platformData.toSet()) {
link(it.name, it.dri, kind = ContentKind.Main)
- platformDependentHint(it.dri, it.platformData.toSet(), kind = ContentKind.Symbol) {
+ platformDependentHint(it.dri, it.platformData.toSet(), kind = ContentKind.PlatformDependantHint) {
+buildSignature(it)
- }
- group(kind = ContentKind.BriefComment) {
- text(it.briefDocumentation())
+ contentForBrief(it)
}
}
}
@@ -99,29 +97,24 @@ open class DefaultPageCreator(
) = contentBuilder.contentFor(s as Documentable) {
block("Types", 2, ContentKind.Classlikes, s.classlikes, platformData.toSet()) {
link(it.name ?: "", it.dri, kind = ContentKind.Main)
- platformDependentHint(it.dri, it.platformData.toSet(), kind = ContentKind.Symbol) {
+ platformDependentHint(it.dri, it.platformData.toSet(), kind = ContentKind.PlatformDependantHint) {
+buildSignature(it)
- }
- group(kind = ContentKind.BriefComment) {
- text(it.briefDocumentation())
+ contentForBrief(it)
}
}
block("Functions", 2, ContentKind.Functions, s.functions, platformData.toSet()) {
link(it.name, it.dri, kind = ContentKind.Main)
- platformDependentHint(it.dri, it.platformData.toSet(), kind = ContentKind.Symbol) {
+ platformDependentHint(it.dri, it.platformData.toSet(), kind = ContentKind.PlatformDependantHint) {
+buildSignature(it)
- }
- group(kind = ContentKind.BriefComment) {
- text(it.briefDocumentation())
+ contentForBrief(it)
}
}
block("Properties", 2, ContentKind.Properties, s.properties, platformData.toSet()) {
link(it.name, it.dri, kind = ContentKind.Main)
- platformDependentHint(it.dri, it.platformData.toSet(), kind = ContentKind.Symbol) {
+ platformDependentHint(it.dri, it.platformData.toSet(), kind = ContentKind.PlatformDependantHint) {
+buildSignature(it)
- }
- group(kind = ContentKind.BriefComment) {
- text(it.briefDocumentation())
+
+ contentForBrief(it)
}
}
s.safeAs<WithExtraProperties<Documentable>>()?.let { it.extra[InheritorsInfo] }?.let { inheritors ->
@@ -174,19 +167,18 @@ open class DefaultPageCreator(
c.platformData.toSet()
) {
link(it.name, it.dri, kind = ContentKind.Main)
- platformDependentHint(it.dri, it.platformData.toSet(), kind = ContentKind.Symbol) {
+ platformDependentHint(it.dri, it.platformData.toSet(), kind = ContentKind.PlatformDependantHint) {
+buildSignature(it)
- }
- group(kind = ContentKind.BriefComment) {
- text(it.briefDocumentation())
+ contentForBrief(it)
}
}
}
if (c is DEnum) {
block("Entries", 2, ContentKind.Classlikes, c.entries, c.platformData.toSet()) {
link(it.name, it.dri, kind = ContentKind.Main)
- group(kind = ContentKind.BriefComment) {
- text(it.briefDocumentation())
+ platformDependentHint(it.dri, it.platformData.toSet(), kind = ContentKind.PlatformDependantHint) {
+ +buildSignature(it)
+ contentForBrief(it)
}
}
}
@@ -241,7 +233,7 @@ open class DefaultPageCreator(
table(kind = ContentKind.Parameters) {
platforms.flatMap { platform ->
val receiverRow = receiver.getOrExpect(platform)?.let {
- buildGroup(platformData = setOf(platform)) {
+ buildGroup(platformData = setOf(platform), kind = ContentKind.Parameters, styles = mainStyles + ContentStyle.KeyValue) {
text("<receiver>")
comment(it.root)
}
@@ -249,8 +241,8 @@ open class DefaultPageCreator(
val paramRows = params.mapNotNull { (_, param) ->
param.getOrExpect(platform)?.let {
- buildGroup(platformData = setOf(platform)) {
- text(it.name)
+ buildGroup(platformData = setOf(platform), kind = ContentKind.Parameters, styles = mainStyles + ContentStyle.KeyValue) {
+ text(it.name, kind = ContentKind.Parameters)
comment(it.root)
}
}
@@ -272,9 +264,9 @@ open class DefaultPageCreator(
platforms.flatMap { platform ->
seeAlsoTags.mapNotNull { (_, see) ->
see.getOrExpect(platform)?.let {
- buildGroup(platformData = setOf(platform)) {
- if (it.address != null) link(it.name, it.address!!)
- else text(it.name)
+ buildGroup(platformData = setOf(platform), kind = ContentKind.Comment, styles = mainStyles + ContentStyle.KeyValue) {
+ if (it.address != null) link(it.name, it.address!!, kind = ContentKind.Comment)
+ else text(it.name, kind = ContentKind.Comment)
comment(it.root)
}
}
@@ -331,6 +323,18 @@ open class DefaultPageCreator(
}.children
}
+ protected open fun DocumentableContentBuilder.contentForBrief(content: Documentable) {
+ content.platformData.forEach { platform ->
+ val root = content.documentation[platform]?.children?.firstOrNull()?.root
+
+ root?.let {
+ group(platformData = setOf(platform), kind = ContentKind.BriefComment) {
+ text(it.docTagSummary(), kind = ContentKind.Comment)
+ }
+ }
+ }
+ }
+
protected open fun contentForFunction(f: DFunction) = contentBuilder.contentFor(f) {
group(kind = ContentKind.Cover) {
header(1) { text(f.name) }
@@ -350,13 +354,4 @@ open class DefaultPageCreator(
}
protected open fun TagWrapper.toHeaderString() = this.javaClass.toGenericString().split('.').last()
-
- //TODO: It isn't platform-aware and produces wrong docs Probably should use platformDependentHint
- protected open fun Documentable.briefDocumentation() = " "
-// documentation.values
-// .firstOrNull()
-// ?.children
-// ?.firstOrNull()
-// ?.root
-// ?.docTagSummary() ?: ""
}