From f625cef495d625d81ee22e950083f57cc4fab875 Mon Sep 17 00:00:00 2001 From: Paweł Marks Date: Mon, 17 Feb 2020 09:32:35 +0100 Subject: Moves PsiToDocumentablesTranslator to the base plugin --- .../kotlin/renderers/html/htmlPreprocessors.kt | 68 ++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt (limited to 'plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt') diff --git a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt new file mode 100644 index 00000000..09164d97 --- /dev/null +++ b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt @@ -0,0 +1,68 @@ +package org.jetbrains.dokka.renderers.html + +import kotlinx.html.h1 +import kotlinx.html.id +import kotlinx.html.table +import kotlinx.html.tbody +import org.jetbrains.dokka.base.renderers.platforms +import org.jetbrains.dokka.pages.* +import org.jetbrains.dokka.transformers.pages.PageNodeTransformer + +object RootCreator : PageNodeTransformer { + override fun invoke(input: RootPageNode) = + RendererSpecificRootPage("", listOf(input), RenderingStrategy.DoNothing) +} + +object SearchPageInstaller : PageNodeTransformer { + override fun invoke(input: RootPageNode) = input.modified(children = input.children + searchPage) + + private val searchPage = RendererSpecificResourcePage( + name = "Search", + children = emptyList(), + strategy = RenderingStrategy { + buildHtml(it, listOf("styles/style.css", "scripts/pages.js")) { + h1 { + id = "searchTitle" + text("Search results for ") + } + table { + tbody { + id = "searchTable" + } + } + } + }) +} + +object NavigationPageInstaller : PageNodeTransformer { + override fun invoke(input: RootPageNode) = input.modified( + children = input.children + NavigationPage( + input.children.filterIsInstance().single().let(::visit) + ) + ) + + private fun visit(page: ContentPage): NavigationNode = NavigationNode( + page.name, + page.dri.first(), + page.platforms(), + page.children.filterIsInstance().map { visit(it) }) +} + +object ResourceInstaller : PageNodeTransformer { + override fun invoke(input: RootPageNode) = input.modified(children = input.children + resourcePages) + + private val resourcePages = listOf("styles", "scripts", "images").map { + RendererSpecificResourcePage(it, emptyList(), RenderingStrategy.Copy("/dokka/$it")) + } +} + +object StyleAndScriptsAppender : PageNodeTransformer { + override fun invoke(input: RootPageNode) = input.transformContentPagesTree { + it.modified( + embeddedResources = it.embeddedResources + listOf( + "styles/style.css", + "scripts/navigationLoader.js" + ) + ) + } +} -- cgit From a89d9a8c87cbe81bdba25b660d1b1fda1d0ce8ec Mon Sep 17 00:00:00 2001 From: Paweł Marks Date: Mon, 17 Feb 2020 12:35:15 +0100 Subject: Moves location providers and output writers to base plugin --- core/src/main/kotlin/CoreExtensions.kt | 5 - .../main/kotlin/plugability/DefaultExtensions.kt | 7 -- core/src/main/kotlin/renderers/FileWriter.kt | 78 ------------- core/src/main/kotlin/renderers/OutputWriter.kt | 7 -- .../kotlin/resolvers/DefaultLocationProvider.kt | 121 --------------------- .../kotlin/resolvers/ExternalLocationProvider.kt | 99 ----------------- core/src/main/kotlin/resolvers/LocationProvider.kt | 13 --- .../kotlin/resolvers/LocationProviderFactory.kt | 14 --- plugins/base/src/main/kotlin/DokkaBase.kt | 16 ++- .../src/main/kotlin/renderers/DefaultRenderer.kt | 11 +- .../base/src/main/kotlin/renderers/FileWriter.kt | 79 ++++++++++++++ .../base/src/main/kotlin/renderers/OutputWriter.kt | 7 ++ .../src/main/kotlin/renderers/html/HtmlRenderer.kt | 3 +- .../main/kotlin/renderers/html/NavigationPage.kt | 2 +- .../kotlin/renderers/html/htmlPreprocessors.kt | 2 +- .../kotlin/resolvers/DefaultLocationProvider.kt | 116 ++++++++++++++++++++ .../resolvers/DefaultLocationProviderFactory.kt | 9 ++ .../kotlin/resolvers/ExternalLocationProvider.kt | 99 +++++++++++++++++ .../src/main/kotlin/resolvers/LocationProvider.kt | 19 ++++ 19 files changed, 353 insertions(+), 354 deletions(-) delete mode 100644 core/src/main/kotlin/renderers/FileWriter.kt delete mode 100644 core/src/main/kotlin/renderers/OutputWriter.kt delete mode 100644 core/src/main/kotlin/resolvers/DefaultLocationProvider.kt delete mode 100644 core/src/main/kotlin/resolvers/ExternalLocationProvider.kt delete mode 100644 core/src/main/kotlin/resolvers/LocationProvider.kt delete mode 100644 core/src/main/kotlin/resolvers/LocationProviderFactory.kt create mode 100644 plugins/base/src/main/kotlin/renderers/FileWriter.kt create mode 100644 plugins/base/src/main/kotlin/renderers/OutputWriter.kt create mode 100644 plugins/base/src/main/kotlin/resolvers/DefaultLocationProvider.kt create mode 100644 plugins/base/src/main/kotlin/resolvers/DefaultLocationProviderFactory.kt create mode 100644 plugins/base/src/main/kotlin/resolvers/ExternalLocationProvider.kt create mode 100644 plugins/base/src/main/kotlin/resolvers/LocationProvider.kt (limited to 'plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt') diff --git a/core/src/main/kotlin/CoreExtensions.kt b/core/src/main/kotlin/CoreExtensions.kt index 859e850e..c8314f4d 100644 --- a/core/src/main/kotlin/CoreExtensions.kt +++ b/core/src/main/kotlin/CoreExtensions.kt @@ -2,8 +2,6 @@ package org.jetbrains.dokka import org.jetbrains.dokka.plugability.ExtensionPoint import org.jetbrains.dokka.renderers.Renderer -import org.jetbrains.dokka.renderers.OutputWriter -import org.jetbrains.dokka.resolvers.LocationProviderFactory import org.jetbrains.dokka.transformers.descriptors.DescriptorToDocumentationTranslator import org.jetbrains.dokka.transformers.documentation.DocumentableMerger import org.jetbrains.dokka.transformers.documentation.DocumentationNodeTransformer @@ -26,9 +24,6 @@ object CoreExtensions { val pageTransformer by coreExtension() val renderer by coreExtension() - val locationProviderFactory by coreExtension() - val outputWriter by coreExtension() - private fun coreExtension() = object { operator fun provideDelegate(thisRef: CoreExtensions, property: KProperty<*>): Lazy> = lazy { ExtensionPoint(thisRef::class.qualifiedName!!, property.name) } diff --git a/core/src/main/kotlin/plugability/DefaultExtensions.kt b/core/src/main/kotlin/plugability/DefaultExtensions.kt index 242eb6b8..798e0f1a 100644 --- a/core/src/main/kotlin/plugability/DefaultExtensions.kt +++ b/core/src/main/kotlin/plugability/DefaultExtensions.kt @@ -1,20 +1,13 @@ package org.jetbrains.dokka.plugability import org.jetbrains.dokka.CoreExtensions -import org.jetbrains.dokka.renderers.FileWriter -import org.jetbrains.dokka.renderers.OutputWriter -import org.jetbrains.dokka.resolvers.DefaultLocationProviderFactory internal object DefaultExtensions { - private val providerFactory: LazyEvaluated = LazyEvaluated.fromRecipe { DefaultLocationProviderFactory(it) } - private val outputWriter: LazyEvaluated = LazyEvaluated.fromRecipe { FileWriter(it) } @Suppress("IMPLICIT_CAST_TO_ANY", "UNCHECKED_CAST") internal fun > get(point: E, fullContext: DokkaContext): List = when (point) { - CoreExtensions.locationProviderFactory -> providerFactory.get(fullContext) - CoreExtensions.outputWriter -> outputWriter.get(fullContext) else -> null }.let { listOfNotNull( it ) as List } } \ No newline at end of file diff --git a/core/src/main/kotlin/renderers/FileWriter.kt b/core/src/main/kotlin/renderers/FileWriter.kt deleted file mode 100644 index 727a8d21..00000000 --- a/core/src/main/kotlin/renderers/FileWriter.kt +++ /dev/null @@ -1,78 +0,0 @@ -package org.jetbrains.dokka.renderers - -import org.jetbrains.dokka.plugability.DokkaContext -import java.io.File -import java.io.IOException -import java.net.URI -import java.nio.file.* - -class FileWriter(val context: DokkaContext): OutputWriter { - private val createdFiles: MutableSet = mutableSetOf() - private val jarUriPrefix = "jar:file:" - private val root = context.configuration.outputDir - - override fun write(path: String, text: String, ext: String) { - if (createdFiles.contains(path)) { - context.logger.error("An attempt to write ${root}/$path several times!") - return - } - createdFiles.add(path) - - try { - val dir = Paths.get(root, path.dropLastWhile { it != '/' }).toFile() - dir.mkdirsOrFail() - Files.write(Paths.get(root, "$path$ext"), text.lines()) - } catch (e: Throwable) { - context.logger.error("Failed to write $this. ${e.message}") - e.printStackTrace() - } - } - - override fun writeResources(pathFrom: String, pathTo: String) = - if (javaClass.getResource(pathFrom).toURI().toString().startsWith(jarUriPrefix)) { - copyFromJar(pathFrom, pathTo) - } else { - copyFromDirectory(pathFrom, pathTo) - } - - - private fun copyFromDirectory(pathFrom: String, pathTo: String) { - val dest = Paths.get(root, pathTo).toFile() - val uri = javaClass.getResource(pathFrom).toURI() - File(uri).copyRecursively(dest, true) - } - - private fun copyFromJar(pathFrom: String, pathTo: String) { - val rebase = fun(path: String) = - "$pathTo/${path.removePrefix(pathFrom)}" - val dest = Paths.get(root, pathTo).toFile() - dest.mkdirsOrFail() - val uri = javaClass.getResource(pathFrom).toURI() - val fs = getFileSystemForURI(uri) - val path = fs.getPath(pathFrom) - for (file in Files.walk(path).iterator()) { - if (Files.isDirectory(file)) { - val dirPath = file.toAbsolutePath().toString() - Paths.get(root, rebase(dirPath)).toFile().mkdirsOrFail() - } else { - val filePath = file.toAbsolutePath().toString() - Paths.get(root, rebase(filePath)).toFile().writeBytes( - javaClass.getResourceAsStream(filePath).readBytes() - ) - } - } - } - - private fun File.mkdirsOrFail() { - if (!mkdirs() && !exists()) { - throw IOException("Failed to create directory $this") - } - } - - private fun getFileSystemForURI(uri: URI): FileSystem = - try { - FileSystems.newFileSystem(uri, emptyMap()) - } catch (e: FileSystemAlreadyExistsException) { - FileSystems.getFileSystem(uri) - } -} \ No newline at end of file diff --git a/core/src/main/kotlin/renderers/OutputWriter.kt b/core/src/main/kotlin/renderers/OutputWriter.kt deleted file mode 100644 index e317f8ef..00000000 --- a/core/src/main/kotlin/renderers/OutputWriter.kt +++ /dev/null @@ -1,7 +0,0 @@ -package org.jetbrains.dokka.renderers - -interface OutputWriter { - - fun write(path: String, text: String, ext: String) - fun writeResources(pathFrom: String, pathTo: String) -} \ No newline at end of file diff --git a/core/src/main/kotlin/resolvers/DefaultLocationProvider.kt b/core/src/main/kotlin/resolvers/DefaultLocationProvider.kt deleted file mode 100644 index 65d2f794..00000000 --- a/core/src/main/kotlin/resolvers/DefaultLocationProvider.kt +++ /dev/null @@ -1,121 +0,0 @@ -package org.jetbrains.dokka.resolvers - -import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.pages.* -import org.jetbrains.dokka.plugability.DokkaContext -import org.jetbrains.dokka.utilities.htmlEscape -import java.util.* - -private const val PAGE_WITH_CHILDREN_SUFFIX = "index" - -open class DefaultLocationProvider( - protected val pageGraphRoot: RootPageNode, - protected val dokkaContext: DokkaContext -) : LocationProvider { - protected val extension = ".html" - - protected val pagesIndex: Map = pageGraphRoot.asSequence().filterIsInstance() - .map { it.dri.map { dri -> dri to it } }.flatten() - .groupingBy { it.first } - .aggregate { dri, _, (_, page), first -> - if (first) page else throw AssertionError("Multiple pages associated with dri: $dri") - } - - protected val pathsIndex: Map> = IdentityHashMap>().apply { - fun registerPath(page: PageNode, prefix: List) { - val newPrefix = prefix + page.pathName - put(page, newPrefix) - page.children.forEach { registerPath(it, newPrefix) } - } - put(pageGraphRoot, emptyList()) - pageGraphRoot.children.forEach { registerPath(it, emptyList()) } - } - - override fun resolve(node: PageNode, context: PageNode?, skipExtension: Boolean): String = - pathTo(node, context) + if (!skipExtension) extension else "" - - override fun resolve(dri: DRI, platforms: List, context: PageNode?): String = - pagesIndex[dri]?.let { resolve(it, context) } ?: - // Not found in PageGraph, that means it's an external link - ExternalLocationProvider.getLocation(dri, - this.dokkaContext.configuration.passesConfigurations - .filter { passConfig -> - platforms.toSet() - .contains(PlatformData(passConfig.moduleName, passConfig.analysisPlatform, passConfig.targets)) - } // TODO: change targets to something better? - .flatMap { it.externalDocumentationLinks }.distinct() - ) - - override fun resolveRoot(node: PageNode): String = - pathTo(pageGraphRoot, node).removeSuffix(PAGE_WITH_CHILDREN_SUFFIX) - - override fun ancestors(node: PageNode): List = - generateSequence(node) { it.parent() }.toList() - - protected open fun pathTo(node: PageNode, context: PageNode?): String { - fun pathFor(page: PageNode) = pathsIndex[page] ?: throw AssertionError( - "${page::class.simpleName}(${page.name}) does not belong to current page graph so it is impossible to compute its path" - ) - - val contextNode = - if (context?.children?.isEmpty() == true && context.parent() != null) context.parent() else context - val nodePath = pathFor(node) - val contextPath = contextNode?.let { pathFor(it) }.orEmpty() - - val commonPathElements = nodePath.asSequence().zip(contextPath.asSequence()) - .takeWhile { (a, b) -> a == b }.count() - - return (List(contextPath.size - commonPathElements) { ".." } + nodePath.drop(commonPathElements) + - if (node.children.isNotEmpty()) listOf(PAGE_WITH_CHILDREN_SUFFIX) else emptyList()).joinToString("/") - } - - private fun PageNode.parent() = pageGraphRoot.parentMap[this] -} - -fun DRI.toJavadocLocation(jdkVersion: Int): String { // TODO: classes without packages? - val packageLink = packageName?.replace(".", "/") - if (classNames == null) { - return "$packageLink/package-summary.html".htmlEscape() - } - val classLink = if (packageLink == null) "$classNames.html" else "$packageLink/$classNames.html" - if (callable == null) { - return classLink.htmlEscape() - } - - val callableLink = "$classLink#${callable.name}" + when { - jdkVersion < 8 -> "(${callable.params.joinToString(", ")})" - jdkVersion < 10 -> "-${callable.params.joinToString("-")}-" - else -> "(${callable.params.joinToString(",")})" - } - - return callableLink.htmlEscape() -} - -fun DRI.toDokkaLocation(extension: String): String { // TODO: classes without packages? - if (classNames == null) { - return "$packageName/index$extension" - } - val classLink = if (packageName == null) { - "" - } else { - "$packageName/" - } + classNames.split('.').joinToString("/", transform = ::identifierToFilename) - - if (callable == null) { - return "$classLink/index$extension" - } - - return "$classLink/${identifierToFilename(callable.name)}$extension" -} - -private val reservedFilenames = setOf("index", "con", "aux", "lst", "prn", "nul", "eof", "inp", "out") - -private fun identifierToFilename(name: String): String { - if (name.isEmpty()) return "--root--" - val escaped = name.replace('<', '-').replace('>', '-') - val lowercase = escaped.replace("[A-Z]".toRegex()) { matchResult -> "-" + matchResult.value.toLowerCase() } - return if (lowercase in reservedFilenames) "--$lowercase--" else lowercase -} - -private val PageNode.pathName: String - get() = if (this is PackagePageNode) name else identifierToFilename(name) diff --git a/core/src/main/kotlin/resolvers/ExternalLocationProvider.kt b/core/src/main/kotlin/resolvers/ExternalLocationProvider.kt deleted file mode 100644 index d3d8fa0d..00000000 --- a/core/src/main/kotlin/resolvers/ExternalLocationProvider.kt +++ /dev/null @@ -1,99 +0,0 @@ -package org.jetbrains.dokka.resolvers - -import org.jetbrains.dokka.DokkaConfiguration.ExternalDocumentationLink -import org.jetbrains.dokka.links.DRI -import java.net.HttpURLConnection -import java.net.URL -import java.net.URLConnection - -object ExternalLocationProvider { // TODO: Refactor this!!! - private const val DOKKA_PARAM_PREFIX = "\$dokka." - - private val cache: MutableMap = mutableMapOf() - - fun getLocation(dri: DRI, externalDocumentationLinks: List): String { - val toResolve: MutableList = mutableListOf() - for(link in externalDocumentationLinks){ - val info = cache[link.packageListUrl] - if(info == null) { - toResolve.add(link) - } else if(info.packages.contains(dri.packageName)) { - return link.url.toExternalForm() + getLink(dri, info) - } - } - // Not in cache, resolve packageLists - while (toResolve.isNotEmpty()){ - val link = toResolve.first().also { toResolve.remove(it) } - val locationInfo = loadPackageList(link.packageListUrl) - if(locationInfo.packages.contains(dri.packageName)) { - return link.url.toExternalForm() + getLink(dri, locationInfo) - } - } - return "" - } - - private fun getLink(dri: DRI, locationInfo: LocationInfo): String = when(locationInfo.format) { - "javadoc" -> dri.toJavadocLocation(8) - "kotlin-website-html", "html" -> locationInfo.locations[dri.packageName + "." + dri.classNames] ?: dri.toDokkaLocation(".html") - "markdown" -> locationInfo.locations[dri.packageName + "." + dri.classNames] ?: dri.toDokkaLocation(".md") - // TODO: rework this - else -> throw RuntimeException("Unrecognized format") - } - - - private fun loadPackageList(url: URL): LocationInfo { - val packageListStream = url.doOpenConnectionToReadContent().getInputStream() - val (params, packages) = - packageListStream - .bufferedReader() - .useLines { lines -> lines.partition { it.startsWith(DOKKA_PARAM_PREFIX) } } - - val paramsMap = params.asSequence() - .map { it.removePrefix(DOKKA_PARAM_PREFIX).split(":", limit = 2) } - .groupBy({ (key, _) -> key }, { (_, value) -> value }) - - val format = paramsMap["format"]?.singleOrNull() ?: "javadoc" - - val locations = paramsMap["location"].orEmpty() - .map { it.split("\u001f", limit = 2) } - .map { (key, value) -> key to value } - .toMap() - - val info = LocationInfo(format, packages.toSet(), locations) - cache[url] = info - return info - } - - private fun URL.doOpenConnectionToReadContent(timeout: Int = 10000, redirectsAllowed: Int = 16): URLConnection { - val connection = this.openConnection().apply { - connectTimeout = timeout - readTimeout = timeout - } - - when (connection) { - is HttpURLConnection -> { - return when (connection.responseCode) { - in 200..299 -> { - connection - } - HttpURLConnection.HTTP_MOVED_PERM, - HttpURLConnection.HTTP_MOVED_TEMP, - HttpURLConnection.HTTP_SEE_OTHER -> { - if (redirectsAllowed > 0) { - val newUrl = connection.getHeaderField("Location") - URL(newUrl).doOpenConnectionToReadContent(timeout, redirectsAllowed - 1) - } else { - throw RuntimeException("Too many redirects") - } - } - else -> { - throw RuntimeException("Unhandled http code: ${connection.responseCode}") - } - } - } - else -> return connection - } - } - data class LocationInfo(val format: String, val packages: Set, val locations: Map) - -} diff --git a/core/src/main/kotlin/resolvers/LocationProvider.kt b/core/src/main/kotlin/resolvers/LocationProvider.kt deleted file mode 100644 index 3bc9ab72..00000000 --- a/core/src/main/kotlin/resolvers/LocationProvider.kt +++ /dev/null @@ -1,13 +0,0 @@ -package org.jetbrains.dokka.resolvers - -import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.pages.ContentPage -import org.jetbrains.dokka.pages.PageNode -import org.jetbrains.dokka.pages.PlatformData - -interface LocationProvider { - fun resolve(dri: DRI, platforms: List, context: PageNode? = null): String - fun resolve(node: PageNode, context: PageNode? = null, skipExtension: Boolean = false): String - fun resolveRoot(node: PageNode): String - fun ancestors(node: PageNode): List -} diff --git a/core/src/main/kotlin/resolvers/LocationProviderFactory.kt b/core/src/main/kotlin/resolvers/LocationProviderFactory.kt deleted file mode 100644 index 782795de..00000000 --- a/core/src/main/kotlin/resolvers/LocationProviderFactory.kt +++ /dev/null @@ -1,14 +0,0 @@ -package org.jetbrains.dokka.resolvers - -import org.jetbrains.dokka.pages.ModulePageNode -import org.jetbrains.dokka.pages.RootPageNode -import org.jetbrains.dokka.plugability.DokkaContext - -interface LocationProviderFactory { - fun getLocationProvider(pageNode: RootPageNode): LocationProvider -} - -class DefaultLocationProviderFactory(val context: DokkaContext) : LocationProviderFactory { - - override fun getLocationProvider(pageNode: RootPageNode) = DefaultLocationProvider(pageNode, context) -} \ No newline at end of file diff --git a/plugins/base/src/main/kotlin/DokkaBase.kt b/plugins/base/src/main/kotlin/DokkaBase.kt index 9b6e9b1a..fd842dc0 100644 --- a/plugins/base/src/main/kotlin/DokkaBase.kt +++ b/plugins/base/src/main/kotlin/DokkaBase.kt @@ -1,6 +1,11 @@ package org.jetbrains.dokka.base import org.jetbrains.dokka.CoreExtensions +import org.jetbrains.dokka.base.renderers.FileWriter +import org.jetbrains.dokka.base.renderers.OutputWriter +import org.jetbrains.dokka.base.renderers.html.HtmlRenderer +import org.jetbrains.dokka.base.resolvers.DefaultLocationProviderFactory +import org.jetbrains.dokka.base.resolvers.LocationProviderFactory import org.jetbrains.dokka.base.transformers.descriptors.DefaultDescriptorToDocumentationTranslator import org.jetbrains.dokka.base.transformers.documentables.DefaultDocumentableMerger import org.jetbrains.dokka.base.transformers.documentables.DefaultDocumentablesToPageTranslator @@ -12,11 +17,12 @@ import org.jetbrains.dokka.base.transformers.pages.merger.PageNodeMerger import org.jetbrains.dokka.base.transformers.pages.merger.SameMethodNamePageMergerStrategy import org.jetbrains.dokka.base.transformers.psi.DefaultPsiToDocumentationTranslator import org.jetbrains.dokka.plugability.DokkaPlugin -import org.jetbrains.dokka.renderers.html.HtmlRenderer class DokkaBase : DokkaPlugin() { val pageMergerStrategy by extensionPoint() val commentsToContentConverter by extensionPoint() + val locationproviderFactory by extensionPoint() + val outputWriter by extensionPoint() val descriptorToDocumentationTranslator by extending(isFallback = true) { CoreExtensions.descriptorToDocumentationTranslator providing ::DefaultDescriptorToDocumentationTranslator @@ -57,4 +63,12 @@ class DokkaBase : DokkaPlugin() { val htmlRenderer by extending { CoreExtensions.renderer providing ::HtmlRenderer applyIf { format == "html" } } + + val locationProvider by extending(isFallback = true) { + locationproviderFactory providing ::DefaultLocationProviderFactory + } + + val fileWriter by extending(isFallback = true) { + outputWriter providing ::FileWriter + } } \ No newline at end of file diff --git a/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt b/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt index c6183cf3..951545d2 100644 --- a/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt @@ -1,18 +1,19 @@ package org.jetbrains.dokka.base.renderers -import org.jetbrains.dokka.CoreExtensions +import org.jetbrains.dokka.base.DokkaBase +import org.jetbrains.dokka.base.resolvers.LocationProvider import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.plugability.DokkaContext -import org.jetbrains.dokka.renderers.OutputWriter +import org.jetbrains.dokka.plugability.plugin +import org.jetbrains.dokka.plugability.querySingle import org.jetbrains.dokka.renderers.Renderer -import org.jetbrains.dokka.resolvers.LocationProvider import org.jetbrains.dokka.transformers.pages.PageNodeTransformer abstract class DefaultRenderer( protected val context: DokkaContext ) : Renderer { - protected val outputWriter = context.single(CoreExtensions.outputWriter) + protected val outputWriter = context.plugin().querySingle { outputWriter } protected lateinit var locationProvider: LocationProvider private set @@ -116,7 +117,7 @@ abstract class DefaultRenderer( val newRoot = preprocessors.fold(root) { acc, t -> t(acc) } locationProvider = - context.single(CoreExtensions.locationProviderFactory).getLocationProvider(newRoot) + context.plugin().querySingle { locationproviderFactory }.getLocationProvider(newRoot) root.children().forEach { renderPackageList(it) } diff --git a/plugins/base/src/main/kotlin/renderers/FileWriter.kt b/plugins/base/src/main/kotlin/renderers/FileWriter.kt new file mode 100644 index 00000000..5d3067fc --- /dev/null +++ b/plugins/base/src/main/kotlin/renderers/FileWriter.kt @@ -0,0 +1,79 @@ +package org.jetbrains.dokka.base.renderers + +import org.jetbrains.dokka.plugability.DokkaContext +import org.jetbrains.dokka.renderers.OutputWriter +import java.io.File +import java.io.IOException +import java.net.URI +import java.nio.file.* + +class FileWriter(val context: DokkaContext): OutputWriter { + private val createdFiles: MutableSet = mutableSetOf() + private val jarUriPrefix = "jar:file:" + private val root = context.configuration.outputDir + + override fun write(path: String, text: String, ext: String) { + if (createdFiles.contains(path)) { + context.logger.error("An attempt to write ${root}/$path several times!") + return + } + createdFiles.add(path) + + try { + val dir = Paths.get(root, path.dropLastWhile { it != '/' }).toFile() + dir.mkdirsOrFail() + Files.write(Paths.get(root, "$path$ext"), text.lines()) + } catch (e: Throwable) { + context.logger.error("Failed to write $this. ${e.message}") + e.printStackTrace() + } + } + + override fun writeResources(pathFrom: String, pathTo: String) = + if (javaClass.getResource(pathFrom).toURI().toString().startsWith(jarUriPrefix)) { + copyFromJar(pathFrom, pathTo) + } else { + copyFromDirectory(pathFrom, pathTo) + } + + + private fun copyFromDirectory(pathFrom: String, pathTo: String) { + val dest = Paths.get(root, pathTo).toFile() + val uri = javaClass.getResource(pathFrom).toURI() + File(uri).copyRecursively(dest, true) + } + + private fun copyFromJar(pathFrom: String, pathTo: String) { + val rebase = fun(path: String) = + "$pathTo/${path.removePrefix(pathFrom)}" + val dest = Paths.get(root, pathTo).toFile() + dest.mkdirsOrFail() + val uri = javaClass.getResource(pathFrom).toURI() + val fs = getFileSystemForURI(uri) + val path = fs.getPath(pathFrom) + for (file in Files.walk(path).iterator()) { + if (Files.isDirectory(file)) { + val dirPath = file.toAbsolutePath().toString() + Paths.get(root, rebase(dirPath)).toFile().mkdirsOrFail() + } else { + val filePath = file.toAbsolutePath().toString() + Paths.get(root, rebase(filePath)).toFile().writeBytes( + javaClass.getResourceAsStream(filePath).readBytes() + ) + } + } + } + + private fun File.mkdirsOrFail() { + if (!mkdirs() && !exists()) { + throw IOException("Failed to create directory $this") + } + } + + private fun getFileSystemForURI(uri: URI): FileSystem = + try { + FileSystems.newFileSystem(uri, emptyMap()) + } catch (e: FileSystemAlreadyExistsException) { + FileSystems.getFileSystem(uri) + } +} \ No newline at end of file diff --git a/plugins/base/src/main/kotlin/renderers/OutputWriter.kt b/plugins/base/src/main/kotlin/renderers/OutputWriter.kt new file mode 100644 index 00000000..a6fda51a --- /dev/null +++ b/plugins/base/src/main/kotlin/renderers/OutputWriter.kt @@ -0,0 +1,7 @@ +package org.jetbrains.dokka.base.renderers + +interface OutputWriter { + + fun write(path: String, text: String, ext: String) + fun writeResources(pathFrom: String, pathTo: String) +} \ No newline at end of file diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt index c9270681..8bf00043 100644 --- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt @@ -1,4 +1,4 @@ -package org.jetbrains.dokka.renderers.html +package org.jetbrains.dokka.base.renderers.html import kotlinx.html.* import kotlinx.html.stream.createHTML @@ -7,7 +7,6 @@ import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.Function import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.plugability.DokkaContext -import org.jetbrains.dokka.renderers.OutputWriter import java.io.File open class HtmlRenderer( diff --git a/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt b/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt index 4a2fb40d..ad574769 100644 --- a/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt +++ b/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt @@ -1,4 +1,4 @@ -package org.jetbrains.dokka.renderers.html +package org.jetbrains.dokka.base.renderers.html import kotlinx.html.* import kotlinx.html.stream.createHTML diff --git a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt index 09164d97..ecd2e89a 100644 --- a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt +++ b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt @@ -1,4 +1,4 @@ -package org.jetbrains.dokka.renderers.html +package org.jetbrains.dokka.base.renderers.html import kotlinx.html.h1 import kotlinx.html.id diff --git a/plugins/base/src/main/kotlin/resolvers/DefaultLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/DefaultLocationProvider.kt new file mode 100644 index 00000000..2238b0c3 --- /dev/null +++ b/plugins/base/src/main/kotlin/resolvers/DefaultLocationProvider.kt @@ -0,0 +1,116 @@ +package org.jetbrains.dokka.base.resolvers + +import org.jetbrains.dokka.links.DRI +import org.jetbrains.dokka.pages.* +import org.jetbrains.dokka.plugability.DokkaContext +import org.jetbrains.dokka.utilities.htmlEscape +import java.util.* + +private const val PAGE_WITH_CHILDREN_SUFFIX = "index" + +open class DefaultLocationProvider( + protected val pageGraphRoot: RootPageNode, + protected val dokkaContext: DokkaContext +) : LocationProvider { + protected val extension = ".html" + + protected val pagesIndex: Map = pageGraphRoot.asSequence().filterIsInstance() + .map { it.dri.map { dri -> dri to it } }.flatten() + .groupingBy { it.first } + .aggregate { dri, _, (_, page), first -> + if (first) page else throw AssertionError("Multiple pages associated with dri: $dri") + } + + protected val pathsIndex: Map> = IdentityHashMap>().apply { + fun registerPath(page: PageNode, prefix: List) { + val newPrefix = prefix + page.pathName + put(page, newPrefix) + page.children.forEach { registerPath(it, newPrefix) } + } + put(pageGraphRoot, emptyList()) + pageGraphRoot.children.forEach { registerPath(it, emptyList()) } + } + + override fun resolve(node: PageNode, context: PageNode?, skipExtension: Boolean): String = + pathTo(node, context) + if (!skipExtension) extension else "" + + override fun resolve(dri: DRI, platforms: List, context: PageNode?): String = + pagesIndex[dri]?.let { resolve(it, context) } ?: + // Not found in PageGraph, that means it's an external link + ExternalLocationProvider.getLocation(dri, + this.dokkaContext.configuration.passesConfigurations + .filter { passConfig -> + platforms.toSet() + .contains(PlatformData(passConfig.moduleName, passConfig.analysisPlatform, passConfig.targets)) + } // TODO: change targets to something better? + .flatMap { it.externalDocumentationLinks }.distinct() + ) + + override fun resolveRoot(node: PageNode): String = + pathTo(pageGraphRoot, node).removeSuffix(PAGE_WITH_CHILDREN_SUFFIX) + + override fun ancestors(node: PageNode): List = + generateSequence(node) { it.parent() }.toList() + + protected open fun pathTo(node: PageNode, context: PageNode?): String { + fun pathFor(page: PageNode) = pathsIndex[page] ?: throw AssertionError( + "${page::class.simpleName}(${page.name}) does not belong to current page graph so it is impossible to compute its path" + ) + + val contextNode = + if (context?.children?.isEmpty() == true && context.parent() != null) context.parent() else context + val nodePath = pathFor(node) + val contextPath = contextNode?.let { pathFor(it) }.orEmpty() + + val commonPathElements = nodePath.asSequence().zip(contextPath.asSequence()) + .takeWhile { (a, b) -> a == b }.count() + + return (List(contextPath.size - commonPathElements) { ".." } + nodePath.drop(commonPathElements) + + if (node.children.isNotEmpty()) listOf(PAGE_WITH_CHILDREN_SUFFIX) else emptyList()).joinToString("/") + } + + private fun PageNode.parent() = pageGraphRoot.parentMap[this] +} + +fun DRI.toJavadocLocation(jdkVersion: Int): String { // TODO: classes without packages? + val packageLink = packageName?.replace(".", "/") + if (classNames == null) { + return "$packageLink/package-summary.html".htmlEscape() + } + val classLink = if (packageLink == null) "$classNames.html" else "$packageLink/$classNames.html" + val callableChecked = callable ?: return classLink.htmlEscape() + + val callableLink = "$classLink#${callableChecked.name}" + when { + jdkVersion < 8 -> "(${callableChecked.params.joinToString(", ")})" + jdkVersion < 10 -> "-${callableChecked.params.joinToString("-")}-" + else -> "(${callableChecked.params.joinToString(",")})" + } + + return callableLink.htmlEscape() +} + +fun DRI.toDokkaLocation(extension: String): String { // TODO: classes without packages? + val classNamesChecked = classNames ?: return "$packageName/index$extension" + + val classLink = if (packageName == null) { + "" + } else { + "$packageName/" + } + classNamesChecked.split('.').joinToString("/", transform = ::identifierToFilename) + + val callableChecked = callable ?: return "$classLink/index$extension" + + return "$classLink/${identifierToFilename(callableChecked.name)}$extension" +} + +private val reservedFilenames = setOf("index", "con", "aux", "lst", "prn", "nul", "eof", "inp", "out") + +private fun identifierToFilename(name: String): String { + if (name.isEmpty()) return "--root--" + val escaped = name.replace('<', '-').replace('>', '-') + val lowercase = escaped.replace("[A-Z]".toRegex()) { matchResult -> "-" + matchResult.value.toLowerCase() } + return if (lowercase in reservedFilenames) "--$lowercase--" else lowercase +} + +private val PageNode.pathName: String + get() = if (this is PackagePageNode) name else identifierToFilename(name) diff --git a/plugins/base/src/main/kotlin/resolvers/DefaultLocationProviderFactory.kt b/plugins/base/src/main/kotlin/resolvers/DefaultLocationProviderFactory.kt new file mode 100644 index 00000000..c649e22b --- /dev/null +++ b/plugins/base/src/main/kotlin/resolvers/DefaultLocationProviderFactory.kt @@ -0,0 +1,9 @@ +package org.jetbrains.dokka.base.resolvers + +import org.jetbrains.dokka.pages.RootPageNode +import org.jetbrains.dokka.plugability.DokkaContext + +class DefaultLocationProviderFactory(private val context: DokkaContext) : LocationProviderFactory { + + override fun getLocationProvider(pageNode: RootPageNode) = DefaultLocationProvider(pageNode, context) +} \ No newline at end of file diff --git a/plugins/base/src/main/kotlin/resolvers/ExternalLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/ExternalLocationProvider.kt new file mode 100644 index 00000000..7c0e9952 --- /dev/null +++ b/plugins/base/src/main/kotlin/resolvers/ExternalLocationProvider.kt @@ -0,0 +1,99 @@ +package org.jetbrains.dokka.base.resolvers + +import org.jetbrains.dokka.DokkaConfiguration.ExternalDocumentationLink +import org.jetbrains.dokka.links.DRI +import java.net.HttpURLConnection +import java.net.URL +import java.net.URLConnection + +object ExternalLocationProvider { // TODO: Refactor this!!! + private const val DOKKA_PARAM_PREFIX = "\$dokka." + + private val cache: MutableMap = mutableMapOf() + + fun getLocation(dri: DRI, externalDocumentationLinks: List): String { + val toResolve: MutableList = mutableListOf() + for(link in externalDocumentationLinks){ + val info = cache[link.packageListUrl] + if(info == null) { + toResolve.add(link) + } else if(info.packages.contains(dri.packageName)) { + return link.url.toExternalForm() + getLink(dri, info) + } + } + // Not in cache, resolve packageLists + while (toResolve.isNotEmpty()){ + val link = toResolve.first().also { toResolve.remove(it) } + val locationInfo = loadPackageList(link.packageListUrl) + if(locationInfo.packages.contains(dri.packageName)) { + return link.url.toExternalForm() + getLink(dri, locationInfo) + } + } + return "" + } + + private fun getLink(dri: DRI, locationInfo: LocationInfo): String = when(locationInfo.format) { + "javadoc" -> dri.toJavadocLocation(8) + "kotlin-website-html", "html" -> locationInfo.locations[dri.packageName + "." + dri.classNames] ?: dri.toDokkaLocation(".html") + "markdown" -> locationInfo.locations[dri.packageName + "." + dri.classNames] ?: dri.toDokkaLocation(".md") + // TODO: rework this + else -> throw RuntimeException("Unrecognized format") + } + + + private fun loadPackageList(url: URL): LocationInfo { + val packageListStream = url.doOpenConnectionToReadContent().getInputStream() + val (params, packages) = + packageListStream + .bufferedReader() + .useLines { lines -> lines.partition { it.startsWith(DOKKA_PARAM_PREFIX) } } + + val paramsMap = params.asSequence() + .map { it.removePrefix(DOKKA_PARAM_PREFIX).split(":", limit = 2) } + .groupBy({ (key, _) -> key }, { (_, value) -> value }) + + val format = paramsMap["format"]?.singleOrNull() ?: "javadoc" + + val locations = paramsMap["location"].orEmpty() + .map { it.split("\u001f", limit = 2) } + .map { (key, value) -> key to value } + .toMap() + + val info = LocationInfo(format, packages.toSet(), locations) + cache[url] = info + return info + } + + private fun URL.doOpenConnectionToReadContent(timeout: Int = 10000, redirectsAllowed: Int = 16): URLConnection { + val connection = this.openConnection().apply { + connectTimeout = timeout + readTimeout = timeout + } + + when (connection) { + is HttpURLConnection -> { + return when (connection.responseCode) { + in 200..299 -> { + connection + } + HttpURLConnection.HTTP_MOVED_PERM, + HttpURLConnection.HTTP_MOVED_TEMP, + HttpURLConnection.HTTP_SEE_OTHER -> { + if (redirectsAllowed > 0) { + val newUrl = connection.getHeaderField("Location") + URL(newUrl).doOpenConnectionToReadContent(timeout, redirectsAllowed - 1) + } else { + throw RuntimeException("Too many redirects") + } + } + else -> { + throw RuntimeException("Unhandled http code: ${connection.responseCode}") + } + } + } + else -> return connection + } + } + data class LocationInfo(val format: String, val packages: Set, val locations: Map) + +} diff --git a/plugins/base/src/main/kotlin/resolvers/LocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/LocationProvider.kt new file mode 100644 index 00000000..13f4563c --- /dev/null +++ b/plugins/base/src/main/kotlin/resolvers/LocationProvider.kt @@ -0,0 +1,19 @@ +package org.jetbrains.dokka.base.resolvers + +import org.jetbrains.dokka.links.DRI +import org.jetbrains.dokka.pages.ContentPage +import org.jetbrains.dokka.pages.PageNode +import org.jetbrains.dokka.pages.PlatformData +import org.jetbrains.dokka.pages.RootPageNode + +interface LocationProvider { + fun resolve(dri: DRI, platforms: List, context: PageNode? = null): String + fun resolve(node: PageNode, context: PageNode? = null, skipExtension: Boolean = false): String + fun resolveRoot(node: PageNode): String + fun ancestors(node: PageNode): List +} + +interface LocationProviderFactory { + fun getLocationProvider(pageNode: RootPageNode): LocationProvider +} + -- cgit From bee52be815bebd7012193728521636b5fbed2829 Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Tue, 18 Feb 2020 17:47:14 +0100 Subject: Rename extensions to make them more uniform --- core/src/main/kotlin/CoreExtensions.kt | 20 +- core/src/main/kotlin/DokkaGenerator.kt | 8 +- .../DescriptorToDocumentableTranslator.kt | 13 + .../DescriptorToDocumentationTranslator.kt | 14 - .../documentation/DocumentableToPageTranslator.kt | 8 + .../documentation/DocumentableTransformer.kt | 8 + .../documentation/DocumentablesToPageTranslator.kt | 9 - .../documentation/DocumentationNodeTransformer.kt | 8 - .../transformers/pages/PageNodeTransformer.kt | 9 - .../kotlin/transformers/pages/PageTransformer.kt | 7 + .../psi/PsiToDocumentableTranslator.kt | 15 + .../psi/PsiToDocumentationTranslator.kt | 15 - plugins/base/src/main/kotlin/DokkaBase.kt | 24 +- .../src/main/kotlin/renderers/DefaultRenderer.kt | 4 +- .../kotlin/renderers/html/htmlPreprocessors.kt | 12 +- .../kotlin/transformers/pages/merger/PageMerger.kt | 29 ++ .../transformers/pages/merger/PageNodeMerger.kt | 29 -- .../psi/DefaultPsiToDocumentableTranslator.kt | 145 +++++++++ .../psi/DefaultPsiToDocumentationTranslator.kt | 145 --------- .../DefaultDescriptorToDocumentableTranslator.kt | 335 +++++++++++++++++++++ .../DefaultDescriptorToDocumentationTranslator.kt | 335 --------------------- .../DefaultDocumentableToPageTranslator.kt | 25 ++ .../DefaultDocumentablesToPageTranslator.kt | 25 -- ...tlinAsJavaDescriptorToDocumentableTranslator.kt | 76 +++++ ...linAsJavaDescriptorToDocumentationTranslator.kt | 76 ----- .../src/main/kotlin/KotlinAsJavaPlugin.kt | 15 +- plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt | 7 +- 27 files changed, 706 insertions(+), 710 deletions(-) create mode 100644 core/src/main/kotlin/transformers/descriptors/DescriptorToDocumentableTranslator.kt delete mode 100644 core/src/main/kotlin/transformers/descriptors/DescriptorToDocumentationTranslator.kt create mode 100644 core/src/main/kotlin/transformers/documentation/DocumentableToPageTranslator.kt create mode 100644 core/src/main/kotlin/transformers/documentation/DocumentableTransformer.kt delete mode 100644 core/src/main/kotlin/transformers/documentation/DocumentablesToPageTranslator.kt delete mode 100644 core/src/main/kotlin/transformers/documentation/DocumentationNodeTransformer.kt delete mode 100644 core/src/main/kotlin/transformers/pages/PageNodeTransformer.kt create mode 100644 core/src/main/kotlin/transformers/pages/PageTransformer.kt create mode 100644 core/src/main/kotlin/transformers/psi/PsiToDocumentableTranslator.kt delete mode 100644 core/src/main/kotlin/transformers/psi/PsiToDocumentationTranslator.kt create mode 100644 plugins/base/src/main/kotlin/transformers/pages/merger/PageMerger.kt delete mode 100644 plugins/base/src/main/kotlin/transformers/pages/merger/PageNodeMerger.kt create mode 100644 plugins/base/src/main/kotlin/transformers/psi/DefaultPsiToDocumentableTranslator.kt delete mode 100644 plugins/base/src/main/kotlin/transformers/psi/DefaultPsiToDocumentationTranslator.kt create mode 100644 plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt delete mode 100644 plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentationTranslator.kt create mode 100644 plugins/base/src/main/kotlin/translators/documentables/DefaultDocumentableToPageTranslator.kt delete mode 100644 plugins/base/src/main/kotlin/translators/documentables/DefaultDocumentablesToPageTranslator.kt create mode 100644 plugins/kotlin-as-java/src/main/kotlin/KotlinAsJavaDescriptorToDocumentableTranslator.kt delete mode 100644 plugins/kotlin-as-java/src/main/kotlin/KotlinAsJavaDescriptorToDocumentationTranslator.kt (limited to 'plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt') diff --git a/core/src/main/kotlin/CoreExtensions.kt b/core/src/main/kotlin/CoreExtensions.kt index 82a1c367..dd6eab1b 100644 --- a/core/src/main/kotlin/CoreExtensions.kt +++ b/core/src/main/kotlin/CoreExtensions.kt @@ -2,21 +2,21 @@ package org.jetbrains.dokka import org.jetbrains.dokka.plugability.ExtensionPoint import org.jetbrains.dokka.renderers.Renderer -import org.jetbrains.dokka.transformers.descriptors.DescriptorToDocumentationTranslator +import org.jetbrains.dokka.transformers.descriptors.DescriptorToDocumentableTranslator import org.jetbrains.dokka.transformers.documentation.DocumentableMerger -import org.jetbrains.dokka.transformers.documentation.DocumentationNodeTransformer -import org.jetbrains.dokka.transformers.documentation.DocumentablesToPageTranslator -import org.jetbrains.dokka.transformers.pages.PageNodeTransformer -import org.jetbrains.dokka.transformers.psi.PsiToDocumentationTranslator +import org.jetbrains.dokka.transformers.documentation.DocumentableToPageTranslator +import org.jetbrains.dokka.transformers.documentation.DocumentableTransformer +import org.jetbrains.dokka.transformers.pages.PageTransformer +import org.jetbrains.dokka.transformers.psi.PsiToDocumentableTranslator import kotlin.reflect.KProperty object CoreExtensions { - val descriptorToDocumentationTranslator by coreExtension() - val psiToDocumentationTranslator by coreExtension() + val descriptorToDocumentableTranslator by coreExtension() + val psiToDocumentableTranslator by coreExtension() val documentableMerger by coreExtension() - val documentationTransformer by coreExtension() - val documentablesToPageTranslator by coreExtension() - val pageTransformer by coreExtension() + val documentableTransformer by coreExtension() + val documentableToPageTranslator by coreExtension() + val pageTransformer by coreExtension() val renderer by coreExtension() private fun coreExtension() = object { diff --git a/core/src/main/kotlin/DokkaGenerator.kt b/core/src/main/kotlin/DokkaGenerator.kt index 8897e68d..e318e969 100644 --- a/core/src/main/kotlin/DokkaGenerator.kt +++ b/core/src/main/kotlin/DokkaGenerator.kt @@ -83,12 +83,12 @@ class DokkaGenerator( fun transformDocumentationModel( documentationModel: Module, context: DokkaContext - ) = context[CoreExtensions.documentationTransformer].fold(documentationModel) { acc, t -> t(acc, context) } + ) = context[CoreExtensions.documentableTransformer].fold(documentationModel) { acc, t -> t(acc, context) } fun createPages( transformedDocumentation: Module, context: DokkaContext - ) = context.single(CoreExtensions.documentablesToPageTranslator).invoke(transformedDocumentation) + ) = context.single(CoreExtensions.documentableToPageTranslator).invoke(transformedDocumentation) fun transformPages( pages: RootPageNode, @@ -128,7 +128,7 @@ class DokkaGenerator( .mapNotNull { facade.resolveSession.getPackageFragment(it) } .toList() - return context.single(CoreExtensions.descriptorToDocumentationTranslator) + return context.single(CoreExtensions.descriptorToDocumentableTranslator) .invoke(platformData.name, packageFragments, platformData) } @@ -149,7 +149,7 @@ class DokkaGenerator( }.toList() }.flatten() - return context.single(CoreExtensions.psiToDocumentationTranslator) + return context.single(CoreExtensions.psiToDocumentableTranslator) .invoke(platformData.name, psiFiles, platformData, context) } diff --git a/core/src/main/kotlin/transformers/descriptors/DescriptorToDocumentableTranslator.kt b/core/src/main/kotlin/transformers/descriptors/DescriptorToDocumentableTranslator.kt new file mode 100644 index 00000000..d72eeafd --- /dev/null +++ b/core/src/main/kotlin/transformers/descriptors/DescriptorToDocumentableTranslator.kt @@ -0,0 +1,13 @@ +package org.jetbrains.dokka.transformers.descriptors + +import org.jetbrains.dokka.model.Module +import org.jetbrains.dokka.pages.PlatformData +import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor + +interface DescriptorToDocumentableTranslator { + fun invoke( + moduleName: String, + packageFragments: Iterable, + platformData: PlatformData + ): Module +} \ No newline at end of file diff --git a/core/src/main/kotlin/transformers/descriptors/DescriptorToDocumentationTranslator.kt b/core/src/main/kotlin/transformers/descriptors/DescriptorToDocumentationTranslator.kt deleted file mode 100644 index 5074833e..00000000 --- a/core/src/main/kotlin/transformers/descriptors/DescriptorToDocumentationTranslator.kt +++ /dev/null @@ -1,14 +0,0 @@ -package org.jetbrains.dokka.transformers.descriptors - -import org.jetbrains.dokka.model.Module -import org.jetbrains.dokka.pages.PlatformData -import org.jetbrains.dokka.plugability.DokkaContext -import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor - -interface DescriptorToDocumentationTranslator { - fun invoke( - moduleName: String, - packageFragments: Iterable, - platformData: PlatformData - ): Module -} \ No newline at end of file diff --git a/core/src/main/kotlin/transformers/documentation/DocumentableToPageTranslator.kt b/core/src/main/kotlin/transformers/documentation/DocumentableToPageTranslator.kt new file mode 100644 index 00000000..e41e0c84 --- /dev/null +++ b/core/src/main/kotlin/transformers/documentation/DocumentableToPageTranslator.kt @@ -0,0 +1,8 @@ +package org.jetbrains.dokka.transformers.documentation + +import org.jetbrains.dokka.model.Module +import org.jetbrains.dokka.pages.ModulePageNode + +interface DocumentableToPageTranslator { + operator fun invoke(module: Module): ModulePageNode +} \ No newline at end of file diff --git a/core/src/main/kotlin/transformers/documentation/DocumentableTransformer.kt b/core/src/main/kotlin/transformers/documentation/DocumentableTransformer.kt new file mode 100644 index 00000000..88a1514d --- /dev/null +++ b/core/src/main/kotlin/transformers/documentation/DocumentableTransformer.kt @@ -0,0 +1,8 @@ +package org.jetbrains.dokka.transformers.documentation + +import org.jetbrains.dokka.model.Module +import org.jetbrains.dokka.plugability.DokkaContext + +interface DocumentableTransformer { + operator fun invoke(original: Module, context: DokkaContext): Module +} \ No newline at end of file diff --git a/core/src/main/kotlin/transformers/documentation/DocumentablesToPageTranslator.kt b/core/src/main/kotlin/transformers/documentation/DocumentablesToPageTranslator.kt deleted file mode 100644 index 19698fa0..00000000 --- a/core/src/main/kotlin/transformers/documentation/DocumentablesToPageTranslator.kt +++ /dev/null @@ -1,9 +0,0 @@ -package org.jetbrains.dokka.transformers.documentation - -import org.jetbrains.dokka.model.Module -import org.jetbrains.dokka.pages.ModulePageNode -import org.jetbrains.dokka.plugability.DokkaContext - -interface DocumentablesToPageTranslator { - operator fun invoke(module: Module): ModulePageNode -} \ No newline at end of file diff --git a/core/src/main/kotlin/transformers/documentation/DocumentationNodeTransformer.kt b/core/src/main/kotlin/transformers/documentation/DocumentationNodeTransformer.kt deleted file mode 100644 index d6358f07..00000000 --- a/core/src/main/kotlin/transformers/documentation/DocumentationNodeTransformer.kt +++ /dev/null @@ -1,8 +0,0 @@ -package org.jetbrains.dokka.transformers.documentation - -import org.jetbrains.dokka.model.Module -import org.jetbrains.dokka.plugability.DokkaContext - -interface DocumentationNodeTransformer { - operator fun invoke(original: Module, context: DokkaContext): Module -} \ No newline at end of file diff --git a/core/src/main/kotlin/transformers/pages/PageNodeTransformer.kt b/core/src/main/kotlin/transformers/pages/PageNodeTransformer.kt deleted file mode 100644 index 45357060..00000000 --- a/core/src/main/kotlin/transformers/pages/PageNodeTransformer.kt +++ /dev/null @@ -1,9 +0,0 @@ -package org.jetbrains.dokka.transformers.pages - -import org.jetbrains.dokka.pages.ModulePageNode -import org.jetbrains.dokka.pages.RootPageNode -import org.jetbrains.dokka.plugability.DokkaContext - -interface PageNodeTransformer { - operator fun invoke(input: RootPageNode): RootPageNode -} \ No newline at end of file diff --git a/core/src/main/kotlin/transformers/pages/PageTransformer.kt b/core/src/main/kotlin/transformers/pages/PageTransformer.kt new file mode 100644 index 00000000..218d9821 --- /dev/null +++ b/core/src/main/kotlin/transformers/pages/PageTransformer.kt @@ -0,0 +1,7 @@ +package org.jetbrains.dokka.transformers.pages + +import org.jetbrains.dokka.pages.RootPageNode + +interface PageTransformer { + operator fun invoke(input: RootPageNode): RootPageNode +} \ No newline at end of file diff --git a/core/src/main/kotlin/transformers/psi/PsiToDocumentableTranslator.kt b/core/src/main/kotlin/transformers/psi/PsiToDocumentableTranslator.kt new file mode 100644 index 00000000..1ea07ff3 --- /dev/null +++ b/core/src/main/kotlin/transformers/psi/PsiToDocumentableTranslator.kt @@ -0,0 +1,15 @@ +package org.jetbrains.dokka.transformers.psi + +import com.intellij.psi.PsiJavaFile +import org.jetbrains.dokka.model.Module +import org.jetbrains.dokka.pages.PlatformData +import org.jetbrains.dokka.plugability.DokkaContext + +interface PsiToDocumentableTranslator { + fun invoke( + moduleName: String, + psiFiles: List, + platformData: PlatformData, + context: DokkaContext + ): Module +} diff --git a/core/src/main/kotlin/transformers/psi/PsiToDocumentationTranslator.kt b/core/src/main/kotlin/transformers/psi/PsiToDocumentationTranslator.kt deleted file mode 100644 index 41290ef8..00000000 --- a/core/src/main/kotlin/transformers/psi/PsiToDocumentationTranslator.kt +++ /dev/null @@ -1,15 +0,0 @@ -package org.jetbrains.dokka.transformers.psi - -import com.intellij.psi.PsiJavaFile -import org.jetbrains.dokka.model.Module -import org.jetbrains.dokka.pages.PlatformData -import org.jetbrains.dokka.plugability.DokkaContext - -interface PsiToDocumentationTranslator { - fun invoke( - moduleName: String, - psiFiles: List, - platformData: PlatformData, - context: DokkaContext - ): Module -} diff --git a/plugins/base/src/main/kotlin/DokkaBase.kt b/plugins/base/src/main/kotlin/DokkaBase.kt index e7cd61a8..489da3ef 100644 --- a/plugins/base/src/main/kotlin/DokkaBase.kt +++ b/plugins/base/src/main/kotlin/DokkaBase.kt @@ -7,15 +7,15 @@ import org.jetbrains.dokka.base.renderers.html.HtmlRenderer import org.jetbrains.dokka.base.resolvers.DefaultLocationProviderFactory import org.jetbrains.dokka.base.resolvers.LocationProviderFactory import org.jetbrains.dokka.base.transformers.documentables.DefaultDocumentableMerger -import org.jetbrains.dokka.base.translators.documentables.DefaultDocumentablesToPageTranslator import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentConverter import org.jetbrains.dokka.base.transformers.pages.comments.DocTagToContentConverter import org.jetbrains.dokka.base.transformers.pages.merger.FallbackPageMergerStrategy +import org.jetbrains.dokka.base.transformers.pages.merger.PageMerger import org.jetbrains.dokka.base.transformers.pages.merger.PageMergerStrategy -import org.jetbrains.dokka.base.transformers.pages.merger.PageNodeMerger import org.jetbrains.dokka.base.transformers.pages.merger.SameMethodNamePageMergerStrategy -import org.jetbrains.dokka.base.transformers.psi.DefaultPsiToDocumentationTranslator -import org.jetbrains.dokka.base.translators.descriptors.DefaultDescriptorToDocumentationTranslator +import org.jetbrains.dokka.base.transformers.psi.DefaultPsiToDocumentableTranslator +import org.jetbrains.dokka.base.translators.descriptors.DefaultDescriptorToDocumentableTranslator +import org.jetbrains.dokka.base.translators.documentables.DefaultDocumentableToPageTranslator import org.jetbrains.dokka.plugability.DokkaPlugin class DokkaBase : DokkaPlugin() { @@ -24,21 +24,21 @@ class DokkaBase : DokkaPlugin() { val locationProviderFactory by extensionPoint() val outputWriter by extensionPoint() - val descriptorToDocumentationTranslator by extending(isFallback = true) { - CoreExtensions.descriptorToDocumentationTranslator providing ::DefaultDescriptorToDocumentationTranslator + val descriptorToDocumentableTranslator by extending(isFallback = true) { + CoreExtensions.descriptorToDocumentableTranslator providing ::DefaultDescriptorToDocumentableTranslator } - val psiToDocumentationTranslator by extending(isFallback = true) { - CoreExtensions.psiToDocumentationTranslator with DefaultPsiToDocumentationTranslator + val psiToDocumentableTranslator by extending(isFallback = true) { + CoreExtensions.psiToDocumentableTranslator with DefaultPsiToDocumentableTranslator } val documentableMerger by extending(isFallback = true) { CoreExtensions.documentableMerger with DefaultDocumentableMerger } - val documentablesToPageTranslator by extending(isFallback = true) { - CoreExtensions.documentablesToPageTranslator providing { ctx -> - DefaultDocumentablesToPageTranslator(ctx.single(commentsToContentConverter), ctx.logger) + val documentableToPageTranslator by extending(isFallback = true) { + CoreExtensions.documentableToPageTranslator providing { ctx -> + DefaultDocumentableToPageTranslator(ctx.single(commentsToContentConverter), ctx.logger) } } @@ -47,7 +47,7 @@ class DokkaBase : DokkaPlugin() { } val pageMerger by extending { - CoreExtensions.pageTransformer providing { ctx -> PageNodeMerger(ctx[pageMergerStrategy]) } + CoreExtensions.pageTransformer providing { ctx -> PageMerger(ctx[pageMergerStrategy]) } } val fallbackMerger by extending { diff --git a/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt b/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt index 75034bda..9c22c879 100644 --- a/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt @@ -7,7 +7,7 @@ import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.plugability.plugin import org.jetbrains.dokka.plugability.querySingle import org.jetbrains.dokka.renderers.Renderer -import org.jetbrains.dokka.transformers.pages.PageNodeTransformer +import org.jetbrains.dokka.transformers.pages.PageTransformer abstract class DefaultRenderer( protected val context: DokkaContext @@ -18,7 +18,7 @@ abstract class DefaultRenderer( protected lateinit var locationProvider: LocationProvider private set - protected open val preprocessors: Iterable = emptyList() + protected open val preprocessors: Iterable = emptyList() abstract fun T.buildHeader(level: Int, content: T.() -> Unit) abstract fun T.buildLink(address: String, content: T.() -> Unit) diff --git a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt index ecd2e89a..9db0f2a8 100644 --- a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt +++ b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt @@ -6,14 +6,14 @@ import kotlinx.html.table import kotlinx.html.tbody import org.jetbrains.dokka.base.renderers.platforms import org.jetbrains.dokka.pages.* -import org.jetbrains.dokka.transformers.pages.PageNodeTransformer +import org.jetbrains.dokka.transformers.pages.PageTransformer -object RootCreator : PageNodeTransformer { +object RootCreator : PageTransformer { override fun invoke(input: RootPageNode) = RendererSpecificRootPage("", listOf(input), RenderingStrategy.DoNothing) } -object SearchPageInstaller : PageNodeTransformer { +object SearchPageInstaller : PageTransformer { override fun invoke(input: RootPageNode) = input.modified(children = input.children + searchPage) private val searchPage = RendererSpecificResourcePage( @@ -34,7 +34,7 @@ object SearchPageInstaller : PageNodeTransformer { }) } -object NavigationPageInstaller : PageNodeTransformer { +object NavigationPageInstaller : PageTransformer { override fun invoke(input: RootPageNode) = input.modified( children = input.children + NavigationPage( input.children.filterIsInstance().single().let(::visit) @@ -48,7 +48,7 @@ object NavigationPageInstaller : PageNodeTransformer { page.children.filterIsInstance().map { visit(it) }) } -object ResourceInstaller : PageNodeTransformer { +object ResourceInstaller : PageTransformer { override fun invoke(input: RootPageNode) = input.modified(children = input.children + resourcePages) private val resourcePages = listOf("styles", "scripts", "images").map { @@ -56,7 +56,7 @@ object ResourceInstaller : PageNodeTransformer { } } -object StyleAndScriptsAppender : PageNodeTransformer { +object StyleAndScriptsAppender : PageTransformer { override fun invoke(input: RootPageNode) = input.transformContentPagesTree { it.modified( embeddedResources = it.embeddedResources + listOf( diff --git a/plugins/base/src/main/kotlin/transformers/pages/merger/PageMerger.kt b/plugins/base/src/main/kotlin/transformers/pages/merger/PageMerger.kt new file mode 100644 index 00000000..93d42e7e --- /dev/null +++ b/plugins/base/src/main/kotlin/transformers/pages/merger/PageMerger.kt @@ -0,0 +1,29 @@ +package org.jetbrains.dokka.base.transformers.pages.merger + +import org.jetbrains.dokka.pages.PageNode +import org.jetbrains.dokka.pages.RootPageNode +import org.jetbrains.dokka.transformers.pages.PageTransformer + +class PageMerger(private val strategies: Iterable) : PageTransformer { + override fun invoke(input: RootPageNode): RootPageNode = + input.modified(children = input.children.map { it.mergeChildren(emptyList()) }) + + private fun PageNode.mergeChildren(path: List): PageNode = children.groupBy { it.name } + .map { (n, v) -> mergePageNodes(v, path + n) } + .let { pages -> + modified(children = pages.map { it.assertSingle(path) }.map { it.mergeChildren(path + it.name) }) + } + + private fun mergePageNodes(pages: List, path: List): List = + strategies.fold(pages) { acc, strategy -> tryMerge(strategy, acc, path) } + + private fun tryMerge(strategy: PageMergerStrategy, pages: List, path: List) = + if (pages.size > 1) strategy.tryMerge(pages, path) else pages +} + +private fun Iterable.assertSingle(path: List): T = try { + single() + } catch (e: Exception) { + val renderedPath = path.joinToString(separator = "/") + throw IllegalStateException("Page merger is misconfigured. Error for $renderedPath: ${e.message}") + } \ No newline at end of file diff --git a/plugins/base/src/main/kotlin/transformers/pages/merger/PageNodeMerger.kt b/plugins/base/src/main/kotlin/transformers/pages/merger/PageNodeMerger.kt deleted file mode 100644 index 96cd126c..00000000 --- a/plugins/base/src/main/kotlin/transformers/pages/merger/PageNodeMerger.kt +++ /dev/null @@ -1,29 +0,0 @@ -package org.jetbrains.dokka.base.transformers.pages.merger - -import org.jetbrains.dokka.pages.PageNode -import org.jetbrains.dokka.pages.RootPageNode -import org.jetbrains.dokka.transformers.pages.PageNodeTransformer - -class PageNodeMerger(private val strategies: Iterable) : PageNodeTransformer { - override fun invoke(input: RootPageNode): RootPageNode = - input.modified(children = input.children.map { it.mergeChildren(emptyList()) }) - - private fun PageNode.mergeChildren(path: List): PageNode = children.groupBy { it.name } - .map { (n, v) -> mergePageNodes(v, path + n) } - .let { pages -> - modified(children = pages.map { it.assertSingle(path) }.map { it.mergeChildren(path + it.name) }) - } - - private fun mergePageNodes(pages: List, path: List): List = - strategies.fold(pages) { acc, strategy -> tryMerge(strategy, acc, path) } - - private fun tryMerge(strategy: PageMergerStrategy, pages: List, path: List) = - if (pages.size > 1) strategy.tryMerge(pages, path) else pages -} - -private fun Iterable.assertSingle(path: List): T = try { - single() - } catch (e: Exception) { - val renderedPath = path.joinToString(separator = "/") - throw IllegalStateException("Page merger is misconfigured. Error for $renderedPath: ${e.message}") - } \ No newline at end of file diff --git a/plugins/base/src/main/kotlin/transformers/psi/DefaultPsiToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/transformers/psi/DefaultPsiToDocumentableTranslator.kt new file mode 100644 index 00000000..364cb34b --- /dev/null +++ b/plugins/base/src/main/kotlin/transformers/psi/DefaultPsiToDocumentableTranslator.kt @@ -0,0 +1,145 @@ +package org.jetbrains.dokka.base.transformers.psi + +import com.intellij.psi.* +import org.jetbrains.dokka.JavadocParser +import org.jetbrains.dokka.links.Callable +import org.jetbrains.dokka.links.DRI +import org.jetbrains.dokka.links.JavaClassReference +import org.jetbrains.dokka.links.withClass +import org.jetbrains.dokka.model.* +import org.jetbrains.dokka.model.Function +import org.jetbrains.dokka.pages.PlatformData +import org.jetbrains.dokka.plugability.DokkaContext +import org.jetbrains.dokka.transformers.psi.PsiToDocumentableTranslator +import org.jetbrains.dokka.utilities.DokkaLogger +import org.jetbrains.kotlin.descriptors.Visibilities + +object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator { + + override fun invoke( + moduleName: String, + psiFiles: List, + platformData: PlatformData, + context: DokkaContext + ): Module { + val docParser = + DokkaPsiParser( + platformData, + context.logger + ) + return Module(moduleName, + psiFiles.map { psiFile -> + val dri = DRI(packageName = psiFile.packageName) + Package( + dri, + emptyList(), + emptyList(), + psiFile.classes.map { docParser.parseClass(it, dri) } + ) + } + ) + } + + class DokkaPsiParser( + private val platformData: PlatformData, + logger: DokkaLogger + ) { + + private val javadocParser: JavadocParser = JavadocParser(logger) + + private fun getComment(psi: PsiNamedElement): List { + val comment = javadocParser.parseDocumentation(psi) + return listOf(BasePlatformInfo(comment, listOf(platformData))) + } + + private fun PsiModifierListOwner.getVisibility() = modifierList?.children?.toList()?.let { ml -> + when { + ml.any { it.text == PsiKeyword.PUBLIC } -> Visibilities.PUBLIC + ml.any { it.text == PsiKeyword.PROTECTED } -> Visibilities.PROTECTED + else -> Visibilities.PRIVATE + } + } ?: Visibilities.PRIVATE + + fun parseClass(psi: PsiClass, parent: DRI): Class = with(psi) { + val kind = when { + isAnnotationType -> JavaClassKindTypes.ANNOTATION_CLASS + isInterface -> JavaClassKindTypes.INTERFACE + isEnum -> JavaClassKindTypes.ENUM_CLASS + else -> JavaClassKindTypes.CLASS + } + val dri = parent.withClass(name.toString()) + /*superTypes.filter { !ignoreSupertype(it) }.forEach { + node.appendType(it, NodeKind.Supertype) + val superClass = it.resolve() + if (superClass != null) { + link(superClass, node, RefKind.Inheritor) + } + }*/ + val inherited = emptyList() //listOf(psi.superClass) + psi.interfaces // TODO DRIs of inherited + val actual = getComment(psi).map { ClassPlatformInfo(it, inherited) } + + return Class( + dri = dri, + name = name.orEmpty(), + kind = kind, + constructors = constructors.map { parseFunction(it, dri, true) }, + functions = methods.mapNotNull { if (!it.isConstructor) parseFunction(it, dri) else null }, + properties = fields.mapNotNull { parseField(it, dri) }, + classlikes = innerClasses.map { parseClass(it, dri) }, + expected = null, + actual = actual, + extra = mutableSetOf(), + visibility = mapOf(platformData to psi.getVisibility()) + ) + } + + private fun parseFunction(psi: PsiMethod, parent: DRI, isConstructor: Boolean = false): Function { + val dri = parent.copy(callable = Callable( + psi.name, + JavaClassReference(psi.containingClass?.name.orEmpty()), + psi.parameterList.parameters.map { parameter -> + JavaClassReference(parameter.type.canonicalText) + } + ) + ) + return Function( + dri, + if (isConstructor) "" else psi.name, + psi.returnType?.let { JavaTypeWrapper(type = it) }, + isConstructor, + null, + psi.parameterList.parameters.mapIndexed { index, psiParameter -> + Parameter( + dri.copy(target = index + 1), + psiParameter.name, + JavaTypeWrapper(psiParameter.type), + null, + getComment(psi) + ) + }, + null, + getComment(psi), + visibility = mapOf(platformData to psi.getVisibility()) + ) + } + + private fun parseField(psi: PsiField, parent: DRI): Property { + val dri = parent.copy( + callable = Callable( + psi.name!!, // TODO: Investigate if this is indeed nullable + JavaClassReference(psi.containingClass?.name.orEmpty()), + emptyList() + ) + ) + return Property( + dri, + psi.name!!, // TODO: Investigate if this is indeed nullable + null, + null, + getComment(psi), + accessors = emptyList(), + visibility = mapOf(platformData to psi.getVisibility()) + ) + } + } +} diff --git a/plugins/base/src/main/kotlin/transformers/psi/DefaultPsiToDocumentationTranslator.kt b/plugins/base/src/main/kotlin/transformers/psi/DefaultPsiToDocumentationTranslator.kt deleted file mode 100644 index b913ae88..00000000 --- a/plugins/base/src/main/kotlin/transformers/psi/DefaultPsiToDocumentationTranslator.kt +++ /dev/null @@ -1,145 +0,0 @@ -package org.jetbrains.dokka.base.transformers.psi - -import com.intellij.psi.* -import org.jetbrains.dokka.JavadocParser -import org.jetbrains.dokka.links.Callable -import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.links.JavaClassReference -import org.jetbrains.dokka.links.withClass -import org.jetbrains.dokka.model.* -import org.jetbrains.dokka.model.Function -import org.jetbrains.dokka.pages.PlatformData -import org.jetbrains.dokka.plugability.DokkaContext -import org.jetbrains.dokka.transformers.psi.PsiToDocumentationTranslator -import org.jetbrains.dokka.utilities.DokkaLogger -import org.jetbrains.kotlin.descriptors.Visibilities - -object DefaultPsiToDocumentationTranslator : PsiToDocumentationTranslator { - - override fun invoke( - moduleName: String, - psiFiles: List, - platformData: PlatformData, - context: DokkaContext - ): Module { - val docParser = - DokkaPsiParser( - platformData, - context.logger - ) - return Module(moduleName, - psiFiles.map { psiFile -> - val dri = DRI(packageName = psiFile.packageName) - Package( - dri, - emptyList(), - emptyList(), - psiFile.classes.map { docParser.parseClass(it, dri) } - ) - } - ) - } - - class DokkaPsiParser( - private val platformData: PlatformData, - logger: DokkaLogger - ) { - - private val javadocParser: JavadocParser = JavadocParser(logger) - - private fun getComment(psi: PsiNamedElement): List { - val comment = javadocParser.parseDocumentation(psi) - return listOf(BasePlatformInfo(comment, listOf(platformData))) - } - - private fun PsiModifierListOwner.getVisibility() = modifierList?.children?.toList()?.let { ml -> - when { - ml.any { it.text == PsiKeyword.PUBLIC } -> Visibilities.PUBLIC - ml.any { it.text == PsiKeyword.PROTECTED } -> Visibilities.PROTECTED - else -> Visibilities.PRIVATE - } - } ?: Visibilities.PRIVATE - - fun parseClass(psi: PsiClass, parent: DRI): Class = with(psi) { - val kind = when { - isAnnotationType -> JavaClassKindTypes.ANNOTATION_CLASS - isInterface -> JavaClassKindTypes.INTERFACE - isEnum -> JavaClassKindTypes.ENUM_CLASS - else -> JavaClassKindTypes.CLASS - } - val dri = parent.withClass(name.toString()) - /*superTypes.filter { !ignoreSupertype(it) }.forEach { - node.appendType(it, NodeKind.Supertype) - val superClass = it.resolve() - if (superClass != null) { - link(superClass, node, RefKind.Inheritor) - } - }*/ - val inherited = emptyList() //listOf(psi.superClass) + psi.interfaces // TODO DRIs of inherited - val actual = getComment(psi).map { ClassPlatformInfo(it, inherited) } - - return Class( - dri = dri, - name = name.orEmpty(), - kind = kind, - constructors = constructors.map { parseFunction(it, dri, true) }, - functions = methods.mapNotNull { if (!it.isConstructor) parseFunction(it, dri) else null }, - properties = fields.mapNotNull { parseField(it, dri) }, - classlikes = innerClasses.map { parseClass(it, dri) }, - expected = null, - actual = actual, - extra = mutableSetOf(), - visibility = mapOf(platformData to psi.getVisibility()) - ) - } - - private fun parseFunction(psi: PsiMethod, parent: DRI, isConstructor: Boolean = false): Function { - val dri = parent.copy(callable = Callable( - psi.name, - JavaClassReference(psi.containingClass?.name.orEmpty()), - psi.parameterList.parameters.map { parameter -> - JavaClassReference(parameter.type.canonicalText) - } - ) - ) - return Function( - dri, - if (isConstructor) "" else psi.name, - psi.returnType?.let { JavaTypeWrapper(type = it) }, - isConstructor, - null, - psi.parameterList.parameters.mapIndexed { index, psiParameter -> - Parameter( - dri.copy(target = index + 1), - psiParameter.name, - JavaTypeWrapper(psiParameter.type), - null, - getComment(psi) - ) - }, - null, - getComment(psi), - visibility = mapOf(platformData to psi.getVisibility()) - ) - } - - private fun parseField(psi: PsiField, parent: DRI): Property { - val dri = parent.copy( - callable = Callable( - psi.name!!, // TODO: Investigate if this is indeed nullable - JavaClassReference(psi.containingClass?.name.orEmpty()), - emptyList() - ) - ) - return Property( - dri, - psi.name!!, // TODO: Investigate if this is indeed nullable - null, - null, - getComment(psi), - accessors = emptyList(), - visibility = mapOf(platformData to psi.getVisibility()) - ) - } - } -} diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt new file mode 100644 index 00000000..95795ece --- /dev/null +++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt @@ -0,0 +1,335 @@ +package org.jetbrains.dokka.base.translators.descriptors + +import org.jetbrains.dokka.analysis.DokkaResolutionFacade +import org.jetbrains.dokka.links.Callable +import org.jetbrains.dokka.links.DRI +import org.jetbrains.dokka.links.withClass +import org.jetbrains.dokka.model.* +import org.jetbrains.dokka.model.Enum +import org.jetbrains.dokka.model.Function +import org.jetbrains.dokka.model.Property +import org.jetbrains.dokka.model.doc.* +import org.jetbrains.dokka.pages.PlatformData +import org.jetbrains.dokka.parsers.MarkdownParser +import org.jetbrains.dokka.plugability.DokkaContext +import org.jetbrains.dokka.transformers.descriptors.DescriptorToDocumentableTranslator +import org.jetbrains.kotlin.descriptors.* +import org.jetbrains.kotlin.descriptors.impl.DeclarationDescriptorVisitorEmptyBodies +import org.jetbrains.kotlin.idea.kdoc.findKDoc +import org.jetbrains.kotlin.resolve.descriptorUtil.getAllSuperclassesWithoutAny +import org.jetbrains.kotlin.resolve.descriptorUtil.getSuperInterfaces +import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter +import org.jetbrains.kotlin.resolve.scopes.MemberScope +import kotlin.reflect.KClass + +class DefaultDescriptorToDocumentableTranslator( + private val context: DokkaContext +) : DescriptorToDocumentableTranslator { + override fun invoke( + moduleName: String, + packageFragments: Iterable, + platformData: PlatformData + ) = DokkaDescriptorVisitor(platformData, context.platforms[platformData]?.facade!!).run { + packageFragments.map { + visitPackageFragmentDescriptor( + it, + DRIWithPlatformInfo(DRI.topLevel, null, emptyList()) + ) + } + }.let { Module(moduleName, it) } + +} + + +data class DRIWithPlatformInfo( + val dri: DRI, + val expected: PlatformInfo?, + val actual: List +) + +fun DRI.withEmptyInfo() = DRIWithPlatformInfo(this, null, emptyList()) + +open class DokkaDescriptorVisitor( // TODO: close this class and make it private together with DRIWithPlatformInfo + private val platformData: PlatformData, + private val resolutionFacade: DokkaResolutionFacade +) : DeclarationDescriptorVisitorEmptyBodies() { + override fun visitDeclarationDescriptor(descriptor: DeclarationDescriptor, parent: DRIWithPlatformInfo): Nothing { + throw IllegalStateException("${javaClass.simpleName} should never enter ${descriptor.javaClass.simpleName}") + } + + override fun visitPackageFragmentDescriptor( + descriptor: PackageFragmentDescriptor, + parent: DRIWithPlatformInfo + ): Package { + val driWithPlatform = DRI(packageName = descriptor.fqName.asString()).withEmptyInfo() + val scope = descriptor.getMemberScope() + + return Package( + dri = driWithPlatform.dri, + functions = scope.functions(driWithPlatform), + properties = scope.properties(driWithPlatform), + classlikes = scope.classlikes(driWithPlatform) + ) + } + + override fun visitClassDescriptor(descriptor: ClassDescriptor, parent: DRIWithPlatformInfo): Classlike = + when (descriptor.kind) { + org.jetbrains.kotlin.descriptors.ClassKind.ENUM_CLASS -> enumDescriptor(descriptor, parent) + else -> classDescriptor(descriptor, parent) + } + + fun enumDescriptor(descriptor: ClassDescriptor, parent: DRIWithPlatformInfo): Enum { + val driWithPlatform = parent.dri.withClass(descriptor.name.asString()).withEmptyInfo() + val scope = descriptor.unsubstitutedMemberScope + val descriptorData = descriptor.takeUnless { it.isExpect }?.resolveClassDescriptionData() + + return Enum( + dri = driWithPlatform.dri, + name = descriptor.name.asString(), + entries = scope.classlikes(driWithPlatform).filter { it.kind == KotlinClassKindTypes.ENUM_ENTRY }.map { + EnumEntry( + it + ) + }, + constructors = descriptor.constructors.map { visitConstructorDescriptor(it, driWithPlatform) }, + functions = scope.functions(driWithPlatform), + properties = scope.properties(driWithPlatform), + classlikes = scope.classlikes(driWithPlatform), + expected = descriptor.takeIf { it.isExpect }?.resolveClassDescriptionData(), + actual = listOfNotNull(descriptorData), + extra = mutableSetOf(), // TODO Implement following method to return proper results getXMLDRIs(descriptor, descriptorData).toMutableSet() + visibility = mapOf(platformData to descriptor.visibility) + ) + } + + fun classDescriptor(descriptor: ClassDescriptor, parent: DRIWithPlatformInfo): Class { + val driWithPlatform = parent.dri.withClass(descriptor.name.asString()).withEmptyInfo() + val scope = descriptor.unsubstitutedMemberScope + val descriptorData = descriptor.takeUnless { it.isExpect }?.resolveClassDescriptionData() + val expected = descriptor.takeIf { it.isExpect }?.resolveClassDescriptionData() + val actual = listOfNotNull(descriptorData) + return Class( + dri = driWithPlatform.dri, + name = descriptor.name.asString(), + kind = KotlinClassKindTypes.valueOf(descriptor.kind.toString()), + constructors = descriptor.constructors.map { + visitConstructorDescriptor( + it, + if (it.isPrimary) + DRIWithPlatformInfo( + driWithPlatform.dri, + expected?.info.filterTagWrappers(listOf(Constructor::class)), + actual.filterTagWrappers(listOf(Constructor::class)) + ) + else + DRIWithPlatformInfo(driWithPlatform.dri, null, emptyList()) + ) + }, + functions = scope.functions(driWithPlatform), + properties = scope.properties(driWithPlatform), + classlikes = scope.classlikes(driWithPlatform), + expected = expected, + actual = actual, + extra = mutableSetOf(), // TODO Implement following method to return proper results getXMLDRIs(descriptor, descriptorData).toMutableSet() + visibility = mapOf(platformData to descriptor.visibility) + ) + } + + override fun visitPropertyDescriptor(descriptor: PropertyDescriptor, parent: DRIWithPlatformInfo): Property { + val expected = descriptor.takeIf { it.isExpect }?.resolveDescriptorData() + val actual = listOfNotNull(descriptor.takeUnless { it.isExpect }?.resolveDescriptorData()) + val dri = parent.dri.copy(callable = Callable.from(descriptor)) + + return Property( + dri = dri, + name = descriptor.name.asString(), + receiver = descriptor.extensionReceiverParameter?.let { + visitReceiverParameterDescriptor( + it, + DRIWithPlatformInfo( + dri, + expected?.filterTagWrappers(listOf(Receiver::class)), + actual.filterTagWrappers(listOf(Receiver::class)) + ) + ) + }, + expected = expected, + actual = actual, + accessors = descriptor.accessors.map { visitPropertyAccessorDescriptor(it, descriptor, dri) }, + visibility = mapOf(platformData to descriptor.visibility) + ) + } + + override fun visitFunctionDescriptor(descriptor: FunctionDescriptor, parent: DRIWithPlatformInfo): Function { + val expected = descriptor.takeIf { it.isExpect }?.resolveDescriptorData() + val actual = listOfNotNull(descriptor.takeUnless { it.isExpect }?.resolveDescriptorData()) + val dri = parent.dri.copy(callable = Callable.from(descriptor)) + + return Function( + dri = dri, + name = descriptor.name.asString(), + returnType = descriptor.returnType?.let { KotlinTypeWrapper(it) }, + isConstructor = false, + receiver = descriptor.extensionReceiverParameter?.let { + visitReceiverParameterDescriptor( + it, + DRIWithPlatformInfo( + dri, + expected?.filterTagWrappers(listOf(Receiver::class)), + actual.filterTagWrappers(listOf(Receiver::class)) + ) + ) + }, + parameters = descriptor.valueParameters.mapIndexed { index, desc -> + parameter( + index, desc, + DRIWithPlatformInfo( + dri, + expected.filterTagWrappers(listOf(Param::class), desc.name.asString()), + actual.filterTagWrappers(listOf(Param::class), desc.name.asString()) + ) + ) + }, + expected = expected, + actual = actual, + visibility = mapOf(platformData to descriptor.visibility) + ) + } + + override fun visitConstructorDescriptor(descriptor: ConstructorDescriptor, parent: DRIWithPlatformInfo): Function { + val dri = parent.dri.copy(callable = Callable.from(descriptor)) + return Function( + dri = dri, + name = "", + returnType = KotlinTypeWrapper(descriptor.returnType), + isConstructor = true, + receiver = null, + parameters = descriptor.valueParameters.mapIndexed { index, desc -> + parameter( + index, desc, + DRIWithPlatformInfo( + dri, + parent.expected.filterTagWrappers(listOf(Param::class)), + parent.actual.filterTagWrappers(listOf(Param::class)) + ) + ) + }, + expected = parent.expected ?: descriptor.takeIf { it.isExpect }?.resolveDescriptorData(), + actual = parent.actual, + visibility = mapOf(platformData to descriptor.visibility) + ) + } + + override fun visitReceiverParameterDescriptor( + descriptor: ReceiverParameterDescriptor, + parent: DRIWithPlatformInfo + ) = Parameter( + dri = parent.dri.copy(target = 0), + name = null, + type = KotlinTypeWrapper(descriptor.type), + expected = parent.expected, + actual = parent.actual + ) + + open fun visitPropertyAccessorDescriptor( + descriptor: PropertyAccessorDescriptor, + propertyDescriptor: PropertyDescriptor, + parent: DRI + ): Function { + val dri = parent.copy(callable = Callable.from(descriptor)) + val isGetter = descriptor is PropertyGetterDescriptor + + fun PropertyDescriptor.asParameter(parent: DRI) = + Parameter( + parent.copy(target = 1), + this.name.asString(), + KotlinTypeWrapper(this.type), + descriptor.takeIf { it.isExpect }?.resolveDescriptorData(), + listOfNotNull(descriptor.takeUnless { it.isExpect }?.resolveDescriptorData()) + ) + + val name = run { + val modifier = if (isGetter) "get" else "set" + val rawName = propertyDescriptor.name.asString() + "$modifier${rawName[0].toUpperCase()}${rawName.drop(1)}" + } + + descriptor.visibility + val parameters = + if (isGetter) { + emptyList() + } else { + listOf(propertyDescriptor.asParameter(dri)) + } + + return Function( + dri, + name, + descriptor.returnType?.let { KotlinTypeWrapper(it) }, + false, + null, + parameters, + descriptor.takeIf { it.isExpect }?.resolveDescriptorData(), + listOfNotNull(descriptor.takeUnless { it.isExpect }?.resolveDescriptorData()), + visibility = mapOf(platformData to descriptor.visibility) + ) + } + + private fun parameter(index: Int, descriptor: ValueParameterDescriptor, parent: DRIWithPlatformInfo) = + Parameter( + dri = parent.dri.copy(target = index + 1), + name = descriptor.name.asString(), + type = KotlinTypeWrapper(descriptor.type), + expected = parent.expected, + actual = parent.actual + ) + + private fun MemberScope.functions(parent: DRIWithPlatformInfo): List = + getContributedDescriptors(DescriptorKindFilter.FUNCTIONS) { true } + .filterIsInstance() + .map { visitFunctionDescriptor(it, parent) } + + private fun MemberScope.properties(parent: DRIWithPlatformInfo): List = + getContributedDescriptors(DescriptorKindFilter.VALUES) { true } + .filterIsInstance() + .map { visitPropertyDescriptor(it, parent) } + + private fun MemberScope.classlikes(parent: DRIWithPlatformInfo): List = + getContributedDescriptors(DescriptorKindFilter.CLASSIFIERS) { true } + .filterIsInstance() + .map { visitClassDescriptor(it, parent) } + + private fun DeclarationDescriptor.resolveDescriptorData(): PlatformInfo { + val doc = findKDoc() + val parser = MarkdownParser(resolutionFacade, this) + val docHeader = parser.parseFromKDocTag(doc) + + return BasePlatformInfo(docHeader, listOf(platformData)) + } + + private fun ClassDescriptor.resolveClassDescriptionData(): ClassPlatformInfo { + return ClassPlatformInfo(resolveDescriptorData(), + (getSuperInterfaces() + getAllSuperclassesWithoutAny()).map { DRI.from(it) }) + } + + private fun PlatformInfo?.filterTagWrappers( + types: List>, + name: String? = null + ): PlatformInfo? { + if (this == null) + return null + return BasePlatformInfo( + DocumentationNode( + this.documentationNode.children.filter { it::class in types && (it as? NamedTagWrapper)?.name == name } + ), + this.platformData + ) + } + + private fun List.filterTagWrappers( + types: List>, + name: String? = null + ): List = + this.map { it.filterTagWrappers(types, name)!! } +} + diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentationTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentationTranslator.kt deleted file mode 100644 index bb572034..00000000 --- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentationTranslator.kt +++ /dev/null @@ -1,335 +0,0 @@ -package org.jetbrains.dokka.base.translators.descriptors - -import org.jetbrains.dokka.analysis.DokkaResolutionFacade -import org.jetbrains.dokka.links.Callable -import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.links.withClass -import org.jetbrains.dokka.model.* -import org.jetbrains.dokka.model.Enum -import org.jetbrains.dokka.model.Function -import org.jetbrains.dokka.model.Property -import org.jetbrains.dokka.model.doc.* -import org.jetbrains.dokka.pages.PlatformData -import org.jetbrains.dokka.parsers.MarkdownParser -import org.jetbrains.dokka.plugability.DokkaContext -import org.jetbrains.dokka.transformers.descriptors.DescriptorToDocumentationTranslator -import org.jetbrains.kotlin.descriptors.* -import org.jetbrains.kotlin.descriptors.impl.DeclarationDescriptorVisitorEmptyBodies -import org.jetbrains.kotlin.idea.kdoc.findKDoc -import org.jetbrains.kotlin.resolve.descriptorUtil.getAllSuperclassesWithoutAny -import org.jetbrains.kotlin.resolve.descriptorUtil.getSuperInterfaces -import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter -import org.jetbrains.kotlin.resolve.scopes.MemberScope -import kotlin.reflect.KClass - -class DefaultDescriptorToDocumentationTranslator( - private val context: DokkaContext -) : DescriptorToDocumentationTranslator { - override fun invoke( - moduleName: String, - packageFragments: Iterable, - platformData: PlatformData - ) = DokkaDescriptorVisitor(platformData, context.platforms[platformData]?.facade!!).run { - packageFragments.map { - visitPackageFragmentDescriptor( - it, - DRIWithPlatformInfo(DRI.topLevel, null, emptyList()) - ) - } - }.let { Module(moduleName, it) } - -} - - -data class DRIWithPlatformInfo( - val dri: DRI, - val expected: PlatformInfo?, - val actual: List -) - -fun DRI.withEmptyInfo() = DRIWithPlatformInfo(this, null, emptyList()) - -open class DokkaDescriptorVisitor( // TODO: close this class and make it private together with DRIWithPlatformInfo - private val platformData: PlatformData, - private val resolutionFacade: DokkaResolutionFacade -) : DeclarationDescriptorVisitorEmptyBodies() { - override fun visitDeclarationDescriptor(descriptor: DeclarationDescriptor, parent: DRIWithPlatformInfo): Nothing { - throw IllegalStateException("${javaClass.simpleName} should never enter ${descriptor.javaClass.simpleName}") - } - - override fun visitPackageFragmentDescriptor( - descriptor: PackageFragmentDescriptor, - parent: DRIWithPlatformInfo - ): Package { - val driWithPlatform = DRI(packageName = descriptor.fqName.asString()).withEmptyInfo() - val scope = descriptor.getMemberScope() - - return Package( - dri = driWithPlatform.dri, - functions = scope.functions(driWithPlatform), - properties = scope.properties(driWithPlatform), - classlikes = scope.classlikes(driWithPlatform) - ) - } - - override fun visitClassDescriptor(descriptor: ClassDescriptor, parent: DRIWithPlatformInfo): Classlike = - when (descriptor.kind) { - org.jetbrains.kotlin.descriptors.ClassKind.ENUM_CLASS -> enumDescriptor(descriptor, parent) - else -> classDescriptor(descriptor, parent) - } - - fun enumDescriptor(descriptor: ClassDescriptor, parent: DRIWithPlatformInfo): Enum { - val driWithPlatform = parent.dri.withClass(descriptor.name.asString()).withEmptyInfo() - val scope = descriptor.unsubstitutedMemberScope - val descriptorData = descriptor.takeUnless { it.isExpect }?.resolveClassDescriptionData() - - return Enum( - dri = driWithPlatform.dri, - name = descriptor.name.asString(), - entries = scope.classlikes(driWithPlatform).filter { it.kind == KotlinClassKindTypes.ENUM_ENTRY }.map { - EnumEntry( - it - ) - }, - constructors = descriptor.constructors.map { visitConstructorDescriptor(it, driWithPlatform) }, - functions = scope.functions(driWithPlatform), - properties = scope.properties(driWithPlatform), - classlikes = scope.classlikes(driWithPlatform), - expected = descriptor.takeIf { it.isExpect }?.resolveClassDescriptionData(), - actual = listOfNotNull(descriptorData), - extra = mutableSetOf(), // TODO Implement following method to return proper results getXMLDRIs(descriptor, descriptorData).toMutableSet() - visibility = mapOf(platformData to descriptor.visibility) - ) - } - - fun classDescriptor(descriptor: ClassDescriptor, parent: DRIWithPlatformInfo): Class { - val driWithPlatform = parent.dri.withClass(descriptor.name.asString()).withEmptyInfo() - val scope = descriptor.unsubstitutedMemberScope - val descriptorData = descriptor.takeUnless { it.isExpect }?.resolveClassDescriptionData() - val expected = descriptor.takeIf { it.isExpect }?.resolveClassDescriptionData() - val actual = listOfNotNull(descriptorData) - return Class( - dri = driWithPlatform.dri, - name = descriptor.name.asString(), - kind = KotlinClassKindTypes.valueOf(descriptor.kind.toString()), - constructors = descriptor.constructors.map { - visitConstructorDescriptor( - it, - if (it.isPrimary) - DRIWithPlatformInfo( - driWithPlatform.dri, - expected?.info.filterTagWrappers(listOf(Constructor::class)), - actual.filterTagWrappers(listOf(Constructor::class)) - ) - else - DRIWithPlatformInfo(driWithPlatform.dri, null, emptyList()) - ) - }, - functions = scope.functions(driWithPlatform), - properties = scope.properties(driWithPlatform), - classlikes = scope.classlikes(driWithPlatform), - expected = expected, - actual = actual, - extra = mutableSetOf(), // TODO Implement following method to return proper results getXMLDRIs(descriptor, descriptorData).toMutableSet() - visibility = mapOf(platformData to descriptor.visibility) - ) - } - - override fun visitPropertyDescriptor(descriptor: PropertyDescriptor, parent: DRIWithPlatformInfo): Property { - val expected = descriptor.takeIf { it.isExpect }?.resolveDescriptorData() - val actual = listOfNotNull(descriptor.takeUnless { it.isExpect }?.resolveDescriptorData()) - val dri = parent.dri.copy(callable = Callable.from(descriptor)) - - return Property( - dri = dri, - name = descriptor.name.asString(), - receiver = descriptor.extensionReceiverParameter?.let { - visitReceiverParameterDescriptor( - it, - DRIWithPlatformInfo( - dri, - expected?.filterTagWrappers(listOf(Receiver::class)), - actual.filterTagWrappers(listOf(Receiver::class)) - ) - ) - }, - expected = expected, - actual = actual, - accessors = descriptor.accessors.map { visitPropertyAccessorDescriptor(it, descriptor, dri) }, - visibility = mapOf(platformData to descriptor.visibility) - ) - } - - override fun visitFunctionDescriptor(descriptor: FunctionDescriptor, parent: DRIWithPlatformInfo): Function { - val expected = descriptor.takeIf { it.isExpect }?.resolveDescriptorData() - val actual = listOfNotNull(descriptor.takeUnless { it.isExpect }?.resolveDescriptorData()) - val dri = parent.dri.copy(callable = Callable.from(descriptor)) - - return Function( - dri = dri, - name = descriptor.name.asString(), - returnType = descriptor.returnType?.let { KotlinTypeWrapper(it) }, - isConstructor = false, - receiver = descriptor.extensionReceiverParameter?.let { - visitReceiverParameterDescriptor( - it, - DRIWithPlatformInfo( - dri, - expected?.filterTagWrappers(listOf(Receiver::class)), - actual.filterTagWrappers(listOf(Receiver::class)) - ) - ) - }, - parameters = descriptor.valueParameters.mapIndexed { index, desc -> - parameter( - index, desc, - DRIWithPlatformInfo( - dri, - expected.filterTagWrappers(listOf(Param::class), desc.name.asString()), - actual.filterTagWrappers(listOf(Param::class), desc.name.asString()) - ) - ) - }, - expected = expected, - actual = actual, - visibility = mapOf(platformData to descriptor.visibility) - ) - } - - override fun visitConstructorDescriptor(descriptor: ConstructorDescriptor, parent: DRIWithPlatformInfo): Function { - val dri = parent.dri.copy(callable = Callable.from(descriptor)) - return Function( - dri = dri, - name = "", - returnType = KotlinTypeWrapper(descriptor.returnType), - isConstructor = true, - receiver = null, - parameters = descriptor.valueParameters.mapIndexed { index, desc -> - parameter( - index, desc, - DRIWithPlatformInfo( - dri, - parent.expected.filterTagWrappers(listOf(Param::class)), - parent.actual.filterTagWrappers(listOf(Param::class)) - ) - ) - }, - expected = parent.expected ?: descriptor.takeIf { it.isExpect }?.resolveDescriptorData(), - actual = parent.actual, - visibility = mapOf(platformData to descriptor.visibility) - ) - } - - override fun visitReceiverParameterDescriptor( - descriptor: ReceiverParameterDescriptor, - parent: DRIWithPlatformInfo - ) = Parameter( - dri = parent.dri.copy(target = 0), - name = null, - type = KotlinTypeWrapper(descriptor.type), - expected = parent.expected, - actual = parent.actual - ) - - open fun visitPropertyAccessorDescriptor( - descriptor: PropertyAccessorDescriptor, - propertyDescriptor: PropertyDescriptor, - parent: DRI - ): Function { - val dri = parent.copy(callable = Callable.from(descriptor)) - val isGetter = descriptor is PropertyGetterDescriptor - - fun PropertyDescriptor.asParameter(parent: DRI) = - Parameter( - parent.copy(target = 1), - this.name.asString(), - KotlinTypeWrapper(this.type), - descriptor.takeIf { it.isExpect }?.resolveDescriptorData(), - listOfNotNull(descriptor.takeUnless { it.isExpect }?.resolveDescriptorData()) - ) - - val name = run { - val modifier = if (isGetter) "get" else "set" - val rawName = propertyDescriptor.name.asString() - "$modifier${rawName[0].toUpperCase()}${rawName.drop(1)}" - } - - descriptor.visibility - val parameters = - if (isGetter) { - emptyList() - } else { - listOf(propertyDescriptor.asParameter(dri)) - } - - return Function( - dri, - name, - descriptor.returnType?.let { KotlinTypeWrapper(it) }, - false, - null, - parameters, - descriptor.takeIf { it.isExpect }?.resolveDescriptorData(), - listOfNotNull(descriptor.takeUnless { it.isExpect }?.resolveDescriptorData()), - visibility = mapOf(platformData to descriptor.visibility) - ) - } - - private fun parameter(index: Int, descriptor: ValueParameterDescriptor, parent: DRIWithPlatformInfo) = - Parameter( - dri = parent.dri.copy(target = index + 1), - name = descriptor.name.asString(), - type = KotlinTypeWrapper(descriptor.type), - expected = parent.expected, - actual = parent.actual - ) - - private fun MemberScope.functions(parent: DRIWithPlatformInfo): List = - getContributedDescriptors(DescriptorKindFilter.FUNCTIONS) { true } - .filterIsInstance() - .map { visitFunctionDescriptor(it, parent) } - - private fun MemberScope.properties(parent: DRIWithPlatformInfo): List = - getContributedDescriptors(DescriptorKindFilter.VALUES) { true } - .filterIsInstance() - .map { visitPropertyDescriptor(it, parent) } - - private fun MemberScope.classlikes(parent: DRIWithPlatformInfo): List = - getContributedDescriptors(DescriptorKindFilter.CLASSIFIERS) { true } - .filterIsInstance() - .map { visitClassDescriptor(it, parent) } - - private fun DeclarationDescriptor.resolveDescriptorData(): PlatformInfo { - val doc = findKDoc() - val parser = MarkdownParser(resolutionFacade, this) - val docHeader = parser.parseFromKDocTag(doc) - - return BasePlatformInfo(docHeader, listOf(platformData)) - } - - private fun ClassDescriptor.resolveClassDescriptionData(): ClassPlatformInfo { - return ClassPlatformInfo(resolveDescriptorData(), - (getSuperInterfaces() + getAllSuperclassesWithoutAny()).map { DRI.from(it) }) - } - - private fun PlatformInfo?.filterTagWrappers( - types: List>, - name: String? = null - ): PlatformInfo? { - if (this == null) - return null - return BasePlatformInfo( - DocumentationNode( - this.documentationNode.children.filter { it::class in types && (it as? NamedTagWrapper)?.name == name } - ), - this.platformData - ) - } - - private fun List.filterTagWrappers( - types: List>, - name: String? = null - ): List = - this.map { it.filterTagWrappers(types, name)!! } -} - diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultDocumentableToPageTranslator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultDocumentableToPageTranslator.kt new file mode 100644 index 00000000..f577c8f4 --- /dev/null +++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultDocumentableToPageTranslator.kt @@ -0,0 +1,25 @@ +package org.jetbrains.dokka.base.translators.documentables + +import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentConverter +import org.jetbrains.dokka.model.Module +import org.jetbrains.dokka.pages.ModulePageNode +import org.jetbrains.dokka.transformers.documentation.DocumentableToPageTranslator +import org.jetbrains.dokka.utilities.DokkaLogger + + +class DefaultDocumentableToPageTranslator( + private val commentsToContentConverter: CommentsToContentConverter, + private val logger: DokkaLogger +) : DocumentableToPageTranslator { + override fun invoke(module: Module): ModulePageNode = + DefaultPageBuilder { node, kind, operation -> + DefaultPageContentBuilder.group( + setOf(node.dri), + node.platformData, + kind, + commentsToContentConverter, + logger, + operation + ) + }.pageForModule(module) +} \ No newline at end of file diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultDocumentablesToPageTranslator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultDocumentablesToPageTranslator.kt deleted file mode 100644 index ee3ae995..00000000 --- a/plugins/base/src/main/kotlin/translators/documentables/DefaultDocumentablesToPageTranslator.kt +++ /dev/null @@ -1,25 +0,0 @@ -package org.jetbrains.dokka.base.translators.documentables - -import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentConverter -import org.jetbrains.dokka.model.Module -import org.jetbrains.dokka.pages.ModulePageNode -import org.jetbrains.dokka.transformers.documentation.DocumentablesToPageTranslator -import org.jetbrains.dokka.utilities.DokkaLogger - - -class DefaultDocumentablesToPageTranslator( - private val commentsToContentConverter: CommentsToContentConverter, - private val logger: DokkaLogger -) : DocumentablesToPageTranslator { - override fun invoke(module: Module): ModulePageNode = - DefaultPageBuilder { node, kind, operation -> - DefaultPageContentBuilder.group( - setOf(node.dri), - node.platformData, - kind, - commentsToContentConverter, - logger, - operation - ) - }.pageForModule(module) -} \ No newline at end of file diff --git a/plugins/kotlin-as-java/src/main/kotlin/KotlinAsJavaDescriptorToDocumentableTranslator.kt b/plugins/kotlin-as-java/src/main/kotlin/KotlinAsJavaDescriptorToDocumentableTranslator.kt new file mode 100644 index 00000000..3b615dcb --- /dev/null +++ b/plugins/kotlin-as-java/src/main/kotlin/KotlinAsJavaDescriptorToDocumentableTranslator.kt @@ -0,0 +1,76 @@ +package org.jetbrains.dokka.kotlinAsJava + +import org.jetbrains.dokka.analysis.DokkaResolutionFacade +import org.jetbrains.dokka.base.translators.descriptors.DRIWithPlatformInfo +import org.jetbrains.dokka.base.translators.descriptors.DokkaDescriptorVisitor +import org.jetbrains.dokka.base.translators.descriptors.withEmptyInfo +import org.jetbrains.dokka.links.Callable +import org.jetbrains.dokka.links.DRI +import org.jetbrains.dokka.links.withClass +import org.jetbrains.dokka.model.* +import org.jetbrains.dokka.model.Function +import org.jetbrains.dokka.pages.PlatformData +import org.jetbrains.dokka.plugability.DokkaContext +import org.jetbrains.dokka.transformers.descriptors.DescriptorToDocumentableTranslator +import org.jetbrains.kotlin.descriptors.* + +class KotlinAsJavaDescriptorToDocumentableTranslator( + private val context: DokkaContext +) : DescriptorToDocumentableTranslator { + override fun invoke( + moduleName: String, + packageFragments: Iterable, + platformData: PlatformData + ): Module = + KotlinAsJavaDokkaDescriptorVisitor(platformData, context.platforms[platformData]?.facade!!).run { + packageFragments.map { visitPackageFragmentDescriptor(it, DRI.topLevel.withEmptyInfo()) } + }.let { Module(moduleName, it) } +} + +class KotlinAsJavaDokkaDescriptorVisitor( + platformData: PlatformData, + resolutionFacade: DokkaResolutionFacade +) : DokkaDescriptorVisitor(platformData, resolutionFacade) { + override fun visitPackageFragmentDescriptor( + descriptor: PackageFragmentDescriptor, + parent: DRIWithPlatformInfo + ): Package { + val dri = DRI(packageName = descriptor.fqName.asString()) + DescriptorCache.add(dri, descriptor) + return super.visitPackageFragmentDescriptor(descriptor, parent) + } + + override fun visitClassDescriptor(descriptor: ClassDescriptor, parent: DRIWithPlatformInfo): Classlike { + val dri = parent.dri.withClass(descriptor.name.asString()) + DescriptorCache.add(dri, descriptor) + return super.visitClassDescriptor(descriptor, parent) + } + + override fun visitPropertyDescriptor(descriptor: PropertyDescriptor, parent: DRIWithPlatformInfo): Property { + val dri = parent.dri.copy(callable = Callable.from(descriptor)) + DescriptorCache.add(dri, descriptor) + return super.visitPropertyDescriptor(descriptor, parent) + } + + override fun visitFunctionDescriptor(descriptor: FunctionDescriptor, parent: DRIWithPlatformInfo): Function { + val dri = parent.dri.copy(callable = Callable.from(descriptor)) + DescriptorCache.add(dri, descriptor) + return super.visitFunctionDescriptor(descriptor, parent) + } + + override fun visitConstructorDescriptor(descriptor: ConstructorDescriptor, parent: DRIWithPlatformInfo): Function { + val dri = parent.dri.copy(callable = Callable.from(descriptor)) + DescriptorCache.add(dri, descriptor) + return super.visitConstructorDescriptor(descriptor, parent) + } + + override fun visitPropertyAccessorDescriptor( + descriptor: PropertyAccessorDescriptor, + propertyDescriptor: PropertyDescriptor, + parent: DRI + ): Function { + val dri = parent.copy(callable = Callable.from(descriptor)) + DescriptorCache.add(dri, descriptor) + return super.visitPropertyAccessorDescriptor(descriptor, propertyDescriptor, parent) + } +} \ No newline at end of file diff --git a/plugins/kotlin-as-java/src/main/kotlin/KotlinAsJavaDescriptorToDocumentationTranslator.kt b/plugins/kotlin-as-java/src/main/kotlin/KotlinAsJavaDescriptorToDocumentationTranslator.kt deleted file mode 100644 index 618ecfcc..00000000 --- a/plugins/kotlin-as-java/src/main/kotlin/KotlinAsJavaDescriptorToDocumentationTranslator.kt +++ /dev/null @@ -1,76 +0,0 @@ -package org.jetbrains.dokka.kotlinAsJava - -import org.jetbrains.dokka.analysis.DokkaResolutionFacade -import org.jetbrains.dokka.base.translators.descriptors.DRIWithPlatformInfo -import org.jetbrains.dokka.base.translators.descriptors.DokkaDescriptorVisitor -import org.jetbrains.dokka.base.translators.descriptors.withEmptyInfo -import org.jetbrains.dokka.links.Callable -import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.links.withClass -import org.jetbrains.dokka.model.* -import org.jetbrains.dokka.model.Function -import org.jetbrains.dokka.pages.PlatformData -import org.jetbrains.dokka.plugability.DokkaContext -import org.jetbrains.dokka.transformers.descriptors.DescriptorToDocumentationTranslator -import org.jetbrains.kotlin.descriptors.* - -class KotlinAsJavaDescriptorToDocumentationTranslator( - private val context: DokkaContext -) : DescriptorToDocumentationTranslator { - override fun invoke( - moduleName: String, - packageFragments: Iterable, - platformData: PlatformData - ): Module = - KotlinAsJavaDokkaDescriptorVisitor(platformData, context.platforms[platformData]?.facade!!).run { - packageFragments.map { visitPackageFragmentDescriptor(it, DRI.topLevel.withEmptyInfo()) } - }.let { Module(moduleName, it) } -} - -class KotlinAsJavaDokkaDescriptorVisitor( - platformData: PlatformData, - resolutionFacade: DokkaResolutionFacade -) : DokkaDescriptorVisitor(platformData, resolutionFacade) { - override fun visitPackageFragmentDescriptor( - descriptor: PackageFragmentDescriptor, - parent: DRIWithPlatformInfo - ): Package { - val dri = DRI(packageName = descriptor.fqName.asString()) - DescriptorCache.add(dri, descriptor) - return super.visitPackageFragmentDescriptor(descriptor, parent) - } - - override fun visitClassDescriptor(descriptor: ClassDescriptor, parent: DRIWithPlatformInfo): Classlike { - val dri = parent.dri.withClass(descriptor.name.asString()) - DescriptorCache.add(dri, descriptor) - return super.visitClassDescriptor(descriptor, parent) - } - - override fun visitPropertyDescriptor(descriptor: PropertyDescriptor, parent: DRIWithPlatformInfo): Property { - val dri = parent.dri.copy(callable = Callable.from(descriptor)) - DescriptorCache.add(dri, descriptor) - return super.visitPropertyDescriptor(descriptor, parent) - } - - override fun visitFunctionDescriptor(descriptor: FunctionDescriptor, parent: DRIWithPlatformInfo): Function { - val dri = parent.dri.copy(callable = Callable.from(descriptor)) - DescriptorCache.add(dri, descriptor) - return super.visitFunctionDescriptor(descriptor, parent) - } - - override fun visitConstructorDescriptor(descriptor: ConstructorDescriptor, parent: DRIWithPlatformInfo): Function { - val dri = parent.dri.copy(callable = Callable.from(descriptor)) - DescriptorCache.add(dri, descriptor) - return super.visitConstructorDescriptor(descriptor, parent) - } - - override fun visitPropertyAccessorDescriptor( - descriptor: PropertyAccessorDescriptor, - propertyDescriptor: PropertyDescriptor, - parent: DRI - ): Function { - val dri = parent.copy(callable = Callable.from(descriptor)) - DescriptorCache.add(dri, descriptor) - return super.visitPropertyAccessorDescriptor(descriptor, propertyDescriptor, parent) - } -} \ No newline at end of file diff --git a/plugins/kotlin-as-java/src/main/kotlin/KotlinAsJavaPlugin.kt b/plugins/kotlin-as-java/src/main/kotlin/KotlinAsJavaPlugin.kt index f9389ebd..1a6bc0db 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/KotlinAsJavaPlugin.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/KotlinAsJavaPlugin.kt @@ -3,21 +3,22 @@ package org.jetbrains.dokka.kotlinAsJava import org.jetbrains.dokka.CoreExtensions import org.jetbrains.dokka.base.DokkaBase -import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentConverter import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.Module import org.jetbrains.dokka.pages.ModulePageNode -import org.jetbrains.dokka.plugability.* -import org.jetbrains.dokka.transformers.documentation.DocumentablesToPageTranslator -import org.jetbrains.dokka.utilities.DokkaLogger +import org.jetbrains.dokka.plugability.DokkaContext +import org.jetbrains.dokka.plugability.DokkaPlugin +import org.jetbrains.dokka.plugability.plugin +import org.jetbrains.dokka.plugability.querySingle +import org.jetbrains.dokka.transformers.documentation.DocumentableToPageTranslator import org.jetbrains.kotlin.descriptors.DeclarationDescriptor class KotlinAsJavaPlugin : DokkaPlugin() { val kotlinAsJavaDescriptorToDocumentableTranslator by extending { - CoreExtensions.descriptorToDocumentationTranslator providing ::KotlinAsJavaDescriptorToDocumentationTranslator + CoreExtensions.descriptorToDocumentableTranslator providing ::KotlinAsJavaDescriptorToDocumentableTranslator } val kotlinAsJavaDocumentableToPageTranslator by extending { - CoreExtensions.documentablesToPageTranslator providing ::KotlinAsJavaDocumentationToPageTranslator + CoreExtensions.documentableToPageTranslator providing ::KotlinAsJavaDocumentationToPageTranslator } } @@ -30,7 +31,7 @@ object DescriptorCache { class KotlinAsJavaDocumentationToPageTranslator( private val context: DokkaContext -) : DocumentablesToPageTranslator { +) : DocumentableToPageTranslator { override fun invoke(module: Module): ModulePageNode = KotlinAsJavaPageBuilder { node, kind, operation -> KotlinAsJavaPageContentBuilder.group( diff --git a/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt b/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt index 52723157..cded0929 100644 --- a/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt +++ b/plugins/mathjax/src/main/kotlin/MathjaxPlugin.kt @@ -1,13 +1,12 @@ package org.jetbrains.dokka.mathjax -import org.jetbrains.dokka.model.doc.CustomWrapperTag import org.jetbrains.dokka.CoreExtensions +import org.jetbrains.dokka.model.doc.CustomWrapperTag import org.jetbrains.dokka.pages.ContentPage -import org.jetbrains.dokka.pages.PageNode import org.jetbrains.dokka.pages.RootPageNode import org.jetbrains.dokka.plugability.DokkaPlugin -import org.jetbrains.dokka.transformers.pages.PageNodeTransformer +import org.jetbrains.dokka.transformers.pages.PageTransformer class MathjaxPlugin : DokkaPlugin() { val transformer by extending { @@ -18,7 +17,7 @@ class MathjaxPlugin : DokkaPlugin() { private const val ANNOTATION = "usesMathJax" private const val LIB_PATH = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.6/MathJax.js?config=TeX-AMS_SVG&latest" -object MathjaxTransformer : PageNodeTransformer { +object MathjaxTransformer : PageTransformer { override fun invoke(input: RootPageNode) = input.transformContentPagesTree { it.modified( embeddedResources = it.embeddedResources + if (it.isNeedingMathjax) listOf(LIB_PATH) else emptyList() -- cgit From be35f8628fbbfe3cc248f6c504a664a77d37c8e7 Mon Sep 17 00:00:00 2001 From: Paweł Marks Date: Wed, 4 Mar 2020 16:51:55 +0100 Subject: Prunes member branches in navigation tree --- plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt') diff --git a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt index 9db0f2a8..787f2b69 100644 --- a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt +++ b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt @@ -45,7 +45,11 @@ object NavigationPageInstaller : PageTransformer { page.name, page.dri.first(), page.platforms(), - page.children.filterIsInstance().map { visit(it) }) + if (page !is ClasslikePageNode) + page.children.filterIsInstance().map { visit(it) } + else + emptyList() + ) } object ResourceInstaller : PageTransformer { -- cgit From 03fef66d5516f14e8c3a63784ccdc1a9fa492934 Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Wed, 11 Mar 2020 19:38:47 +0100 Subject: Fix searching in HTML format by appending js --- plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt') diff --git a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt index 787f2b69..a72c77ea 100644 --- a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt +++ b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt @@ -20,7 +20,7 @@ object SearchPageInstaller : PageTransformer { name = "Search", children = emptyList(), strategy = RenderingStrategy { - buildHtml(it, listOf("styles/style.css", "scripts/pages.js")) { + buildHtml(it, listOf("styles/style.css", "scripts/pages.js", "scripts/search.js")) { h1 { id = "searchTitle" text("Search results for ") -- cgit From fee86d79a3aa7357c68c2f8f519d187f43447e8c Mon Sep 17 00:00:00 2001 From: Andrzej Ratajczak Date: Fri, 3 Apr 2020 13:57:33 +0200 Subject: Refactor package list to be a preprocessor --- core/src/main/kotlin/links/DRI.kt | 2 +- plugins/base/src/main/kotlin/DokkaBase.kt | 14 ++++-- .../src/main/kotlin/renderers/DefaultRenderer.kt | 19 -------- .../main/kotlin/renderers/PackageListService.kt | 51 ++++++++++++++++++++++ .../kotlin/renderers/html/htmlPreprocessors.kt | 29 ++++++------ .../src/main/kotlin/renderers/preprocessors.kt | 27 ++++++++++++ .../test/kotlin/renderers/RenderingOnlyTestBase.kt | 2 +- .../annotatedFunction/out/html/root/package-list | 5 +++ .../out/html/root/package-list | 8 ++++ .../expect/function/out/html/root/package-list | 5 +++ .../out/html/root/package-list | 8 ++++ .../out/html/root/package-list | 5 +++ .../out/html/root/package-list | 5 +++ .../out/html/root/package-list | 5 +++ .../functionWithParams/out/html/root/package-list | 5 +++ .../out/html/root/package-list | 6 +++ .../genericFunction/out/html/root/package-list | 5 +++ .../out/html/root/package-list | 5 +++ .../inlineFunction/out/html/root/package-list | 5 +++ .../out/html/root/package-list | 5 +++ .../signatureTest/out/html/root/package-list | 5 +++ .../expect/sinceKotlin/out/html/root/package-list | 5 +++ .../suspendFunction/out/html/root/package-list | 5 +++ .../out/html/root/package-list | 5 +++ plugins/gfm/src/main/kotlin/GfmPlugin.kt | 25 ++++++++++- plugins/jekyll/src/main/kotlin/JekyllPlugin.kt | 23 ++++++++++ 26 files changed, 244 insertions(+), 40 deletions(-) create mode 100644 plugins/base/src/main/kotlin/renderers/PackageListService.kt create mode 100644 plugins/base/src/main/kotlin/renderers/preprocessors.kt create mode 100644 plugins/base/src/test/resources/expect/annotatedFunction/out/html/root/package-list create mode 100644 plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root/package-list create mode 100644 plugins/base/src/test/resources/expect/function/out/html/root/package-list create mode 100644 plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root/package-list create mode 100644 plugins/base/src/test/resources/expect/functionWithDefaultParameter/out/html/root/package-list create mode 100644 plugins/base/src/test/resources/expect/functionWithNoinlineParam/out/html/root/package-list create mode 100644 plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/out/html/root/package-list create mode 100644 plugins/base/src/test/resources/expect/functionWithParams/out/html/root/package-list create mode 100644 plugins/base/src/test/resources/expect/functionWithReceiver/out/html/root/package-list create mode 100644 plugins/base/src/test/resources/expect/genericFunction/out/html/root/package-list create mode 100644 plugins/base/src/test/resources/expect/genericFunctionWithConstraints/out/html/root/package-list create mode 100644 plugins/base/src/test/resources/expect/inlineFunction/out/html/root/package-list create mode 100644 plugins/base/src/test/resources/expect/inlineSuspendFunction/out/html/root/package-list create mode 100644 plugins/base/src/test/resources/expect/signatureTest/out/html/root/package-list create mode 100644 plugins/base/src/test/resources/expect/sinceKotlin/out/html/root/package-list create mode 100644 plugins/base/src/test/resources/expect/suspendFunction/out/html/root/package-list create mode 100644 plugins/base/src/test/resources/expect/suspendInlineFunction/out/html/root/package-list (limited to 'plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt') diff --git a/core/src/main/kotlin/links/DRI.kt b/core/src/main/kotlin/links/DRI.kt index f961c982..3d9012ec 100644 --- a/core/src/main/kotlin/links/DRI.kt +++ b/core/src/main/kotlin/links/DRI.kt @@ -69,7 +69,7 @@ val DRI.parent: DRI genericTarget != null -> copy(genericTarget = null) target != null -> copy(target = null) callable != null -> copy(callable = null) - classNames != null -> copy(classNames = classNames.substringBeforeLast('.').takeIf { it.isNotBlank() }) + classNames != null -> copy(classNames = classNames.substringBeforeLast(".", "").takeIf { it.isNotBlank() }) else -> DRI.topLevel } diff --git a/plugins/base/src/main/kotlin/DokkaBase.kt b/plugins/base/src/main/kotlin/DokkaBase.kt index e8614507..5a86780b 100644 --- a/plugins/base/src/main/kotlin/DokkaBase.kt +++ b/plugins/base/src/main/kotlin/DokkaBase.kt @@ -1,10 +1,8 @@ package org.jetbrains.dokka.base import org.jetbrains.dokka.CoreExtensions -import org.jetbrains.dokka.base.renderers.FileWriter -import org.jetbrains.dokka.base.renderers.OutputWriter +import org.jetbrains.dokka.base.renderers.* import org.jetbrains.dokka.base.renderers.html.* -import org.jetbrains.dokka.base.renderers.html.HtmlRenderer import org.jetbrains.dokka.base.signatures.KotlinSignatureProvider import org.jetbrains.dokka.base.signatures.SignatureProvider import org.jetbrains.dokka.base.resolvers.external.* @@ -154,4 +152,14 @@ class DokkaBase : DokkaPlugin() { val styleAndScriptsAppender by extending { htmlPreprocessors with StyleAndScriptsAppender order { after(rootCreator) } } + + val packageListCreator by extending { + htmlPreprocessors providing { + PackageListCreator( + it, + "html", + "html" + ) + } order { after(rootCreator) } + } } \ No newline at end of file diff --git a/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt b/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt index 0ff0511a..26c75dbf 100644 --- a/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt @@ -114,31 +114,12 @@ abstract class DefaultRenderer( root.children.forEach { renderPages(it) } } - // reimplement this as preprocessor - open fun renderPackageList(root: ContentPage) = - getPackageNamesAndPlatforms(root) - .keys - .joinToString("\n") - .also { outputWriter.write("${root.name}/package-list", it, "") } - - open fun getPackageNamesAndPlatforms(root: PageNode): Map> = - root.children - .map(::getPackageNamesAndPlatforms) - .fold(emptyMap>()) { e, acc -> acc + e } + - if (root is PackagePageNode) { - mapOf(root.name to root.platforms()) - } else { - emptyMap() - } - override fun render(root: RootPageNode) { val newRoot = preprocessors.fold(root) { acc, t -> t(acc) } locationProvider = context.plugin().querySingle { locationProviderFactory }.getLocationProvider(newRoot) - root.children().forEach { renderPackageList(it) } - renderPages(newRoot) } } diff --git a/plugins/base/src/main/kotlin/renderers/PackageListService.kt b/plugins/base/src/main/kotlin/renderers/PackageListService.kt new file mode 100644 index 00000000..d4333200 --- /dev/null +++ b/plugins/base/src/main/kotlin/renderers/PackageListService.kt @@ -0,0 +1,51 @@ +package org.jetbrains.dokka.base.renderers + +import org.jetbrains.dokka.base.DokkaBase +import org.jetbrains.dokka.links.DRI +import org.jetbrains.dokka.links.parent +import org.jetbrains.dokka.pages.* +import org.jetbrains.dokka.plugability.DokkaContext +import org.jetbrains.dokka.plugability.plugin +import org.jetbrains.dokka.plugability.querySingle +import org.jetbrains.kotlin.utils.addToStdlib.safeAs + +class PackageListService(val context: DokkaContext) { + + fun formatPackageList(module: RootPageNode, format: String, linkExtension: String): String { + + val packages = mutableSetOf() + val nonStandardLocations = mutableMapOf() + + val locationProvider = + context.plugin().querySingle { locationProviderFactory }.getLocationProvider(module) + + fun visit(node: PageNode, parentDris: Set) { + + if (node is PackagePageNode) { + packages.add(node.name) + } + + val contentPage = node.safeAs() + contentPage?.dri?.forEach { + if (parentDris.isNotEmpty() && it.parent !in parentDris) { + nonStandardLocations[it.toString()] = locationProvider.resolve(node) + } + } + + node.children.forEach { visit(it, contentPage?.dri ?: setOf()) } + } + + visit(module, setOf()) + + return buildString { + appendln("\$dokka.format:${format}") + appendln("\$dokka.linkExtension:${linkExtension}") + nonStandardLocations.map { (signature, location) -> "\$dokka.location:$signature\u001f$location" } + .sorted().joinTo(this, separator = "\n", postfix = "\n") + + packages.sorted().joinTo(this, separator = "\n", postfix = "\n") + } + + } + +} \ No newline at end of file diff --git a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt index a72c77ea..9fed74e2 100644 --- a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt +++ b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt @@ -8,10 +8,6 @@ import org.jetbrains.dokka.base.renderers.platforms import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.transformers.pages.PageTransformer -object RootCreator : PageTransformer { - override fun invoke(input: RootPageNode) = - RendererSpecificRootPage("", listOf(input), RenderingStrategy.DoNothing) -} object SearchPageInstaller : PageTransformer { override fun invoke(input: RootPageNode) = input.modified(children = input.children + searchPage) @@ -37,19 +33,22 @@ object SearchPageInstaller : PageTransformer { object NavigationPageInstaller : PageTransformer { override fun invoke(input: RootPageNode) = input.modified( children = input.children + NavigationPage( - input.children.filterIsInstance().single().let(::visit) + input.children.filterIsInstance().single() + .let(NavigationPageInstaller::visit) ) ) - private fun visit(page: ContentPage): NavigationNode = NavigationNode( - page.name, - page.dri.first(), - page.platforms(), - if (page !is ClasslikePageNode) - page.children.filterIsInstance().map { visit(it) } - else - emptyList() - ) + private fun visit(page: ContentPage): NavigationNode = + NavigationNode( + page.name, + page.dri.first(), + page.platforms(), + if (page !is ClasslikePageNode) + page.children.filterIsInstance() + .map { visit(it) } + else + emptyList() + ) } object ResourceInstaller : PageTransformer { @@ -69,4 +68,4 @@ object StyleAndScriptsAppender : PageTransformer { ) ) } -} +} \ No newline at end of file diff --git a/plugins/base/src/main/kotlin/renderers/preprocessors.kt b/plugins/base/src/main/kotlin/renderers/preprocessors.kt new file mode 100644 index 00000000..bf2a9eb4 --- /dev/null +++ b/plugins/base/src/main/kotlin/renderers/preprocessors.kt @@ -0,0 +1,27 @@ +package org.jetbrains.dokka.base.renderers + +import org.jetbrains.dokka.pages.* +import org.jetbrains.dokka.plugability.DokkaContext +import org.jetbrains.dokka.transformers.pages.PageTransformer + +object RootCreator : PageTransformer { + override fun invoke(input: RootPageNode) = + RendererSpecificRootPage("", listOf(input), RenderingStrategy.DoNothing) +} + + +class PackageListCreator(val context: DokkaContext, val format: String, val linkExtension: String) : PageTransformer { + override fun invoke(input: RootPageNode) = + input.modified(children = input.children.map { + it.takeUnless { it is ModulePageNode } + ?: it.modified(children = it.children + packageList(input)) // TODO packageList should take module as an input + }) + + + private fun packageList(pageNode: RootPageNode) = + RendererSpecificResourcePage( + "${pageNode.name}/package-list", + emptyList(), + RenderingStrategy.Write(PackageListService(context).formatPackageList(pageNode, format, linkExtension)) + ) +} diff --git a/plugins/base/src/test/kotlin/renderers/RenderingOnlyTestBase.kt b/plugins/base/src/test/kotlin/renderers/RenderingOnlyTestBase.kt index 5f8d1dc4..b9809ac1 100644 --- a/plugins/base/src/test/kotlin/renderers/RenderingOnlyTestBase.kt +++ b/plugins/base/src/test/kotlin/renderers/RenderingOnlyTestBase.kt @@ -2,7 +2,7 @@ package renderers import org.jetbrains.dokka.DokkaConfigurationImpl import org.jetbrains.dokka.base.DokkaBase -import org.jetbrains.dokka.base.renderers.html.RootCreator +import org.jetbrains.dokka.base.renderers.RootCreator import org.jetbrains.dokka.base.resolvers.external.DokkaExternalLocationProviderFactory import org.jetbrains.dokka.base.resolvers.external.JavadocExternalLocationProviderFactory import org.jetbrains.dokka.base.resolvers.local.DefaultLocationProviderFactory diff --git a/plugins/base/src/test/resources/expect/annotatedFunction/out/html/root/package-list b/plugins/base/src/test/resources/expect/annotatedFunction/out/html/root/package-list new file mode 100644 index 00000000..caf6273a --- /dev/null +++ b/plugins/base/src/test/resources/expect/annotatedFunction/out/html/root/package-list @@ -0,0 +1,5 @@ +$dokka.format:html +$dokka.linkExtension:html +$dokka.location://f/#//root//f.html + + diff --git a/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root/package-list b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root/package-list new file mode 100644 index 00000000..d2e42c86 --- /dev/null +++ b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root/package-list @@ -0,0 +1,8 @@ +$dokka.format:html +$dokka.linkExtension:html +$dokka.location://f/#//root//f.html +$dokka.location:/Fancy/equals/#kotlin.Any?//root//-fancy/equals.html +$dokka.location:/Fancy/hashCode/#//root//-fancy/hash-code.html +$dokka.location:/Fancy/toString/#//root//-fancy/to-string.html + + diff --git a/plugins/base/src/test/resources/expect/function/out/html/root/package-list b/plugins/base/src/test/resources/expect/function/out/html/root/package-list new file mode 100644 index 00000000..3a7c6807 --- /dev/null +++ b/plugins/base/src/test/resources/expect/function/out/html/root/package-list @@ -0,0 +1,5 @@ +$dokka.format:html +$dokka.linkExtension:html +$dokka.location://fn/#//root//fn.html + + diff --git a/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root/package-list b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root/package-list new file mode 100644 index 00000000..0b48e7e0 --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root/package-list @@ -0,0 +1,8 @@ +$dokka.format:html +$dokka.linkExtension:html +$dokka.location://function/#kotlin.Function0[kotlin.Unit]//root//function.html +$dokka.location:/Fancy/equals/#kotlin.Any?//root//-fancy/equals.html +$dokka.location:/Fancy/hashCode/#//root//-fancy/hash-code.html +$dokka.location:/Fancy/toString/#//root//-fancy/to-string.html + + diff --git a/plugins/base/src/test/resources/expect/functionWithDefaultParameter/out/html/root/package-list b/plugins/base/src/test/resources/expect/functionWithDefaultParameter/out/html/root/package-list new file mode 100644 index 00000000..c8e4e8e1 --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithDefaultParameter/out/html/root/package-list @@ -0,0 +1,5 @@ +$dokka.format:html +$dokka.linkExtension:html +$dokka.location://f/#kotlin.String//root//f.html + + diff --git a/plugins/base/src/test/resources/expect/functionWithNoinlineParam/out/html/root/package-list b/plugins/base/src/test/resources/expect/functionWithNoinlineParam/out/html/root/package-list new file mode 100644 index 00000000..7de7dd3b --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithNoinlineParam/out/html/root/package-list @@ -0,0 +1,5 @@ +$dokka.format:html +$dokka.linkExtension:html +$dokka.location://function/#kotlin.Function0[kotlin.Unit]//root//function.html + + diff --git a/plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/out/html/root/package-list b/plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/out/html/root/package-list new file mode 100644 index 00000000..caf6273a --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/out/html/root/package-list @@ -0,0 +1,5 @@ +$dokka.format:html +$dokka.linkExtension:html +$dokka.location://f/#//root//f.html + + diff --git a/plugins/base/src/test/resources/expect/functionWithParams/out/html/root/package-list b/plugins/base/src/test/resources/expect/functionWithParams/out/html/root/package-list new file mode 100644 index 00000000..8b5d43ee --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithParams/out/html/root/package-list @@ -0,0 +1,5 @@ +$dokka.format:html +$dokka.linkExtension:html +$dokka.location://function/#kotlin.Int//root//function.html + + diff --git a/plugins/base/src/test/resources/expect/functionWithReceiver/out/html/root/package-list b/plugins/base/src/test/resources/expect/functionWithReceiver/out/html/root/package-list new file mode 100644 index 00000000..13dc2923 --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithReceiver/out/html/root/package-list @@ -0,0 +1,6 @@ +$dokka.format:html +$dokka.linkExtension:html +$dokka.location://fn/kotlin.String#//root//fn.html +$dokka.location://fn/kotlin.String#kotlin.Int//root//fn.html + + diff --git a/plugins/base/src/test/resources/expect/genericFunction/out/html/root/package-list b/plugins/base/src/test/resources/expect/genericFunction/out/html/root/package-list new file mode 100644 index 00000000..30905d0f --- /dev/null +++ b/plugins/base/src/test/resources/expect/genericFunction/out/html/root/package-list @@ -0,0 +1,5 @@ +$dokka.format:html +$dokka.linkExtension:html +$dokka.location://generic/#//root//generic.html + + diff --git a/plugins/base/src/test/resources/expect/genericFunctionWithConstraints/out/html/root/package-list b/plugins/base/src/test/resources/expect/genericFunctionWithConstraints/out/html/root/package-list new file mode 100644 index 00000000..30905d0f --- /dev/null +++ b/plugins/base/src/test/resources/expect/genericFunctionWithConstraints/out/html/root/package-list @@ -0,0 +1,5 @@ +$dokka.format:html +$dokka.linkExtension:html +$dokka.location://generic/#//root//generic.html + + diff --git a/plugins/base/src/test/resources/expect/inlineFunction/out/html/root/package-list b/plugins/base/src/test/resources/expect/inlineFunction/out/html/root/package-list new file mode 100644 index 00000000..60993388 --- /dev/null +++ b/plugins/base/src/test/resources/expect/inlineFunction/out/html/root/package-list @@ -0,0 +1,5 @@ +$dokka.format:html +$dokka.linkExtension:html +$dokka.location://f/#kotlin.Function0[kotlin.String]//root//f.html + + diff --git a/plugins/base/src/test/resources/expect/inlineSuspendFunction/out/html/root/package-list b/plugins/base/src/test/resources/expect/inlineSuspendFunction/out/html/root/package-list new file mode 100644 index 00000000..60993388 --- /dev/null +++ b/plugins/base/src/test/resources/expect/inlineSuspendFunction/out/html/root/package-list @@ -0,0 +1,5 @@ +$dokka.format:html +$dokka.linkExtension:html +$dokka.location://f/#kotlin.Function0[kotlin.String]//root//f.html + + diff --git a/plugins/base/src/test/resources/expect/signatureTest/out/html/root/package-list b/plugins/base/src/test/resources/expect/signatureTest/out/html/root/package-list new file mode 100644 index 00000000..3c53d355 --- /dev/null +++ b/plugins/base/src/test/resources/expect/signatureTest/out/html/root/package-list @@ -0,0 +1,5 @@ +$dokka.format:html +$dokka.linkExtension:html + +signatureTest + diff --git a/plugins/base/src/test/resources/expect/sinceKotlin/out/html/root/package-list b/plugins/base/src/test/resources/expect/sinceKotlin/out/html/root/package-list new file mode 100644 index 00000000..8810ec13 --- /dev/null +++ b/plugins/base/src/test/resources/expect/sinceKotlin/out/html/root/package-list @@ -0,0 +1,5 @@ +$dokka.format:html +$dokka.linkExtension:html +$dokka.location://availableSince1.1/#//root//available-since1.1.html + + diff --git a/plugins/base/src/test/resources/expect/suspendFunction/out/html/root/package-list b/plugins/base/src/test/resources/expect/suspendFunction/out/html/root/package-list new file mode 100644 index 00000000..caf6273a --- /dev/null +++ b/plugins/base/src/test/resources/expect/suspendFunction/out/html/root/package-list @@ -0,0 +1,5 @@ +$dokka.format:html +$dokka.linkExtension:html +$dokka.location://f/#//root//f.html + + diff --git a/plugins/base/src/test/resources/expect/suspendInlineFunction/out/html/root/package-list b/plugins/base/src/test/resources/expect/suspendInlineFunction/out/html/root/package-list new file mode 100644 index 00000000..60993388 --- /dev/null +++ b/plugins/base/src/test/resources/expect/suspendInlineFunction/out/html/root/package-list @@ -0,0 +1,5 @@ +$dokka.format:html +$dokka.linkExtension:html +$dokka.location://f/#kotlin.Function0[kotlin.String]//root//f.html + + diff --git a/plugins/gfm/src/main/kotlin/GfmPlugin.kt b/plugins/gfm/src/main/kotlin/GfmPlugin.kt index 7c0ce509..91b6f7b5 100644 --- a/plugins/gfm/src/main/kotlin/GfmPlugin.kt +++ b/plugins/gfm/src/main/kotlin/GfmPlugin.kt @@ -3,17 +3,23 @@ package org.jetbrains.dokka.gfm import org.jetbrains.dokka.CoreExtensions import org.jetbrains.dokka.base.DokkaBase import org.jetbrains.dokka.base.renderers.DefaultRenderer -import org.jetbrains.dokka.base.renderers.OutputWriter +import org.jetbrains.dokka.base.renderers.PackageListCreator +import org.jetbrains.dokka.base.renderers.RootCreator import org.jetbrains.dokka.base.resolvers.local.DefaultLocationProvider import org.jetbrains.dokka.base.resolvers.local.LocationProviderFactory import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.plugability.DokkaPlugin +import org.jetbrains.dokka.plugability.plugin +import org.jetbrains.dokka.plugability.query +import org.jetbrains.dokka.transformers.pages.PageTransformer import java.lang.StringBuilder class GfmPlugin : DokkaPlugin() { + val gfmPreprocessors by extensionPoint() + val renderer by extending { CoreExtensions.renderer providing { CommonmarkRenderer(it) } applyIf { format == "gfm" } } @@ -21,11 +27,28 @@ class GfmPlugin : DokkaPlugin() { val locationProvider by extending { plugin().locationProviderFactory providing { MarkdownLocationProviderFactory(it) } applyIf { format == "gfm" } } + + val rootCreator by extending { + gfmPreprocessors with RootCreator + } + + val packageListCreator by extending { + gfmPreprocessors providing { + PackageListCreator( + it, + "gfm", + "md" + ) + } order { after(rootCreator) } + } } open class CommonmarkRenderer( context: DokkaContext ) : DefaultRenderer(context) { + + override val preprocessors = context.plugin().query { gfmPreprocessors } + override fun StringBuilder.buildHeader(level: Int, content: StringBuilder.() -> Unit) { buildParagraph() append("#".repeat(level) + " ") diff --git a/plugins/jekyll/src/main/kotlin/JekyllPlugin.kt b/plugins/jekyll/src/main/kotlin/JekyllPlugin.kt index c4f7f2c7..b9f5e1a5 100644 --- a/plugins/jekyll/src/main/kotlin/JekyllPlugin.kt +++ b/plugins/jekyll/src/main/kotlin/JekyllPlugin.kt @@ -1,24 +1,47 @@ package org.jetbrains.dokka.jekyll import org.jetbrains.dokka.CoreExtensions +import org.jetbrains.dokka.base.renderers.PackageListCreator +import org.jetbrains.dokka.base.renderers.RootCreator import org.jetbrains.dokka.gfm.CommonmarkRenderer import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.plugability.DokkaPlugin +import org.jetbrains.dokka.plugability.plugin +import org.jetbrains.dokka.plugability.query +import org.jetbrains.dokka.transformers.pages.PageTransformer import java.lang.StringBuilder class JekyllPlugin : DokkaPlugin() { + val jekyllPreprocessors by extensionPoint() + val renderer by extending { CoreExtensions.renderer providing { JekyllRenderer(it) } applyIf { format == "jekyll" } } + + val rootCreator by extending { + jekyllPreprocessors with RootCreator + } + + val packageListCreator by extending { + jekyllPreprocessors providing { + PackageListCreator( + it, + "jekyll", + "md" + ) + } order { after(rootCreator) } + } } class JekyllRenderer( context: DokkaContext ) : CommonmarkRenderer(context) { + override val preprocessors = context.plugin().query { jekyllPreprocessors } + override fun buildPage(page: ContentPage, content: (StringBuilder, ContentPage) -> Unit): String { val builder = StringBuilder() builder.append("---\n") -- cgit From 72db3a16521408509f4a0f61ef110851a252d2cc Mon Sep 17 00:00:00 2001 From: Filip Zybała Date: Mon, 6 Apr 2020 14:24:07 +0200 Subject: Change PlatformHintedContent rendering, js and css to match Figma style --- .../resources/dokka/scripts/navigationLoader.js | 4 +- .../dokka/scripts/platformContentHandler.js | 29 +++++++++++++ core/src/main/resources/dokka/styles/style.css | 50 ++++++++++++++++++++++ .../src/main/kotlin/renderers/html/HtmlRenderer.kt | 37 ++++++++++------ .../kotlin/renderers/html/htmlPreprocessors.kt | 3 +- .../renderers/html/PlatformDependentHintTest.kt | 14 +++--- .../out/html/root//f.html | 4 +- .../out/html/root//index.html | 4 +- .../annotatedFunction/out/html/root/index.html | 1 + .../out/html/scripts/navigationLoader.js | 4 +- .../out/html/scripts/platformContentHandler.js | 29 +++++++++++++ .../annotatedFunction/out/html/styles/style.css | 50 ++++++++++++++++++++++ .../out/html/root//-fancy/-init-.html | 4 +- .../out/html/root//-fancy/equals.html | 4 +- .../out/html/root//-fancy/hash-code.html | 4 +- .../out/html/root//-fancy/index.html | 16 ++++--- .../out/html/root//-fancy/to-string.html | 4 +- .../out/html/root//f.html | 4 +- .../out/html/root//index.html | 7 ++- .../out/html/root/index.html | 1 + .../out/html/scripts/navigationLoader.js | 4 +- .../out/html/scripts/platformContentHandler.js | 29 +++++++++++++ .../out/html/styles/style.css | 50 ++++++++++++++++++++++ .../function/out/html/root//fn.html | 7 ++- .../function/out/html/root//index.html | 4 +- .../expect/function/out/html/root/index.html | 1 + .../function/out/html/scripts/navigationLoader.js | 4 +- .../out/html/scripts/platformContentHandler.js | 29 +++++++++++++ .../expect/function/out/html/styles/style.css | 50 ++++++++++++++++++++++ .../out/html/root//-fancy/-init-.html | 4 +- .../out/html/root//-fancy/equals.html | 4 +- .../out/html/root//-fancy/hash-code.html | 4 +- .../out/html/root//-fancy/index.html | 13 ++++-- .../out/html/root//-fancy/to-string.html | 4 +- .../out/html/root//function.html | 4 +- .../out/html/root//index.html | 7 ++- .../out/html/root/index.html | 1 + .../out/html/scripts/navigationLoader.js | 4 +- .../out/html/scripts/platformContentHandler.js | 29 +++++++++++++ .../out/html/styles/style.css | 50 ++++++++++++++++++++++ .../out/html/root//f.html | 4 +- .../out/html/root//index.html | 4 +- .../out/html/root/index.html | 1 + .../out/html/scripts/navigationLoader.js | 4 +- .../out/html/scripts/platformContentHandler.js | 29 +++++++++++++ .../out/html/styles/style.css | 50 ++++++++++++++++++++++ .../out/html/root//function.html | 4 +- .../out/html/root//index.html | 4 +- .../out/html/root/index.html | 1 + .../out/html/scripts/navigationLoader.js | 4 +- .../out/html/scripts/platformContentHandler.js | 29 +++++++++++++ .../out/html/styles/style.css | 50 ++++++++++++++++++++++ .../out/html/root//f.html | 4 +- .../out/html/root//index.html | 4 +- .../out/html/root/index.html | 1 + .../out/html/scripts/navigationLoader.js | 4 +- .../out/html/scripts/platformContentHandler.js | 29 +++++++++++++ .../out/html/styles/style.css | 50 ++++++++++++++++++++++ .../out/html/root//function.html | 7 ++- .../out/html/root//index.html | 4 +- .../functionWithParams/out/html/root/index.html | 1 + .../out/html/scripts/navigationLoader.js | 4 +- .../out/html/scripts/platformContentHandler.js | 29 +++++++++++++ .../functionWithParams/out/html/styles/style.css | 50 ++++++++++++++++++++++ .../out/html/root//fn.html | 13 ++++-- .../out/html/root//index.html | 7 ++- .../functionWithReceiver/out/html/root/index.html | 1 + .../out/html/scripts/navigationLoader.js | 4 +- .../out/html/scripts/platformContentHandler.js | 29 +++++++++++++ .../functionWithReceiver/out/html/styles/style.css | 50 ++++++++++++++++++++++ .../out/html/root//generic.html | 7 ++- .../out/html/root//index.html | 4 +- .../genericFunction/out/html/root/index.html | 1 + .../out/html/scripts/navigationLoader.js | 4 +- .../out/html/scripts/platformContentHandler.js | 29 +++++++++++++ .../genericFunction/out/html/styles/style.css | 50 ++++++++++++++++++++++ .../out/html/root//generic.html | 7 ++- .../out/html/root//index.html | 4 +- .../out/html/root/index.html | 1 + .../out/html/scripts/navigationLoader.js | 4 +- .../out/html/scripts/platformContentHandler.js | 29 +++++++++++++ .../out/html/styles/style.css | 50 ++++++++++++++++++++++ .../inlineFunction/out/html/root//f.html | 4 +- .../out/html/root//index.html | 4 +- .../expect/inlineFunction/out/html/root/index.html | 1 + .../out/html/scripts/navigationLoader.js | 4 +- .../out/html/scripts/platformContentHandler.js | 29 +++++++++++++ .../inlineFunction/out/html/styles/style.css | 50 ++++++++++++++++++++++ .../out/html/root//f.html | 4 +- .../out/html/root//index.html | 4 +- .../inlineSuspendFunction/out/html/root/index.html | 1 + .../out/html/scripts/navigationLoader.js | 4 +- .../out/html/scripts/platformContentHandler.js | 29 +++++++++++++ .../out/html/styles/style.css | 50 ++++++++++++++++++++++ .../expect/signatureTest/out/html/root/index.html | 1 + .../out/html/root/signatureTest/index.html | 7 ++- .../out/html/root/signatureTest/test.html | 4 +- .../out/html/root/signatureTest/test2.html | 4 +- .../out/html/scripts/navigationLoader.js | 4 +- .../out/html/scripts/platformContentHandler.js | 29 +++++++++++++ .../expect/signatureTest/out/html/styles/style.css | 50 ++++++++++++++++++++++ .../html/root//available-since1.1.html | 7 ++- .../out/html/root//index.html | 4 +- .../expect/sinceKotlin/out/html/root/index.html | 1 + .../out/html/scripts/navigationLoader.js | 4 +- .../out/html/scripts/platformContentHandler.js | 29 +++++++++++++ .../expect/sinceKotlin/out/html/styles/style.css | 50 ++++++++++++++++++++++ .../out/html/root//f.html | 4 +- .../out/html/root//index.html | 4 +- .../suspendFunction/out/html/root/index.html | 1 + .../out/html/scripts/navigationLoader.js | 4 +- .../out/html/scripts/platformContentHandler.js | 29 +++++++++++++ .../suspendFunction/out/html/styles/style.css | 50 ++++++++++++++++++++++ .../out/html/root//f.html | 4 +- .../out/html/root//index.html | 4 +- .../suspendInlineFunction/out/html/root/index.html | 1 + .../out/html/scripts/navigationLoader.js | 4 +- .../out/html/scripts/platformContentHandler.js | 29 +++++++++++++ .../out/html/styles/style.css | 50 ++++++++++++++++++++++ 119 files changed, 1682 insertions(+), 120 deletions(-) create mode 100644 core/src/main/resources/dokka/scripts/platformContentHandler.js create mode 100644 plugins/base/src/test/resources/expect/annotatedFunction/out/html/scripts/platformContentHandler.js create mode 100644 plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/scripts/platformContentHandler.js create mode 100644 plugins/base/src/test/resources/expect/function/out/html/scripts/platformContentHandler.js create mode 100644 plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/scripts/platformContentHandler.js create mode 100644 plugins/base/src/test/resources/expect/functionWithDefaultParameter/out/html/scripts/platformContentHandler.js create mode 100644 plugins/base/src/test/resources/expect/functionWithNoinlineParam/out/html/scripts/platformContentHandler.js create mode 100644 plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/out/html/scripts/platformContentHandler.js create mode 100644 plugins/base/src/test/resources/expect/functionWithParams/out/html/scripts/platformContentHandler.js create mode 100644 plugins/base/src/test/resources/expect/functionWithReceiver/out/html/scripts/platformContentHandler.js create mode 100644 plugins/base/src/test/resources/expect/genericFunction/out/html/scripts/platformContentHandler.js create mode 100644 plugins/base/src/test/resources/expect/genericFunctionWithConstraints/out/html/scripts/platformContentHandler.js create mode 100644 plugins/base/src/test/resources/expect/inlineFunction/out/html/scripts/platformContentHandler.js create mode 100644 plugins/base/src/test/resources/expect/inlineSuspendFunction/out/html/scripts/platformContentHandler.js create mode 100644 plugins/base/src/test/resources/expect/signatureTest/out/html/scripts/platformContentHandler.js create mode 100644 plugins/base/src/test/resources/expect/sinceKotlin/out/html/scripts/platformContentHandler.js create mode 100644 plugins/base/src/test/resources/expect/suspendFunction/out/html/scripts/platformContentHandler.js create mode 100644 plugins/base/src/test/resources/expect/suspendInlineFunction/out/html/scripts/platformContentHandler.js (limited to 'plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt') diff --git a/core/src/main/resources/dokka/scripts/navigationLoader.js b/core/src/main/resources/dokka/scripts/navigationLoader.js index 5fe52ade..ecbabb4c 100644 --- a/core/src/main/resources/dokka/scripts/navigationLoader.js +++ b/core/src/main/resources/dokka/scripts/navigationLoader.js @@ -1,4 +1,4 @@ -onload = () => { +window.addEventListener('load', () => { fetch(pathToRoot + "navigation.html") .then(response => response.text()) .then(data => { @@ -15,7 +15,7 @@ onload = () => { }).then(() => { revealNavigationForCurrentPage() }) -}; +}) revealNavigationForCurrentPage = () => { let pageId = document.getElementById("content").attributes["pageIds"].value.toString(); diff --git a/core/src/main/resources/dokka/scripts/platformContentHandler.js b/core/src/main/resources/dokka/scripts/platformContentHandler.js new file mode 100644 index 00000000..b4a9e7c9 --- /dev/null +++ b/core/src/main/resources/dokka/scripts/platformContentHandler.js @@ -0,0 +1,29 @@ +window.addEventListener('load', () => { + document.querySelectorAll("div[data-platform-hinted]") + .forEach(elem => elem.addEventListener('click', (event) => togglePlatformDependent(event,elem))) + } +) + +function togglePlatformDependent(e, container) { + let target = e.target + if (target.tagName != 'BUTTON') return; + let index = target.getAttribute('data-toggle') + + for(let child of container.children){ + if(child.hasAttribute('data-toggle-list')){ + for(let bm of child.children){ + if(bm == target){ + bm.setAttribute('data-active',"") + } else if(bm != target) { + bm.removeAttribute('data-active') + } + } + } + else if(child.getAttribute('data-togglable') == index) { + child.setAttribute('data-active',"") + } + else { + child.removeAttribute('data-active') + } + } +} diff --git a/core/src/main/resources/dokka/styles/style.css b/core/src/main/resources/dokka/styles/style.css index 5c347128..720998ad 100644 --- a/core/src/main/resources/dokka/styles/style.css +++ b/core/src/main/resources/dokka/styles/style.css @@ -487,6 +487,56 @@ td.content { color: #5B5DEF; } +.platform-hinted { + display: block; +} + +.platform-hinted > .platform-bookmarks-row { + display: flex; + flex-direction: row; + padding: 0px; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark { + min-width: 64px; + height: 36px; + border: 2px solid white; + background: white; + outline: none; + flex: none; + order: 5; + align-self: flex-start; + margin: 0; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(1):hover { + border-top: 2px solid gray; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(2):hover { + border-top: 2px solid orange; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(3):hover { + border-top: 2px solid crimson; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(4):hover { + border-top: 2px solid blue; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark[data-active=''] { + border: 2px solid #F4F4F4; + border-top: 2px solid #4DBB5F; + + background: #F4F4F4; +} + +.platform-hinted > .content:not([data-active]) { + display: none +} + + @media print, screen and (max-width: 960px) { div.wrapper { diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt index e1025ed4..bbb5b685 100644 --- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt @@ -60,20 +60,33 @@ open class HtmlRenderer( } override fun FlowContent.buildPlatformDependent(content: PlatformHintedContent, pageContext: ContentPage) { - val distinct = content.platforms.map { - it to createHTML(prettyPrint = false).div { - buildContentNode(content.inner, pageContext, it) - }.drop(5).dropLast(6) // TODO: Find a way to do it without arbitrary trims - }.groupBy(Pair::second, Pair::first) - - if (distinct.size == 1) - consumer.onTagContentUnsafe { +distinct.keys.single() } - else - distinct.forEach { text, platforms -> - consumer.onTagContentUnsafe { - +platforms.joinToString(prefix = " [", postfix = "] $text") { it.platformType.key } + div("platform-hinted") { + attributes["data-platform-hinted"] = "data-platform-hinted" + val contents = content.platforms.mapIndexed { index,platform -> + platform to createHTML(prettyPrint = false).div(classes = "content") { + if (index == 0) attributes["data-active"] = "" + attributes["data-togglable"] = platform.targets.joinToString("-") + buildContentNode(content.inner, pageContext, platform) } } + + if(contents.size != 1) { + div("platform-bookmarks-row") { + attributes["data-toggle-list"] = "data-toggle-list" + contents.forEachIndexed { index,pair -> + button(classes = "platform-bookmark") { + if (index == 0) attributes["data-active"] = "" + attributes["data-toggle"] = pair.first.targets.joinToString("-") + text(pair.first.targets.joinToString(", ")); + } + } + } + } + + contents.forEach { + consumer.onTagContentUnsafe { +it.second } + } + } } override fun FlowContent.buildList( diff --git a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt index 9fed74e2..aaf82ba8 100644 --- a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt +++ b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt @@ -64,7 +64,8 @@ object StyleAndScriptsAppender : PageTransformer { it.modified( embeddedResources = it.embeddedResources + listOf( "styles/style.css", - "scripts/navigationLoader.js" + "scripts/navigationLoader.js", + "scripts/platformContentHandler.js" ) ) } diff --git a/plugins/base/src/test/kotlin/renderers/html/PlatformDependentHintTest.kt b/plugins/base/src/test/kotlin/renderers/html/PlatformDependentHintTest.kt index a985886d..cf1ac0a9 100644 --- a/plugins/base/src/test/kotlin/renderers/html/PlatformDependentHintTest.kt +++ b/plugins/base/src/test/kotlin/renderers/html/PlatformDependentHintTest.kt @@ -26,7 +26,7 @@ class PlatformDependentHintTest : RenderingOnlyTestBase() { } HtmlRenderer(context).render(page) - renderedContent.match(Div("abc")) + renderedContent.match(Div(Div(Div("abc")))) } @Test @@ -40,7 +40,7 @@ class PlatformDependentHintTest : RenderingOnlyTestBase() { } HtmlRenderer(context).render(page) - renderedContent.match("[js]", Div("a"), "[jvm]", Div("b"), "[native]", Div("c")) + renderedContent.match(Div(Div(Div("a")), Div(Div("b")), Div(Div("c")))) } @Test @@ -54,7 +54,7 @@ class PlatformDependentHintTest : RenderingOnlyTestBase() { } HtmlRenderer(context).render(page) - renderedContent.match("[js]", Div("ab"), "[jvm]", Div("bc")) + renderedContent.match(Div(Div(Div("ab")), Div(Div("bc")))) } @Test @@ -68,7 +68,7 @@ class PlatformDependentHintTest : RenderingOnlyTestBase() { } HtmlRenderer(context).render(page) - renderedContent.match(Div("ab")) + renderedContent.match(Div(Div(Div("ab")))) } @Test @@ -84,7 +84,7 @@ class PlatformDependentHintTest : RenderingOnlyTestBase() { } HtmlRenderer(context).render(page) - renderedContent.match("[js]", Div(Div("ab")), "[jvm]", Div(Div("a"), "b")) + renderedContent.match(Div(Div(Div(Div("ab"))), Div(Div(Div("a"), "b")))) } @Test @@ -101,7 +101,7 @@ class PlatformDependentHintTest : RenderingOnlyTestBase() { HtmlRenderer(context).render(page) println(renderedContent) - renderedContent.match("ab") + renderedContent.match(Div(Div("ab"))) } @Test @@ -115,6 +115,6 @@ class PlatformDependentHintTest : RenderingOnlyTestBase() { } HtmlRenderer(context).render(page) - renderedContent.match("[js, jvm]", Div("a"), "[native]", Div("b")) + renderedContent.match(Div(Div(Div("a")), Div(Div("b")))) } } \ No newline at end of file diff --git a/plugins/base/src/test/resources/expect/annotatedFunction/out/html/root//f.html b/plugins/base/src/test/resources/expect/annotatedFunction/out/html/root//f.html index dafca58f..9de96412 100644 --- a/plugins/base/src/test/resources/expect/annotatedFunction/out/html/root//f.html +++ b/plugins/base/src/test/resources/expect/annotatedFunction/out/html/root//f.html @@ -4,6 +4,7 @@ f + @@ -20,7 +21,8 @@

f

-
final fun f()
+
final fun f()
+ diff --git a/plugins/base/src/test/resources/expect/annotatedFunction/out/html/root//index.html b/plugins/base/src/test/resources/expect/annotatedFunction/out/html/root//index.html index 59b7070b..1ebe6dce 100644 --- a/plugins/base/src/test/resources/expect/annotatedFunction/out/html/root//index.html +++ b/plugins/base/src/test/resources/expect/annotatedFunction/out/html/root//index.html @@ -4,6 +4,7 @@ <jvm root> + @@ -27,7 +28,8 @@ f -
final fun f()
+ +
final fun f()
diff --git a/plugins/base/src/test/resources/expect/annotatedFunction/out/html/root/index.html b/plugins/base/src/test/resources/expect/annotatedFunction/out/html/root/index.html index f8c89bbf..a3211166 100644 --- a/plugins/base/src/test/resources/expect/annotatedFunction/out/html/root/index.html +++ b/plugins/base/src/test/resources/expect/annotatedFunction/out/html/root/index.html @@ -4,6 +4,7 @@ root + diff --git a/plugins/base/src/test/resources/expect/annotatedFunction/out/html/scripts/navigationLoader.js b/plugins/base/src/test/resources/expect/annotatedFunction/out/html/scripts/navigationLoader.js index 5fe52ade..ecbabb4c 100644 --- a/plugins/base/src/test/resources/expect/annotatedFunction/out/html/scripts/navigationLoader.js +++ b/plugins/base/src/test/resources/expect/annotatedFunction/out/html/scripts/navigationLoader.js @@ -1,4 +1,4 @@ -onload = () => { +window.addEventListener('load', () => { fetch(pathToRoot + "navigation.html") .then(response => response.text()) .then(data => { @@ -15,7 +15,7 @@ onload = () => { }).then(() => { revealNavigationForCurrentPage() }) -}; +}) revealNavigationForCurrentPage = () => { let pageId = document.getElementById("content").attributes["pageIds"].value.toString(); diff --git a/plugins/base/src/test/resources/expect/annotatedFunction/out/html/scripts/platformContentHandler.js b/plugins/base/src/test/resources/expect/annotatedFunction/out/html/scripts/platformContentHandler.js new file mode 100644 index 00000000..b4a9e7c9 --- /dev/null +++ b/plugins/base/src/test/resources/expect/annotatedFunction/out/html/scripts/platformContentHandler.js @@ -0,0 +1,29 @@ +window.addEventListener('load', () => { + document.querySelectorAll("div[data-platform-hinted]") + .forEach(elem => elem.addEventListener('click', (event) => togglePlatformDependent(event,elem))) + } +) + +function togglePlatformDependent(e, container) { + let target = e.target + if (target.tagName != 'BUTTON') return; + let index = target.getAttribute('data-toggle') + + for(let child of container.children){ + if(child.hasAttribute('data-toggle-list')){ + for(let bm of child.children){ + if(bm == target){ + bm.setAttribute('data-active',"") + } else if(bm != target) { + bm.removeAttribute('data-active') + } + } + } + else if(child.getAttribute('data-togglable') == index) { + child.setAttribute('data-active',"") + } + else { + child.removeAttribute('data-active') + } + } +} diff --git a/plugins/base/src/test/resources/expect/annotatedFunction/out/html/styles/style.css b/plugins/base/src/test/resources/expect/annotatedFunction/out/html/styles/style.css index 5c347128..720998ad 100644 --- a/plugins/base/src/test/resources/expect/annotatedFunction/out/html/styles/style.css +++ b/plugins/base/src/test/resources/expect/annotatedFunction/out/html/styles/style.css @@ -487,6 +487,56 @@ td.content { color: #5B5DEF; } +.platform-hinted { + display: block; +} + +.platform-hinted > .platform-bookmarks-row { + display: flex; + flex-direction: row; + padding: 0px; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark { + min-width: 64px; + height: 36px; + border: 2px solid white; + background: white; + outline: none; + flex: none; + order: 5; + align-self: flex-start; + margin: 0; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(1):hover { + border-top: 2px solid gray; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(2):hover { + border-top: 2px solid orange; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(3):hover { + border-top: 2px solid crimson; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(4):hover { + border-top: 2px solid blue; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark[data-active=''] { + border: 2px solid #F4F4F4; + border-top: 2px solid #4DBB5F; + + background: #F4F4F4; +} + +.platform-hinted > .content:not([data-active]) { + display: none +} + + @media print, screen and (max-width: 960px) { div.wrapper { diff --git a/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root//-fancy/-init-.html b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root//-fancy/-init-.html index 0ad7d7df..d1bfe590 100644 --- a/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root//-fancy/-init-.html +++ b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root//-fancy/-init-.html @@ -4,6 +4,7 @@ <init> + @@ -20,7 +21,8 @@

<init>

-
final fun <init>(size: Int)
+
final fun <init>(size: Int)
+ diff --git a/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root//-fancy/equals.html b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root//-fancy/equals.html index d1a73c8d..2645051d 100644 --- a/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root//-fancy/equals.html +++ b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root//-fancy/equals.html @@ -4,6 +4,7 @@ equals + @@ -20,7 +21,8 @@

equals

-
open fun equals(other: Any): Boolean
+
open fun equals(other: Any): Boolean
+ diff --git a/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root//-fancy/hash-code.html b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root//-fancy/hash-code.html index 68e223af..09cf0e01 100644 --- a/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root//-fancy/hash-code.html +++ b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root//-fancy/hash-code.html @@ -4,6 +4,7 @@ hashCode + @@ -20,7 +21,8 @@

hashCode

-
open fun hashCode(): Int
+
open fun hashCode(): Int
+ diff --git a/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root//-fancy/index.html b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root//-fancy/index.html index 77b20479..743c6dcc 100644 --- a/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root//-fancy/index.html +++ b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root//-fancy/index.html @@ -4,6 +4,7 @@ Fancy + @@ -20,14 +21,16 @@

Fancy

-
annotation class Fancy
+
annotation class Fancy
+

Functions

- - - - - - -
equals
open fun equals(other: Any): Boolean
+
+
open fun equals(other: Any): Boolean
@@ -36,7 +39,8 @@
hashCode
open fun hashCode(): Int
+
+
open fun hashCode(): Int
@@ -45,7 +49,8 @@
toString
open fun toString(): String
+
+
open fun toString(): String
@@ -60,7 +65,8 @@
size + +
diff --git a/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root//-fancy/to-string.html b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root//-fancy/to-string.html index 905cddc2..48b4711c 100644 --- a/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root//-fancy/to-string.html +++ b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root//-fancy/to-string.html @@ -4,6 +4,7 @@ toString + @@ -20,7 +21,8 @@

toString

-
open fun toString(): String
+
open fun toString(): String
+ diff --git a/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root//f.html b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root//f.html index dafca58f..9de96412 100644 --- a/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root//f.html +++ b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root//f.html @@ -4,6 +4,7 @@ f + @@ -20,7 +21,8 @@

f

-
final fun f()
+
final fun f()
+ diff --git a/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root//index.html b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root//index.html index cbe266c3..25340ae7 100644 --- a/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root//index.html +++ b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root//index.html @@ -4,6 +4,7 @@ <jvm root> + @@ -27,7 +28,8 @@
Fancy
annotation class Fancy
+
+
annotation class Fancy
@@ -42,7 +44,8 @@
f
final fun f()
+
+
final fun f()
diff --git a/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root/index.html b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root/index.html index f8c89bbf..a3211166 100644 --- a/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root/index.html +++ b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root/index.html @@ -4,6 +4,7 @@ root + diff --git a/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/scripts/navigationLoader.js b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/scripts/navigationLoader.js index 5fe52ade..ecbabb4c 100644 --- a/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/scripts/navigationLoader.js +++ b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/scripts/navigationLoader.js @@ -1,4 +1,4 @@ -onload = () => { +window.addEventListener('load', () => { fetch(pathToRoot + "navigation.html") .then(response => response.text()) .then(data => { @@ -15,7 +15,7 @@ onload = () => { }).then(() => { revealNavigationForCurrentPage() }) -}; +}) revealNavigationForCurrentPage = () => { let pageId = document.getElementById("content").attributes["pageIds"].value.toString(); diff --git a/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/scripts/platformContentHandler.js b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/scripts/platformContentHandler.js new file mode 100644 index 00000000..b4a9e7c9 --- /dev/null +++ b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/scripts/platformContentHandler.js @@ -0,0 +1,29 @@ +window.addEventListener('load', () => { + document.querySelectorAll("div[data-platform-hinted]") + .forEach(elem => elem.addEventListener('click', (event) => togglePlatformDependent(event,elem))) + } +) + +function togglePlatformDependent(e, container) { + let target = e.target + if (target.tagName != 'BUTTON') return; + let index = target.getAttribute('data-toggle') + + for(let child of container.children){ + if(child.hasAttribute('data-toggle-list')){ + for(let bm of child.children){ + if(bm == target){ + bm.setAttribute('data-active',"") + } else if(bm != target) { + bm.removeAttribute('data-active') + } + } + } + else if(child.getAttribute('data-togglable') == index) { + child.setAttribute('data-active',"") + } + else { + child.removeAttribute('data-active') + } + } +} diff --git a/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/styles/style.css b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/styles/style.css index 5c347128..720998ad 100644 --- a/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/styles/style.css +++ b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/styles/style.css @@ -487,6 +487,56 @@ td.content { color: #5B5DEF; } +.platform-hinted { + display: block; +} + +.platform-hinted > .platform-bookmarks-row { + display: flex; + flex-direction: row; + padding: 0px; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark { + min-width: 64px; + height: 36px; + border: 2px solid white; + background: white; + outline: none; + flex: none; + order: 5; + align-self: flex-start; + margin: 0; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(1):hover { + border-top: 2px solid gray; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(2):hover { + border-top: 2px solid orange; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(3):hover { + border-top: 2px solid crimson; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(4):hover { + border-top: 2px solid blue; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark[data-active=''] { + border: 2px solid #F4F4F4; + border-top: 2px solid #4DBB5F; + + background: #F4F4F4; +} + +.platform-hinted > .content:not([data-active]) { + display: none +} + + @media print, screen and (max-width: 960px) { div.wrapper { diff --git a/plugins/base/src/test/resources/expect/function/out/html/root//fn.html b/plugins/base/src/test/resources/expect/function/out/html/root//fn.html index 91d784c8..e49ade86 100644 --- a/plugins/base/src/test/resources/expect/function/out/html/root//fn.html +++ b/plugins/base/src/test/resources/expect/function/out/html/root//fn.html @@ -4,6 +4,7 @@ fn + @@ -20,9 +21,11 @@

fn

-
final fun fn()
+
final fun fn()
+

Description

-Function fn +
Function fn
+ diff --git a/plugins/base/src/test/resources/expect/function/out/html/root//index.html b/plugins/base/src/test/resources/expect/function/out/html/root//index.html index 1f7ac4a3..58d5c404 100644 --- a/plugins/base/src/test/resources/expect/function/out/html/root//index.html +++ b/plugins/base/src/test/resources/expect/function/out/html/root//index.html @@ -4,6 +4,7 @@ <jvm root> + @@ -27,7 +28,8 @@
fn
final fun fn()
+
+
final fun fn()
diff --git a/plugins/base/src/test/resources/expect/function/out/html/root/index.html b/plugins/base/src/test/resources/expect/function/out/html/root/index.html index f8c89bbf..a3211166 100644 --- a/plugins/base/src/test/resources/expect/function/out/html/root/index.html +++ b/plugins/base/src/test/resources/expect/function/out/html/root/index.html @@ -4,6 +4,7 @@ root + diff --git a/plugins/base/src/test/resources/expect/function/out/html/scripts/navigationLoader.js b/plugins/base/src/test/resources/expect/function/out/html/scripts/navigationLoader.js index 5fe52ade..ecbabb4c 100644 --- a/plugins/base/src/test/resources/expect/function/out/html/scripts/navigationLoader.js +++ b/plugins/base/src/test/resources/expect/function/out/html/scripts/navigationLoader.js @@ -1,4 +1,4 @@ -onload = () => { +window.addEventListener('load', () => { fetch(pathToRoot + "navigation.html") .then(response => response.text()) .then(data => { @@ -15,7 +15,7 @@ onload = () => { }).then(() => { revealNavigationForCurrentPage() }) -}; +}) revealNavigationForCurrentPage = () => { let pageId = document.getElementById("content").attributes["pageIds"].value.toString(); diff --git a/plugins/base/src/test/resources/expect/function/out/html/scripts/platformContentHandler.js b/plugins/base/src/test/resources/expect/function/out/html/scripts/platformContentHandler.js new file mode 100644 index 00000000..b4a9e7c9 --- /dev/null +++ b/plugins/base/src/test/resources/expect/function/out/html/scripts/platformContentHandler.js @@ -0,0 +1,29 @@ +window.addEventListener('load', () => { + document.querySelectorAll("div[data-platform-hinted]") + .forEach(elem => elem.addEventListener('click', (event) => togglePlatformDependent(event,elem))) + } +) + +function togglePlatformDependent(e, container) { + let target = e.target + if (target.tagName != 'BUTTON') return; + let index = target.getAttribute('data-toggle') + + for(let child of container.children){ + if(child.hasAttribute('data-toggle-list')){ + for(let bm of child.children){ + if(bm == target){ + bm.setAttribute('data-active',"") + } else if(bm != target) { + bm.removeAttribute('data-active') + } + } + } + else if(child.getAttribute('data-togglable') == index) { + child.setAttribute('data-active',"") + } + else { + child.removeAttribute('data-active') + } + } +} diff --git a/plugins/base/src/test/resources/expect/function/out/html/styles/style.css b/plugins/base/src/test/resources/expect/function/out/html/styles/style.css index 5c347128..720998ad 100644 --- a/plugins/base/src/test/resources/expect/function/out/html/styles/style.css +++ b/plugins/base/src/test/resources/expect/function/out/html/styles/style.css @@ -487,6 +487,56 @@ td.content { color: #5B5DEF; } +.platform-hinted { + display: block; +} + +.platform-hinted > .platform-bookmarks-row { + display: flex; + flex-direction: row; + padding: 0px; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark { + min-width: 64px; + height: 36px; + border: 2px solid white; + background: white; + outline: none; + flex: none; + order: 5; + align-self: flex-start; + margin: 0; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(1):hover { + border-top: 2px solid gray; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(2):hover { + border-top: 2px solid orange; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(3):hover { + border-top: 2px solid crimson; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(4):hover { + border-top: 2px solid blue; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark[data-active=''] { + border: 2px solid #F4F4F4; + border-top: 2px solid #4DBB5F; + + background: #F4F4F4; +} + +.platform-hinted > .content:not([data-active]) { + display: none +} + + @media print, screen and (max-width: 960px) { div.wrapper { diff --git a/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root//-fancy/-init-.html b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root//-fancy/-init-.html index 755863db..03d4d238 100644 --- a/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root//-fancy/-init-.html +++ b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root//-fancy/-init-.html @@ -4,6 +4,7 @@ <init> + @@ -20,7 +21,8 @@

<init>

-
final fun <init>()
+
final fun <init>()
+ diff --git a/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root//-fancy/equals.html b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root//-fancy/equals.html index d1a73c8d..2645051d 100644 --- a/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root//-fancy/equals.html +++ b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root//-fancy/equals.html @@ -4,6 +4,7 @@ equals + @@ -20,7 +21,8 @@

equals

-
open fun equals(other: Any): Boolean
+
open fun equals(other: Any): Boolean
+ diff --git a/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root//-fancy/hash-code.html b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root//-fancy/hash-code.html index 68e223af..09cf0e01 100644 --- a/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root//-fancy/hash-code.html +++ b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root//-fancy/hash-code.html @@ -4,6 +4,7 @@ hashCode + @@ -20,7 +21,8 @@

hashCode

-
open fun hashCode(): Int
+
open fun hashCode(): Int
+ diff --git a/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root//-fancy/index.html b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root//-fancy/index.html index 28585a2a..4f02e43a 100644 --- a/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root//-fancy/index.html +++ b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root//-fancy/index.html @@ -4,6 +4,7 @@ Fancy + @@ -20,14 +21,16 @@

Fancy

-
annotation class Fancy
+
annotation class Fancy
+

Functions

- - - - - - - - - - - - - - - - - - - -
equals
open fun equals(other: Any): Boolean
+
+
open fun equals(other: Any): Boolean
@@ -36,7 +39,8 @@
hashCode
open fun hashCode(): Int
+
+
open fun hashCode(): Int
@@ -45,7 +49,8 @@
toString
open fun toString(): String
+
+
open fun toString(): String
diff --git a/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root//-fancy/to-string.html b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root//-fancy/to-string.html index 905cddc2..48b4711c 100644 --- a/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root//-fancy/to-string.html +++ b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root//-fancy/to-string.html @@ -4,6 +4,7 @@ toString + @@ -20,7 +21,8 @@

toString

-
open fun toString(): String
+
open fun toString(): String
+ diff --git a/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root//function.html b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root//function.html index a6a78b74..6464397a 100644 --- a/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root//function.html +++ b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root//function.html @@ -4,6 +4,7 @@ function + @@ -20,7 +21,8 @@

function

-
final fun function(notInlined:
() -> Unit
)
+
final fun function(notInlined:
() -> Unit
)
+ diff --git a/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root//index.html b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root//index.html index 61723ee4..b6f76db9 100644 --- a/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root//index.html +++ b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root//index.html @@ -4,6 +4,7 @@ <jvm root> + @@ -27,7 +28,8 @@
Fancy
annotation class Fancy
+
+
annotation class Fancy
@@ -42,7 +44,8 @@
function
final fun function(notInlined:
() -> Unit
)
+
+
final fun function(notInlined:
() -> Unit
)
diff --git a/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root/index.html b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root/index.html index f8c89bbf..a3211166 100644 --- a/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root/index.html +++ b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root/index.html @@ -4,6 +4,7 @@ root + diff --git a/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/scripts/navigationLoader.js b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/scripts/navigationLoader.js index 5fe52ade..ecbabb4c 100644 --- a/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/scripts/navigationLoader.js +++ b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/scripts/navigationLoader.js @@ -1,4 +1,4 @@ -onload = () => { +window.addEventListener('load', () => { fetch(pathToRoot + "navigation.html") .then(response => response.text()) .then(data => { @@ -15,7 +15,7 @@ onload = () => { }).then(() => { revealNavigationForCurrentPage() }) -}; +}) revealNavigationForCurrentPage = () => { let pageId = document.getElementById("content").attributes["pageIds"].value.toString(); diff --git a/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/scripts/platformContentHandler.js b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/scripts/platformContentHandler.js new file mode 100644 index 00000000..b4a9e7c9 --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/scripts/platformContentHandler.js @@ -0,0 +1,29 @@ +window.addEventListener('load', () => { + document.querySelectorAll("div[data-platform-hinted]") + .forEach(elem => elem.addEventListener('click', (event) => togglePlatformDependent(event,elem))) + } +) + +function togglePlatformDependent(e, container) { + let target = e.target + if (target.tagName != 'BUTTON') return; + let index = target.getAttribute('data-toggle') + + for(let child of container.children){ + if(child.hasAttribute('data-toggle-list')){ + for(let bm of child.children){ + if(bm == target){ + bm.setAttribute('data-active',"") + } else if(bm != target) { + bm.removeAttribute('data-active') + } + } + } + else if(child.getAttribute('data-togglable') == index) { + child.setAttribute('data-active',"") + } + else { + child.removeAttribute('data-active') + } + } +} diff --git a/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/styles/style.css b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/styles/style.css index 5c347128..720998ad 100644 --- a/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/styles/style.css +++ b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/styles/style.css @@ -487,6 +487,56 @@ td.content { color: #5B5DEF; } +.platform-hinted { + display: block; +} + +.platform-hinted > .platform-bookmarks-row { + display: flex; + flex-direction: row; + padding: 0px; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark { + min-width: 64px; + height: 36px; + border: 2px solid white; + background: white; + outline: none; + flex: none; + order: 5; + align-self: flex-start; + margin: 0; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(1):hover { + border-top: 2px solid gray; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(2):hover { + border-top: 2px solid orange; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(3):hover { + border-top: 2px solid crimson; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(4):hover { + border-top: 2px solid blue; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark[data-active=''] { + border: 2px solid #F4F4F4; + border-top: 2px solid #4DBB5F; + + background: #F4F4F4; +} + +.platform-hinted > .content:not([data-active]) { + display: none +} + + @media print, screen and (max-width: 960px) { div.wrapper { diff --git a/plugins/base/src/test/resources/expect/functionWithDefaultParameter/out/html/root//f.html b/plugins/base/src/test/resources/expect/functionWithDefaultParameter/out/html/root//f.html index 0165e179..47b3db1c 100644 --- a/plugins/base/src/test/resources/expect/functionWithDefaultParameter/out/html/root//f.html +++ b/plugins/base/src/test/resources/expect/functionWithDefaultParameter/out/html/root//f.html @@ -4,6 +4,7 @@ f + @@ -20,7 +21,8 @@

f

-
final fun f(x: String)
+
final fun f(x: String)
+ diff --git a/plugins/base/src/test/resources/expect/functionWithDefaultParameter/out/html/root//index.html b/plugins/base/src/test/resources/expect/functionWithDefaultParameter/out/html/root//index.html index 2d08f84f..fb7eacf2 100644 --- a/plugins/base/src/test/resources/expect/functionWithDefaultParameter/out/html/root//index.html +++ b/plugins/base/src/test/resources/expect/functionWithDefaultParameter/out/html/root//index.html @@ -4,6 +4,7 @@ <jvm root> + @@ -27,7 +28,8 @@
f
final fun f(x: String)
+
+
final fun f(x: String)
diff --git a/plugins/base/src/test/resources/expect/functionWithDefaultParameter/out/html/root/index.html b/plugins/base/src/test/resources/expect/functionWithDefaultParameter/out/html/root/index.html index f8c89bbf..a3211166 100644 --- a/plugins/base/src/test/resources/expect/functionWithDefaultParameter/out/html/root/index.html +++ b/plugins/base/src/test/resources/expect/functionWithDefaultParameter/out/html/root/index.html @@ -4,6 +4,7 @@ root + diff --git a/plugins/base/src/test/resources/expect/functionWithDefaultParameter/out/html/scripts/navigationLoader.js b/plugins/base/src/test/resources/expect/functionWithDefaultParameter/out/html/scripts/navigationLoader.js index 5fe52ade..ecbabb4c 100644 --- a/plugins/base/src/test/resources/expect/functionWithDefaultParameter/out/html/scripts/navigationLoader.js +++ b/plugins/base/src/test/resources/expect/functionWithDefaultParameter/out/html/scripts/navigationLoader.js @@ -1,4 +1,4 @@ -onload = () => { +window.addEventListener('load', () => { fetch(pathToRoot + "navigation.html") .then(response => response.text()) .then(data => { @@ -15,7 +15,7 @@ onload = () => { }).then(() => { revealNavigationForCurrentPage() }) -}; +}) revealNavigationForCurrentPage = () => { let pageId = document.getElementById("content").attributes["pageIds"].value.toString(); diff --git a/plugins/base/src/test/resources/expect/functionWithDefaultParameter/out/html/scripts/platformContentHandler.js b/plugins/base/src/test/resources/expect/functionWithDefaultParameter/out/html/scripts/platformContentHandler.js new file mode 100644 index 00000000..b4a9e7c9 --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithDefaultParameter/out/html/scripts/platformContentHandler.js @@ -0,0 +1,29 @@ +window.addEventListener('load', () => { + document.querySelectorAll("div[data-platform-hinted]") + .forEach(elem => elem.addEventListener('click', (event) => togglePlatformDependent(event,elem))) + } +) + +function togglePlatformDependent(e, container) { + let target = e.target + if (target.tagName != 'BUTTON') return; + let index = target.getAttribute('data-toggle') + + for(let child of container.children){ + if(child.hasAttribute('data-toggle-list')){ + for(let bm of child.children){ + if(bm == target){ + bm.setAttribute('data-active',"") + } else if(bm != target) { + bm.removeAttribute('data-active') + } + } + } + else if(child.getAttribute('data-togglable') == index) { + child.setAttribute('data-active',"") + } + else { + child.removeAttribute('data-active') + } + } +} diff --git a/plugins/base/src/test/resources/expect/functionWithDefaultParameter/out/html/styles/style.css b/plugins/base/src/test/resources/expect/functionWithDefaultParameter/out/html/styles/style.css index 5c347128..720998ad 100644 --- a/plugins/base/src/test/resources/expect/functionWithDefaultParameter/out/html/styles/style.css +++ b/plugins/base/src/test/resources/expect/functionWithDefaultParameter/out/html/styles/style.css @@ -487,6 +487,56 @@ td.content { color: #5B5DEF; } +.platform-hinted { + display: block; +} + +.platform-hinted > .platform-bookmarks-row { + display: flex; + flex-direction: row; + padding: 0px; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark { + min-width: 64px; + height: 36px; + border: 2px solid white; + background: white; + outline: none; + flex: none; + order: 5; + align-self: flex-start; + margin: 0; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(1):hover { + border-top: 2px solid gray; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(2):hover { + border-top: 2px solid orange; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(3):hover { + border-top: 2px solid crimson; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(4):hover { + border-top: 2px solid blue; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark[data-active=''] { + border: 2px solid #F4F4F4; + border-top: 2px solid #4DBB5F; + + background: #F4F4F4; +} + +.platform-hinted > .content:not([data-active]) { + display: none +} + + @media print, screen and (max-width: 960px) { div.wrapper { diff --git a/plugins/base/src/test/resources/expect/functionWithNoinlineParam/out/html/root//function.html b/plugins/base/src/test/resources/expect/functionWithNoinlineParam/out/html/root//function.html index a6a78b74..6464397a 100644 --- a/plugins/base/src/test/resources/expect/functionWithNoinlineParam/out/html/root//function.html +++ b/plugins/base/src/test/resources/expect/functionWithNoinlineParam/out/html/root//function.html @@ -4,6 +4,7 @@ function + @@ -20,7 +21,8 @@

function

-
final fun function(notInlined:
() -> Unit
)
+
final fun function(notInlined:
() -> Unit
)
+ diff --git a/plugins/base/src/test/resources/expect/functionWithNoinlineParam/out/html/root//index.html b/plugins/base/src/test/resources/expect/functionWithNoinlineParam/out/html/root//index.html index a14357c0..c509e95e 100644 --- a/plugins/base/src/test/resources/expect/functionWithNoinlineParam/out/html/root//index.html +++ b/plugins/base/src/test/resources/expect/functionWithNoinlineParam/out/html/root//index.html @@ -4,6 +4,7 @@ <jvm root> + @@ -27,7 +28,8 @@
function
final fun function(notInlined:
() -> Unit
)
+
+
final fun function(notInlined:
() -> Unit
)
diff --git a/plugins/base/src/test/resources/expect/functionWithNoinlineParam/out/html/root/index.html b/plugins/base/src/test/resources/expect/functionWithNoinlineParam/out/html/root/index.html index f8c89bbf..a3211166 100644 --- a/plugins/base/src/test/resources/expect/functionWithNoinlineParam/out/html/root/index.html +++ b/plugins/base/src/test/resources/expect/functionWithNoinlineParam/out/html/root/index.html @@ -4,6 +4,7 @@ root + diff --git a/plugins/base/src/test/resources/expect/functionWithNoinlineParam/out/html/scripts/navigationLoader.js b/plugins/base/src/test/resources/expect/functionWithNoinlineParam/out/html/scripts/navigationLoader.js index 5fe52ade..ecbabb4c 100644 --- a/plugins/base/src/test/resources/expect/functionWithNoinlineParam/out/html/scripts/navigationLoader.js +++ b/plugins/base/src/test/resources/expect/functionWithNoinlineParam/out/html/scripts/navigationLoader.js @@ -1,4 +1,4 @@ -onload = () => { +window.addEventListener('load', () => { fetch(pathToRoot + "navigation.html") .then(response => response.text()) .then(data => { @@ -15,7 +15,7 @@ onload = () => { }).then(() => { revealNavigationForCurrentPage() }) -}; +}) revealNavigationForCurrentPage = () => { let pageId = document.getElementById("content").attributes["pageIds"].value.toString(); diff --git a/plugins/base/src/test/resources/expect/functionWithNoinlineParam/out/html/scripts/platformContentHandler.js b/plugins/base/src/test/resources/expect/functionWithNoinlineParam/out/html/scripts/platformContentHandler.js new file mode 100644 index 00000000..b4a9e7c9 --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithNoinlineParam/out/html/scripts/platformContentHandler.js @@ -0,0 +1,29 @@ +window.addEventListener('load', () => { + document.querySelectorAll("div[data-platform-hinted]") + .forEach(elem => elem.addEventListener('click', (event) => togglePlatformDependent(event,elem))) + } +) + +function togglePlatformDependent(e, container) { + let target = e.target + if (target.tagName != 'BUTTON') return; + let index = target.getAttribute('data-toggle') + + for(let child of container.children){ + if(child.hasAttribute('data-toggle-list')){ + for(let bm of child.children){ + if(bm == target){ + bm.setAttribute('data-active',"") + } else if(bm != target) { + bm.removeAttribute('data-active') + } + } + } + else if(child.getAttribute('data-togglable') == index) { + child.setAttribute('data-active',"") + } + else { + child.removeAttribute('data-active') + } + } +} diff --git a/plugins/base/src/test/resources/expect/functionWithNoinlineParam/out/html/styles/style.css b/plugins/base/src/test/resources/expect/functionWithNoinlineParam/out/html/styles/style.css index 5c347128..720998ad 100644 --- a/plugins/base/src/test/resources/expect/functionWithNoinlineParam/out/html/styles/style.css +++ b/plugins/base/src/test/resources/expect/functionWithNoinlineParam/out/html/styles/style.css @@ -487,6 +487,56 @@ td.content { color: #5B5DEF; } +.platform-hinted { + display: block; +} + +.platform-hinted > .platform-bookmarks-row { + display: flex; + flex-direction: row; + padding: 0px; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark { + min-width: 64px; + height: 36px; + border: 2px solid white; + background: white; + outline: none; + flex: none; + order: 5; + align-self: flex-start; + margin: 0; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(1):hover { + border-top: 2px solid gray; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(2):hover { + border-top: 2px solid orange; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(3):hover { + border-top: 2px solid crimson; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(4):hover { + border-top: 2px solid blue; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark[data-active=''] { + border: 2px solid #F4F4F4; + border-top: 2px solid #4DBB5F; + + background: #F4F4F4; +} + +.platform-hinted > .content:not([data-active]) { + display: none +} + + @media print, screen and (max-width: 960px) { div.wrapper { diff --git a/plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/out/html/root//f.html b/plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/out/html/root//f.html index dafca58f..9de96412 100644 --- a/plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/out/html/root//f.html +++ b/plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/out/html/root//f.html @@ -4,6 +4,7 @@ f + @@ -20,7 +21,8 @@

f

-
final fun f()
+
final fun f()
+ diff --git a/plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/out/html/root//index.html b/plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/out/html/root//index.html index 59b7070b..1ebe6dce 100644 --- a/plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/out/html/root//index.html +++ b/plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/out/html/root//index.html @@ -4,6 +4,7 @@ <jvm root> + @@ -27,7 +28,8 @@
f
final fun f()
+
+
final fun f()
diff --git a/plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/out/html/root/index.html b/plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/out/html/root/index.html index f8c89bbf..a3211166 100644 --- a/plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/out/html/root/index.html +++ b/plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/out/html/root/index.html @@ -4,6 +4,7 @@ root + diff --git a/plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/out/html/scripts/navigationLoader.js b/plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/out/html/scripts/navigationLoader.js index 5fe52ade..ecbabb4c 100644 --- a/plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/out/html/scripts/navigationLoader.js +++ b/plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/out/html/scripts/navigationLoader.js @@ -1,4 +1,4 @@ -onload = () => { +window.addEventListener('load', () => { fetch(pathToRoot + "navigation.html") .then(response => response.text()) .then(data => { @@ -15,7 +15,7 @@ onload = () => { }).then(() => { revealNavigationForCurrentPage() }) -}; +}) revealNavigationForCurrentPage = () => { let pageId = document.getElementById("content").attributes["pageIds"].value.toString(); diff --git a/plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/out/html/scripts/platformContentHandler.js b/plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/out/html/scripts/platformContentHandler.js new file mode 100644 index 00000000..b4a9e7c9 --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/out/html/scripts/platformContentHandler.js @@ -0,0 +1,29 @@ +window.addEventListener('load', () => { + document.querySelectorAll("div[data-platform-hinted]") + .forEach(elem => elem.addEventListener('click', (event) => togglePlatformDependent(event,elem))) + } +) + +function togglePlatformDependent(e, container) { + let target = e.target + if (target.tagName != 'BUTTON') return; + let index = target.getAttribute('data-toggle') + + for(let child of container.children){ + if(child.hasAttribute('data-toggle-list')){ + for(let bm of child.children){ + if(bm == target){ + bm.setAttribute('data-active',"") + } else if(bm != target) { + bm.removeAttribute('data-active') + } + } + } + else if(child.getAttribute('data-togglable') == index) { + child.setAttribute('data-active',"") + } + else { + child.removeAttribute('data-active') + } + } +} diff --git a/plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/out/html/styles/style.css b/plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/out/html/styles/style.css index 5c347128..720998ad 100644 --- a/plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/out/html/styles/style.css +++ b/plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/out/html/styles/style.css @@ -487,6 +487,56 @@ td.content { color: #5B5DEF; } +.platform-hinted { + display: block; +} + +.platform-hinted > .platform-bookmarks-row { + display: flex; + flex-direction: row; + padding: 0px; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark { + min-width: 64px; + height: 36px; + border: 2px solid white; + background: white; + outline: none; + flex: none; + order: 5; + align-self: flex-start; + margin: 0; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(1):hover { + border-top: 2px solid gray; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(2):hover { + border-top: 2px solid orange; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(3):hover { + border-top: 2px solid crimson; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(4):hover { + border-top: 2px solid blue; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark[data-active=''] { + border: 2px solid #F4F4F4; + border-top: 2px solid #4DBB5F; + + background: #F4F4F4; +} + +.platform-hinted > .content:not([data-active]) { + display: none +} + + @media print, screen and (max-width: 960px) { div.wrapper { diff --git a/plugins/base/src/test/resources/expect/functionWithParams/out/html/root//function.html b/plugins/base/src/test/resources/expect/functionWithParams/out/html/root//function.html index 41bbfa81..6e34095f 100644 --- a/plugins/base/src/test/resources/expect/functionWithParams/out/html/root//function.html +++ b/plugins/base/src/test/resources/expect/functionWithParams/out/html/root//function.html @@ -4,6 +4,7 @@ function + @@ -20,9 +21,11 @@

function

-
final fun function(x: Int)
+
final fun function(x: Int)
+

Description

-MultilineFunction Documentation +
MultilineFunction Documentation
+ diff --git a/plugins/base/src/test/resources/expect/functionWithParams/out/html/root//index.html b/plugins/base/src/test/resources/expect/functionWithParams/out/html/root//index.html index c05dafcb..42458c2a 100644 --- a/plugins/base/src/test/resources/expect/functionWithParams/out/html/root//index.html +++ b/plugins/base/src/test/resources/expect/functionWithParams/out/html/root//index.html @@ -4,6 +4,7 @@ <jvm root> + @@ -27,7 +28,8 @@
function
final fun function(x: Int)
+
+
final fun function(x: Int)
diff --git a/plugins/base/src/test/resources/expect/functionWithParams/out/html/root/index.html b/plugins/base/src/test/resources/expect/functionWithParams/out/html/root/index.html index f8c89bbf..a3211166 100644 --- a/plugins/base/src/test/resources/expect/functionWithParams/out/html/root/index.html +++ b/plugins/base/src/test/resources/expect/functionWithParams/out/html/root/index.html @@ -4,6 +4,7 @@ root + diff --git a/plugins/base/src/test/resources/expect/functionWithParams/out/html/scripts/navigationLoader.js b/plugins/base/src/test/resources/expect/functionWithParams/out/html/scripts/navigationLoader.js index 5fe52ade..ecbabb4c 100644 --- a/plugins/base/src/test/resources/expect/functionWithParams/out/html/scripts/navigationLoader.js +++ b/plugins/base/src/test/resources/expect/functionWithParams/out/html/scripts/navigationLoader.js @@ -1,4 +1,4 @@ -onload = () => { +window.addEventListener('load', () => { fetch(pathToRoot + "navigation.html") .then(response => response.text()) .then(data => { @@ -15,7 +15,7 @@ onload = () => { }).then(() => { revealNavigationForCurrentPage() }) -}; +}) revealNavigationForCurrentPage = () => { let pageId = document.getElementById("content").attributes["pageIds"].value.toString(); diff --git a/plugins/base/src/test/resources/expect/functionWithParams/out/html/scripts/platformContentHandler.js b/plugins/base/src/test/resources/expect/functionWithParams/out/html/scripts/platformContentHandler.js new file mode 100644 index 00000000..b4a9e7c9 --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithParams/out/html/scripts/platformContentHandler.js @@ -0,0 +1,29 @@ +window.addEventListener('load', () => { + document.querySelectorAll("div[data-platform-hinted]") + .forEach(elem => elem.addEventListener('click', (event) => togglePlatformDependent(event,elem))) + } +) + +function togglePlatformDependent(e, container) { + let target = e.target + if (target.tagName != 'BUTTON') return; + let index = target.getAttribute('data-toggle') + + for(let child of container.children){ + if(child.hasAttribute('data-toggle-list')){ + for(let bm of child.children){ + if(bm == target){ + bm.setAttribute('data-active',"") + } else if(bm != target) { + bm.removeAttribute('data-active') + } + } + } + else if(child.getAttribute('data-togglable') == index) { + child.setAttribute('data-active',"") + } + else { + child.removeAttribute('data-active') + } + } +} diff --git a/plugins/base/src/test/resources/expect/functionWithParams/out/html/styles/style.css b/plugins/base/src/test/resources/expect/functionWithParams/out/html/styles/style.css index 5c347128..720998ad 100644 --- a/plugins/base/src/test/resources/expect/functionWithParams/out/html/styles/style.css +++ b/plugins/base/src/test/resources/expect/functionWithParams/out/html/styles/style.css @@ -487,6 +487,56 @@ td.content { color: #5B5DEF; } +.platform-hinted { + display: block; +} + +.platform-hinted > .platform-bookmarks-row { + display: flex; + flex-direction: row; + padding: 0px; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark { + min-width: 64px; + height: 36px; + border: 2px solid white; + background: white; + outline: none; + flex: none; + order: 5; + align-self: flex-start; + margin: 0; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(1):hover { + border-top: 2px solid gray; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(2):hover { + border-top: 2px solid orange; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(3):hover { + border-top: 2px solid crimson; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(4):hover { + border-top: 2px solid blue; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark[data-active=''] { + border: 2px solid #F4F4F4; + border-top: 2px solid #4DBB5F; + + background: #F4F4F4; +} + +.platform-hinted > .content:not([data-active]) { + display: none +} + + @media print, screen and (max-width: 960px) { div.wrapper { diff --git a/plugins/base/src/test/resources/expect/functionWithReceiver/out/html/root//fn.html b/plugins/base/src/test/resources/expect/functionWithReceiver/out/html/root//fn.html index 2ef82b0e..fdcd4a9d 100644 --- a/plugins/base/src/test/resources/expect/functionWithReceiver/out/html/root//fn.html +++ b/plugins/base/src/test/resources/expect/functionWithReceiver/out/html/root//fn.html @@ -4,6 +4,7 @@ fn + @@ -20,13 +21,17 @@

fn

-
final fun String.fn()
+
final fun String.fn()
+

Description

-Function with receiver
+
Function with receiver
+

fn

-
final fun String.fn(x: Int)
+
final fun String.fn(x: Int)
+

Description

-Function with receiver +
Function with receiver
+ diff --git a/plugins/base/src/test/resources/expect/functionWithReceiver/out/html/root//index.html b/plugins/base/src/test/resources/expect/functionWithReceiver/out/html/root//index.html index fbe99965..4e481086 100644 --- a/plugins/base/src/test/resources/expect/functionWithReceiver/out/html/root//index.html +++ b/plugins/base/src/test/resources/expect/functionWithReceiver/out/html/root//index.html @@ -4,6 +4,7 @@ <jvm root> + @@ -27,7 +28,8 @@
fn
final fun String.fn()
+
+
final fun String.fn()
@@ -36,7 +38,8 @@
fn
final fun String.fn(x: Int)
+
+
final fun String.fn(x: Int)
diff --git a/plugins/base/src/test/resources/expect/functionWithReceiver/out/html/root/index.html b/plugins/base/src/test/resources/expect/functionWithReceiver/out/html/root/index.html index f8c89bbf..a3211166 100644 --- a/plugins/base/src/test/resources/expect/functionWithReceiver/out/html/root/index.html +++ b/plugins/base/src/test/resources/expect/functionWithReceiver/out/html/root/index.html @@ -4,6 +4,7 @@ root + diff --git a/plugins/base/src/test/resources/expect/functionWithReceiver/out/html/scripts/navigationLoader.js b/plugins/base/src/test/resources/expect/functionWithReceiver/out/html/scripts/navigationLoader.js index 5fe52ade..ecbabb4c 100644 --- a/plugins/base/src/test/resources/expect/functionWithReceiver/out/html/scripts/navigationLoader.js +++ b/plugins/base/src/test/resources/expect/functionWithReceiver/out/html/scripts/navigationLoader.js @@ -1,4 +1,4 @@ -onload = () => { +window.addEventListener('load', () => { fetch(pathToRoot + "navigation.html") .then(response => response.text()) .then(data => { @@ -15,7 +15,7 @@ onload = () => { }).then(() => { revealNavigationForCurrentPage() }) -}; +}) revealNavigationForCurrentPage = () => { let pageId = document.getElementById("content").attributes["pageIds"].value.toString(); diff --git a/plugins/base/src/test/resources/expect/functionWithReceiver/out/html/scripts/platformContentHandler.js b/plugins/base/src/test/resources/expect/functionWithReceiver/out/html/scripts/platformContentHandler.js new file mode 100644 index 00000000..b4a9e7c9 --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithReceiver/out/html/scripts/platformContentHandler.js @@ -0,0 +1,29 @@ +window.addEventListener('load', () => { + document.querySelectorAll("div[data-platform-hinted]") + .forEach(elem => elem.addEventListener('click', (event) => togglePlatformDependent(event,elem))) + } +) + +function togglePlatformDependent(e, container) { + let target = e.target + if (target.tagName != 'BUTTON') return; + let index = target.getAttribute('data-toggle') + + for(let child of container.children){ + if(child.hasAttribute('data-toggle-list')){ + for(let bm of child.children){ + if(bm == target){ + bm.setAttribute('data-active',"") + } else if(bm != target) { + bm.removeAttribute('data-active') + } + } + } + else if(child.getAttribute('data-togglable') == index) { + child.setAttribute('data-active',"") + } + else { + child.removeAttribute('data-active') + } + } +} diff --git a/plugins/base/src/test/resources/expect/functionWithReceiver/out/html/styles/style.css b/plugins/base/src/test/resources/expect/functionWithReceiver/out/html/styles/style.css index 5c347128..720998ad 100644 --- a/plugins/base/src/test/resources/expect/functionWithReceiver/out/html/styles/style.css +++ b/plugins/base/src/test/resources/expect/functionWithReceiver/out/html/styles/style.css @@ -487,6 +487,56 @@ td.content { color: #5B5DEF; } +.platform-hinted { + display: block; +} + +.platform-hinted > .platform-bookmarks-row { + display: flex; + flex-direction: row; + padding: 0px; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark { + min-width: 64px; + height: 36px; + border: 2px solid white; + background: white; + outline: none; + flex: none; + order: 5; + align-self: flex-start; + margin: 0; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(1):hover { + border-top: 2px solid gray; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(2):hover { + border-top: 2px solid orange; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(3):hover { + border-top: 2px solid crimson; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(4):hover { + border-top: 2px solid blue; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark[data-active=''] { + border: 2px solid #F4F4F4; + border-top: 2px solid #4DBB5F; + + background: #F4F4F4; +} + +.platform-hinted > .content:not([data-active]) { + display: none +} + + @media print, screen and (max-width: 960px) { div.wrapper { diff --git a/plugins/base/src/test/resources/expect/genericFunction/out/html/root//generic.html b/plugins/base/src/test/resources/expect/genericFunction/out/html/root//generic.html index 7a811876..2d8a5c7f 100644 --- a/plugins/base/src/test/resources/expect/genericFunction/out/html/root//generic.html +++ b/plugins/base/src/test/resources/expect/genericFunction/out/html/root//generic.html @@ -4,6 +4,7 @@ generic + @@ -20,9 +21,11 @@

generic

-
private final fun <T : Any> generic()
+
private final fun <T : Any> generic()
+

Description

-generic function +
generic function
+ diff --git a/plugins/base/src/test/resources/expect/genericFunction/out/html/root//index.html b/plugins/base/src/test/resources/expect/genericFunction/out/html/root//index.html index 02e9c431..4cf172df 100644 --- a/plugins/base/src/test/resources/expect/genericFunction/out/html/root//index.html +++ b/plugins/base/src/test/resources/expect/genericFunction/out/html/root//index.html @@ -4,6 +4,7 @@ <jvm root> + @@ -27,7 +28,8 @@
generic
private final fun <T : Any> generic()
+
+
private final fun <T : Any> generic()
diff --git a/plugins/base/src/test/resources/expect/genericFunction/out/html/root/index.html b/plugins/base/src/test/resources/expect/genericFunction/out/html/root/index.html index f8c89bbf..a3211166 100644 --- a/plugins/base/src/test/resources/expect/genericFunction/out/html/root/index.html +++ b/plugins/base/src/test/resources/expect/genericFunction/out/html/root/index.html @@ -4,6 +4,7 @@ root + diff --git a/plugins/base/src/test/resources/expect/genericFunction/out/html/scripts/navigationLoader.js b/plugins/base/src/test/resources/expect/genericFunction/out/html/scripts/navigationLoader.js index 5fe52ade..ecbabb4c 100644 --- a/plugins/base/src/test/resources/expect/genericFunction/out/html/scripts/navigationLoader.js +++ b/plugins/base/src/test/resources/expect/genericFunction/out/html/scripts/navigationLoader.js @@ -1,4 +1,4 @@ -onload = () => { +window.addEventListener('load', () => { fetch(pathToRoot + "navigation.html") .then(response => response.text()) .then(data => { @@ -15,7 +15,7 @@ onload = () => { }).then(() => { revealNavigationForCurrentPage() }) -}; +}) revealNavigationForCurrentPage = () => { let pageId = document.getElementById("content").attributes["pageIds"].value.toString(); diff --git a/plugins/base/src/test/resources/expect/genericFunction/out/html/scripts/platformContentHandler.js b/plugins/base/src/test/resources/expect/genericFunction/out/html/scripts/platformContentHandler.js new file mode 100644 index 00000000..b4a9e7c9 --- /dev/null +++ b/plugins/base/src/test/resources/expect/genericFunction/out/html/scripts/platformContentHandler.js @@ -0,0 +1,29 @@ +window.addEventListener('load', () => { + document.querySelectorAll("div[data-platform-hinted]") + .forEach(elem => elem.addEventListener('click', (event) => togglePlatformDependent(event,elem))) + } +) + +function togglePlatformDependent(e, container) { + let target = e.target + if (target.tagName != 'BUTTON') return; + let index = target.getAttribute('data-toggle') + + for(let child of container.children){ + if(child.hasAttribute('data-toggle-list')){ + for(let bm of child.children){ + if(bm == target){ + bm.setAttribute('data-active',"") + } else if(bm != target) { + bm.removeAttribute('data-active') + } + } + } + else if(child.getAttribute('data-togglable') == index) { + child.setAttribute('data-active',"") + } + else { + child.removeAttribute('data-active') + } + } +} diff --git a/plugins/base/src/test/resources/expect/genericFunction/out/html/styles/style.css b/plugins/base/src/test/resources/expect/genericFunction/out/html/styles/style.css index 5c347128..720998ad 100644 --- a/plugins/base/src/test/resources/expect/genericFunction/out/html/styles/style.css +++ b/plugins/base/src/test/resources/expect/genericFunction/out/html/styles/style.css @@ -487,6 +487,56 @@ td.content { color: #5B5DEF; } +.platform-hinted { + display: block; +} + +.platform-hinted > .platform-bookmarks-row { + display: flex; + flex-direction: row; + padding: 0px; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark { + min-width: 64px; + height: 36px; + border: 2px solid white; + background: white; + outline: none; + flex: none; + order: 5; + align-self: flex-start; + margin: 0; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(1):hover { + border-top: 2px solid gray; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(2):hover { + border-top: 2px solid orange; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(3):hover { + border-top: 2px solid crimson; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(4):hover { + border-top: 2px solid blue; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark[data-active=''] { + border: 2px solid #F4F4F4; + border-top: 2px solid #4DBB5F; + + background: #F4F4F4; +} + +.platform-hinted > .content:not([data-active]) { + display: none +} + + @media print, screen and (max-width: 960px) { div.wrapper { diff --git a/plugins/base/src/test/resources/expect/genericFunctionWithConstraints/out/html/root//generic.html b/plugins/base/src/test/resources/expect/genericFunctionWithConstraints/out/html/root//generic.html index 0c135b62..0c00617f 100644 --- a/plugins/base/src/test/resources/expect/genericFunctionWithConstraints/out/html/root//generic.html +++ b/plugins/base/src/test/resources/expect/genericFunctionWithConstraints/out/html/root//generic.html @@ -4,6 +4,7 @@ generic + @@ -20,9 +21,11 @@

generic

-
final fun <T : R, R : Any> generic()
+
final fun <T : R, R : Any> generic()
+

Description

-generic function +
generic function
+ diff --git a/plugins/base/src/test/resources/expect/genericFunctionWithConstraints/out/html/root//index.html b/plugins/base/src/test/resources/expect/genericFunctionWithConstraints/out/html/root//index.html index 3161a78f..a59f1ad7 100644 --- a/plugins/base/src/test/resources/expect/genericFunctionWithConstraints/out/html/root//index.html +++ b/plugins/base/src/test/resources/expect/genericFunctionWithConstraints/out/html/root//index.html @@ -4,6 +4,7 @@ <jvm root> + @@ -27,7 +28,8 @@
generic
final fun <T : R, R : Any> generic()
+
+
final fun <T : R, R : Any> generic()
diff --git a/plugins/base/src/test/resources/expect/genericFunctionWithConstraints/out/html/root/index.html b/plugins/base/src/test/resources/expect/genericFunctionWithConstraints/out/html/root/index.html index f8c89bbf..a3211166 100644 --- a/plugins/base/src/test/resources/expect/genericFunctionWithConstraints/out/html/root/index.html +++ b/plugins/base/src/test/resources/expect/genericFunctionWithConstraints/out/html/root/index.html @@ -4,6 +4,7 @@ root + diff --git a/plugins/base/src/test/resources/expect/genericFunctionWithConstraints/out/html/scripts/navigationLoader.js b/plugins/base/src/test/resources/expect/genericFunctionWithConstraints/out/html/scripts/navigationLoader.js index 5fe52ade..ecbabb4c 100644 --- a/plugins/base/src/test/resources/expect/genericFunctionWithConstraints/out/html/scripts/navigationLoader.js +++ b/plugins/base/src/test/resources/expect/genericFunctionWithConstraints/out/html/scripts/navigationLoader.js @@ -1,4 +1,4 @@ -onload = () => { +window.addEventListener('load', () => { fetch(pathToRoot + "navigation.html") .then(response => response.text()) .then(data => { @@ -15,7 +15,7 @@ onload = () => { }).then(() => { revealNavigationForCurrentPage() }) -}; +}) revealNavigationForCurrentPage = () => { let pageId = document.getElementById("content").attributes["pageIds"].value.toString(); diff --git a/plugins/base/src/test/resources/expect/genericFunctionWithConstraints/out/html/scripts/platformContentHandler.js b/plugins/base/src/test/resources/expect/genericFunctionWithConstraints/out/html/scripts/platformContentHandler.js new file mode 100644 index 00000000..b4a9e7c9 --- /dev/null +++ b/plugins/base/src/test/resources/expect/genericFunctionWithConstraints/out/html/scripts/platformContentHandler.js @@ -0,0 +1,29 @@ +window.addEventListener('load', () => { + document.querySelectorAll("div[data-platform-hinted]") + .forEach(elem => elem.addEventListener('click', (event) => togglePlatformDependent(event,elem))) + } +) + +function togglePlatformDependent(e, container) { + let target = e.target + if (target.tagName != 'BUTTON') return; + let index = target.getAttribute('data-toggle') + + for(let child of container.children){ + if(child.hasAttribute('data-toggle-list')){ + for(let bm of child.children){ + if(bm == target){ + bm.setAttribute('data-active',"") + } else if(bm != target) { + bm.removeAttribute('data-active') + } + } + } + else if(child.getAttribute('data-togglable') == index) { + child.setAttribute('data-active',"") + } + else { + child.removeAttribute('data-active') + } + } +} diff --git a/plugins/base/src/test/resources/expect/genericFunctionWithConstraints/out/html/styles/style.css b/plugins/base/src/test/resources/expect/genericFunctionWithConstraints/out/html/styles/style.css index 5c347128..720998ad 100644 --- a/plugins/base/src/test/resources/expect/genericFunctionWithConstraints/out/html/styles/style.css +++ b/plugins/base/src/test/resources/expect/genericFunctionWithConstraints/out/html/styles/style.css @@ -487,6 +487,56 @@ td.content { color: #5B5DEF; } +.platform-hinted { + display: block; +} + +.platform-hinted > .platform-bookmarks-row { + display: flex; + flex-direction: row; + padding: 0px; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark { + min-width: 64px; + height: 36px; + border: 2px solid white; + background: white; + outline: none; + flex: none; + order: 5; + align-self: flex-start; + margin: 0; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(1):hover { + border-top: 2px solid gray; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(2):hover { + border-top: 2px solid orange; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(3):hover { + border-top: 2px solid crimson; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(4):hover { + border-top: 2px solid blue; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark[data-active=''] { + border: 2px solid #F4F4F4; + border-top: 2px solid #4DBB5F; + + background: #F4F4F4; +} + +.platform-hinted > .content:not([data-active]) { + display: none +} + + @media print, screen and (max-width: 960px) { div.wrapper { diff --git a/plugins/base/src/test/resources/expect/inlineFunction/out/html/root//f.html b/plugins/base/src/test/resources/expect/inlineFunction/out/html/root//f.html index 1d2532b6..37795eb2 100644 --- a/plugins/base/src/test/resources/expect/inlineFunction/out/html/root//f.html +++ b/plugins/base/src/test/resources/expect/inlineFunction/out/html/root//f.html @@ -4,6 +4,7 @@ f + @@ -20,7 +21,8 @@

f

-
final fun f(a:
() -> String
)
+
final fun f(a:
() -> String
)
+ diff --git a/plugins/base/src/test/resources/expect/inlineFunction/out/html/root//index.html b/plugins/base/src/test/resources/expect/inlineFunction/out/html/root//index.html index 8666b724..cfd0ab30 100644 --- a/plugins/base/src/test/resources/expect/inlineFunction/out/html/root//index.html +++ b/plugins/base/src/test/resources/expect/inlineFunction/out/html/root//index.html @@ -4,6 +4,7 @@ <jvm root> + @@ -27,7 +28,8 @@
f
final fun f(a:
() -> String
)
+
+
final fun f(a:
() -> String
)
diff --git a/plugins/base/src/test/resources/expect/inlineFunction/out/html/root/index.html b/plugins/base/src/test/resources/expect/inlineFunction/out/html/root/index.html index f8c89bbf..a3211166 100644 --- a/plugins/base/src/test/resources/expect/inlineFunction/out/html/root/index.html +++ b/plugins/base/src/test/resources/expect/inlineFunction/out/html/root/index.html @@ -4,6 +4,7 @@ root + diff --git a/plugins/base/src/test/resources/expect/inlineFunction/out/html/scripts/navigationLoader.js b/plugins/base/src/test/resources/expect/inlineFunction/out/html/scripts/navigationLoader.js index 5fe52ade..ecbabb4c 100644 --- a/plugins/base/src/test/resources/expect/inlineFunction/out/html/scripts/navigationLoader.js +++ b/plugins/base/src/test/resources/expect/inlineFunction/out/html/scripts/navigationLoader.js @@ -1,4 +1,4 @@ -onload = () => { +window.addEventListener('load', () => { fetch(pathToRoot + "navigation.html") .then(response => response.text()) .then(data => { @@ -15,7 +15,7 @@ onload = () => { }).then(() => { revealNavigationForCurrentPage() }) -}; +}) revealNavigationForCurrentPage = () => { let pageId = document.getElementById("content").attributes["pageIds"].value.toString(); diff --git a/plugins/base/src/test/resources/expect/inlineFunction/out/html/scripts/platformContentHandler.js b/plugins/base/src/test/resources/expect/inlineFunction/out/html/scripts/platformContentHandler.js new file mode 100644 index 00000000..b4a9e7c9 --- /dev/null +++ b/plugins/base/src/test/resources/expect/inlineFunction/out/html/scripts/platformContentHandler.js @@ -0,0 +1,29 @@ +window.addEventListener('load', () => { + document.querySelectorAll("div[data-platform-hinted]") + .forEach(elem => elem.addEventListener('click', (event) => togglePlatformDependent(event,elem))) + } +) + +function togglePlatformDependent(e, container) { + let target = e.target + if (target.tagName != 'BUTTON') return; + let index = target.getAttribute('data-toggle') + + for(let child of container.children){ + if(child.hasAttribute('data-toggle-list')){ + for(let bm of child.children){ + if(bm == target){ + bm.setAttribute('data-active',"") + } else if(bm != target) { + bm.removeAttribute('data-active') + } + } + } + else if(child.getAttribute('data-togglable') == index) { + child.setAttribute('data-active',"") + } + else { + child.removeAttribute('data-active') + } + } +} diff --git a/plugins/base/src/test/resources/expect/inlineFunction/out/html/styles/style.css b/plugins/base/src/test/resources/expect/inlineFunction/out/html/styles/style.css index 5c347128..720998ad 100644 --- a/plugins/base/src/test/resources/expect/inlineFunction/out/html/styles/style.css +++ b/plugins/base/src/test/resources/expect/inlineFunction/out/html/styles/style.css @@ -487,6 +487,56 @@ td.content { color: #5B5DEF; } +.platform-hinted { + display: block; +} + +.platform-hinted > .platform-bookmarks-row { + display: flex; + flex-direction: row; + padding: 0px; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark { + min-width: 64px; + height: 36px; + border: 2px solid white; + background: white; + outline: none; + flex: none; + order: 5; + align-self: flex-start; + margin: 0; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(1):hover { + border-top: 2px solid gray; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(2):hover { + border-top: 2px solid orange; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(3):hover { + border-top: 2px solid crimson; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(4):hover { + border-top: 2px solid blue; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark[data-active=''] { + border: 2px solid #F4F4F4; + border-top: 2px solid #4DBB5F; + + background: #F4F4F4; +} + +.platform-hinted > .content:not([data-active]) { + display: none +} + + @media print, screen and (max-width: 960px) { div.wrapper { diff --git a/plugins/base/src/test/resources/expect/inlineSuspendFunction/out/html/root//f.html b/plugins/base/src/test/resources/expect/inlineSuspendFunction/out/html/root//f.html index 1d2532b6..37795eb2 100644 --- a/plugins/base/src/test/resources/expect/inlineSuspendFunction/out/html/root//f.html +++ b/plugins/base/src/test/resources/expect/inlineSuspendFunction/out/html/root//f.html @@ -4,6 +4,7 @@ f + @@ -20,7 +21,8 @@

f

-
final fun f(a:
() -> String
)
+
final fun f(a:
() -> String
)
+ diff --git a/plugins/base/src/test/resources/expect/inlineSuspendFunction/out/html/root//index.html b/plugins/base/src/test/resources/expect/inlineSuspendFunction/out/html/root//index.html index 8666b724..cfd0ab30 100644 --- a/plugins/base/src/test/resources/expect/inlineSuspendFunction/out/html/root//index.html +++ b/plugins/base/src/test/resources/expect/inlineSuspendFunction/out/html/root//index.html @@ -4,6 +4,7 @@ <jvm root> + @@ -27,7 +28,8 @@
f
final fun f(a:
() -> String
)
+
+
final fun f(a:
() -> String
)
diff --git a/plugins/base/src/test/resources/expect/inlineSuspendFunction/out/html/root/index.html b/plugins/base/src/test/resources/expect/inlineSuspendFunction/out/html/root/index.html index f8c89bbf..a3211166 100644 --- a/plugins/base/src/test/resources/expect/inlineSuspendFunction/out/html/root/index.html +++ b/plugins/base/src/test/resources/expect/inlineSuspendFunction/out/html/root/index.html @@ -4,6 +4,7 @@ root + diff --git a/plugins/base/src/test/resources/expect/inlineSuspendFunction/out/html/scripts/navigationLoader.js b/plugins/base/src/test/resources/expect/inlineSuspendFunction/out/html/scripts/navigationLoader.js index 5fe52ade..ecbabb4c 100644 --- a/plugins/base/src/test/resources/expect/inlineSuspendFunction/out/html/scripts/navigationLoader.js +++ b/plugins/base/src/test/resources/expect/inlineSuspendFunction/out/html/scripts/navigationLoader.js @@ -1,4 +1,4 @@ -onload = () => { +window.addEventListener('load', () => { fetch(pathToRoot + "navigation.html") .then(response => response.text()) .then(data => { @@ -15,7 +15,7 @@ onload = () => { }).then(() => { revealNavigationForCurrentPage() }) -}; +}) revealNavigationForCurrentPage = () => { let pageId = document.getElementById("content").attributes["pageIds"].value.toString(); diff --git a/plugins/base/src/test/resources/expect/inlineSuspendFunction/out/html/scripts/platformContentHandler.js b/plugins/base/src/test/resources/expect/inlineSuspendFunction/out/html/scripts/platformContentHandler.js new file mode 100644 index 00000000..b4a9e7c9 --- /dev/null +++ b/plugins/base/src/test/resources/expect/inlineSuspendFunction/out/html/scripts/platformContentHandler.js @@ -0,0 +1,29 @@ +window.addEventListener('load', () => { + document.querySelectorAll("div[data-platform-hinted]") + .forEach(elem => elem.addEventListener('click', (event) => togglePlatformDependent(event,elem))) + } +) + +function togglePlatformDependent(e, container) { + let target = e.target + if (target.tagName != 'BUTTON') return; + let index = target.getAttribute('data-toggle') + + for(let child of container.children){ + if(child.hasAttribute('data-toggle-list')){ + for(let bm of child.children){ + if(bm == target){ + bm.setAttribute('data-active',"") + } else if(bm != target) { + bm.removeAttribute('data-active') + } + } + } + else if(child.getAttribute('data-togglable') == index) { + child.setAttribute('data-active',"") + } + else { + child.removeAttribute('data-active') + } + } +} diff --git a/plugins/base/src/test/resources/expect/inlineSuspendFunction/out/html/styles/style.css b/plugins/base/src/test/resources/expect/inlineSuspendFunction/out/html/styles/style.css index 5c347128..720998ad 100644 --- a/plugins/base/src/test/resources/expect/inlineSuspendFunction/out/html/styles/style.css +++ b/plugins/base/src/test/resources/expect/inlineSuspendFunction/out/html/styles/style.css @@ -487,6 +487,56 @@ td.content { color: #5B5DEF; } +.platform-hinted { + display: block; +} + +.platform-hinted > .platform-bookmarks-row { + display: flex; + flex-direction: row; + padding: 0px; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark { + min-width: 64px; + height: 36px; + border: 2px solid white; + background: white; + outline: none; + flex: none; + order: 5; + align-self: flex-start; + margin: 0; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(1):hover { + border-top: 2px solid gray; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(2):hover { + border-top: 2px solid orange; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(3):hover { + border-top: 2px solid crimson; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(4):hover { + border-top: 2px solid blue; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark[data-active=''] { + border: 2px solid #F4F4F4; + border-top: 2px solid #4DBB5F; + + background: #F4F4F4; +} + +.platform-hinted > .content:not([data-active]) { + display: none +} + + @media print, screen and (max-width: 960px) { div.wrapper { diff --git a/plugins/base/src/test/resources/expect/signatureTest/out/html/root/index.html b/plugins/base/src/test/resources/expect/signatureTest/out/html/root/index.html index 8dded9be..7cec6415 100644 --- a/plugins/base/src/test/resources/expect/signatureTest/out/html/root/index.html +++ b/plugins/base/src/test/resources/expect/signatureTest/out/html/root/index.html @@ -4,6 +4,7 @@ root + diff --git a/plugins/base/src/test/resources/expect/signatureTest/out/html/root/signatureTest/index.html b/plugins/base/src/test/resources/expect/signatureTest/out/html/root/signatureTest/index.html index 2f75a288..f6c108eb 100644 --- a/plugins/base/src/test/resources/expect/signatureTest/out/html/root/signatureTest/index.html +++ b/plugins/base/src/test/resources/expect/signatureTest/out/html/root/signatureTest/index.html @@ -4,6 +4,7 @@ signatureTest + @@ -27,7 +28,8 @@
test
final fun test(i:
(Int) -> Int
)
+
+
final fun test(i:
(Int) -> Int
)
@@ -36,7 +38,8 @@
test2
final fun test2(i:
Int.(Int) -> Int
)
+
+
final fun test2(i:
Int.(Int) -> Int
)
diff --git a/plugins/base/src/test/resources/expect/signatureTest/out/html/root/signatureTest/test.html b/plugins/base/src/test/resources/expect/signatureTest/out/html/root/signatureTest/test.html index 6eda8f33..b0e440b1 100644 --- a/plugins/base/src/test/resources/expect/signatureTest/out/html/root/signatureTest/test.html +++ b/plugins/base/src/test/resources/expect/signatureTest/out/html/root/signatureTest/test.html @@ -4,6 +4,7 @@ test + @@ -20,7 +21,8 @@

test

-
final fun test(i:
(Int) -> Int
)
+
final fun test(i:
(Int) -> Int
)
+ diff --git a/plugins/base/src/test/resources/expect/signatureTest/out/html/root/signatureTest/test2.html b/plugins/base/src/test/resources/expect/signatureTest/out/html/root/signatureTest/test2.html index d01ffd73..3128a10b 100644 --- a/plugins/base/src/test/resources/expect/signatureTest/out/html/root/signatureTest/test2.html +++ b/plugins/base/src/test/resources/expect/signatureTest/out/html/root/signatureTest/test2.html @@ -4,6 +4,7 @@ test2 + @@ -20,7 +21,8 @@

test2

-
final fun test2(i:
Int.(Int) -> Int
)
+
final fun test2(i:
Int.(Int) -> Int
)
+ diff --git a/plugins/base/src/test/resources/expect/signatureTest/out/html/scripts/navigationLoader.js b/plugins/base/src/test/resources/expect/signatureTest/out/html/scripts/navigationLoader.js index 5fe52ade..ecbabb4c 100644 --- a/plugins/base/src/test/resources/expect/signatureTest/out/html/scripts/navigationLoader.js +++ b/plugins/base/src/test/resources/expect/signatureTest/out/html/scripts/navigationLoader.js @@ -1,4 +1,4 @@ -onload = () => { +window.addEventListener('load', () => { fetch(pathToRoot + "navigation.html") .then(response => response.text()) .then(data => { @@ -15,7 +15,7 @@ onload = () => { }).then(() => { revealNavigationForCurrentPage() }) -}; +}) revealNavigationForCurrentPage = () => { let pageId = document.getElementById("content").attributes["pageIds"].value.toString(); diff --git a/plugins/base/src/test/resources/expect/signatureTest/out/html/scripts/platformContentHandler.js b/plugins/base/src/test/resources/expect/signatureTest/out/html/scripts/platformContentHandler.js new file mode 100644 index 00000000..b4a9e7c9 --- /dev/null +++ b/plugins/base/src/test/resources/expect/signatureTest/out/html/scripts/platformContentHandler.js @@ -0,0 +1,29 @@ +window.addEventListener('load', () => { + document.querySelectorAll("div[data-platform-hinted]") + .forEach(elem => elem.addEventListener('click', (event) => togglePlatformDependent(event,elem))) + } +) + +function togglePlatformDependent(e, container) { + let target = e.target + if (target.tagName != 'BUTTON') return; + let index = target.getAttribute('data-toggle') + + for(let child of container.children){ + if(child.hasAttribute('data-toggle-list')){ + for(let bm of child.children){ + if(bm == target){ + bm.setAttribute('data-active',"") + } else if(bm != target) { + bm.removeAttribute('data-active') + } + } + } + else if(child.getAttribute('data-togglable') == index) { + child.setAttribute('data-active',"") + } + else { + child.removeAttribute('data-active') + } + } +} diff --git a/plugins/base/src/test/resources/expect/signatureTest/out/html/styles/style.css b/plugins/base/src/test/resources/expect/signatureTest/out/html/styles/style.css index 5c347128..720998ad 100644 --- a/plugins/base/src/test/resources/expect/signatureTest/out/html/styles/style.css +++ b/plugins/base/src/test/resources/expect/signatureTest/out/html/styles/style.css @@ -487,6 +487,56 @@ td.content { color: #5B5DEF; } +.platform-hinted { + display: block; +} + +.platform-hinted > .platform-bookmarks-row { + display: flex; + flex-direction: row; + padding: 0px; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark { + min-width: 64px; + height: 36px; + border: 2px solid white; + background: white; + outline: none; + flex: none; + order: 5; + align-self: flex-start; + margin: 0; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(1):hover { + border-top: 2px solid gray; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(2):hover { + border-top: 2px solid orange; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(3):hover { + border-top: 2px solid crimson; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(4):hover { + border-top: 2px solid blue; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark[data-active=''] { + border: 2px solid #F4F4F4; + border-top: 2px solid #4DBB5F; + + background: #F4F4F4; +} + +.platform-hinted > .content:not([data-active]) { + display: none +} + + @media print, screen and (max-width: 960px) { div.wrapper { diff --git a/plugins/base/src/test/resources/expect/sinceKotlin/out/html/root//available-since1.1.html b/plugins/base/src/test/resources/expect/sinceKotlin/out/html/root//available-since1.1.html index b3075587..628af947 100644 --- a/plugins/base/src/test/resources/expect/sinceKotlin/out/html/root//available-since1.1.html +++ b/plugins/base/src/test/resources/expect/sinceKotlin/out/html/root//available-since1.1.html @@ -4,6 +4,7 @@ availableSince1.1 + @@ -20,9 +21,11 @@

availableSince1.1

-
+ +

Description

-Quite useful String +
Quite useful String
+ diff --git a/plugins/base/src/test/resources/expect/sinceKotlin/out/html/root//index.html b/plugins/base/src/test/resources/expect/sinceKotlin/out/html/root//index.html index 069b17ac..0f343034 100644 --- a/plugins/base/src/test/resources/expect/sinceKotlin/out/html/root//index.html +++ b/plugins/base/src/test/resources/expect/sinceKotlin/out/html/root//index.html @@ -4,6 +4,7 @@ <jvm root> + @@ -27,7 +28,8 @@
availableSince1.1 + +
diff --git a/plugins/base/src/test/resources/expect/sinceKotlin/out/html/root/index.html b/plugins/base/src/test/resources/expect/sinceKotlin/out/html/root/index.html index f8c89bbf..a3211166 100644 --- a/plugins/base/src/test/resources/expect/sinceKotlin/out/html/root/index.html +++ b/plugins/base/src/test/resources/expect/sinceKotlin/out/html/root/index.html @@ -4,6 +4,7 @@ root + diff --git a/plugins/base/src/test/resources/expect/sinceKotlin/out/html/scripts/navigationLoader.js b/plugins/base/src/test/resources/expect/sinceKotlin/out/html/scripts/navigationLoader.js index 5fe52ade..ecbabb4c 100644 --- a/plugins/base/src/test/resources/expect/sinceKotlin/out/html/scripts/navigationLoader.js +++ b/plugins/base/src/test/resources/expect/sinceKotlin/out/html/scripts/navigationLoader.js @@ -1,4 +1,4 @@ -onload = () => { +window.addEventListener('load', () => { fetch(pathToRoot + "navigation.html") .then(response => response.text()) .then(data => { @@ -15,7 +15,7 @@ onload = () => { }).then(() => { revealNavigationForCurrentPage() }) -}; +}) revealNavigationForCurrentPage = () => { let pageId = document.getElementById("content").attributes["pageIds"].value.toString(); diff --git a/plugins/base/src/test/resources/expect/sinceKotlin/out/html/scripts/platformContentHandler.js b/plugins/base/src/test/resources/expect/sinceKotlin/out/html/scripts/platformContentHandler.js new file mode 100644 index 00000000..b4a9e7c9 --- /dev/null +++ b/plugins/base/src/test/resources/expect/sinceKotlin/out/html/scripts/platformContentHandler.js @@ -0,0 +1,29 @@ +window.addEventListener('load', () => { + document.querySelectorAll("div[data-platform-hinted]") + .forEach(elem => elem.addEventListener('click', (event) => togglePlatformDependent(event,elem))) + } +) + +function togglePlatformDependent(e, container) { + let target = e.target + if (target.tagName != 'BUTTON') return; + let index = target.getAttribute('data-toggle') + + for(let child of container.children){ + if(child.hasAttribute('data-toggle-list')){ + for(let bm of child.children){ + if(bm == target){ + bm.setAttribute('data-active',"") + } else if(bm != target) { + bm.removeAttribute('data-active') + } + } + } + else if(child.getAttribute('data-togglable') == index) { + child.setAttribute('data-active',"") + } + else { + child.removeAttribute('data-active') + } + } +} diff --git a/plugins/base/src/test/resources/expect/sinceKotlin/out/html/styles/style.css b/plugins/base/src/test/resources/expect/sinceKotlin/out/html/styles/style.css index 5c347128..720998ad 100644 --- a/plugins/base/src/test/resources/expect/sinceKotlin/out/html/styles/style.css +++ b/plugins/base/src/test/resources/expect/sinceKotlin/out/html/styles/style.css @@ -487,6 +487,56 @@ td.content { color: #5B5DEF; } +.platform-hinted { + display: block; +} + +.platform-hinted > .platform-bookmarks-row { + display: flex; + flex-direction: row; + padding: 0px; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark { + min-width: 64px; + height: 36px; + border: 2px solid white; + background: white; + outline: none; + flex: none; + order: 5; + align-self: flex-start; + margin: 0; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(1):hover { + border-top: 2px solid gray; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(2):hover { + border-top: 2px solid orange; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(3):hover { + border-top: 2px solid crimson; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(4):hover { + border-top: 2px solid blue; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark[data-active=''] { + border: 2px solid #F4F4F4; + border-top: 2px solid #4DBB5F; + + background: #F4F4F4; +} + +.platform-hinted > .content:not([data-active]) { + display: none +} + + @media print, screen and (max-width: 960px) { div.wrapper { diff --git a/plugins/base/src/test/resources/expect/suspendFunction/out/html/root//f.html b/plugins/base/src/test/resources/expect/suspendFunction/out/html/root//f.html index dafca58f..9de96412 100644 --- a/plugins/base/src/test/resources/expect/suspendFunction/out/html/root//f.html +++ b/plugins/base/src/test/resources/expect/suspendFunction/out/html/root//f.html @@ -4,6 +4,7 @@ f + @@ -20,7 +21,8 @@

f

-
final fun f()
+
final fun f()
+ diff --git a/plugins/base/src/test/resources/expect/suspendFunction/out/html/root//index.html b/plugins/base/src/test/resources/expect/suspendFunction/out/html/root//index.html index 59b7070b..1ebe6dce 100644 --- a/plugins/base/src/test/resources/expect/suspendFunction/out/html/root//index.html +++ b/plugins/base/src/test/resources/expect/suspendFunction/out/html/root//index.html @@ -4,6 +4,7 @@ <jvm root> + @@ -27,7 +28,8 @@
f
final fun f()
+
+
final fun f()
diff --git a/plugins/base/src/test/resources/expect/suspendFunction/out/html/root/index.html b/plugins/base/src/test/resources/expect/suspendFunction/out/html/root/index.html index f8c89bbf..a3211166 100644 --- a/plugins/base/src/test/resources/expect/suspendFunction/out/html/root/index.html +++ b/plugins/base/src/test/resources/expect/suspendFunction/out/html/root/index.html @@ -4,6 +4,7 @@ root + diff --git a/plugins/base/src/test/resources/expect/suspendFunction/out/html/scripts/navigationLoader.js b/plugins/base/src/test/resources/expect/suspendFunction/out/html/scripts/navigationLoader.js index 5fe52ade..ecbabb4c 100644 --- a/plugins/base/src/test/resources/expect/suspendFunction/out/html/scripts/navigationLoader.js +++ b/plugins/base/src/test/resources/expect/suspendFunction/out/html/scripts/navigationLoader.js @@ -1,4 +1,4 @@ -onload = () => { +window.addEventListener('load', () => { fetch(pathToRoot + "navigation.html") .then(response => response.text()) .then(data => { @@ -15,7 +15,7 @@ onload = () => { }).then(() => { revealNavigationForCurrentPage() }) -}; +}) revealNavigationForCurrentPage = () => { let pageId = document.getElementById("content").attributes["pageIds"].value.toString(); diff --git a/plugins/base/src/test/resources/expect/suspendFunction/out/html/scripts/platformContentHandler.js b/plugins/base/src/test/resources/expect/suspendFunction/out/html/scripts/platformContentHandler.js new file mode 100644 index 00000000..b4a9e7c9 --- /dev/null +++ b/plugins/base/src/test/resources/expect/suspendFunction/out/html/scripts/platformContentHandler.js @@ -0,0 +1,29 @@ +window.addEventListener('load', () => { + document.querySelectorAll("div[data-platform-hinted]") + .forEach(elem => elem.addEventListener('click', (event) => togglePlatformDependent(event,elem))) + } +) + +function togglePlatformDependent(e, container) { + let target = e.target + if (target.tagName != 'BUTTON') return; + let index = target.getAttribute('data-toggle') + + for(let child of container.children){ + if(child.hasAttribute('data-toggle-list')){ + for(let bm of child.children){ + if(bm == target){ + bm.setAttribute('data-active',"") + } else if(bm != target) { + bm.removeAttribute('data-active') + } + } + } + else if(child.getAttribute('data-togglable') == index) { + child.setAttribute('data-active',"") + } + else { + child.removeAttribute('data-active') + } + } +} diff --git a/plugins/base/src/test/resources/expect/suspendFunction/out/html/styles/style.css b/plugins/base/src/test/resources/expect/suspendFunction/out/html/styles/style.css index 5c347128..720998ad 100644 --- a/plugins/base/src/test/resources/expect/suspendFunction/out/html/styles/style.css +++ b/plugins/base/src/test/resources/expect/suspendFunction/out/html/styles/style.css @@ -487,6 +487,56 @@ td.content { color: #5B5DEF; } +.platform-hinted { + display: block; +} + +.platform-hinted > .platform-bookmarks-row { + display: flex; + flex-direction: row; + padding: 0px; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark { + min-width: 64px; + height: 36px; + border: 2px solid white; + background: white; + outline: none; + flex: none; + order: 5; + align-self: flex-start; + margin: 0; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(1):hover { + border-top: 2px solid gray; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(2):hover { + border-top: 2px solid orange; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(3):hover { + border-top: 2px solid crimson; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(4):hover { + border-top: 2px solid blue; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark[data-active=''] { + border: 2px solid #F4F4F4; + border-top: 2px solid #4DBB5F; + + background: #F4F4F4; +} + +.platform-hinted > .content:not([data-active]) { + display: none +} + + @media print, screen and (max-width: 960px) { div.wrapper { diff --git a/plugins/base/src/test/resources/expect/suspendInlineFunction/out/html/root//f.html b/plugins/base/src/test/resources/expect/suspendInlineFunction/out/html/root//f.html index 1d2532b6..37795eb2 100644 --- a/plugins/base/src/test/resources/expect/suspendInlineFunction/out/html/root//f.html +++ b/plugins/base/src/test/resources/expect/suspendInlineFunction/out/html/root//f.html @@ -4,6 +4,7 @@ f + @@ -20,7 +21,8 @@

f

-
final fun f(a:
() -> String
)
+
final fun f(a:
() -> String
)
+ diff --git a/plugins/base/src/test/resources/expect/suspendInlineFunction/out/html/root//index.html b/plugins/base/src/test/resources/expect/suspendInlineFunction/out/html/root//index.html index 8666b724..cfd0ab30 100644 --- a/plugins/base/src/test/resources/expect/suspendInlineFunction/out/html/root//index.html +++ b/plugins/base/src/test/resources/expect/suspendInlineFunction/out/html/root//index.html @@ -4,6 +4,7 @@ <jvm root> + @@ -27,7 +28,8 @@
f
final fun f(a:
() -> String
)
+
+
final fun f(a:
() -> String
)
diff --git a/plugins/base/src/test/resources/expect/suspendInlineFunction/out/html/root/index.html b/plugins/base/src/test/resources/expect/suspendInlineFunction/out/html/root/index.html index f8c89bbf..a3211166 100644 --- a/plugins/base/src/test/resources/expect/suspendInlineFunction/out/html/root/index.html +++ b/plugins/base/src/test/resources/expect/suspendInlineFunction/out/html/root/index.html @@ -4,6 +4,7 @@ root + diff --git a/plugins/base/src/test/resources/expect/suspendInlineFunction/out/html/scripts/navigationLoader.js b/plugins/base/src/test/resources/expect/suspendInlineFunction/out/html/scripts/navigationLoader.js index 5fe52ade..ecbabb4c 100644 --- a/plugins/base/src/test/resources/expect/suspendInlineFunction/out/html/scripts/navigationLoader.js +++ b/plugins/base/src/test/resources/expect/suspendInlineFunction/out/html/scripts/navigationLoader.js @@ -1,4 +1,4 @@ -onload = () => { +window.addEventListener('load', () => { fetch(pathToRoot + "navigation.html") .then(response => response.text()) .then(data => { @@ -15,7 +15,7 @@ onload = () => { }).then(() => { revealNavigationForCurrentPage() }) -}; +}) revealNavigationForCurrentPage = () => { let pageId = document.getElementById("content").attributes["pageIds"].value.toString(); diff --git a/plugins/base/src/test/resources/expect/suspendInlineFunction/out/html/scripts/platformContentHandler.js b/plugins/base/src/test/resources/expect/suspendInlineFunction/out/html/scripts/platformContentHandler.js new file mode 100644 index 00000000..b4a9e7c9 --- /dev/null +++ b/plugins/base/src/test/resources/expect/suspendInlineFunction/out/html/scripts/platformContentHandler.js @@ -0,0 +1,29 @@ +window.addEventListener('load', () => { + document.querySelectorAll("div[data-platform-hinted]") + .forEach(elem => elem.addEventListener('click', (event) => togglePlatformDependent(event,elem))) + } +) + +function togglePlatformDependent(e, container) { + let target = e.target + if (target.tagName != 'BUTTON') return; + let index = target.getAttribute('data-toggle') + + for(let child of container.children){ + if(child.hasAttribute('data-toggle-list')){ + for(let bm of child.children){ + if(bm == target){ + bm.setAttribute('data-active',"") + } else if(bm != target) { + bm.removeAttribute('data-active') + } + } + } + else if(child.getAttribute('data-togglable') == index) { + child.setAttribute('data-active',"") + } + else { + child.removeAttribute('data-active') + } + } +} diff --git a/plugins/base/src/test/resources/expect/suspendInlineFunction/out/html/styles/style.css b/plugins/base/src/test/resources/expect/suspendInlineFunction/out/html/styles/style.css index 5c347128..720998ad 100644 --- a/plugins/base/src/test/resources/expect/suspendInlineFunction/out/html/styles/style.css +++ b/plugins/base/src/test/resources/expect/suspendInlineFunction/out/html/styles/style.css @@ -487,6 +487,56 @@ td.content { color: #5B5DEF; } +.platform-hinted { + display: block; +} + +.platform-hinted > .platform-bookmarks-row { + display: flex; + flex-direction: row; + padding: 0px; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark { + min-width: 64px; + height: 36px; + border: 2px solid white; + background: white; + outline: none; + flex: none; + order: 5; + align-self: flex-start; + margin: 0; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(1):hover { + border-top: 2px solid gray; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(2):hover { + border-top: 2px solid orange; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(3):hover { + border-top: 2px solid crimson; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark:nth-child(4):hover { + border-top: 2px solid blue; +} + +.platform-hinted > .platform-bookmarks-row > .platform-bookmark[data-active=''] { + border: 2px solid #F4F4F4; + border-top: 2px solid #4DBB5F; + + background: #F4F4F4; +} + +.platform-hinted > .content:not([data-active]) { + display: none +} + + @media print, screen and (max-width: 960px) { div.wrapper { -- cgit From 02a46b2035e6d7bf1b93b15d4d2e39933191b90d Mon Sep 17 00:00:00 2001 From: Filip Zybała Date: Wed, 15 Apr 2020 10:30:52 +0200 Subject: Adjusts to css: font-families, font size, active navigation part style --- .../src/main/resources/dokka/scripts/navigationLoader.js | 5 ++++- core/src/main/resources/dokka/styles/jetbrains-mono.css | 13 +++++++++++++ core/src/main/resources/dokka/styles/style.css | 16 ++++++++++++---- .../src/main/kotlin/renderers/html/htmlPreprocessors.kt | 3 ++- 4 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 core/src/main/resources/dokka/styles/jetbrains-mono.css (limited to 'plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt') diff --git a/core/src/main/resources/dokka/scripts/navigationLoader.js b/core/src/main/resources/dokka/scripts/navigationLoader.js index ecbabb4c..b30a866d 100644 --- a/core/src/main/resources/dokka/scripts/navigationLoader.js +++ b/core/src/main/resources/dokka/scripts/navigationLoader.js @@ -25,7 +25,10 @@ revealNavigationForCurrentPage = () => { parts.forEach(part => { if (part.attributes['pageId'].value.indexOf(pageId) !== -1 && found === 0) { found = 1; - if (part.classList.contains("hidden")) part.classList.remove("hidden"); + if (part.classList.contains("hidden")){ + part.classList.remove("hidden"); + part.setAttribute('data-active',""); + } revealParents(part) } }); diff --git a/core/src/main/resources/dokka/styles/jetbrains-mono.css b/core/src/main/resources/dokka/styles/jetbrains-mono.css new file mode 100644 index 00000000..2af32a92 --- /dev/null +++ b/core/src/main/resources/dokka/styles/jetbrains-mono.css @@ -0,0 +1,13 @@ +@font-face{ + font-family: 'JetBrains Mono'; + src: url('https://raw.githubusercontent.com/JetBrains/JetBrainsMono/master/web/woff2/JetBrainsMono-Regular.woff2') format('woff2'); + font-weight: normal; + font-style: normal; +} + +@font-face{ + font-family: 'JetBrains Mono'; + src: url('https://raw.githubusercontent.com/JetBrains/JetBrainsMono/master/web/woff2/JetBrainsMono-Bold.woff2') format('woff2'); + font-weight: bold; + font-style: normal; +} \ No newline at end of file diff --git a/core/src/main/resources/dokka/styles/style.css b/core/src/main/resources/dokka/styles/style.css index 720998ad..caa088b4 100644 --- a/core/src/main/resources/dokka/styles/style.css +++ b/core/src/main/resources/dokka/styles/style.css @@ -1,5 +1,6 @@ @import url(https://fonts.googleapis.com/css?family=Open+Sans:300i,400,700); - +@import url('https://rsms.me/inter/inter.css'); +@import url('jetbrains-mono.css'); #container { display: flex; @@ -163,9 +164,12 @@ } body, table { - font: 14px/1.5 'Open Sans', "Helvetica Neue", Helvetica, Arial, sans-serif; + font-family: 'Inter'; background: #F4F4F4; - font-weight: 300; + font-style: normal; + font-weight: normal; + font-size: 14px; + line-height: 24px; margin: 0; max-width: 1440px; } @@ -193,7 +197,7 @@ td:first-child { } .symbol { - font-family: Monaco, Bitstream Vera Sans Mono, Lucida Console, Terminal; + font-family: JetBrains Mono; font-size: 12px; min-height: 43px; } @@ -536,6 +540,10 @@ td.content { display: none } +.sideMenuPart[data-active] { + background: rgba(91, 93, 239, 0.15); + border-left: 4px solid #5B5DEF; +} @media print, screen and (max-width: 960px) { diff --git a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt index aaf82ba8..710407c5 100644 --- a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt +++ b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt @@ -65,7 +65,8 @@ object StyleAndScriptsAppender : PageTransformer { embeddedResources = it.embeddedResources + listOf( "styles/style.css", "scripts/navigationLoader.js", - "scripts/platformContentHandler.js" + "scripts/platformContentHandler.js", + "styles/jetbrains-mono.css" ) ) } -- cgit From 0f1c461d20336444bc667713954ea2879cc0a396 Mon Sep 17 00:00:00 2001 From: Filip Zybała Date: Thu, 21 May 2020 09:51:54 +0200 Subject: Added filtering to HTML pages --- plugins/base/src/main/kotlin/DokkaBase.kt | 6 ++ .../src/main/kotlin/renderers/html/HtmlRenderer.kt | 39 ++++++++- .../kotlin/renderers/html/htmlPreprocessors.kt | 26 ++++++ .../dokka/scripts/platformContentHandler.js | 95 +++++++++++++++++++++- .../base/src/main/resources/dokka/styles/style.css | 33 +++++++- 5 files changed, 195 insertions(+), 4 deletions(-) (limited to 'plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt') diff --git a/plugins/base/src/main/kotlin/DokkaBase.kt b/plugins/base/src/main/kotlin/DokkaBase.kt index a6052a9e..382b8f86 100644 --- a/plugins/base/src/main/kotlin/DokkaBase.kt +++ b/plugins/base/src/main/kotlin/DokkaBase.kt @@ -174,4 +174,10 @@ class DokkaBase : DokkaPlugin() { ) } order { after(rootCreator) } } + + val sourcesetDependencyAppender by extending { + htmlPreprocessors providing ::SourcesetDependencyAppender order { after(rootCreator)} + } + + } \ No newline at end of file diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt index 52f7024a..b089c71a 100644 --- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt @@ -63,13 +63,35 @@ open class HtmlRenderer( } node.dci.kind == ContentKind.Symbol -> div("symbol $additionalClasses") { childrenCallback() } node.dci.kind == ContentKind.BriefComment -> div("brief $additionalClasses") { childrenCallback() } - node.dci.kind == ContentKind.Cover -> div("cover $additionalClasses") { childrenCallback() } + node.dci.kind == ContentKind.Cover -> div("cover $additionalClasses") { + filterButtons(node) + childrenCallback() + } node.hasStyle(TextStyle.Paragraph) -> p(additionalClasses) { childrenCallback() } node.hasStyle(TextStyle.Block) -> div(additionalClasses) { childrenCallback() } else -> childrenCallback() } } + private fun FlowContent.filterButtons(group: ContentGroup) { + div(classes = "filter-section") { + id = "filter-section" + group.sourceSets.forEach { + button(classes = "platform-tag platform-selector") { + attributes["data-active"] = "" + attributes["data-filter"] = it.sourceSetName + when(it.platform.key){ + "common" -> classes = classes + "common-like" + "native" -> classes = classes + "native-like" + "jvm" -> classes = classes + "jvm-like" + "js" -> classes = classes + "js-like" + } + text(it.sourceSetName) + } + } + } + } + override fun FlowContent.buildPlatformDependent(content: PlatformHintedContent, pageContext: ContentPage) = buildPlatformDependent(content.sourceSets.map { it to setOf(content.inner) }.toMap(), pageContext, content.extra) @@ -108,6 +130,8 @@ open class HtmlRenderer( attributes["data-toggle-list"] = "data-toggle-list" contents.forEachIndexed { index, pair -> button(classes = "platform-bookmark") { + attributes["data-filterable-current"] = pair.first.sourceSetName + attributes["data-filterable-set"] = pair.first.sourceSetName if (index == 0) attributes["data-active"] = "" attributes["data-toggle"] = pair.first.sourceSetName when( @@ -160,8 +184,15 @@ open class HtmlRenderer( consumer.onTagContentUnsafe { +createHTML().div("divergent-group"){ + attributes["data-filterable-current"] = groupedDivergent.keys.joinToString(" ") { + it.sourceSetName + } + attributes["data-filterable-set"] = groupedDivergent.keys.joinToString(" ") { + it.sourceSetName + } consumer.onTagContentUnsafe { +it.key.first } div("main-subrow") { + if (node.implicitlySourceSetHinted) { buildPlatformDependent( groupedDivergent.map { (sourceSet, elements) -> @@ -242,6 +273,12 @@ open class HtmlRenderer( ?.let { withAnchor(node.dci.dri.first().toString()) { div(classes = "table-row") { + attributes["data-filterable-current"] = node.sourceSets.joinToString(" ") { + it.sourceSetName + } + attributes["data-filterable-set"] = node.sourceSets.joinToString(" ") { + it.sourceSetName + } it.filterIsInstance().takeIf { it.isNotEmpty() }?.let { div("main-subrow " + node.style.joinToString(" ")) { it.filter { sourceSetRestriction == null || it.sourceSets.any { s -> s in sourceSetRestriction } } diff --git a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt index 710407c5..45ef1457 100644 --- a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt +++ b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt @@ -6,6 +6,7 @@ import kotlinx.html.table import kotlinx.html.tbody import org.jetbrains.dokka.base.renderers.platforms import org.jetbrains.dokka.pages.* +import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.transformers.pages.PageTransformer @@ -66,8 +67,33 @@ object StyleAndScriptsAppender : PageTransformer { "styles/style.css", "scripts/navigationLoader.js", "scripts/platformContentHandler.js", + "scripts/sourceset_dependencies.js", "styles/jetbrains-mono.css" ) ) } +} + +class SourcesetDependencyAppender(val context: DokkaContext) : PageTransformer{ + override fun invoke(input: RootPageNode): RootPageNode { + val dependenciesMap = context.configuration.passesConfigurations.map { + it.sourceSetName to it.dependentSourceSets + }.toMap() + fun createDependenciesJson() : String = "sourceset_dependencies = '{${ + dependenciesMap.entries.joinToString(", ") { + "\"${it.key}\": [${it.value.joinToString(","){ + "\"$it\"" + }}]" + } + }}'" + val deps = RendererSpecificResourcePage( + name = "scripts/sourceset_dependencies.js", + children = emptyList(), + strategy = RenderingStrategy.Write(createDependenciesJson()) + ) + + return input.modified( + children = input.children + deps + ) + } } \ No newline at end of file diff --git a/plugins/base/src/main/resources/dokka/scripts/platformContentHandler.js b/plugins/base/src/main/resources/dokka/scripts/platformContentHandler.js index 72c8daae..cd993587 100644 --- a/plugins/base/src/main/resources/dokka/scripts/platformContentHandler.js +++ b/plugins/base/src/main/resources/dokka/scripts/platformContentHandler.js @@ -1,13 +1,71 @@ +filteringContext = { + dependencies: {}, + restrictedDependencies: [], + activeFilters: [] +} window.addEventListener('load', () => { + initializeFiltering() document.querySelectorAll("div[data-platform-hinted]") .forEach(elem => elem.addEventListener('click', (event) => togglePlatformDependent(event,elem))) document.querySelectorAll("div[tabs-section]") - .forEach(elem => elem.addEventListener('click', (event) => toggleSections(event))) + .forEach(elem => elem.addEventListener('click', (event) => toggleSections(event))) + document.getElementById('filter-section').addEventListener('click', (event) => filterButtonHandler(event)) document.querySelector(".tabs-section-body") .querySelector("div[data-togglable]") .setAttribute("data-active", "") }) +function filterButtonHandler(event) { + if(event.target.tagName == "BUTTON" && event.target.hasAttribute("data-filter")) { + let sourceset = event.target.getAttribute("data-filter") + if(filteringContext.activeFilters.indexOf(sourceset) != -1) { + filterSourceset(sourceset) + } else { + unfilterSourceset(sourceset) + } + } + refreshFilterButtons(); + refreshPlatformTabs() +} + +function initializeFiltering() { + filteringContext.dependencies = JSON.parse(sourceset_dependencies) + document.querySelectorAll("#filter-section > button") + .forEach(p => filteringContext.restrictedDependencies.push(p.getAttribute("data-filter"))) + Object.keys(filteringContext.dependencies).forEach(p => { + filteringContext.dependencies[p] = filteringContext.dependencies[p] + .filter(q => -1 !== filteringContext.restrictedDependencies.indexOf(q)) + }) + filteringContext.activeFilters = filteringContext.restrictedDependencies +} + +function refreshFilterButtons() { + document.querySelectorAll("#filter-section > button") + .forEach(f => { + if(filteringContext.activeFilters.indexOf(f.getAttribute("data-filter")) != -1){ + f.setAttribute("data-active","") + } else { + f.removeAttribute("data-active") + } + }) +} + +function filterSourceset(sourceset) { + filteringContext.activeFilters = filteringContext.activeFilters.filter(p => p != sourceset) + refreshFiltering() +} + +function unfilterSourceset(sourceset) { + if(filteringContext.activeFilters.length == 0) { + filteringContext.activeFilters = filteringContext.dependencies[sourceset].concat([sourceset]) + refreshFiltering() + } else { + filteringContext.activeFilters.push(sourceset) + refreshFiltering() + } +} + + function toggleSections(evt){ if(!evt.target.getAttribute("data-togglable")) return @@ -50,3 +108,38 @@ function togglePlatformDependent(e, container) { } } } + +function refreshFiltering() { + let sourcesetList = filteringContext.activeFilters + document.querySelectorAll("[data-filterable-set]") + .forEach( + elem => { + let platformList = elem.getAttribute("data-filterable-set").split(' ').filter(v => -1 !== sourcesetList.indexOf(v)) + elem.setAttribute("data-filterable-current", platformList.join(' ')) + } + ) +} + +function refreshPlatformTabs() { + document.querySelectorAll(".platform-hinted > .platform-bookmarks-row").forEach( + p => { + let active = false; + let firstAvailable = null + p.childNodes.forEach( + element => { + if(element.getAttribute("data-filterable-current") != ''){ + if( firstAvailable == null) { + firstAvailable = element + } + if(element.hasAttribute("data-active")) { + active = true; + } + } + } + ) + if( active == false && firstAvailable !== null ) { + firstAvailable.click() + } + } + ) +} diff --git a/plugins/base/src/main/resources/dokka/styles/style.css b/plugins/base/src/main/resources/dokka/styles/style.css index 671dfe8a..d9927046 100644 --- a/plugins/base/src/main/resources/dokka/styles/style.css +++ b/plugins/base/src/main/resources/dokka/styles/style.css @@ -62,6 +62,11 @@ padding: 24px 0 } +.cover { + display: flex; + flex-direction: column; +} + .tabbedcontent { padding: 24px 0; } @@ -483,9 +488,11 @@ footer { display: flex; flex-direction: row; padding: 4px 8px; - height: 16px; + height: 24px; border-radius: 100px; - + box-sizing: border-box; + border: 1px solid transparent; + margin: 2px; font-family: Inter, Arial, sans-serif; font-size: 12px; font-weight: 400; @@ -494,6 +501,7 @@ footer { line-height: normal; letter-spacing: normal; text-align: center; + outline: none; color: #fff @@ -528,6 +536,27 @@ footer { color: white; } +.filter-section { + display: flex; + display: flex; + flex-direction: row; + align-self: flex-end; + min-height: 30px; +} + +.platform-selector:hover { + border: 1px solid #A6AFBA !important; +} + +[data-filterable-current=''] { + display: none !important; +} +.platform-selector:not([data-active]) { + border: 1px solid #DADFE6; + background-color: white; + color: #637282; +} + td.content { padding-left: 24px; padding-top: 16px; -- cgit From 77c8777b7f66bddd374d68decd507547d356d602 Mon Sep 17 00:00:00 2001 From: Marcin Aman Date: Sun, 31 May 2020 21:02:46 +0200 Subject: Improve CSS, pages navigation tree and create anchors on page --- core/src/main/kotlin/pages/ContentNodes.kt | 14 +- core/src/main/kotlin/pages/PageNodes.kt | 1 - .../frontend/src/main/components/app/index.scss | 8 +- .../frontend/src/main/components/app/index.tsx | 45 +-- .../src/main/components/search/search.scss | 14 + .../frontend/src/main/components/search/search.tsx | 16 +- .../src/main/kotlin/renderers/html/HtmlRenderer.kt | 258 +++++++++++----- .../kotlin/renderers/html/htmlPreprocessors.kt | 20 +- .../kotlin/signatures/KotlinSignatureProvider.kt | 2 +- .../documentables/DefaultPageCreator.kt | 67 ++--- .../documentables/PageContentBuilder.kt | 14 +- .../src/main/resources/dokka/scripts/clipboard.js | 52 ++++ .../resources/dokka/scripts/navigationLoader.js | 11 + .../base/src/main/resources/dokka/styles/style.css | 330 ++++++++++++++++++--- .../kotlin/content/params/ContentForParamsTest.kt | 146 ++++----- .../content/seealso/ContentForSeeAlsoTest.kt | 170 +++++------ plugins/base/src/test/kotlin/enums/EnumsTest.kt | 8 + .../kotlin/linkableContent/LinkableContentTest.kt | 4 +- plugins/base/src/test/kotlin/markdown/LinkTest.kt | 13 +- .../test/kotlin/renderers/RenderingOnlyTestBase.kt | 1 + .../test/kotlin/renderers/html/DivergentTest.kt | 26 +- 21 files changed, 842 insertions(+), 378 deletions(-) create mode 100644 plugins/base/frontend/src/main/components/search/search.scss create mode 100644 plugins/base/src/main/resources/dokka/scripts/clipboard.js (limited to 'plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt') diff --git a/core/src/main/kotlin/pages/ContentNodes.kt b/core/src/main/kotlin/pages/ContentNodes.kt index 95b7b371..d6105bec 100644 --- a/core/src/main/kotlin/pages/ContentNodes.kt +++ b/core/src/main/kotlin/pages/ContentNodes.kt @@ -13,6 +13,8 @@ interface ContentNode : WithExtraProperties { val dci: DCI val sourceSets: Set val style: Set