diff options
author | Kamil Doległo <kamilok1965@interia.pl> | 2020-03-03 17:42:48 +0100 |
---|---|---|
committer | Paweł Marks <Kordyjan@users.noreply.github.com> | 2020-03-04 14:28:14 +0100 |
commit | 156396f7520b3ac45e37068d6b72087008322cbe (patch) | |
tree | 51253dde720aae57111760862038393e4cc06204 /plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt | |
parent | 973cc5238e2f7ede6d9cf54437785770a3e020c9 (diff) | |
download | dokka-156396f7520b3ac45e37068d6b72087008322cbe.tar.gz dokka-156396f7520b3ac45e37068d6b72087008322cbe.tar.bz2 dokka-156396f7520b3ac45e37068d6b72087008322cbe.zip |
Replace inline signature generation with KotlinSignatureProvider
Diffstat (limited to 'plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt')
-rw-r--r-- | plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt | 43 |
1 files changed, 17 insertions, 26 deletions
diff --git a/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt b/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt index 8d04e986..eb422920 100644 --- a/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt +++ b/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt @@ -1,9 +1,9 @@ package org.jetbrains.dokka.base.translators.documentables +import org.jetbrains.dokka.base.signatures.SignatureProvider import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentConverter import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.Documentable -import org.jetbrains.dokka.model.Function import org.jetbrains.dokka.model.TypeWrapper import org.jetbrains.dokka.model.doc.DocTag import org.jetbrains.dokka.pages.* @@ -14,6 +14,7 @@ annotation class ContentBuilderMarker open class PageContentBuilder( val commentsConverter: CommentsToContentConverter, + val signatureProvider: SignatureProvider, val logger: DokkaLogger ) { fun contentFor( @@ -61,6 +62,14 @@ open class PageContentBuilder( extras ) + operator fun ContentNode.unaryPlus() { + contents += this + } + + operator fun Collection<ContentNode>.unaryPlus() { + contents += this + } + fun header( level: Int, kind: Kind = ContentKind.Main, @@ -84,31 +93,13 @@ open class PageContentBuilder( contents += createText(text, kind, platformData, styles, extras) } - fun signature(f: Function, block: DocumentableContentBuilder.() -> Unit) { - contents += buildGroup(f.dri, f.platformData.toSet(), ContentKind.Symbol, mainStyles, mainExtras, block) - } - - fun signature(f: Function) = signature(f) { - text("fun ") - f.receiver?.also { - // TODO signature should be rewritten - type(it.type) - text(".") - } - link(f.name, f.dri) - text("(") - list(f.parameters) { - link(it.name!!, it.dri) - text(": ") - type(it.type) - } - text(")") - val returnType = f.type - if (!f.isConstructor && returnType.constructorFqName != Unit::class.qualifiedName) { - text(": ") - type(returnType) - } - } + fun signature(d: Documentable) = ContentGroup( + signatureProvider.signature(d), + DCI(setOf(d.dri), ContentKind.Symbol), + d.platformData.toSet(), + mainStyles, + mainExtras + ) fun linkTable( elements: List<DRI>, |