aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src
diff options
context:
space:
mode:
authorBłażej Kardyś <bkardys@virtuslab.com>2020-03-11 15:23:41 +0100
committerBłażej Kardyś <bkardys@virtuslab.com>2020-03-11 16:19:43 +0100
commitf48bffb05efcfd03cf72189ab13472c196f2a948 (patch)
tree79e10d919cf8485b37bff9c5ce4a753577e043c0 /plugins/base/src
parent356be7009f857032f87bf0e5943cdef7f1438f65 (diff)
downloaddokka-f48bffb05efcfd03cf72189ab13472c196f2a948.tar.gz
dokka-f48bffb05efcfd03cf72189ab13472c196f2a948.tar.bz2
dokka-f48bffb05efcfd03cf72189ab13472c196f2a948.zip
Fixing signatures font, incorrect links and line breaking
Diffstat (limited to 'plugins/base/src')
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt14
-rw-r--r--plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt11
-rw-r--r--plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt1
-rw-r--r--plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt2
-rw-r--r--plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt4
5 files changed, 21 insertions, 11 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
index 2af547b8..a2a31340 100644
--- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
@@ -27,11 +27,15 @@ open class HtmlRenderer(
node: ContentGroup,
pageContext: ContentPage,
childrenCallback: FlowContent.() -> Unit
- ) = when {
- node.dci.kind == ContentKind.BriefComment -> div("brief") { childrenCallback() }
- node.style.contains(TextStyle.Paragraph) -> p { childrenCallback() }
- node.style.contains(TextStyle.Block) -> div { childrenCallback() }
- else -> childrenCallback()
+ ) {
+ val additionalClasses = node.style.joinToString { it.toString().toLowerCase() }
+ return when {
+ node.dci.kind == ContentKind.BriefComment -> div("brief $additionalClasses") { childrenCallback() }
+ node.style.contains(TextStyle.Paragraph) -> p(additionalClasses) { childrenCallback() }
+ node.style.contains(TextStyle.Block) -> div(additionalClasses) { childrenCallback() }
+ additionalClasses.isNotBlank() -> span(additionalClasses) { childrenCallback() }
+ else -> childrenCallback()
+ }
}
override fun FlowContent.buildPlatformDependent(content: PlatformHintedContent, pageContext: ContentPage) {
diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
index c8a5105d..b468c56b 100644
--- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
+++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
@@ -10,6 +10,7 @@ import org.jetbrains.dokka.model.Function
import org.jetbrains.dokka.pages.ContentKind
import org.jetbrains.dokka.pages.ContentNode
import org.jetbrains.dokka.pages.PlatformData
+import org.jetbrains.dokka.pages.TextStyle
import org.jetbrains.dokka.utilities.DokkaLogger
class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogger) : SignatureProvider {
@@ -26,7 +27,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
)
}
- private fun signature(c: Classlike) = contentBuilder.contentFor(c, ContentKind.Symbol) {
+ private fun signature(c: Classlike) = contentBuilder.contentFor(c, ContentKind.Symbol, setOf(TextStyle.Monospace)) {
platformText(c.visibility) { (it.takeIf { it !in ignoredVisibilities }?.name ?: "") + " " }
if (c is Class) {
text(c.modifier.name + " ")
@@ -38,7 +39,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
is Object -> text("object ")
is Annotation -> text("annotation class ")
}
- text(c.name!!)
+ link(c.name!!, c.dri)
if (c is WithSupertypes) {
c.supertypes.map { (p, dris) ->
list(dris, prefix = " : ", platformData = setOf(p)) {
@@ -48,7 +49,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
}
}
- private fun signature(f: Function) = contentBuilder.contentFor(f, ContentKind.Symbol) {
+ private fun signature(f: Function) = contentBuilder.contentFor(f, ContentKind.Symbol, setOf(TextStyle.Monospace)) {
platformText(f.visibility) { (it.takeIf { it !in ignoredVisibilities }?.name ?: "") + " " }
text(f.modifier.name + " ")
text("fun ")
@@ -62,7 +63,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
}
text("(")
list(f.parameters) {
- link(it.name!!, it.dri)
+ text(it.name!!)
text(": ")
type(it.type)
}
@@ -74,7 +75,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
}
}
- private fun signature(t: TypeParameter) = contentBuilder.contentFor(t, ContentKind.Symbol) {
+ private fun signature(t: TypeParameter) = contentBuilder.contentFor(t, ContentKind.Symbol, setOf(TextStyle.Monospace)) {
link(t.name, t.dri)
list(t.bounds, prefix = " : ") {
signatureForProjection(it)
diff --git a/plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt b/plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt
index 5332b0f8..885fbfee 100644
--- a/plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt
+++ b/plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt
@@ -42,7 +42,6 @@ object DocTagToContentConverter : CommentsToContentConverter {
)
fun buildNewLine() = listOf(ContentBreakLine(
- dci,
platforms
))
diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
index b92c058a..9bc06ae8 100644
--- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
+++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
@@ -61,6 +61,7 @@ open class DefaultPageCreator(
link(it.name.orEmpty(), it.dri)
group {
+buildSignature(it)
+ breakLine()
group(kind = ContentKind.BriefComment) {
text(it.briefDocumentation())
}
@@ -70,6 +71,7 @@ open class DefaultPageCreator(
link(it.name, it.dri)
group {
+buildSignature(it)
+ breakLine()
group(kind = ContentKind.BriefComment) {
text(it.briefDocumentation())
}
diff --git a/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt b/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt
index b9e20919..f5880656 100644
--- a/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt
+++ b/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt
@@ -229,6 +229,10 @@ 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,