diff options
author | Dmitry Jemerov <yole@jetbrains.com> | 2015-02-19 19:51:01 +0100 |
---|---|---|
committer | Dmitry Jemerov <yole@jetbrains.com> | 2015-02-19 19:51:01 +0100 |
commit | ea1f4cc2987536c3ed3df5899e6cec2df890f1e6 (patch) | |
tree | ceb0324a2829523587c750d771fc83d849ae4e13 /src/Formats | |
parent | d9bfa029b0ecf300ae47cf1033db2d5cb323d705 (diff) | |
download | dokka-ea1f4cc2987536c3ed3df5899e6cec2df890f1e6.tar.gz dokka-ea1f4cc2987536c3ed3df5899e6cec2df890f1e6.tar.bz2 dokka-ea1f4cc2987536c3ed3df5899e6cec2df890f1e6.zip |
refactor extension setup; encapsulate extension in LocationService
Diffstat (limited to 'src/Formats')
-rw-r--r-- | src/Formats/HtmlFormatService.kt | 4 | ||||
-rw-r--r-- | src/Formats/KotlinWebsiteFormatService.kt | 2 | ||||
-rw-r--r-- | src/Formats/MarkdownFormatService.kt | 5 | ||||
-rw-r--r-- | src/Formats/StructuredFormatService.kt | 12 |
4 files changed, 9 insertions, 14 deletions
diff --git a/src/Formats/HtmlFormatService.kt b/src/Formats/HtmlFormatService.kt index 8442c66f..733425d7 100644 --- a/src/Formats/HtmlFormatService.kt +++ b/src/Formats/HtmlFormatService.kt @@ -5,9 +5,7 @@ import java.io.File public open class HtmlFormatService(locationService: LocationService, signatureGenerator: LanguageService, val templateService: HtmlTemplateService = HtmlTemplateService.default()) -: StructuredFormatService(locationService, signatureGenerator), OutlineFormatService { - override val extension: String = "html" - +: StructuredFormatService(locationService, signatureGenerator, "html"), OutlineFormatService { override public fun formatText(text: String): String { return text.htmlEscape() } diff --git a/src/Formats/KotlinWebsiteFormatService.kt b/src/Formats/KotlinWebsiteFormatService.kt index 5e616fad..3ded2d6d 100644 --- a/src/Formats/KotlinWebsiteFormatService.kt +++ b/src/Formats/KotlinWebsiteFormatService.kt @@ -3,8 +3,6 @@ package org.jetbrains.dokka public class KotlinWebsiteFormatService(locationService: LocationService, signatureGenerator: LanguageService) : JekyllFormatService(locationService, signatureGenerator) { - override val extension: String = "md" - override fun appendFrontMatter(nodes: Iterable<DocumentationNode>, to: StringBuilder) { super.appendFrontMatter(nodes, to) to.appendln("layout: api") diff --git a/src/Formats/MarkdownFormatService.kt b/src/Formats/MarkdownFormatService.kt index b855ec9c..281ca21d 100644 --- a/src/Formats/MarkdownFormatService.kt +++ b/src/Formats/MarkdownFormatService.kt @@ -3,10 +3,7 @@ package org.jetbrains.dokka public open class MarkdownFormatService(locationService: LocationService, signatureGenerator: LanguageService) -: StructuredFormatService(locationService, signatureGenerator) { - - override val extension: String = "md" - +: StructuredFormatService(locationService, signatureGenerator, "md") { override public fun formatBreadcrumbs(items: Iterable<FormatLink>): String { return items.map { formatLink(it) }.joinToString(" / ") } diff --git a/src/Formats/StructuredFormatService.kt b/src/Formats/StructuredFormatService.kt index 32e22fd7..14eb490a 100644 --- a/src/Formats/StructuredFormatService.kt +++ b/src/Formats/StructuredFormatService.kt @@ -5,8 +5,10 @@ import org.jetbrains.dokka.LanguageService.RenderMode public data class FormatLink(val text: String, val href: String) -public abstract class StructuredFormatService(val locationService: LocationService, - val languageService: LanguageService) : FormatService { +public abstract class StructuredFormatService(locationService: LocationService, + val languageService: LanguageService, + override val extension: String) : FormatService { + val locationService: LocationService = locationService.withExtension(extension) abstract public fun appendBlockCode(to: StringBuilder, line: String) abstract public fun appendBlockCode(to: StringBuilder, lines: Iterable<String>) @@ -54,7 +56,7 @@ public abstract class StructuredFormatService(val locationService: LocationServi is ContentListItem -> append(formatListItem(formatText(location, content.children))) is ContentNodeLink -> { - val linkTo = location.relativePathTo(locationService.location(content.node), extension) + val linkTo = location.relativePathTo(locationService.location(content.node)) val linkText = formatText(location, content.children) append(formatLink(linkText, linkTo)) } @@ -76,7 +78,7 @@ public abstract class StructuredFormatService(val locationService: LocationServi open public fun link(from: DocumentationNode, to: DocumentationNode): FormatLink = link(from, to, extension) open public fun link(from: DocumentationNode, to: DocumentationNode, extension: String): FormatLink { - return FormatLink(to.name, locationService.relativePathToLocation(from, to, extension)) + return FormatLink(to.name, locationService.relativePathToLocation(from, to)) } fun appendDocumentation(location: Location, to: StringBuilder, overloads: Iterable<DocumentationNode>) { @@ -132,7 +134,7 @@ public abstract class StructuredFormatService(val locationService: LocationServi private fun DocumentationNode.appendOverrides(to: StringBuilder) { overrides.forEach { to.append("Overrides ") - val location = locationService.relativePathToLocation(this, it, extension) + val location = locationService.relativePathToLocation(this, it) appendLine(to, formatLink(FormatLink(it.owner!!.name + "." + it.name, location))) } } |