diff options
author | Simon Ogorodnik <Simon.Ogorodnik@jetbrains.com> | 2016-11-30 16:55:05 +0300 |
---|---|---|
committer | Simon Ogorodnik <Simon.Ogorodnik@jetbrains.com> | 2016-11-30 16:55:05 +0300 |
commit | 9c6ffa354621e2cab39941e98597009917c4cfb6 (patch) | |
tree | a9483e76410a57c2c17739ef1be903ddffb15f6c /core/src | |
parent | 7a6bc78fbd58a7bca8263e0341a60365a8c49c5d (diff) | |
download | dokka-9c6ffa354621e2cab39941e98597009917c4cfb6.tar.gz dokka-9c6ffa354621e2cab39941e98597009917c4cfb6.tar.bz2 dokka-9c6ffa354621e2cab39941e98597009917c4cfb6.zip |
Added special format for experimental kotlin website samples format
Diffstat (limited to 'core/src')
3 files changed, 42 insertions, 18 deletions
diff --git a/core/src/main/kotlin/Formats/KotlinWebsiteFormatService.kt b/core/src/main/kotlin/Formats/KotlinWebsiteFormatService.kt index ac70bb02..007e9353 100644 --- a/core/src/main/kotlin/Formats/KotlinWebsiteFormatService.kt +++ b/core/src/main/kotlin/Formats/KotlinWebsiteFormatService.kt @@ -3,11 +3,11 @@ package org.jetbrains.dokka import com.google.inject.Inject -class KotlinWebsiteOutputBuilder(to: StringBuilder, - location: Location, - locationService: LocationService, - languageService: LanguageService, - extension: String) +open class KotlinWebsiteOutputBuilder(to: StringBuilder, + location: Location, + locationService: LocationService, + languageService: LanguageService, + extension: String) : JekyllOutputBuilder(to, location, locationService, languageService, extension) { private var needHardLineBreaks = false @@ -30,7 +30,7 @@ class KotlinWebsiteOutputBuilder(to: StringBuilder, override fun appendStrikethrough(body: () -> Unit) = wrapInTag("s", body) - private fun div(to: StringBuilder, cssClass: String, markdown: Boolean = false, block: () -> Unit) { + protected fun div(to: StringBuilder, cssClass: String, markdown: Boolean = false, block: () -> Unit) { to.append("<div class=\"$cssClass\"") if (markdown) to.append(" markdown=\"1\"") to.append(">") @@ -53,17 +53,6 @@ class KotlinWebsiteOutputBuilder(to: StringBuilder, } } - override fun appendSampleBlockCode(language: String, imports: () -> Unit, body: () -> Unit) { - div(to, "sample", true) { - appendBlockCode(language) { - imports() - wrap("\nfun main(args: Array<String>) {", "}") { - wrap("\n//sampleStart\n", "\n//sampleEnd\n", body) - } - } - } - } - override fun appendAsOverloadGroup(to: StringBuilder, block: () -> Unit) { div(to, "overload-group", true) { ensureParagraph() @@ -162,3 +151,31 @@ class KotlinWebsiteFormatService @Inject constructor(locationService: LocationSe override fun createOutputBuilder(to: StringBuilder, location: Location) = KotlinWebsiteOutputBuilder(to, location, locationService, languageService, extension) } + + +class KotlinWebsiteRunnableSamplesOutputBuilder(to: StringBuilder, + location: Location, + locationService: LocationService, + languageService: LanguageService, + extension: String) + : KotlinWebsiteOutputBuilder(to, location, locationService, languageService, extension) { + + override fun appendSampleBlockCode(language: String, imports: () -> Unit, body: () -> Unit) { + div(to, "sample", true) { + appendBlockCode(language) { + imports() + wrap("\nfun main(args: Array<String>) {", "}") { + wrap("\n//sampleStart\n", "\n//sampleEnd\n", body) + } + } + } + } +} + +class KotlinWebsiteRunnableSamplesFormatService @Inject constructor(locationService: LocationService, + signatureGenerator: LanguageService) + : JekyllFormatService(locationService, signatureGenerator, "html") { + override fun createOutputBuilder(to: StringBuilder, location: Location) = + KotlinWebsiteRunnableSamplesOutputBuilder(to, location, locationService, languageService, extension) +} + diff --git a/core/src/main/kotlin/Formats/StandardFormats.kt b/core/src/main/kotlin/Formats/StandardFormats.kt index dabde881..6b077444 100644 --- a/core/src/main/kotlin/Formats/StandardFormats.kt +++ b/core/src/main/kotlin/Formats/StandardFormats.kt @@ -32,7 +32,12 @@ class HtmlAsJavaFormatDescriptor : FormatDescriptor { class KotlinWebsiteFormatDescriptor : KotlinFormatDescriptorBase() { override val formatServiceClass = KotlinWebsiteFormatService::class override val outlineServiceClass = YamlOutlineService::class - override val sampleProcessingService: KClass<out SampleProcessingService> = KotlinWebsiteSampleProcessingService::class +} + +class KotlinWebsiteFormatRunnableSamplesDescriptor : KotlinFormatDescriptorBase() { + override val formatServiceClass = KotlinWebsiteRunnableSamplesFormatService::class + override val sampleProcessingService = KotlinWebsiteSampleProcessingService::class + override val outlineServiceClass = YamlOutlineService::class } class JekyllFormatDescriptor : KotlinFormatDescriptorBase() { diff --git a/core/src/main/resources/dokka/format/kotlin-website-samples.properties b/core/src/main/resources/dokka/format/kotlin-website-samples.properties new file mode 100644 index 00000000..bda616a4 --- /dev/null +++ b/core/src/main/resources/dokka/format/kotlin-website-samples.properties @@ -0,0 +1,2 @@ +class=org.jetbrains.dokka.Formats.KotlinWebsiteFormatRunnableSamplesDescriptor +description=Generates Kotlin website documentation
\ No newline at end of file |