diff options
Diffstat (limited to 'plugins/all-modules-page/src/main/kotlin/AllModulesPageGeneration.kt')
-rw-r--r-- | plugins/all-modules-page/src/main/kotlin/AllModulesPageGeneration.kt | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/plugins/all-modules-page/src/main/kotlin/AllModulesPageGeneration.kt b/plugins/all-modules-page/src/main/kotlin/AllModulesPageGeneration.kt index 0013feed..c11b18b2 100644 --- a/plugins/all-modules-page/src/main/kotlin/AllModulesPageGeneration.kt +++ b/plugins/all-modules-page/src/main/kotlin/AllModulesPageGeneration.kt @@ -9,6 +9,8 @@ import org.jetbrains.dokka.plugability.plugin import org.jetbrains.dokka.plugability.query import org.jetbrains.dokka.plugability.querySingle import org.jetbrains.dokka.templates.TemplatingPlugin +import org.jetbrains.dokka.templates.TemplatingResult +import org.jetbrains.dokka.transformers.pages.CreationContext import org.jetbrains.dokka.versioning.VersioningPlugin class AllModulesPageGeneration(private val context: DokkaContext) : Generation { @@ -18,9 +20,11 @@ class AllModulesPageGeneration(private val context: DokkaContext) : Generation { private val versioningPlugin by lazy { context.plugin<VersioningPlugin>() } override fun Timer.generate() { + report("Processing submodules") + val generationContext = processSubmodules() report("Creating all modules page") - val pages = createAllModulesPage() + val pages = createAllModulesPage(generationContext) report("Copy previous documentation") handlePreviousDocs() @@ -31,15 +35,19 @@ class AllModulesPageGeneration(private val context: DokkaContext) : Generation { report("Rendering") render(transformedPages) - report("Processing submodules") - processSubmodules() + report("Processing multimodule") + processMultiModule(transformedPages) + + report("Finish submodule processing") + finishProcessingSubmodules() } override val generationName = "index page for project" fun handlePreviousDocs() = versioningPlugin.querySingle { versioningHandler }.invoke() - fun createAllModulesPage() = allModulesPagePlugin.querySingle { allModulesPageCreator }.invoke() + fun createAllModulesPage(allModulesContext: DefaultAllModulesContext) = + allModulesPagePlugin.querySingle { allModulesPageCreator }.invoke(allModulesContext) fun transformAllModulesPage(pages: RootPageNode) = allModulesPagePlugin.query { allModulesPageTransformer }.fold(pages) { acc, t -> t(acc) } @@ -49,5 +57,17 @@ class AllModulesPageGeneration(private val context: DokkaContext) : Generation { } fun processSubmodules() = - templatingPlugin.querySingle { templateProcessor }.process() + templatingPlugin.querySingle { submoduleTemplateProcessor } + .process(context.configuration.modules) + .let { DefaultAllModulesContext(it) } + + fun processMultiModule(root: RootPageNode) = + templatingPlugin.querySingle { multimoduleTemplateProcessor }.process(root) + + fun finishProcessingSubmodules() = + templatingPlugin.query { templateProcessingStrategy }.forEach { it.finish(context.configuration.outputDir) } + + data class DefaultAllModulesContext(val nonEmptyModules: List<String>) : CreationContext { + constructor(templating: TemplatingResult) : this(templating.modules) + } }
\ No newline at end of file |