-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9b86ddf
commit a04d53d
Showing
7 changed files
with
206 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
plugins { | ||
kotlin("jvm") | ||
} | ||
|
||
val dokkaVersion: String by rootProject.ext | ||
|
||
dependencies { | ||
compileOnly("org.jetbrains.dokka:dokka-core:$dokkaVersion") | ||
compileOnly("org.jetbrains.dokka:dokka-base:$dokkaVersion") | ||
compileOnly("org.jetbrains.dokka:analysis-markdown:$dokkaVersion") | ||
api("org.jetbrains.dokka:all-modules-page-plugin:$dokkaVersion") | ||
api("org.jetbrains.dokka:templating-plugin:$dokkaVersion") | ||
} |
98 changes: 98 additions & 0 deletions
98
dokka-site/src/main/kotlin/com/ensody/dokka/site/DokkaSitePlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package com.ensody.dokka.site | ||
|
||
import org.jetbrains.dokka.CoreExtensions | ||
import org.jetbrains.dokka.Timer | ||
import org.jetbrains.dokka.allModulesPage.AllModulesPageGeneration | ||
import org.jetbrains.dokka.allModulesPage.AllModulesPagePlugin | ||
import org.jetbrains.dokka.base.DokkaBase | ||
import org.jetbrains.dokka.base.renderers.html.HtmlRenderer | ||
import org.jetbrains.dokka.base.translators.documentables.DefaultDocumentableToPageTranslator | ||
import org.jetbrains.dokka.generation.Generation | ||
import org.jetbrains.dokka.model.DModule | ||
import org.jetbrains.dokka.pages.PageNode | ||
import org.jetbrains.dokka.pages.RootPageNode | ||
import org.jetbrains.dokka.plugability.DokkaContext | ||
import org.jetbrains.dokka.plugability.DokkaPlugin | ||
import org.jetbrains.dokka.plugability.DokkaPluginApiPreview | ||
import org.jetbrains.dokka.plugability.Extension | ||
import org.jetbrains.dokka.plugability.PluginApiPreviewAcknowledgement | ||
import org.jetbrains.dokka.transformers.documentation.DocumentableToPageTranslator | ||
import org.jetbrains.dokka.transformers.pages.PageTransformer | ||
|
||
public class DokkaSitePlugin : DokkaPlugin() { | ||
|
||
private val dokkaBase by lazy { plugin<DokkaBase>() } | ||
private val allModulePagesPlugin by lazy { plugin<AllModulesPagePlugin>() } | ||
|
||
public val allModulesPageTransformer: Extension<PageTransformer, *, *> by extending { | ||
allModulePagesPlugin.allModulesPageTransformer providing ::ExtraPageTransformer | ||
} | ||
|
||
public val ourPageTranslator: Extension<DocumentableToPageTranslator, *, *> by extending { | ||
(CoreExtensions.documentableToPageTranslator | ||
providing ::SiteDocumentableToPageTranslator | ||
override dokkaBase.documentableToPageTranslator) | ||
} | ||
|
||
public val allModulesPageGeneration: Extension<Generation, *, *> by extending { | ||
(CoreExtensions.generation | ||
providing ::SiteModulesPageGeneration | ||
override allModulePagesPlugin.allModulesPageGeneration) | ||
} | ||
|
||
@OptIn(DokkaPluginApiPreview::class) | ||
override fun pluginApiPreviewAcknowledgement(): PluginApiPreviewAcknowledgement = | ||
PluginApiPreviewAcknowledgement | ||
} | ||
|
||
public class SiteDocumentableToPageTranslator(private val context: DokkaContext) : DocumentableToPageTranslator { | ||
init { | ||
println("INIT!!!!!!!!") | ||
} | ||
|
||
val delegate = DefaultDocumentableToPageTranslator(context) | ||
|
||
override fun invoke(module: DModule): RootPageNode { | ||
println("TRANSLATE $module") | ||
return delegate(module) | ||
} | ||
} | ||
|
||
public class SiteModulesPageGeneration(private val context: DokkaContext) : Generation { | ||
override val generationName: String = "Site" | ||
|
||
val delegate = AllModulesPageGeneration(context) | ||
|
||
override fun Timer.generate() { | ||
delegate.apply { | ||
report("Processing submodules") | ||
val generationContext = processSubmodules() | ||
|
||
report("Creating all modules page") | ||
val pages = createAllModulesPage(generationContext) | ||
|
||
report("Transforming pages") | ||
val transformedPages = transformAllModulesPage(pages) | ||
|
||
report("Rendering") | ||
val renderer = MyRenderer(context) | ||
renderer.render(transformedPages) | ||
|
||
report("Processing multimodule") | ||
processMultiModule(transformedPages) | ||
|
||
report("Finish submodule processing") | ||
finishProcessingSubmodules() | ||
|
||
report("Running post-actions") | ||
runPostActions() | ||
} | ||
} | ||
} | ||
|
||
public class MyRenderer(context: DokkaContext) : HtmlRenderer(context) { | ||
override suspend fun renderPage(page: PageNode) { | ||
println("PAGE $page") | ||
super.renderPage(page) | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
dokka-site/src/main/kotlin/com/ensody/dokka/site/ExtraPageTransformer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
@file:OptIn(InternalDokkaApi::class) | ||
|
||
package com.ensody.dokka.site | ||
|
||
import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet | ||
import org.jetbrains.dokka.InternalDokkaApi | ||
import org.jetbrains.dokka.base.DokkaBase | ||
import org.jetbrains.dokka.base.translators.documentables.PageContentBuilder | ||
import org.jetbrains.dokka.links.DRI | ||
import org.jetbrains.dokka.pages.ContentGroup | ||
import org.jetbrains.dokka.pages.ContentKind | ||
import org.jetbrains.dokka.pages.MultimoduleRootPageNode | ||
import org.jetbrains.dokka.pages.RootPageNode | ||
import org.jetbrains.dokka.plugability.DokkaContext | ||
import org.jetbrains.dokka.plugability.plugin | ||
import org.jetbrains.dokka.plugability.querySingle | ||
import org.jetbrains.dokka.transformers.pages.PageTransformer | ||
|
||
public class ExtraPageTransformer( | ||
private val context: DokkaContext, | ||
) : PageTransformer { | ||
private val commentsConverter by lazy { context.plugin<DokkaBase>().querySingle { commentsToContentConverter } } | ||
private val signatureProvider by lazy { context.plugin<DokkaBase>().querySingle { signatureProvider } } | ||
|
||
override fun invoke(input: RootPageNode): RootPageNode { | ||
input as MultimoduleRootPageNode | ||
val sourceSetData = emptySet<DokkaSourceSet>() | ||
val builder = PageContentBuilder(commentsConverter, signatureProvider, context.logger) | ||
val contentNode: ContentGroup = builder.contentFor( | ||
dri = DRI(extra = ".foo"), | ||
kind = ContentKind.Cover, | ||
sourceSets = sourceSetData | ||
) { | ||
text("Hello") | ||
+input.content | ||
} | ||
return input.modified( | ||
content = contentNode | ||
) as RootPageNode | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
dokka-site/src/main/resources/META-INF/services/org.jetbrains.dokka.plugability.DokkaPlugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
com.ensody.dokka.site.DokkaSitePlugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters