aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/src/main/kotlin/Formats/JavaLayoutHtml/JavaLayoutHtmlGenerator.kt9
-rw-r--r--core/src/test/kotlin/format/JavaLayoutHtmlFormatTest.kt37
-rw-r--r--core/src/test/kotlin/format/JavaLayoutHtmlFormatTestCase.kt72
-rw-r--r--core/testdata/format/java-layout-html/simple.kt8
-rw-r--r--core/testdata/format/java-layout-html/topLevel.kt15
5 files changed, 137 insertions, 4 deletions
diff --git a/core/src/main/kotlin/Formats/JavaLayoutHtml/JavaLayoutHtmlGenerator.kt b/core/src/main/kotlin/Formats/JavaLayoutHtml/JavaLayoutHtmlGenerator.kt
index 63668e786..6f09a7b89 100644
--- a/core/src/main/kotlin/Formats/JavaLayoutHtml/JavaLayoutHtmlGenerator.kt
+++ b/core/src/main/kotlin/Formats/JavaLayoutHtml/JavaLayoutHtmlGenerator.kt
@@ -13,10 +13,9 @@ import java.net.URI
class JavaLayoutHtmlFormatGenerator @Inject constructor(
@Named("outputDir") val root: File,
- val languageService: LanguageService,
- val templateService: JavaLayoutHtmlTemplateService,
val packageListService: PackageListService,
val outputBuilderFactoryService: JavaLayoutHtmlFormatOutputBuilderFactory,
+ private val options: DocumentationOptions,
val logger: DokkaLogger
) : Generator, JavaLayoutHtmlUriProvider {
@@ -107,8 +106,10 @@ class JavaLayoutHtmlFormatGenerator @Inject constructor(
val packages = module.members.filter { it.kind == NodeKind.Package }
packages.forEach { buildPackage(it, moduleRoot) }
- buildClassIndex(module.members.single { it.kind == NodeKind.AllTypes }, moduleRoot)
- buildPackageIndex(packages, moduleRoot)
+ if (options.generateIndexPages) {
+ buildClassIndex(module.members.single { it.kind == NodeKind.AllTypes }, moduleRoot)
+ buildPackageIndex(packages, moduleRoot)
+ }
}
override fun buildOutlines(nodes: Iterable<DocumentationNode>) {
diff --git a/core/src/test/kotlin/format/JavaLayoutHtmlFormatTest.kt b/core/src/test/kotlin/format/JavaLayoutHtmlFormatTest.kt
new file mode 100644
index 000000000..64a11c9f7
--- /dev/null
+++ b/core/src/test/kotlin/format/JavaLayoutHtmlFormatTest.kt
@@ -0,0 +1,37 @@
+package org.jetbrains.dokka.tests
+
+import org.jetbrains.dokka.Formats.JavaLayoutHtmlFormatDescriptor
+import org.junit.Test
+
+class JavaLayoutHtmlFormatTest : JavaLayoutHtmlFormatTestCase() {
+ override val formatDescriptor = JavaLayoutHtmlFormatDescriptor()
+
+ @Test
+ fun simple() {
+ verifyNode("simple.kt")
+ }
+
+ @Test
+ fun topLevel() {
+ verifyPackageNode("topLevel.kt")
+ }
+
+ private fun verifyNode(fileName: String) {
+ verifyOutput("testdata/format/java-layout-html/$fileName", ".html", format = "java-layout-html") { model, output ->
+ buildPagesAndReadInto(
+ model,
+ listOf(model.members.single().members.single()),
+ output
+ )
+ }
+ }
+ private fun verifyPackageNode(fileName: String) {
+ verifyOutput("testdata/format/java-layout-html/$fileName", ".package-summary.html", format = "java-layout-html") { model, output ->
+ buildPagesAndReadInto(
+ model,
+ listOf(model.members.single()),
+ output
+ )
+ }
+ }
+} \ No newline at end of file
diff --git a/core/src/test/kotlin/format/JavaLayoutHtmlFormatTestCase.kt b/core/src/test/kotlin/format/JavaLayoutHtmlFormatTestCase.kt
new file mode 100644
index 000000000..928a7d269
--- /dev/null
+++ b/core/src/test/kotlin/format/JavaLayoutHtmlFormatTestCase.kt
@@ -0,0 +1,72 @@
+package org.jetbrains.dokka.tests
+
+import com.google.inject.Guice
+import com.google.inject.Injector
+import com.google.inject.Module
+import com.google.inject.name.Names
+import org.jetbrains.dokka.DocumentationNode
+import org.jetbrains.dokka.DocumentationOptions
+import org.jetbrains.dokka.DokkaLogger
+import org.jetbrains.dokka.Formats.JavaLayoutHtmlFormatDescriptorBase
+import org.jetbrains.dokka.Formats.JavaLayoutHtmlFormatGenerator
+import org.jetbrains.dokka.Generator
+import org.jetbrains.dokka.Utilities.bind
+import org.junit.Rule
+import org.junit.rules.TemporaryFolder
+import java.io.File
+import java.net.URI
+
+abstract class JavaLayoutHtmlFormatTestCase {
+
+ abstract val formatDescriptor: JavaLayoutHtmlFormatDescriptorBase
+
+ @get:Rule
+ var folder = TemporaryFolder()
+
+ var options =
+ DocumentationOptions(
+ "",
+ "java-layout-html",
+ apiVersion = null,
+ languageVersion = null,
+ generateIndexPages = false,
+ noStdlibLink = false
+ )
+
+ val injector: Injector by lazy {
+ Guice.createInjector(Module { binder ->
+ binder.bind<File>().annotatedWith(Names.named("outputDir")).toInstance(folder.apply { create() }.root)
+
+ binder.bind<DocumentationOptions>().toProvider { options }
+ binder.bind<DokkaLogger>().toInstance(object : DokkaLogger {
+ override fun info(message: String) {
+ println(message)
+ }
+
+ override fun warn(message: String) {
+ println("WARN: $message")
+ }
+
+ override fun error(message: String) {
+ println("ERROR: $message")
+ }
+
+ })
+
+ formatDescriptor.configureOutput(binder)
+ })
+ }
+
+
+ fun buildPagesAndReadInto(model: DocumentationNode, nodes: List<DocumentationNode>, sb: StringBuilder) =
+ with(injector.getInstance(Generator::class.java)) {
+ this as JavaLayoutHtmlFormatGenerator
+ buildPages(listOf(model))
+ val byLocations = nodes.groupBy { mainUri(it) }
+ byLocations.forEach { (loc, _) ->
+ sb.appendln("<!-- File: $loc -->")
+ sb.append(folder.root.toURI().resolve(URI("/").relativize(loc)).toURL().readText())
+ }
+ }
+
+} \ No newline at end of file
diff --git a/core/testdata/format/java-layout-html/simple.kt b/core/testdata/format/java-layout-html/simple.kt
new file mode 100644
index 000000000..89789c452
--- /dev/null
+++ b/core/testdata/format/java-layout-html/simple.kt
@@ -0,0 +1,8 @@
+package p
+
+
+class Foo {
+ fun s(): Unit {}
+
+ val g = ""
+} \ No newline at end of file
diff --git a/core/testdata/format/java-layout-html/topLevel.kt b/core/testdata/format/java-layout-html/topLevel.kt
new file mode 100644
index 000000000..85b1a4372
--- /dev/null
+++ b/core/testdata/format/java-layout-html/topLevel.kt
@@ -0,0 +1,15 @@
+package p
+
+class Some
+
+fun topLevelFun() {}
+
+val topLevelVal = ""
+
+const val topLevelConst = ""
+
+val topLevelGetVal get() = ""
+
+val Some.topLevelExtVal get() = ""
+
+fun Some.topLevelExtFun() {} \ No newline at end of file