diff options
author | Marcin Aman <marcin.aman@gmail.com> | 2021-08-25 20:55:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-25 20:55:41 +0200 |
commit | f2adc0a50462a63f7e1901db2e58077001acd622 (patch) | |
tree | a0a21d3c99b2d8cbe77ebf95d865aabd36d6598f /plugins/templating/src | |
parent | 939cbcd4d867961516da71f7c55d037ec88cb7f3 (diff) | |
parent | efc9f92b0ac083c73ac494c95b530305ac04115a (diff) | |
download | dokka-f2adc0a50462a63f7e1901db2e58077001acd622.tar.gz dokka-f2adc0a50462a63f7e1901db2e58077001acd622.tar.bz2 dokka-f2adc0a50462a63f7e1901db2e58077001acd622.zip |
Merge pull request #2066 from Kotlin/webhelp-like-frontend
Webhelp like frontend
Diffstat (limited to 'plugins/templating/src')
4 files changed, 19 insertions, 13 deletions
diff --git a/plugins/templating/src/main/kotlin/templates/JsonElementBasedTemplateProcessingStrategy.kt b/plugins/templating/src/main/kotlin/templates/JsonElementBasedTemplateProcessingStrategy.kt index 9e064a6a..533c12f6 100644 --- a/plugins/templating/src/main/kotlin/templates/JsonElementBasedTemplateProcessingStrategy.kt +++ b/plugins/templating/src/main/kotlin/templates/JsonElementBasedTemplateProcessingStrategy.kt @@ -53,12 +53,6 @@ abstract class BaseJsonNavigationTemplateProcessingStrategy(val context: DokkaCo } -class NavigationSearchTemplateStrategy(val dokkaContext: DokkaContext) : - BaseJsonNavigationTemplateProcessingStrategy(dokkaContext) { - override val navigationFileNameWithoutExtension: String = "navigation-pane" - override val path: String = "scripts" -} - class PagesSearchTemplateStrategy(val dokkaContext: DokkaContext) : BaseJsonNavigationTemplateProcessingStrategy(dokkaContext) { override val navigationFileNameWithoutExtension: String = "pages" diff --git a/plugins/templating/src/main/kotlin/templates/ProjectNameSubstitutor.kt b/plugins/templating/src/main/kotlin/templates/ProjectNameSubstitutor.kt new file mode 100644 index 00000000..8fc12b6c --- /dev/null +++ b/plugins/templating/src/main/kotlin/templates/ProjectNameSubstitutor.kt @@ -0,0 +1,13 @@ +package templates + +import org.jetbrains.dokka.base.templating.ProjectNameSubstitutionCommand +import org.jetbrains.dokka.base.templating.SubstitutionCommand +import org.jetbrains.dokka.plugability.DokkaContext +import org.jetbrains.dokka.templates.Substitutor +import org.jetbrains.dokka.templates.TemplatingContext + +class ProjectNameSubstitutor(private val dokkaContext: DokkaContext) : Substitutor { + + override fun trySubstitute(context: TemplatingContext<SubstitutionCommand>, match: MatchResult): String? = + dokkaContext.configuration.moduleName.takeIf { context.command is ProjectNameSubstitutionCommand } +}
\ No newline at end of file diff --git a/plugins/templating/src/main/kotlin/templates/TemplatingPlugin.kt b/plugins/templating/src/main/kotlin/templates/TemplatingPlugin.kt index 0842bb2b..1a02d41f 100644 --- a/plugins/templating/src/main/kotlin/templates/TemplatingPlugin.kt +++ b/plugins/templating/src/main/kotlin/templates/TemplatingPlugin.kt @@ -1,9 +1,9 @@ package org.jetbrains.dokka.templates -import org.jetbrains.dokka.allModulesPage.templates.NavigationSearchTemplateStrategy import org.jetbrains.dokka.allModulesPage.templates.PackageListProcessingStrategy import org.jetbrains.dokka.allModulesPage.templates.PagesSearchTemplateStrategy import org.jetbrains.dokka.plugability.DokkaPlugin +import templates.ProjectNameSubstitutor import templates.SourcesetDependencyProcessingStrategy class TemplatingPlugin : DokkaPlugin() { @@ -28,11 +28,6 @@ class TemplatingPlugin : DokkaPlugin() { before(fallbackProcessingStrategy) } } - val navigationSearchTemplateStrategy by extending { - templateProcessingStrategy providing ::NavigationSearchTemplateStrategy order { - before(fallbackProcessingStrategy) - } - } val sourcesetDependencyProcessingStrategy by extending { templateProcessingStrategy providing ::SourcesetDependencyProcessingStrategy order { @@ -60,6 +55,10 @@ class TemplatingPlugin : DokkaPlugin() { substitutor providing ::PathToRootSubstitutor } + val projectNameSubstitutor by extending { + substitutor providing ::ProjectNameSubstitutor + } + val addToNavigationCommandHandler by extending { directiveBasedCommandHandlers providing ::AddToNavigationCommandHandler } diff --git a/plugins/templating/src/test/kotlin/templates/AddToSearchCommandResolutionTest.kt b/plugins/templating/src/test/kotlin/templates/AddToSearchCommandResolutionTest.kt index aba668f7..96fcc8dd 100644 --- a/plugins/templating/src/test/kotlin/templates/AddToSearchCommandResolutionTest.kt +++ b/plugins/templating/src/test/kotlin/templates/AddToSearchCommandResolutionTest.kt @@ -32,7 +32,7 @@ class AddToSearchCommandResolutionTest : TemplatingAbstractTest() { val folder: TemporaryFolder = TemporaryFolder() @ParameterizedTest - @ValueSource(strings = ["navigation-pane.json", "pages.json"]) + @ValueSource(strings = ["pages.json"]) fun `should merge navigation templates`(fileName: String) { val (module1Navigation, module2Navigation) = setupTestDirectoriesWithContent(fileName) |