aboutsummaryrefslogtreecommitdiff
path: root/core/src/main
diff options
context:
space:
mode:
authorDmitry Jemerov <yole@jetbrains.com>2016-07-01 16:39:32 +0200
committerDmitry Jemerov <yole@jetbrains.com>2016-07-01 16:39:32 +0200
commitcb97c45aa0b0204ebc61a149794518d50b262814 (patch)
tree687b99d5966f8db53c9075464c605f51d4affaee /core/src/main
parentae642832a1a27aa98e34195047f0c08e325f23de (diff)
downloaddokka-cb97c45aa0b0204ebc61a149794518d50b262814.tar.gz
dokka-cb97c45aa0b0204ebc61a149794518d50b262814.tar.bz2
dokka-cb97c45aa0b0204ebc61a149794518d50b262814.zip
introduce GFM output format
Diffstat (limited to 'core/src/main')
-rw-r--r--core/src/main/kotlin/Formats/GFMFormatService.kt18
-rw-r--r--core/src/main/kotlin/Formats/HtmlFormatService.kt2
-rw-r--r--core/src/main/kotlin/Formats/KotlinWebsiteFormatService.kt2
-rw-r--r--core/src/main/kotlin/Formats/MarkdownFormatService.kt2
-rw-r--r--core/src/main/kotlin/Formats/StandardFormats.kt8
-rw-r--r--core/src/main/kotlin/Formats/StructuredFormatService.kt6
-rw-r--r--core/src/main/resources/dokka/format/gfm.properties2
7 files changed, 32 insertions, 8 deletions
diff --git a/core/src/main/kotlin/Formats/GFMFormatService.kt b/core/src/main/kotlin/Formats/GFMFormatService.kt
new file mode 100644
index 00000000..7b1eab85
--- /dev/null
+++ b/core/src/main/kotlin/Formats/GFMFormatService.kt
@@ -0,0 +1,18 @@
+package org.jetbrains.dokka
+
+import com.google.inject.Inject
+
+open class GFMFormatService(locationService: LocationService,
+ signatureGenerator: LanguageService,
+ linkExtension: String)
+: MarkdownFormatService(locationService, signatureGenerator, linkExtension) {
+
+ @Inject constructor(locationService: LocationService,
+ signatureGenerator: LanguageService) : this(locationService, signatureGenerator, "md")
+
+ override fun appendTable(to: StringBuilder, vararg columns: String, body: () -> Unit) {
+ to.appendln(columns.joinToString(" | ", "| ", " "))
+ to.appendln("|" + "---|".repeat(columns.size))
+ body()
+ }
+}
diff --git a/core/src/main/kotlin/Formats/HtmlFormatService.kt b/core/src/main/kotlin/Formats/HtmlFormatService.kt
index e6635cef..c7443128 100644
--- a/core/src/main/kotlin/Formats/HtmlFormatService.kt
+++ b/core/src/main/kotlin/Formats/HtmlFormatService.kt
@@ -49,7 +49,7 @@ open class HtmlFormatService @Inject constructor(@Named("folders") locationServi
to.appendln("<a name=\"${anchor.htmlEscape()}\"></a>")
}
- override fun appendTable(to: StringBuilder, body: () -> Unit) {
+ override fun appendTable(to: StringBuilder, vararg columns: String, body: () -> Unit) {
to.appendln("<table>")
body()
to.appendln("</table>")
diff --git a/core/src/main/kotlin/Formats/KotlinWebsiteFormatService.kt b/core/src/main/kotlin/Formats/KotlinWebsiteFormatService.kt
index eba82a3a..1f3a3750 100644
--- a/core/src/main/kotlin/Formats/KotlinWebsiteFormatService.kt
+++ b/core/src/main/kotlin/Formats/KotlinWebsiteFormatService.kt
@@ -77,7 +77,7 @@ class KotlinWebsiteFormatService @Inject constructor(locationService: LocationSe
}
}
- override fun appendTable(to: StringBuilder, body: () -> Unit) {
+ override fun appendTable(to: StringBuilder, vararg columns: String, body: () -> Unit) {
to.appendln("<table class=\"api-docs-table\">")
body()
to.appendln("</table>")
diff --git a/core/src/main/kotlin/Formats/MarkdownFormatService.kt b/core/src/main/kotlin/Formats/MarkdownFormatService.kt
index 9684b5c1..79177239 100644
--- a/core/src/main/kotlin/Formats/MarkdownFormatService.kt
+++ b/core/src/main/kotlin/Formats/MarkdownFormatService.kt
@@ -75,7 +75,7 @@ open class MarkdownFormatService(locationService: LocationService,
appendLine(to)
}
- override fun appendTable(to: StringBuilder, body: () -> Unit) {
+ override fun appendTable(to: StringBuilder, vararg columns: String, body: () -> Unit) {
to.appendln()
body()
to.appendln()
diff --git a/core/src/main/kotlin/Formats/StandardFormats.kt b/core/src/main/kotlin/Formats/StandardFormats.kt
index 94e1b115..fdc8eb9e 100644
--- a/core/src/main/kotlin/Formats/StandardFormats.kt
+++ b/core/src/main/kotlin/Formats/StandardFormats.kt
@@ -1,12 +1,14 @@
package org.jetbrains.dokka.Formats
import org.jetbrains.dokka.*
+import kotlin.reflect.KClass
abstract class KotlinFormatDescriptorBase : FormatDescriptor {
override val packageDocumentationBuilderClass = KotlinPackageDocumentationBuilder::class
override val javaDocumentationBuilderClass = KotlinJavaDocumentationBuilder::class
override val generatorServiceClass = FileGenerator::class
+ override val outlineServiceClass: KClass<out OutlineFormatService>? = null
}
class HtmlFormatDescriptor : KotlinFormatDescriptorBase() {
@@ -29,10 +31,12 @@ class KotlinWebsiteFormatDescriptor : KotlinFormatDescriptorBase() {
class JekyllFormatDescriptor : KotlinFormatDescriptorBase() {
override val formatServiceClass = JekyllFormatService::class
- override val outlineServiceClass = null
}
class MarkdownFormatDescriptor : KotlinFormatDescriptorBase() {
override val formatServiceClass = MarkdownFormatService::class
- override val outlineServiceClass = null
+}
+
+class GFMFormatDescriptor : KotlinFormatDescriptorBase() {
+ override val formatServiceClass = GFMFormatService::class
}
diff --git a/core/src/main/kotlin/Formats/StructuredFormatService.kt b/core/src/main/kotlin/Formats/StructuredFormatService.kt
index bb27aab5..72b6833d 100644
--- a/core/src/main/kotlin/Formats/StructuredFormatService.kt
+++ b/core/src/main/kotlin/Formats/StructuredFormatService.kt
@@ -22,7 +22,7 @@ abstract class StructuredFormatService(locationService: LocationService,
abstract fun appendLine(to: StringBuilder, text: String = "")
abstract fun appendAnchor(to: StringBuilder, anchor: String)
- abstract fun appendTable(to: StringBuilder, body: () -> Unit)
+ abstract fun appendTable(to: StringBuilder, vararg columns: String, body: () -> Unit)
abstract fun appendTableBody(to: StringBuilder, body: () -> Unit)
abstract fun appendTableRow(to: StringBuilder, body: () -> Unit)
abstract fun appendTableCell(to: StringBuilder, body: () -> Unit)
@@ -355,7 +355,7 @@ abstract class StructuredFormatService(locationService: LocationService,
val children = if (sortMembers) members.sortedBy { it.name } else members
val membersMap = children.groupBy { link(node, it) }
- appendTable(to) {
+ appendTable(to, "Name", "Summary") {
appendTableBody(to) {
for ((memberLocation, members) in membersMap) {
appendTableRow(to) {
@@ -404,7 +404,7 @@ abstract class StructuredFormatService(locationService: LocationService,
to.append(formatText(location, node.owner!!.summary))
appendHeader(to, "All Types", 3)
- appendTable(to) {
+ appendTable(to, "Name", "Summary") {
appendTableBody(to) {
for (type in node.members) {
appendTableRow(to) {
diff --git a/core/src/main/resources/dokka/format/gfm.properties b/core/src/main/resources/dokka/format/gfm.properties
new file mode 100644
index 00000000..5e8f7aa8
--- /dev/null
+++ b/core/src/main/resources/dokka/format/gfm.properties
@@ -0,0 +1,2 @@
+class=org.jetbrains.dokka.Formats.GFMFormatDescriptor
+description=Produces documentation in GitHub-flavored markdown format