aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin/renderers
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/base/src/main/kotlin/renderers')
-rw-r--r--plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt79
-rw-r--r--plugins/base/src/main/kotlin/renderers/FileWriter.kt7
-rw-r--r--plugins/base/src/main/kotlin/renderers/OutputWriter.kt6
-rw-r--r--plugins/base/src/main/kotlin/renderers/PackageListService.kt23
-rw-r--r--plugins/base/src/main/kotlin/renderers/TabSortingStrategy.kt4
-rw-r--r--plugins/base/src/main/kotlin/renderers/contentTypeChecking.kt11
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt103
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/NavigationDataProvider.kt6
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt24
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/SearchbarDataInstaller.kt25
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/Tags.kt34
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/command/consumers/ImmediateResolutionTagConsumer.kt10
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/command/consumers/PathToRootConsumer.kt4
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/command/consumers/ReplaceVersionsConsumer.kt4
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/command/consumers/ResolveLinkConsumer.kt4
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/htmlFormatingUtils.kt7
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt20
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/innerTemplating/DefaultTemplateModelFactory.kt6
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/innerTemplating/DefaultTemplateModelMerger.kt2
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/innerTemplating/HtmlTemplater.kt12
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/innerTemplating/TemplateModelFactory.kt6
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/innerTemplating/TemplateModelMerger.kt4
-rw-r--r--plugins/base/src/main/kotlin/renderers/preprocessors.kt16
23 files changed, 244 insertions, 173 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt b/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt
index edbf1037..eed7794e 100644
--- a/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt
@@ -19,61 +19,68 @@ import org.jetbrains.dokka.plugability.querySingle
import org.jetbrains.dokka.renderers.Renderer
import org.jetbrains.dokka.transformers.pages.PageTransformer
-abstract class DefaultRenderer<T>(
+public abstract class DefaultRenderer<T>(
protected val context: DokkaContext
) : Renderer {
- protected val outputWriter = context.plugin<DokkaBase>().querySingle { outputWriter }
+ protected val outputWriter: OutputWriter = context.plugin<DokkaBase>().querySingle { outputWriter }
protected lateinit var locationProvider: LocationProvider
private set
protected open val preprocessors: Iterable<PageTransformer> = emptyList()
- abstract fun T.buildHeader(level: Int, node: ContentHeader, content: T.() -> Unit)
- abstract fun T.buildLink(address: String, content: T.() -> Unit)
- abstract fun T.buildList(
+ public abstract fun T.buildHeader(level: Int, node: ContentHeader, content: T.() -> Unit)
+ public abstract fun T.buildLink(address: String, content: T.() -> Unit)
+ public abstract fun T.buildList(
node: ContentList,
pageContext: ContentPage,
sourceSetRestriction: Set<DisplaySourceSet>? = null
)
- abstract fun T.buildLineBreak()
- open fun T.buildLineBreak(node: ContentBreakLine, pageContext: ContentPage) = buildLineBreak()
+ public abstract fun T.buildLineBreak()
+ public open fun T.buildLineBreak(node: ContentBreakLine, pageContext: ContentPage) {
+ buildLineBreak()
+ }
- abstract fun T.buildResource(node: ContentEmbeddedResource, pageContext: ContentPage)
- abstract fun T.buildTable(
+ public abstract fun T.buildResource(node: ContentEmbeddedResource, pageContext: ContentPage)
+ public abstract fun T.buildTable(
node: ContentTable,
pageContext: ContentPage,
sourceSetRestriction: Set<DisplaySourceSet>? = null
)
- abstract fun T.buildText(textNode: ContentText)
- abstract fun T.buildNavigation(page: PageNode)
+ public abstract fun T.buildText(textNode: ContentText)
+ public abstract fun T.buildNavigation(page: PageNode)
- abstract fun buildPage(page: ContentPage, content: (T, ContentPage) -> Unit): String
- abstract fun buildError(node: ContentNode)
+ public abstract fun buildPage(page: ContentPage, content: (T, ContentPage) -> Unit): String
+ public abstract fun buildError(node: ContentNode)
- open fun T.buildPlatformDependent(
+ public open fun T.buildPlatformDependent(
content: PlatformHintedContent,
pageContext: ContentPage,
sourceSetRestriction: Set<DisplaySourceSet>?
- ) = buildContentNode(content.inner, pageContext)
+ ) {
+ buildContentNode(content.inner, pageContext)
+ }
- open fun T.buildGroup(
+ public open fun T.buildGroup(
node: ContentGroup,
pageContext: ContentPage,
sourceSetRestriction: Set<DisplaySourceSet>? = null
- ) =
+ ) {
wrapGroup(node, pageContext) { node.children.forEach { it.build(this, pageContext, sourceSetRestriction) } }
+ }
- open fun T.buildDivergent(node: ContentDivergentGroup, pageContext: ContentPage) =
+ public open fun T.buildDivergent(node: ContentDivergentGroup, pageContext: ContentPage) {
node.children.forEach { it.build(this, pageContext) }
+ }
- open fun T.wrapGroup(node: ContentGroup, pageContext: ContentPage, childrenCallback: T.() -> Unit) =
+ public open fun T.wrapGroup(node: ContentGroup, pageContext: ContentPage, childrenCallback: T.() -> Unit) {
childrenCallback()
+ }
- open fun T.buildText(
+ public open fun T.buildText(
nodes: List<ContentNode>,
pageContext: ContentPage,
sourceSetRestriction: Set<DisplaySourceSet>? = null
@@ -81,15 +88,15 @@ abstract class DefaultRenderer<T>(
nodes.forEach { it.build(this, pageContext, sourceSetRestriction) }
}
- open fun T.buildCodeBlock(code: ContentCodeBlock, pageContext: ContentPage) {
+ public open fun T.buildCodeBlock(code: ContentCodeBlock, pageContext: ContentPage) {
code.children.forEach { it.build(this, pageContext) }
}
- open fun T.buildCodeInline(code: ContentCodeInline, pageContext: ContentPage) {
+ public open fun T.buildCodeInline(code: ContentCodeInline, pageContext: ContentPage) {
code.children.forEach { it.build(this, pageContext) }
}
- open fun T.buildHeader(
+ public open fun T.buildHeader(
node: ContentHeader,
pageContext: ContentPage,
sourceSetRestriction: Set<DisplaySourceSet>? = null
@@ -97,19 +104,23 @@ abstract class DefaultRenderer<T>(
buildHeader(node.level, node) { node.children.forEach { it.build(this, pageContext, sourceSetRestriction) } }
}
- open fun ContentNode.build(
+ public open fun ContentNode.build(
builder: T,
pageContext: ContentPage,
sourceSetRestriction: Set<DisplaySourceSet>? = null
- ) = builder.buildContentNode(this, pageContext, sourceSetRestriction)
+ ) {
+ builder.buildContentNode(this, pageContext, sourceSetRestriction)
+ }
- fun T.buildContentNode(
+ public fun T.buildContentNode(
node: ContentNode,
pageContext: ContentPage,
sourceSetRestriction: DisplaySourceSet
- ) = buildContentNode(node, pageContext, setOf(sourceSetRestriction))
+ ) {
+ buildContentNode(node, pageContext, setOf(sourceSetRestriction))
+ }
- open fun T.buildContentNode(
+ public open fun T.buildContentNode(
node: ContentNode,
pageContext: ContentPage,
sourceSetRestriction: Set<DisplaySourceSet>? = null
@@ -135,7 +146,7 @@ abstract class DefaultRenderer<T>(
}
}
- open fun T.buildDRILink(
+ public open fun T.buildDRILink(
node: ContentDRILink,
pageContext: ContentPage,
sourceSetRestriction: Set<DisplaySourceSet>?
@@ -147,7 +158,7 @@ abstract class DefaultRenderer<T>(
} ?: buildText(node.children, pageContext, sourceSetRestriction)
}
- open fun T.buildResolvedLink(
+ public open fun T.buildResolvedLink(
node: ContentResolvedLink,
pageContext: ContentPage,
sourceSetRestriction: Set<DisplaySourceSet>?
@@ -157,18 +168,18 @@ abstract class DefaultRenderer<T>(
}
}
- open fun T.buildDivergentInstance(node: ContentDivergentInstance, pageContext: ContentPage) {
+ public open fun T.buildDivergentInstance(node: ContentDivergentInstance, pageContext: ContentPage) {
node.before?.build(this, pageContext)
node.divergent.build(this, pageContext)
node.after?.build(this, pageContext)
}
- open fun buildPageContent(context: T, page: ContentPage) {
+ public open fun buildPageContent(context: T, page: ContentPage) {
context.buildNavigation(page)
page.content.build(context, page)
}
- open suspend fun renderPage(page: PageNode) {
+ public open suspend fun renderPage(page: PageNode) {
val path by lazy {
locationProvider.resolve(page, skipExtension = true)
?: throw DokkaException("Cannot resolve path for ${page.name}")
@@ -243,4 +254,4 @@ abstract class DefaultRenderer<T>(
internal typealias SerializedBeforeAndAfter = Pair<String, String>
internal typealias InstanceWithSource = Pair<ContentDivergentInstance, DisplaySourceSet>
-fun ContentPage.sourceSets() = this.content.sourceSets
+public fun ContentPage.sourceSets(): Set<DisplaySourceSet> = this.content.sourceSets
diff --git a/plugins/base/src/main/kotlin/renderers/FileWriter.kt b/plugins/base/src/main/kotlin/renderers/FileWriter.kt
index 0bca1591..1a1c3b42 100644
--- a/plugins/base/src/main/kotlin/renderers/FileWriter.kt
+++ b/plugins/base/src/main/kotlin/renderers/FileWriter.kt
@@ -14,7 +14,9 @@ import java.io.IOException
import java.net.URI
import java.nio.file.*
-class FileWriter(val context: DokkaContext): OutputWriter {
+public class FileWriter(
+ public val context: DokkaContext
+): OutputWriter {
private val createdFiles: MutableSet<String> = mutableSetOf()
private val createdFilesMutex = Mutex()
private val jarUriPrefix = "jar:file:"
@@ -44,12 +46,13 @@ class FileWriter(val context: DokkaContext): OutputWriter {
return false
}
- override suspend fun writeResources(pathFrom: String, pathTo: String) =
+ override suspend fun writeResources(pathFrom: String, pathTo: String) {
if (javaClass.getResource(pathFrom)?.toURI()?.toString()?.startsWith(jarUriPrefix) == true) {
copyFromJar(pathFrom, pathTo)
} else {
copyFromDirectory(pathFrom, pathTo)
}
+ }
private suspend fun copyFromDirectory(pathFrom: String, pathTo: String) {
diff --git a/plugins/base/src/main/kotlin/renderers/OutputWriter.kt b/plugins/base/src/main/kotlin/renderers/OutputWriter.kt
index 9c5de394..3fdd1802 100644
--- a/plugins/base/src/main/kotlin/renderers/OutputWriter.kt
+++ b/plugins/base/src/main/kotlin/renderers/OutputWriter.kt
@@ -4,8 +4,8 @@
package org.jetbrains.dokka.base.renderers
-interface OutputWriter {
+public interface OutputWriter {
- suspend fun write(path: String, text: String, ext: String)
- suspend fun writeResources(pathFrom: String, pathTo: String)
+ public suspend fun write(path: String, text: String, ext: String)
+ public suspend fun writeResources(pathFrom: String, pathTo: String)
}
diff --git a/plugins/base/src/main/kotlin/renderers/PackageListService.kt b/plugins/base/src/main/kotlin/renderers/PackageListService.kt
index 1d062542..3ed6cd21 100644
--- a/plugins/base/src/main/kotlin/renderers/PackageListService.kt
+++ b/plugins/base/src/main/kotlin/renderers/PackageListService.kt
@@ -15,9 +15,12 @@ import org.jetbrains.dokka.plugability.DokkaContext
import org.jetbrains.dokka.plugability.plugin
import org.jetbrains.dokka.plugability.querySingle
-class PackageListService(val context: DokkaContext, val rootPage: RootPageNode) {
+public class PackageListService(
+ public val context: DokkaContext,
+ public val rootPage: RootPageNode
+) {
- fun createPackageList(module: ModulePage, format: LinkFormat): String {
+ public fun createPackageList(module: ModulePage, format: LinkFormat): String {
val packages = mutableSetOf<String>()
val nonStandardLocations = mutableMapOf<String, String>()
@@ -46,11 +49,21 @@ class PackageListService(val context: DokkaContext, val rootPage: RootPageNode)
}
visit(module)
- return renderPackageList(nonStandardLocations, mapOf(SINGLE_MODULE_NAME to packages), format.formatName, format.linkExtension)
+ return renderPackageList(
+ nonStandardLocations = nonStandardLocations,
+ modules = mapOf(SINGLE_MODULE_NAME to packages),
+ format = format.formatName,
+ linkExtension = format.linkExtension
+ )
}
- companion object {
- fun renderPackageList(nonStandardLocations: Map<String, String>, modules: Map<String, Set<String>>, format: String, linkExtension: String): String = buildString {
+ public companion object {
+ public fun renderPackageList(
+ nonStandardLocations: Map<String, String>,
+ modules: Map<String, Set<String>>,
+ format: String,
+ linkExtension: String
+ ): String = buildString {
appendLine("$DOKKA_PARAM_PREFIX.format:${format}")
appendLine("$DOKKA_PARAM_PREFIX.linkExtension:${linkExtension}")
nonStandardLocations.map { (signature, location) ->
diff --git a/plugins/base/src/main/kotlin/renderers/TabSortingStrategy.kt b/plugins/base/src/main/kotlin/renderers/TabSortingStrategy.kt
index c76094f9..665b6717 100644
--- a/plugins/base/src/main/kotlin/renderers/TabSortingStrategy.kt
+++ b/plugins/base/src/main/kotlin/renderers/TabSortingStrategy.kt
@@ -6,6 +6,6 @@ package org.jetbrains.dokka.base.renderers
import org.jetbrains.dokka.pages.ContentNode
-interface TabSortingStrategy {
- fun <T: ContentNode> sort(tabs: Collection<T>) : List<T>
+public interface TabSortingStrategy {
+ public fun <T: ContentNode> sort(tabs: Collection<T>) : List<T>
}
diff --git a/plugins/base/src/main/kotlin/renderers/contentTypeChecking.kt b/plugins/base/src/main/kotlin/renderers/contentTypeChecking.kt
index 8074dab6..0fcb0efb 100644
--- a/plugins/base/src/main/kotlin/renderers/contentTypeChecking.kt
+++ b/plugins/base/src/main/kotlin/renderers/contentTypeChecking.kt
@@ -8,16 +8,17 @@ import org.jetbrains.dokka.base.renderers.HtmlFileExtensions.imageExtensions
import org.jetbrains.dokka.pages.ContentEmbeddedResource
import java.io.File
-fun ContentEmbeddedResource.isImage(): Boolean {
+public fun ContentEmbeddedResource.isImage(): Boolean {
return File(address).extension.toLowerCase() in imageExtensions
}
-val String.URIExtension: String
+public val String.URIExtension: String
get() = substringBefore('?').substringAfterLast('.')
-fun String.isImage(): Boolean =
+public fun String.isImage(): Boolean =
URIExtension in imageExtensions
-object HtmlFileExtensions {
- val imageExtensions = setOf("png", "jpg", "jpeg", "gif", "bmp", "tif", "webp", "svg")
+public object HtmlFileExtensions {
+ public val imageExtensions: Set<String> = setOf("png", "jpg", "jpeg", "gif", "bmp", "tif", "webp", "svg")
}
+
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
index 9d361f70..083876d5 100644
--- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
@@ -27,12 +27,13 @@ import org.jetbrains.dokka.model.properties.WithExtraProperties
import org.jetbrains.dokka.pages.*
import org.jetbrains.dokka.pages.HtmlContent
import org.jetbrains.dokka.plugability.*
+import org.jetbrains.dokka.transformers.pages.PageTransformer
import org.jetbrains.dokka.utilities.htmlEscape
internal const val TEMPLATE_REPLACEMENT: String = "###"
internal const val TOGGLEABLE_CONTENT_TYPE_ATTR = "data-togglable"
-open class HtmlRenderer(
+public open class HtmlRenderer(
context: DokkaContext
) : DefaultRenderer<FlowContent>(context) {
private val sourceSetDependencyMap: Map<DokkaSourceSetID, List<DokkaSourceSetID>> =
@@ -50,7 +51,7 @@ open class HtmlRenderer(
private var shouldRenderSourceSetTabs: Boolean = false
- override val preprocessors = context.plugin<DokkaBase>().query { htmlPreprocessors }
+ override val preprocessors: List<PageTransformer> = context.plugin<DokkaBase>().query { htmlPreprocessors }
/**
* Tabs themselves are created in HTML plugin since, currently, only HTML format supports them.
@@ -253,7 +254,7 @@ open class HtmlRenderer(
content: PlatformHintedContent,
pageContext: ContentPage,
sourceSetRestriction: Set<DisplaySourceSet>?
- ) =
+ ) {
buildPlatformDependent(
content.sourceSets.filter {
sourceSetRestriction == null || it in sourceSetRestriction
@@ -262,6 +263,7 @@ open class HtmlRenderer(
content.extra,
content.style
)
+ }
private fun FlowContent.buildPlatformDependent(
nodes: Map<DisplaySourceSet, Collection<ContentNode>>,
@@ -409,19 +411,21 @@ open class HtmlRenderer(
node: ContentList,
pageContext: ContentPage,
sourceSetRestriction: Set<DisplaySourceSet>?
- ) = when {
- node.ordered -> {
- ol { buildListItems(node.children, pageContext, sourceSetRestriction) }
- }
- node.hasStyle(ListStyle.DescriptionList) -> {
- dl { node.children.forEach { it.build(this, pageContext, sourceSetRestriction) } }
- }
- else -> {
- ul { buildListItems(node.children, pageContext, sourceSetRestriction) }
+ ) {
+ return when {
+ node.ordered -> {
+ ol { buildListItems(node.children, pageContext, sourceSetRestriction) }
+ }
+ node.hasStyle(ListStyle.DescriptionList) -> {
+ dl { node.children.forEach { it.build(this, pageContext, sourceSetRestriction) } }
+ }
+ else -> {
+ ul { buildListItems(node.children, pageContext, sourceSetRestriction) }
+ }
}
}
- open fun OL.buildListItems(
+ public open fun OL.buildListItems(
items: List<ContentNode>,
pageContext: ContentPage,
sourceSetRestriction: Set<DisplaySourceSet>? = null
@@ -434,7 +438,7 @@ open class HtmlRenderer(
}
}
- open fun UL.buildListItems(
+ public open fun UL.buildListItems(
items: List<ContentNode>,
pageContext: ContentPage,
sourceSetRestriction: Set<DisplaySourceSet>? = null
@@ -450,12 +454,13 @@ open class HtmlRenderer(
override fun FlowContent.buildResource(
node: ContentEmbeddedResource,
pageContext: ContentPage
- ) = // TODO: extension point there
+ ) { // TODO: extension point there
if (node.isImage()) {
img(src = node.address, alt = node.altText)
} else {
println("Unrecognized resource type: $node")
}
+ }
private fun FlowContent.buildRow(
node: ContentGroup,
@@ -642,7 +647,7 @@ open class HtmlRenderer(
}
- fun FlowContent.buildDefaultTable(
+ public fun FlowContent.buildDefaultTable(
node: ContentTable,
pageContext: ContentPage,
sourceSetRestriction: Set<DisplaySourceSet>?
@@ -709,7 +714,7 @@ open class HtmlRenderer(
}
- override fun FlowContent.buildNavigation(page: PageNode) =
+ override fun FlowContent.buildNavigation(page: PageNode) {
div(classes = "breadcrumbs") {
val path = locationProvider.ancestors(page).filterNot { it is RendererSpecificPage }.asReversed()
if (path.size > 1) {
@@ -722,6 +727,7 @@ open class HtmlRenderer(
}
}
}
+ }
private fun FlowContent.buildNavigationElement(node: PageNode, page: PageNode) =
if (node.isNavigable) {
@@ -747,7 +753,7 @@ open class HtmlRenderer(
text(to.name)
}
- fun FlowContent.buildAnchorCopyButton(pointingTo: String) {
+ public fun FlowContent.buildAnchorCopyButton(pointingTo: String) {
span(classes = "anchor-wrapper") {
span(classes = "anchor-icon") {
attributes["pointing-to"] = pointingTo
@@ -756,17 +762,23 @@ open class HtmlRenderer(
}
}
- fun FlowContent.buildLink(
+ public fun FlowContent.buildLink(
to: DRI,
platforms: List<DisplaySourceSet>,
from: PageNode? = null,
block: FlowContent.() -> Unit
- ) = locationProvider.resolve(to, platforms.toSet(), from)?.let { buildLink(it, block) }
- ?: run { context.logger.error("Cannot resolve path for `$to` from `$from`"); block() }
+ ) {
+ locationProvider.resolve(to, platforms.toSet(), from)?.let { buildLink(it, block) }
+ ?: run { context.logger.error("Cannot resolve path for `$to` from `$from`"); block() }
+ }
- override fun buildError(node: ContentNode) = context.logger.error("Unknown ContentNode type: $node")
+ override fun buildError(node: ContentNode) {
+ context.logger.error("Unknown ContentNode type: $node")
+ }
- override fun FlowContent.buildLineBreak() = br()
+ override fun FlowContent.buildLineBreak() {
+ br()
+ }
override fun FlowContent.buildLineBreak(node: ContentBreakLine, pageContext: ContentPage) {
if (node.style.contains(HorizontalBreakLineStyle)) {
hr()
@@ -775,25 +787,28 @@ open class HtmlRenderer(
}
}
- override fun FlowContent.buildLink(address: String, content: FlowContent.() -> Unit) =
+ override fun FlowContent.buildLink(address: String, content: FlowContent.() -> Unit) {
a(href = address, block = content)
+ }
override fun FlowContent.buildDRILink(
node: ContentDRILink,
pageContext: ContentPage,
sourceSetRestriction: Set<DisplaySourceSet>?
- ) = locationProvider.resolve(node.address, node.sourceSets, pageContext)?.let { address ->
- buildLink(address) {
- buildText(node.children, pageContext, sourceSetRestriction)
- }
- } ?: if (isPartial) {
- templateCommand(ResolveLinkCommand(node.address)) {
- buildText(node.children, pageContext, sourceSetRestriction)
- }
- } else {
- span {
- attributes["data-unresolved-link"] = node.address.toString().htmlEscape()
- buildText(node.children, pageContext, sourceSetRestriction)
+ ) {
+ locationProvider.resolve(node.address, node.sourceSets, pageContext)?.let { address ->
+ buildLink(address) {
+ buildText(node.children, pageContext, sourceSetRestriction)
+ }
+ } ?: if (isPartial) {
+ templateCommand(ResolveLinkCommand(node.address)) {
+ buildText(node.children, pageContext, sourceSetRestriction)
+ }
+ } else {
+ span {
+ attributes["data-unresolved-link"] = node.address.toString().htmlEscape()
+ buildText(node.children, pageContext, sourceSetRestriction)
+ }
}
}
@@ -830,7 +845,9 @@ open class HtmlRenderer(
}
}
- override fun FlowContent.buildText(textNode: ContentText) = buildText(textNode, textNode.style)
+ override fun FlowContent.buildText(textNode: ContentText) {
+ buildText(textNode, textNode.style)
+ }
private fun FlowContent.buildText(textNode: ContentText, unappliedStyles: Set<Style>) {
when {
@@ -891,8 +908,11 @@ open class HtmlRenderer(
else -> null
}
- open fun buildHtml(page: PageNode, resources: List<String>, content: FlowContent.() -> Unit): String =
- templater.renderFromTemplate(DokkaTemplateTypes.BASE) {
+ public open fun buildHtml(
+ page: PageNode,
+ resources: List<String>, content: FlowContent.() -> Unit
+ ): String {
+ return templater.renderFromTemplate(DokkaTemplateTypes.BASE) {
val generatedContent =
createHTML().div("main-content") {
page.getDocumentableType()?.let { attributes["data-page-type"] = it }
@@ -912,12 +932,13 @@ open class HtmlRenderer(
)
}
}
+ }
/**
* This is deliberately left open for plugins that have some other pages above ours and would like to link to them
* instead of ours when clicking the logo
*/
- open fun FlowContent.clickableLogo(page: PageNode, pathToRoot: String) {
+ public open fun FlowContent.clickableLogo(page: PageNode, pathToRoot: String) {
if (context.configuration.delayTemplateSubstitution && page is ContentPage) {
templateCommand(PathToRootSubstitutionCommand(pattern = "###", default = pathToRoot)) {
a {
@@ -978,7 +999,7 @@ private fun TabbedContentType.toHtmlAttribute(): String =
*/
private data class ContentTab(val text: String, val tabbedContentTypes: List<TabbedContentType>)
-fun List<SimpleAttr>.joinAttr() = joinToString(" ") { it.extraKey + "=" + it.extraValue }
+public fun List<SimpleAttr>.joinAttr(): String = joinToString(" ") { it.extraKey + "=" + it.extraValue }
private fun String.stripDiv() = drop(5).dropLast(6) // TODO: Find a way to do it without arbitrary trims
diff --git a/plugins/base/src/main/kotlin/renderers/html/NavigationDataProvider.kt b/plugins/base/src/main/kotlin/renderers/html/NavigationDataProvider.kt
index 1c414ad8..fccfd145 100644
--- a/plugins/base/src/main/kotlin/renderers/html/NavigationDataProvider.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/NavigationDataProvider.kt
@@ -17,15 +17,15 @@ import org.jetbrains.dokka.plugability.querySingle
import org.jetbrains.dokka.analysis.kotlin.internal.DocumentableLanguage
import org.jetbrains.dokka.analysis.kotlin.internal.InternalKotlinAnalysisPlugin
-abstract class NavigationDataProvider(
+public abstract class NavigationDataProvider(
dokkaContext: DokkaContext
) {
private val documentableSourceLanguageParser = dokkaContext.plugin<InternalKotlinAnalysisPlugin>().querySingle { documentableSourceLanguageParser }
- open fun navigableChildren(input: RootPageNode): NavigationNode = input.withDescendants()
+ public open fun navigableChildren(input: RootPageNode): NavigationNode = input.withDescendants()
.first { it is ModulePage || it is MultimoduleRootPage }.let { visit(it as ContentPage) }
- open fun visit(page: ContentPage): NavigationNode =
+ public open fun visit(page: ContentPage): NavigationNode =
NavigationNode(
name = page.displayableName(),
dri = page.dri.first(),
diff --git a/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt b/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt
index c4d53588..eae43daf 100644
--- a/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt
@@ -16,19 +16,19 @@ import org.jetbrains.dokka.model.WithChildren
import org.jetbrains.dokka.pages.*
import org.jetbrains.dokka.plugability.DokkaContext
-class NavigationPage(
- val root: NavigationNode,
- val moduleName: String,
- val context: DokkaContext
+public class NavigationPage(
+ public val root: NavigationNode,
+ public val moduleName: String,
+ public val context: DokkaContext
) : RendererSpecificPage {
- override val name = "navigation"
+ override val name: String = "navigation"
- override val children = emptyList<PageNode>()
+ override val children: List<PageNode> = emptyList()
- override fun modified(name: String, children: List<PageNode>) = this
+ override fun modified(name: String, children: List<PageNode>): NavigationPage = this
- override val strategy = RenderingStrategy<HtmlRenderer> {
+ override val strategy: RenderingStrategy = RenderingStrategy<HtmlRenderer> {
createHTML().visit(root, this)
}
@@ -86,7 +86,7 @@ class NavigationPage(
}
}
-data class NavigationNode(
+public data class NavigationNode(
val name: String,
val dri: DRI,
val sourceSets: Set<DisplaySourceSet>,
@@ -99,7 +99,7 @@ data class NavigationNode(
* [CLASS] represents a neutral (a.k.a Java-style) icon,
* whereas [CLASS_KT] should be Kotlin-styled
*/
-enum class NavigationNodeIcon(
+public enum class NavigationNodeIcon(
private val cssClass: String
) {
CLASS("class"),
@@ -122,8 +122,8 @@ enum class NavigationNodeIcon(
internal fun style(): String = "nav-icon $cssClass"
}
-fun NavigationPage.transform(block: (NavigationNode) -> NavigationNode) =
+public fun NavigationPage.transform(block: (NavigationNode) -> NavigationNode): NavigationPage =
NavigationPage(root.transform(block), moduleName, context)
-fun NavigationNode.transform(block: (NavigationNode) -> NavigationNode) =
+public fun NavigationNode.transform(block: (NavigationNode) -> NavigationNode): NavigationNode =
run(block).let { NavigationNode(it.name, it.dri, it.sourceSets, it.icon, it.styles, it.children.map(block)) }
diff --git a/plugins/base/src/main/kotlin/renderers/html/SearchbarDataInstaller.kt b/plugins/base/src/main/kotlin/renderers/html/SearchbarDataInstaller.kt
index f985e4d0..83d4b24f 100644
--- a/plugins/base/src/main/kotlin/renderers/html/SearchbarDataInstaller.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/SearchbarDataInstaller.kt
@@ -16,19 +16,23 @@ import org.jetbrains.dokka.pages.*
import org.jetbrains.dokka.plugability.DokkaContext
import org.jetbrains.dokka.transformers.pages.PageTransformer
-data class SearchRecord(
+public data class SearchRecord(
val name: String,
val description: String? = null,
val location: String,
val searchKeys: List<String> = listOf(name)
) {
- companion object
+ public companion object
}
-open class SearchbarDataInstaller(val context: DokkaContext) : PageTransformer {
- data class DRIWithSourceSets(val dri: DRI, val sourceSet: Set<DisplaySourceSet>)
- data class SignatureWithId(val driWithSourceSets: DRIWithSourceSets, val displayableSignature: String) {
- constructor(dri: DRI, page: ContentPage) : this( DRIWithSourceSets(dri, page.sourceSets()),
+public open class SearchbarDataInstaller(
+ public val context: DokkaContext
+) : PageTransformer {
+
+ public data class DRIWithSourceSets(val dri: DRI, val sourceSet: Set<DisplaySourceSet>)
+
+ public data class SignatureWithId(val driWithSourceSets: DRIWithSourceSets, val displayableSignature: String) {
+ public constructor(dri: DRI, page: ContentPage) : this( DRIWithSourceSets(dri, page.sourceSets()),
getSymbolSignature(page, dri)?.let { flattenToText(it) } ?: page.name)
val id: String
@@ -43,7 +47,10 @@ open class SearchbarDataInstaller(val context: DokkaContext) : PageTransformer {
private val mapper = jacksonObjectMapper()
- open fun generatePagesList(pages: List<SignatureWithId>, locationResolver: DriResolver): List<SearchRecord> =
+ public open fun generatePagesList(
+ pages: List<SignatureWithId>,
+ locationResolver: DriResolver
+ ): List<SearchRecord> =
pages.map { pageWithId ->
createSearchRecord(
name = pageWithId.displayableSignature,
@@ -57,7 +64,7 @@ open class SearchbarDataInstaller(val context: Dok