Adding Dokka source to AOSP

This is taken from commit 4ff3d4153ca344398bffcdaaa28f1a1f6e76f6ad from
https://github.com/google/dokka, which is Google's customized fork of
Dokka (https://github.com/Kotlin/dokka).

Bug: 135767980
Test: ./gradlew :core:cleanTest :core:test
Test: ./gradlew :runners:gradle-integration-tests:clean :runners:gradle-integration-tests:test

Change-Id: I332d0b522706e353c3837f6308aac1a8340d71d3
diff --git a/core/src/main/kotlin/Formats/OutlineService.kt b/core/src/main/kotlin/Formats/OutlineService.kt
new file mode 100644
index 0000000..958e93a
--- /dev/null
+++ b/core/src/main/kotlin/Formats/OutlineService.kt
@@ -0,0 +1,29 @@
+package org.jetbrains.dokka
+
+import java.io.File
+
+/**
+ * Service for building the outline of the package contents.
+ */
+interface OutlineFormatService {
+    fun getOutlineFileName(location: Location): File
+
+    fun appendOutlineHeader(location: Location, node: DocumentationNode, to: StringBuilder)
+    fun appendOutlineLevel(to: StringBuilder, body: () -> Unit)
+
+    /** Appends formatted outline to [StringBuilder](to) using specified [location] */
+    fun appendOutline(location: Location, to: StringBuilder, nodes: Iterable<DocumentationNode>) {
+        for (node in nodes) {
+            appendOutlineHeader(location, node, to)
+            if (node.members.any()) {
+                val sortedMembers = node.members.sortedBy { it.name.toLowerCase() }
+                appendOutlineLevel(to) {
+                    appendOutline(location, to, sortedMembers)
+                }
+            }
+        }
+    }
+
+    fun formatOutline(location: Location, nodes: Iterable<DocumentationNode>): String =
+            StringBuilder().apply { appendOutline(location, this, nodes) }.toString()
+}