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.kt4
-rw-r--r--plugins/base/src/main/kotlin/transformers/pages/comments/CommentsToContentConverter.kt3
-rw-r--r--plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt31
-rw-r--r--plugins/base/src/main/kotlin/transformers/pages/merger/SameMethodNamePageMergerStrategy.kt7
-rw-r--r--plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt67
5 files changed, 53 insertions, 59 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
index 0dd3b34b..74bc6fea 100644
--- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
@@ -88,7 +88,7 @@ open class HtmlRenderer(
val imageExtensions = setOf("png", "jpg", "jpeg", "gif", "bmp", "tif", "webp", "svg")
return if (File(node.address).extension.toLowerCase() in imageExtensions) {
//TODO: add imgAttrs parsing
- val imgAttrs = node.extras.filterIsInstance<HTMLSimpleAttr>().joinAttr()
+ val imgAttrs = node.extra.allOfType<SimpleAttr>().joinAttr()
img(src = node.address, alt = node.altText)
} else {
println("Unrecognized resource type: $node")
@@ -239,7 +239,7 @@ open class HtmlRenderer(
}
}
-fun List<HTMLMetadata>.joinAttr() = joinToString(" ") { it.key + "=" + it.value }
+fun List<SimpleAttr>.joinAttr() = joinToString(" ") { it.extraKey + "=" + it.extraValue }
private fun PageNode.pageKind() = when (this) {
is PackagePageNode -> "package"
diff --git a/plugins/base/src/main/kotlin/transformers/pages/comments/CommentsToContentConverter.kt b/plugins/base/src/main/kotlin/transformers/pages/comments/CommentsToContentConverter.kt
index 4d2f14a5..778e0498 100644
--- a/plugins/base/src/main/kotlin/transformers/pages/comments/CommentsToContentConverter.kt
+++ b/plugins/base/src/main/kotlin/transformers/pages/comments/CommentsToContentConverter.kt
@@ -1,6 +1,7 @@
package org.jetbrains.dokka.base.transformers.pages.comments
import org.jetbrains.dokka.model.doc.DocTag
+import org.jetbrains.dokka.model.properties.PropertyContainer
import org.jetbrains.dokka.pages.*
interface CommentsToContentConverter {
@@ -9,6 +10,6 @@ interface CommentsToContentConverter {
dci: DCI,
platforms: Set<PlatformData>,
styles: Set<Style> = emptySet(),
- extras: Set<Extra> = emptySet()
+ extras: PropertyContainer<ContentNode> = PropertyContainer.empty()
): List<ContentNode>
}
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 70792534..900f5c19 100644
--- a/plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt
+++ b/plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt
@@ -1,6 +1,7 @@
package org.jetbrains.dokka.base.transformers.pages.comments
import org.jetbrains.dokka.model.doc.*
+import org.jetbrains.dokka.model.properties.PropertyContainer
import org.jetbrains.dokka.pages.*
import org.jetbrains.dokka.plugability.DokkaContext
@@ -10,13 +11,12 @@ object DocTagToContentConverter : CommentsToContentConverter {
dci: DCI,
platforms: Set<PlatformData>,
styles: Set<Style>,
- extras: Set<Extra>
-
+ extra: PropertyContainer<ContentNode>
): List<ContentNode> {
- fun buildChildren(docTag: DocTag, newStyles: Set<Style> = emptySet(), newExtras: Set<Extra> = emptySet()) =
+ fun buildChildren(docTag: DocTag, newStyles: Set<Style> = emptySet(), newExtras: SimpleAttr? = null) =
docTag.children.flatMap {
- buildContent(it, dci, platforms, styles + newStyles, extras + newExtras)
+ buildContent(it, dci, platforms, styles + newStyles, newExtras?.let { extra + it } ?: extra)
}
fun buildHeader(level: Int) =
@@ -26,8 +26,7 @@ object DocTagToContentConverter : CommentsToContentConverter {
level,
dci,
platforms,
- styles,
- extras
+ styles
)
)
@@ -38,8 +37,7 @@ object DocTagToContentConverter : CommentsToContentConverter {
ordered,
dci,
platforms,
- styles,
- extras
+ styles
)
)
@@ -62,8 +60,7 @@ object DocTagToContentConverter : CommentsToContentConverter {
docTag.params.get("href")!!,
dci,
platforms,
- styles,
- extras
+ styles
)
)
is DocumentationLink -> listOf(
@@ -75,8 +72,7 @@ object DocTagToContentConverter : CommentsToContentConverter {
ContentKind.Symbol
),
platforms,
- styles,
- extras
+ styles
)
)
is BlockQuote -> listOf(
@@ -85,8 +81,7 @@ object DocTagToContentConverter : CommentsToContentConverter {
"",
dci,
platforms,
- styles,
- extras
+ styles
)
)
is Code -> listOf(
@@ -95,8 +90,7 @@ object DocTagToContentConverter : CommentsToContentConverter {
"",
dci,
platforms,
- styles,
- extras
+ styles
)
)
is Img -> listOf(
@@ -106,7 +100,7 @@ object DocTagToContentConverter : CommentsToContentConverter {
dci = dci,
platforms = platforms,
style = styles,
- extras = extras
+ extra = extra
)
)
is HorizontalRule -> listOf(
@@ -122,8 +116,7 @@ object DocTagToContentConverter : CommentsToContentConverter {
docTag.body,
dci,
platforms,
- styles,
- extras
+ styles
)
)
else -> buildChildren(docTag)
diff --git a/plugins/base/src/main/kotlin/transformers/pages/merger/SameMethodNamePageMergerStrategy.kt b/plugins/base/src/main/kotlin/transformers/pages/merger/SameMethodNamePageMergerStrategy.kt
index ce57d28c..fb904f47 100644
--- a/plugins/base/src/main/kotlin/transformers/pages/merger/SameMethodNamePageMergerStrategy.kt
+++ b/plugins/base/src/main/kotlin/transformers/pages/merger/SameMethodNamePageMergerStrategy.kt
@@ -31,8 +31,7 @@ object SameMethodNamePageMergerStrategy : PageMergerStrategy {
return others + listOf(merged)
}
- fun asGroup(dci: DCI, nodes: List<ContentNode>): ContentGroup {
- val n = nodes.first()
- return ContentGroup(nodes, dci, n.platforms, n.style, n.extras)
- }
+ fun asGroup(dci: DCI, nodes: List<ContentNode>): ContentGroup =
+ nodes.first().let { ContentGroup(nodes, dci, it.platforms, it.style, it.extra) }
+
} \ No newline at end of file
diff --git a/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt b/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt
index 369c9c81..ef1b8ec1 100644
--- a/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt
+++ b/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt
@@ -6,6 +6,7 @@ import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.model.Documentable
import org.jetbrains.dokka.model.TypeWrapper
import org.jetbrains.dokka.model.doc.DocTag
+import org.jetbrains.dokka.model.properties.PropertyContainer
import org.jetbrains.dokka.pages.*
import org.jetbrains.dokka.utilities.DokkaLogger
@@ -22,30 +23,30 @@ open class PageContentBuilder(
platformData: Set<PlatformData>,
kind: Kind = ContentKind.Main,
styles: Set<Style> = emptySet(),
- extras: Set<Extra> = emptySet(),
+ extra: PropertyContainer<ContentNode> = PropertyContainer.empty(),
block: DocumentableContentBuilder.() -> Unit
): ContentGroup =
- DocumentableContentBuilder(dri, platformData, styles, extras)
+ DocumentableContentBuilder(dri, platformData, styles, extra)
.apply(block)
- .build(platformData, kind, styles, extras)
+ .build(platformData, kind, styles, extra)
fun contentFor(
d: Documentable,
kind: Kind = ContentKind.Main,
styles: Set<Style> = emptySet(),
- extras: Set<Extra> = emptySet(),
+ extra: PropertyContainer<ContentNode> = PropertyContainer.empty(),
block: DocumentableContentBuilder.() -> Unit
): ContentGroup =
- DocumentableContentBuilder(d.dri, d.platformData.toSet(), styles, extras)
+ DocumentableContentBuilder(d.dri, d.platformData.toSet(), styles, extra)
.apply(block)
- .build(d.platformData.toSet(), kind, styles, extras)
+ .build(d.platformData.toSet(), kind, styles, extra)
@ContentBuilderMarker
open inner class DocumentableContentBuilder(
val mainDRI: DRI,
val mainPlatformData: Set<PlatformData>,
val mainStyles: Set<Style>,
- val mainExtras: Set<Extra>
+ val mainExtra: PropertyContainer<ContentNode>
) {
protected val contents = mutableListOf<ContentNode>()
@@ -53,13 +54,13 @@ open class PageContentBuilder(
platformData: Set<PlatformData>,
kind: Kind,
styles: Set<Style>,
- extras: Set<Extra>
+ extra: PropertyContainer<ContentNode>
) = ContentGroup(
contents.toList(),
DCI(setOf(mainDRI), kind),
platformData,
styles,
- extras
+ extra
)
operator fun ContentNode.unaryPlus() {
@@ -74,12 +75,12 @@ open class PageContentBuilder(
level: Int,
kind: Kind = ContentKind.Main,
styles: Set<Style> = mainStyles,
- extras: Set<Extra> = mainExtras,
+ extra: PropertyContainer<ContentNode> = mainExtra,
block: DocumentableContentBuilder.() -> Unit
) {
contents += ContentHeader(
level,
- contentFor(mainDRI, mainPlatformData, kind, styles, extras, block)
+ contentFor(mainDRI, mainPlatformData, kind, styles, extra, block)
)
}
@@ -88,9 +89,9 @@ open class PageContentBuilder(
kind: Kind = ContentKind.Main,
platformData: Set<PlatformData> = mainPlatformData,
styles: Set<Style> = mainStyles,
- extras: Set<Extra> = mainExtras
+ extra: PropertyContainer<ContentNode> = mainExtra
) {
- contents += createText(text, kind, platformData, styles, extras)
+ contents += createText(text, kind, platformData, styles, extra)
}
fun buildSignature(d: Documentable) = signatureProvider.signature(d)
@@ -100,17 +101,17 @@ open class PageContentBuilder(
kind: Kind = ContentKind.Main,
platformData: Set<PlatformData> = mainPlatformData,
styles: Set<Style> = mainStyles,
- extras: Set<Extra> = mainExtras
+ extra: PropertyContainer<ContentNode> = mainExtra
) {
contents += ContentTable(
emptyList(),
elements.map {
- contentFor(it, platformData, kind, styles, extras) {
+ contentFor(it, platformData, kind, styles, extra) {
link(it.classNames ?: "", it)
}
},
DCI(setOf(mainDRI), kind),
- platformData, styles, extras
+ platformData, styles, extra
)
}
@@ -121,7 +122,7 @@ open class PageContentBuilder(
elements: Iterable<T>,
platformData: Set<PlatformData> = mainPlatformData,
styles: Set<Style> = mainStyles,
- extras: Set<Extra> = mainExtras,
+ extra: PropertyContainer<ContentNode> = mainExtra,
renderWhenEmpty: Boolean = false,
operation: DocumentableContentBuilder.(T) -> Unit
) {
@@ -130,13 +131,13 @@ open class PageContentBuilder(
contents += ContentTable(
emptyList(),
elements.map {
- buildGroup(it.dri, it.platformData.toSet(), kind, styles, extras) {
+ buildGroup(it.dri, it.platformData.toSet(), kind, styles, extra) {
// TODO this will fail
operation(it)
}
},
DCI(setOf(mainDRI), kind),
- platformData, styles, extras
+ platformData, styles, extra
)
}
}
@@ -166,10 +167,10 @@ open class PageContentBuilder(
kind: Kind = ContentKind.Main,
platformData: Set<PlatformData> = mainPlatformData,
styles: Set<Style> = mainStyles,
- extras: Set<Extra> = mainExtras
+ extra: PropertyContainer<ContentNode> = mainExtra
) {
contents += ContentDRILink(
- listOf(createText(text, kind, platformData, styles, extras)),
+ listOf(createText(text, kind, platformData, styles, extra)),
address,
DCI(setOf(mainDRI), kind),
platformData
@@ -181,11 +182,11 @@ open class PageContentBuilder(
kind: Kind = ContentKind.Main,
platformData: Set<PlatformData> = mainPlatformData,
styles: Set<Style> = mainStyles,
- extras: Set<Extra> = mainExtras,
+ extra: PropertyContainer<ContentNode> = mainExtra,
block: DocumentableContentBuilder.() -> Unit
) {
contents += ContentDRILink(
- contentFor(mainDRI, platformData, kind, styles, extras, block).children,
+ contentFor(mainDRI, platformData, kind, styles, extra, block).children,
address,
DCI(setOf(mainDRI), kind),
platformData
@@ -197,14 +198,14 @@ open class PageContentBuilder(
kind: Kind = ContentKind.Comment,
platformData: Set<PlatformData> = mainPlatformData,
styles: Set<Style> = mainStyles,
- extras: Set<Extra> = mainExtras
+ extra: PropertyContainer<ContentNode> = mainExtra
) {
val content = commentsConverter.buildContent(
docTag,
DCI(setOf(mainDRI), kind),
platformData
)
- contents += ContentGroup(content, DCI(setOf(mainDRI), kind), platformData, styles, extras)
+ contents += ContentGroup(content, DCI(setOf(mainDRI), kind), platformData, styles, extra)
}
fun group(
@@ -212,10 +213,10 @@ open class PageContentBuilder(
platformData: Set<PlatformData> = mainPlatformData,
kind: Kind = ContentKind.Main,
styles: Set<Style> = mainStyles,
- extras: Set<Extra> = mainExtras,
+ extra: PropertyContainer<ContentNode> = mainExtra,
block: DocumentableContentBuilder.() -> Unit
) {
- contents += buildGroup(dri, platformData, kind, styles, extras, block)
+ contents += buildGroup(dri, platformData, kind, styles, extra, block)
}
fun buildGroup(
@@ -223,20 +224,20 @@ open class PageContentBuilder(
platformData: Set<PlatformData> = mainPlatformData,
kind: Kind = ContentKind.Main,
styles: Set<Style> = mainStyles,
- extras: Set<Extra> = mainExtras,
+ extra: PropertyContainer<ContentNode> = mainExtra,
block: DocumentableContentBuilder.() -> Unit
- ): ContentGroup = contentFor(dri, platformData, kind, styles, extras, block)
+ ): ContentGroup = contentFor(dri, platformData, kind, styles, extra, block)
fun platformDependentHint(
dri: DRI = mainDRI,
platformData: Set<PlatformData> = mainPlatformData,
kind: Kind = ContentKind.Main,
styles: Set<Style> = mainStyles,
- extras: Set<Extra> = mainExtras,
+ extra: PropertyContainer<ContentNode> = mainExtra,
block: DocumentableContentBuilder.() -> Unit
) {
contents += PlatformHintedContent(
- buildGroup(dri, platformData, kind, styles, extras, block),
+ buildGroup(dri, platformData, kind, styles, extra, block),
platformData
)
}
@@ -246,9 +247,9 @@ open class PageContentBuilder(
kind: Kind,
platformData: Set<PlatformData>,
styles: Set<Style>,
- extras: Set<Extra>
+ extra: PropertyContainer<ContentNode>
) =
- ContentText(text, DCI(setOf(mainDRI), kind), platformData, styles, extras)
+ ContentText(text, DCI(setOf(mainDRI), kind), platformData, styles, extra)
fun type(t: TypeWrapper) {
if (t.constructorNamePathSegments.isNotEmpty() && t.dri != null)