Skip to content

Commit

Permalink
Update dokka to 1.4
Browse files Browse the repository at this point in the history
Change the way how we render pages, so we parse .md files and then apply html layouts.

Add basic support for linking.
  • Loading branch information
romanowski committed Sep 7, 2020
1 parent 9c84ccb commit 7b53d0d
Show file tree
Hide file tree
Showing 15 changed files with 766 additions and 229 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
build/
gradle/
lib/
out
5 changes: 3 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
}

group = "com.virtuslab.dokka"
version = "0.1.1"
version = "0.1.2"

tasks.withType(KotlinCompile::class).all {
val language_version: String by project
Expand Down Expand Up @@ -39,6 +39,7 @@ dependencies {
implementation("junit:junit:4.13")

dokkaHtmlPlugin(project(":"))
testImplementation("org.jetbrains.dokka:dokka-core:$dokka_version")
}

// Gradle metadata
Expand Down Expand Up @@ -83,5 +84,5 @@ publishing {

// Configure dokka
tasks.dokkaHtml {
pluginsConfiguration += "ExternalDocsTooKey" to "documentation"
pluginsConfiguration.put("ExternalDocsTooKey", "documentation")
}
File renamed without changes.
2 changes: 1 addition & 1 deletion documentation/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ layout: vl_header

**Yes, this page was generated using dokka-site**

You can learn more from out [documentation](dokka-site/index.html).
You can learn more from our [documentation](dokka-site/index.html).

## Getting started

Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
kotlin.code.style=official

kotlin_version=1.4-M3
dokka_version=1.4.0-rc
kotlin_version=1.4.0
dokka_version=1.4.0

language_version=1.4
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ pluginManagement {
mavenCentral()
jcenter()
gradlePluginPortal()
mavenLocal()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class StaticSitePlugin : DokkaPlugin() {

val customRenderer by extending {
(CoreExtensions.renderer
providing { ctx -> ExternalDocsToolRenderer(ctx) }
providing { ctx -> RendererDispatcher(ctx) }
override dokkaBase.htmlRenderer)
}

Expand Down
26 changes: 26 additions & 0 deletions src/main/kotlin/com/virtuslab/dokka/site/contentNodes.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.virtuslab.dokka.site

import org.jetbrains.dokka.model.DisplaySourceSet
import org.jetbrains.dokka.model.properties.PropertyContainer
import org.jetbrains.dokka.pages.*

data class PartiallyRenderedContend(
val page: PreResolvedPage,
override val children: List<ContentNode>,
override val dci: DCI,
override val sourceSets: Set<DisplaySourceSet>,
override val style: Set<Style> = emptySet(),
override val extra: PropertyContainer<ContentNode> = PropertyContainer.empty()
) : ContentNode {
override fun hasAnyContent(): Boolean = children.find { hasAnyContent() } != null

override fun withNewExtras(newExtras: PropertyContainer<ContentNode>): ContentNode =
copy(extra = extra)

override fun withSourceSets(sourceSets: Set<DisplaySourceSet>): ContentNode =
copy(sourceSets = sourceSets)

val allResources: List<String> by lazy {
page.render("").resources
}
}
14 changes: 10 additions & 4 deletions src/main/kotlin/com/virtuslab/dokka/site/locationProvider.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.virtuslab.dokka.site

import org.jetbrains.dokka.base.resolvers.local.DefaultLocationProvider
import org.jetbrains.dokka.base.resolvers.local.DokkaLocationProvider
import org.jetbrains.dokka.base.resolvers.local.LocationProvider
import org.jetbrains.dokka.base.resolvers.local.LocationProviderFactory
import org.jetbrains.dokka.pages.PageNode
Expand All @@ -13,10 +13,16 @@ class StaticSiteLocationProviderFactory(private val ctx: DokkaContext) : Locatio
}
}

class StaticSiteLocationProvider(ctx: DokkaContext, pageNode: RootPageNode) : DefaultLocationProvider(pageNode, ctx) {
class StaticSiteLocationProvider(ctx: DokkaContext, pageNode: RootPageNode) : DokkaLocationProvider(pageNode, ctx) {
override fun pathTo(node: PageNode, context: PageNode?): String =
if (node is BaseStaticSiteProcessor.BasePageNode && node.dri.contains(docsRootDRI))
"index"
if (node is BaseStaticSiteProcessor.StaticPageNode)
if (node.dri.contains(docsRootDRI)) "index"
else {
// replace title with original markdown file name
val original = super.pathTo(node, context)
val paths = original.split("/")
(paths.dropLast(1) + listOf(node.template.template.name())).joinToString("/")
}
else
super.pathTo(node, context)
}
Loading

0 comments on commit 7b53d0d

Please sign in to comment.