From fec5256e2f3b68596508d5f5769761d84231003b Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Tue, 24 Oct 2017 17:49:04 +0300 Subject: Fix building of maven plugin --- gradle.properties | 4 ++-- runners/maven-plugin/build.gradle | 45 ++++++++++++++++++++++++++++----------- 2 files changed, 34 insertions(+), 15 deletions(-) diff --git a/gradle.properties b/gradle.properties index 44e510d6..4d4e40ad 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,11 +8,11 @@ kotlin_for_gradle_version=1.0.7 ant_version=1.9.6 #Maven plugin dependencies -maven_version=3.0.5 +maven_version=3.5.0 maven_archiver_version=2.5 plexus_utils_version=3.0.22 plexus_archiver_version=3.4 -maven_plugin_tools_version=3.4 +maven_plugin_tools_version=3.5 #For CI mvn=mvn \ No newline at end of file diff --git a/runners/maven-plugin/build.gradle b/runners/maven-plugin/build.gradle index bac05b2b..37a79a69 100644 --- a/runners/maven-plugin/build.gradle +++ b/runners/maven-plugin/build.gradle @@ -1,14 +1,18 @@ -import groovy.xml.QName +import groovy.io.FileType import org.jetbrains.CrossPlatformExec +import shadow.org.apache.commons.io.FileUtils + +import java.nio.file.FileVisitResult +import java.nio.file.Files +import java.nio.file.Paths +import java.nio.file.StandardCopyOption +import java.nio.file.attribute.BasicFileAttributes + apply plugin: 'kotlin' apply plugin: 'com.github.johnrengelman.shadow' -tasks.withType(AbstractCompile) { - classpath += configurations.shadow -} - dependencies { shadow project(":runners:fatjar") shadow "org.apache.maven:maven-core:$maven_version" @@ -28,14 +32,33 @@ task ("generatePom") doLast { .replace("maven-plugin-plugin", "$maven_plugin_tools_version") } +task mergeClassOutputs doLast { + def sourceDir = new File(buildDir, "classes/kotlin") + def targetDir = new File(buildDir, "classes/java") + + sourceDir.eachFileRecurse FileType.ANY, { + def filePath = it.toPath() + def targetFilePath = targetDir.toPath().resolve(sourceDir.toPath().relativize(filePath)) + if (it.isFile()) { + Files.move(filePath, targetFilePath, StandardCopyOption.REPLACE_EXISTING) + } else if (it.isDirectory()) { + targetFilePath.toFile().mkdirs() + } + } +} + task pluginDescriptor(type: CrossPlatformExec) { workingDir buildDir commandLine mvn, '-e', '-B', 'org.apache.maven.plugins:maven-plugin-plugin:descriptor' + + dependsOn mergeClassOutputs } task helpMojo(type: CrossPlatformExec) { workingDir buildDir commandLine mvn, '-e', '-B', 'org.apache.maven.plugins:maven-plugin-plugin:helpmojo' + + dependsOn mergeClassOutputs } helpMojo.dependsOn generatePom @@ -67,6 +90,8 @@ publishing { classifier "sources" } + project.shadow.component(publication) + pom.withXml { Node root = asNode() @@ -81,7 +106,7 @@ publishing { ''') root.children().find { - return ((QName) it.name()).qualifiedName == "dependencies" + return it.name() == "dependencies" }.append(dependency) def profiles = new XmlParser().parseText(''' @@ -115,14 +140,8 @@ publishing { root.append(profiles) } - project.shadow.component(publication) - } - } -} - -tasks.withType(GenerateMavenPom) { Task generatePom -> - generatePom.doLast { + } } } -- cgit From 3a3baf1014b731957e46ba663ab961fcb5beb4a7 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Tue, 24 Oct 2017 17:49:44 +0300 Subject: Update Gradle to 4.2.1 --- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 9d081673..2acdec8f 100644 --- a/build.gradle +++ b/build.gradle @@ -60,6 +60,6 @@ def bintrayPublication(project, List _publications) { } task wrapper(type: Wrapper) { - gradleVersion = '4.2' + gradleVersion = '4.2.1' distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip" } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 26b61d74..c583957d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.2.1-all.zip -- cgit From d92518ab71a2b10cb50758cc6f6a20c55253ffea Mon Sep 17 00:00:00 2001 From: Eric Wendelin Date: Wed, 1 Nov 2017 16:43:57 -0700 Subject: Ensure build directory exists before generating POM into it (#236) This declares the inputs and outputs for the maven-plugin generatePom task, which improves incremental build support and as of Gradle 4.3 (updated) automatically creates directory paths for declared outputs. Issue: #235 --- gradle/wrapper/gradle-wrapper.properties | 2 +- runners/maven-plugin/build.gradle | 18 +++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index c583957d..590f0e81 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.2.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.3-all.zip diff --git a/runners/maven-plugin/build.gradle b/runners/maven-plugin/build.gradle index 37a79a69..a9a77a8b 100644 --- a/runners/maven-plugin/build.gradle +++ b/runners/maven-plugin/build.gradle @@ -24,12 +24,16 @@ dependencies { shadow "org.apache.maven.plugin-tools:maven-plugin-annotations:$maven_plugin_tools_version" } -task ("generatePom") doLast { - final pomTemplate = new File(projectDir, "pom.tpl.xml") - final pom = new File(buildDir, "pom.xml") - pom.text = pomTemplate.text.replace("dokka_version", "$dokka_version") - .replace("", "$maven_version") - .replace("maven-plugin-plugin", "$maven_plugin_tools_version") +task generatePom() { + inputs.file(new File(projectDir, "pom.tpl.xml")) + outputs.file(new File(buildDir, "pom.xml")) + doLast { + final pomTemplate = new File(projectDir, "pom.tpl.xml") + final pom = new File(buildDir, "pom.xml") + pom.text = pomTemplate.text.replace("dokka_version", "$dokka_version") + .replace("", "$maven_version") + .replace("maven-plugin-plugin", "$maven_plugin_tools_version") + } } task mergeClassOutputs doLast { @@ -145,4 +149,4 @@ publishing { } } -bintrayPublication(project, ['dokkaMavenPlugin']) \ No newline at end of file +bintrayPublication(project, ['dokkaMavenPlugin']) -- cgit From d6d320eb13a24fb8e70df0ba11effabe429f0fd4 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Fri, 27 Oct 2017 03:18:28 +0300 Subject: Correctly handle redirects in ExternalDocumentationLinkResolver --- .../Kotlin/ExternalDocumentationLinkResolver.kt | 41 +++++++++++++++++++--- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/core/src/main/kotlin/Kotlin/ExternalDocumentationLinkResolver.kt b/core/src/main/kotlin/Kotlin/ExternalDocumentationLinkResolver.kt index 84d83c73..f28fcc16 100644 --- a/core/src/main/kotlin/Kotlin/ExternalDocumentationLinkResolver.kt +++ b/core/src/main/kotlin/Kotlin/ExternalDocumentationLinkResolver.kt @@ -15,7 +15,9 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe import org.jetbrains.kotlin.resolve.descriptorUtil.parents import java.io.ByteArrayOutputStream import java.io.PrintWriter +import java.net.HttpURLConnection import java.net.URL +import java.net.URLConnection import java.nio.file.Path import java.security.MessageDigest @@ -30,12 +32,43 @@ class ExternalDocumentationLinkResolver @Inject constructor( val packageFqNameToLocation = mutableMapOf() val formats = mutableMapOf() - class ExternalDocumentationRoot(val rootUrl: URL, val resolver: InboundExternalLinkResolutionService, val locations: Map) + class ExternalDocumentationRoot(val rootUrl: URL, val resolver: InboundExternalLinkResolutionService, val locations: Map) { + override fun toString(): String = rootUrl.toString() + } val cacheDir: Path? = options.cacheRoot?.resolve("packageListCache")?.apply { createDirectories() } val cachedProtocols = setOf("http", "https", "ftp") + fun URL.doOpenConnectionToReadContent(timeout: Int = 10000, redirectsAllowed: Int = 16): URLConnection { + val connection = this.openConnection() + connection.connectTimeout = timeout + + when (connection) { + is HttpURLConnection -> { + return when (connection.responseCode) { + in 200..299 -> { + connection + } + HttpURLConnection.HTTP_MOVED_PERM, + HttpURLConnection.HTTP_MOVED_TEMP, + HttpURLConnection.HTTP_SEE_OTHER -> { + if (redirectsAllowed > 0) { + val newUrl = connection.getHeaderField("Location") + URL(newUrl).doOpenConnectionToReadContent(timeout, redirectsAllowed - 1) + } else { + throw RuntimeException("Too many redirects") + } + } + else -> { + throw RuntimeException("Unhandled http code: ${connection.responseCode}") + } + } + } + else -> return connection + } + } + fun loadPackageList(link: DokkaConfiguration.ExternalDocumentationLink) { val packageListUrl = link.packageListUrl @@ -50,7 +83,7 @@ class ExternalDocumentationLinkResolver @Inject constructor( if (cacheEntry.exists()) { try { - val connection = packageListUrl.openConnection() + val connection = packageListUrl.doOpenConnectionToReadContent() val originModifiedDate = connection.date val cacheDate = cacheEntry.lastModified().toMillis() if (originModifiedDate > cacheDate || originModifiedDate == 0L) { @@ -60,7 +93,7 @@ class ExternalDocumentationLinkResolver @Inject constructor( logger.info("Renewing package-list from $packageListUrl") connection.getInputStream().copyTo(cacheEntry.outputStream()) } - } catch(e: Exception) { + } catch (e: Exception) { logger.error("Failed to update package-list cache for $link") val baos = ByteArrayOutputStream() PrintWriter(baos).use { @@ -75,7 +108,7 @@ class ExternalDocumentationLinkResolver @Inject constructor( } cacheEntry.inputStream() } else { - packageListUrl.openStream() + packageListUrl.doOpenConnectionToReadContent().getInputStream() } val (params, packages) = -- cgit From e9ab5d88150323067672661d37f8d7f8b146311d Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Fri, 27 Oct 2017 03:46:49 +0300 Subject: #228: Correctly render multiline indented code blocks Fix #228 --- core/src/main/kotlin/Kotlin/ContentBuilder.kt | 9 ++++++--- core/src/test/kotlin/format/HtmlFormatTest.kt | 4 ++++ core/src/test/kotlin/format/MarkdownFormatTest.kt | 4 ++++ core/testdata/format/indentedCodeBlock.html | 17 +++++++++++++++++ core/testdata/format/indentedCodeBlock.kt | 10 ++++++++++ core/testdata/format/indentedCodeBlock.md | 14 ++++++++++++++ 6 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 core/testdata/format/indentedCodeBlock.html create mode 100644 core/testdata/format/indentedCodeBlock.kt create mode 100644 core/testdata/format/indentedCodeBlock.md diff --git a/core/src/main/kotlin/Kotlin/ContentBuilder.kt b/core/src/main/kotlin/Kotlin/ContentBuilder.kt index 771bc44b..c60625a4 100644 --- a/core/src/main/kotlin/Kotlin/ContentBuilder.kt +++ b/core/src/main/kotlin/Kotlin/ContentBuilder.kt @@ -110,9 +110,12 @@ fun buildContentTo(tree: MarkdownNode, target: ContentBlock, linkResolver: LinkR } MarkdownTokenTypes.CODE_LINE -> { - val block = ContentBlockCode() - block.append(ContentText(node.text)) - parent.append(block) + val content = ContentText(node.text) + if (parent is ContentBlockCode) { + parent.append(content) + } else { + parent.append(ContentBlockCode().apply { append(content) }) + } } MarkdownTokenTypes.TEXT -> { diff --git a/core/src/test/kotlin/format/HtmlFormatTest.kt b/core/src/test/kotlin/format/HtmlFormatTest.kt index 4fe4f6ab..01e4559e 100644 --- a/core/src/test/kotlin/format/HtmlFormatTest.kt +++ b/core/src/test/kotlin/format/HtmlFormatTest.kt @@ -146,6 +146,10 @@ class HtmlFormatTest { verifyHtmlNode("blankLineInsideCodeBlock") } + @Test fun indentedCodeBlock() { + verifyHtmlNode("indentedCodeBlock") + } + private fun verifyHtmlNode(fileName: String, withKotlinRuntime: Boolean = false) { verifyHtmlNodes(fileName, withKotlinRuntime) { model -> model.members.single().members } } diff --git a/core/src/test/kotlin/format/MarkdownFormatTest.kt b/core/src/test/kotlin/format/MarkdownFormatTest.kt index 48b06d6e..fbebfbfd 100644 --- a/core/src/test/kotlin/format/MarkdownFormatTest.kt +++ b/core/src/test/kotlin/format/MarkdownFormatTest.kt @@ -376,6 +376,10 @@ class MarkdownFormatTest { verifyMarkdownPackage("newlineInTableCell") } + @Test fun indentedCodeBlock() { + verifyMarkdownNode("indentedCodeBlock") + } + private fun buildMultiplePlatforms(path: String): DocumentationModule { val module = DocumentationModule("test") val options = DocumentationOptions("", "html", generateIndexPages = false, noStdlibLink = true) diff --git a/core/testdata/format/indentedCodeBlock.html b/core/testdata/format/indentedCodeBlock.html new file mode 100644 index 00000000..1ccf800a --- /dev/null +++ b/core/testdata/format/indentedCodeBlock.html @@ -0,0 +1,17 @@ + + + +foo - test + + +test / foo
+
+

foo

+ +fun foo(): Unit +

Create a new Foo value as follows:

+
    val foo = Foo.create {
+        type { "ABC" }
+    }
+ + diff --git a/core/testdata/format/indentedCodeBlock.kt b/core/testdata/format/indentedCodeBlock.kt new file mode 100644 index 00000000..19c5365b --- /dev/null +++ b/core/testdata/format/indentedCodeBlock.kt @@ -0,0 +1,10 @@ +/** + * Create a new Foo value as follows: + * + * val foo = Foo.create { + * type { "ABC" } + * } + */ +fun foo() { + +} \ No newline at end of file diff --git a/core/testdata/format/indentedCodeBlock.md b/core/testdata/format/indentedCodeBlock.md new file mode 100644 index 00000000..515bfee3 --- /dev/null +++ b/core/testdata/format/indentedCodeBlock.md @@ -0,0 +1,14 @@ +[test](test/index) / [foo](test/foo) + +# foo + +`fun foo(): Unit` + +Create a new Foo value as follows: + +``` + val foo = Foo.create { + type { "ABC" } + } +``` + -- cgit From 05d613daf13d7a0866b65ed555544b62e8197547 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Tue, 31 Oct 2017 18:51:45 +0300 Subject: Fix android-sdk license accepting on TeamCity --- .../android-licenses/android-sdk-license | 2 + .../android-licenses/android-sdk-preview-license | 2 + runners/gradle-integration-tests/build.gradle | 6 ++- .../dokka/gradle/AbstractDokkaAndroidGradleTest.kt | 43 ++++++++++++++++++++++ .../org/jetbrains/dokka/gradle/AndroidAppTest.kt | 3 +- .../dokka/gradle/AndroidMultiFlavourAppTest.kt | 2 +- 6 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 runners/gradle-integration-tests/android-licenses/android-sdk-license create mode 100644 runners/gradle-integration-tests/android-licenses/android-sdk-preview-license create mode 100644 runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaAndroidGradleTest.kt diff --git a/runners/gradle-integration-tests/android-licenses/android-sdk-license b/runners/gradle-integration-tests/android-licenses/android-sdk-license new file mode 100644 index 00000000..c311cf48 --- /dev/null +++ b/runners/gradle-integration-tests/android-licenses/android-sdk-license @@ -0,0 +1,2 @@ + +d56f5187479451eabf01fb78af6dfcb131a6481e \ No newline at end of file diff --git a/runners/gradle-integration-tests/android-licenses/android-sdk-preview-license b/runners/gradle-integration-tests/android-licenses/android-sdk-preview-license new file mode 100644 index 00000000..da4552d2 --- /dev/null +++ b/runners/gradle-integration-tests/android-licenses/android-sdk-preview-license @@ -0,0 +1,2 @@ + +84831b9409646a918e30573bab4c9c91346d8abd \ No newline at end of file diff --git a/runners/gradle-integration-tests/build.gradle b/runners/gradle-integration-tests/build.gradle index 179b6455..1b4ff5ed 100644 --- a/runners/gradle-integration-tests/build.gradle +++ b/runners/gradle-integration-tests/build.gradle @@ -42,4 +42,8 @@ task createClasspathManifest { createClasspathManifest.mustRunAfter project(":runners:fatjar").shadowJar testClasses.dependsOn project(":runners:fatjar").shadowJar -testClasses.dependsOn createClasspathManifest \ No newline at end of file +testClasses.dependsOn createClasspathManifest + +test { + systemProperty "android.licenses.overwrite", project.findProperty("android.licenses.overwrite") ?: "" +} \ No newline at end of file diff --git a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaAndroidGradleTest.kt b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaAndroidGradleTest.kt new file mode 100644 index 00000000..52aa4f15 --- /dev/null +++ b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaAndroidGradleTest.kt @@ -0,0 +1,43 @@ +package org.jetbrains.dokka.gradle + +import org.junit.BeforeClass +import java.io.File + +abstract class AbstractDokkaAndroidGradleTest : AbstractDokkaGradleTest() { + + companion object { + + @JvmStatic + @BeforeClass + fun acceptAndroidSdkLicenses() { + val sdkDir = androidLocalProperties?.toFile()?.let { + val lines = it.readLines().map { it.trim() } + val sdkDirLine = lines.firstOrNull { "sdk.dir" in it } + sdkDirLine?.substringAfter("=")?.trim() + } ?: System.getenv("ANDROID_HOME") + + if (sdkDir == null || sdkDir.isEmpty()) { + error("Android SDK home not set, " + + "try setting \$ANDROID_HOME " + + "or sdk.dir in runners/gradle-integration-tests/testData/android.local.properties") + } + val sdkDirFile = File(sdkDir) + if (!sdkDirFile.exists()) error("\$ANDROID_HOME and android.local.properties points to non-existing location") + val sdkLicensesDir = sdkDirFile.resolve("licenses") + + val acceptedLicenses = File("android-licenses") + acceptedLicenses.listFiles().forEach { licenseFile -> + val target = sdkLicensesDir.resolve(licenseFile.name) + if(!target.exists() || target.readText() != licenseFile.readText()) { + val overwrite = System.getProperty("android.licenses.overwrite", "false").toBoolean() + if (!target.exists() || overwrite) { + licenseFile.copyTo(target, true) + println("Accepted ${licenseFile.name}, by copying $licenseFile to $target") + } + } + + } + } + + } +} \ No newline at end of file diff --git a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidAppTest.kt b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidAppTest.kt index de22a980..1975d6e2 100644 --- a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidAppTest.kt +++ b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidAppTest.kt @@ -3,10 +3,9 @@ package org.jetbrains.dokka.gradle import org.gradle.testkit.runner.TaskOutcome import org.junit.Test import java.io.File -import java.nio.file.Files import kotlin.test.assertEquals -class AndroidAppTest : AbstractDokkaGradleTest() { +class AndroidAppTest : AbstractDokkaAndroidGradleTest() { override val pluginClasspath: List = androidPluginClasspathData.toFile().readLines().map { File(it) } fun prepareTestData(testDataRootPath: String) { diff --git a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidMultiFlavourAppTest.kt b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidMultiFlavourAppTest.kt index aee0e14c..0a9b2427 100644 --- a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidMultiFlavourAppTest.kt +++ b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidMultiFlavourAppTest.kt @@ -6,7 +6,7 @@ import org.junit.Test import java.io.File import kotlin.test.assertEquals -class AndroidMultiFlavourAppTest : AbstractDokkaGradleTest() { +class AndroidMultiFlavourAppTest : AbstractDokkaAndroidGradleTest() { override val pluginClasspath: List = androidPluginClasspathData.toFile().readLines().map { File(it) } fun prepareTestData(testDataRootPath: String) { -- cgit From a10c1f852813ea1c0e4f15b3c25a7a5388bbc996 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Thu, 2 Nov 2017 03:06:41 +0300 Subject: Make classpath Iterable #218 Fix #218 --- runners/gradle-plugin/src/main/kotlin/main.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runners/gradle-plugin/src/main/kotlin/main.kt b/runners/gradle-plugin/src/main/kotlin/main.kt index 37feccc9..02970ae0 100644 --- a/runners/gradle-plugin/src/main/kotlin/main.kt +++ b/runners/gradle-plugin/src/main/kotlin/main.kt @@ -82,7 +82,7 @@ open class DokkaTask : DefaultTask() { @Deprecated("Going to be removed in 0.9.16, use classpath + sourceDirs instead if kotlinTasks is not suitable for you") @Input var processConfigurations: List = emptyList() - @Input var classpath: List = arrayListOf() + @InputFiles var classpath: Iterable = arrayListOf() @Input var includes: List = arrayListOf() -- cgit From 2290bcbd6efc8ac8d36b88d37b4281c1a90b106c Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Thu, 2 Nov 2017 05:32:50 +0300 Subject: Fix not rebuilding on source change Fixes #227 --- .../dokka/gradle/RebuildAfterSourceChangeTest.kt | 69 ++++++++++++++++++++++ .../kotlin/org/jetbrains/dokka/gradle/Utils.kt | 7 +-- .../testData/sourcesChange/build.gradle | 39 ++++++++++++ .../testData/sourcesChange/fileTree.txt | 10 ++++ .../testData/sourcesChange/fileTree1.txt | 11 ++++ .../testData/sourcesChange/settings.gradle | 1 + .../src/main/kotlin/demo/HelloWorld.kt | 6 ++ .../src1/main/kotlin/demo/HelloWorld.kt | 11 ++++ runners/gradle-plugin/src/main/kotlin/main.kt | 18 ++++-- 9 files changed, 162 insertions(+), 10 deletions(-) create mode 100644 runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/RebuildAfterSourceChangeTest.kt create mode 100644 runners/gradle-integration-tests/testData/sourcesChange/build.gradle create mode 100644 runners/gradle-integration-tests/testData/sourcesChange/fileTree.txt create mode 100644 runners/gradle-integration-tests/testData/sourcesChange/fileTree1.txt create mode 100644 runners/gradle-integration-tests/testData/sourcesChange/settings.gradle create mode 100644 runners/gradle-integration-tests/testData/sourcesChange/src/main/kotlin/demo/HelloWorld.kt create mode 100644 runners/gradle-integration-tests/testData/sourcesChange/src1/main/kotlin/demo/HelloWorld.kt diff --git a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/RebuildAfterSourceChangeTest.kt b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/RebuildAfterSourceChangeTest.kt new file mode 100644 index 00000000..42e79696 --- /dev/null +++ b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/RebuildAfterSourceChangeTest.kt @@ -0,0 +1,69 @@ +package org.jetbrains.dokka.gradle + +import org.gradle.testkit.runner.TaskOutcome +import org.junit.Test +import java.nio.file.Path +import kotlin.test.assertEquals + +class RebuildAfterSourceChangeTest : AbstractDokkaGradleTest() { + + fun prepareTestData(testDataRootPath: String): Pair { + val testDataRoot = testDataFolder.resolve(testDataRootPath) + val tmpRoot = testProjectDir.root.toPath() + + testDataRoot.resolve("src").copy(tmpRoot.resolve("src")) + testDataRoot.resolve("build.gradle").copy(tmpRoot.resolve("build.gradle")) + testDataRoot.resolve("settings.gradle").copy(tmpRoot.resolve("settings.gradle")) + + return testDataRoot to tmpRoot + } + + private fun doTest(gradleVersion: String, kotlinVersion: String) { + + val (testDataRoot, tmpRoot) = prepareTestData("sourcesChange") + val docsOutput = "build/dokka" + + configure(gradleVersion, kotlinVersion, arguments = arrayOf("dokka", "--stacktrace")).build().let { result -> + println(result.output) + + assertEquals(TaskOutcome.SUCCESS, result.task(":dokka")?.outcome) + } + + + configure(gradleVersion, kotlinVersion, arguments = arrayOf("dokka", "--stacktrace")).build().let { result -> + println(result.output) + + assertEquals(TaskOutcome.UP_TO_DATE, result.task(":dokka")?.outcome) + } + + checkOutputStructure("sourcesChange/fileTree.txt", docsOutput) + + testDataRoot.resolve("src1").copy(tmpRoot.resolve("src")) + + configure(gradleVersion, kotlinVersion, arguments = arrayOf("dokka", "--stacktrace")).build().let { result -> + println(result.output) + + assertEquals(TaskOutcome.SUCCESS, result.task(":dokka")?.outcome) + } + + + checkOutputStructure("sourcesChange/fileTree1.txt", docsOutput) + + } + + + @Test + fun `test kotlin 1_1_2 and gradle 3_5`() { + doTest("3.5", "1.1.2") + } + + @Test + fun `test kotlin 1_0_7 and gradle 2_14_1`() { + doTest("2.14.1", "1.0.7") + } + + @Test + fun `test kotlin 1_1_2 and gradle 4_0`() { + doTest("4.0", "1.1.2") + } +} \ No newline at end of file diff --git a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/Utils.kt b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/Utils.kt index d44459b1..6f17af22 100644 --- a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/Utils.kt +++ b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/Utils.kt @@ -3,10 +3,7 @@ package org.jetbrains.dokka.gradle import com.intellij.rt.execution.junit.FileComparisonFailure import java.io.File import java.io.IOException -import java.nio.file.FileVisitResult -import java.nio.file.Files -import java.nio.file.Path -import java.nio.file.SimpleFileVisitor +import java.nio.file.* import java.nio.file.attribute.BasicFileAttributes @@ -48,7 +45,7 @@ class CopyFileVisitor(private var sourcePath: Path?, private val targetPath: Pat @Throws(IOException::class) override fun visitFile(file: Path, attrs: BasicFileAttributes): FileVisitResult { - Files.copy(file, targetPath.resolve(sourcePath?.relativize(file))) + Files.copy(file, targetPath.resolve(sourcePath?.relativize(file)), StandardCopyOption.REPLACE_EXISTING) return FileVisitResult.CONTINUE } } diff --git a/runners/gradle-integration-tests/testData/sourcesChange/build.gradle b/runners/gradle-integration-tests/testData/sourcesChange/build.gradle new file mode 100644 index 00000000..bc20e1cf --- /dev/null +++ b/runners/gradle-integration-tests/testData/sourcesChange/build.gradle @@ -0,0 +1,39 @@ +buildscript { + repositories { + mavenCentral() + jcenter() + maven { url "http://dl.bintray.com/kotlin/kotlin-eap-1.1" } + maven { url "https://dl.bintray.com/kotlin/kotlin-dev" } + } + dependencies { + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$test_kotlin_version" + } +} + +plugins { + id 'org.jetbrains.dokka' +} + +apply plugin: 'kotlin' +apply plugin: 'org.jetbrains.dokka' + +repositories { + mavenCentral() + jcenter() + maven { + url "http://dl.bintray.com/kotlin/kotlin-eap-1.1" + } + maven { + url "https://dl.bintray.com/kotlin/kotlin-dev" + } +} + +dependencies { + compile group: 'org.jetbrains.kotlin', name: 'kotlin-runtime', version: test_kotlin_version + compile group: 'org.jetbrains.kotlin', name: 'kotlin-reflect', version: test_kotlin_version +} + + +dokka { + dokkaFatJar = new File(dokka_fatjar) +} \ No newline at end of file diff --git a/runners/gradle-integration-tests/testData/sourcesChange/fileTree.txt b/runners/gradle-integration-tests/testData/sourcesChange/fileTree.txt new file mode 100644 index 00000000..09f3724b --- /dev/null +++ b/runners/gradle-integration-tests/testData/sourcesChange/fileTree.txt @@ -0,0 +1,10 @@ +/ + sources-change/ + alltypes.html + demo/ + hello.html + index.html + index-outline.html + index.html + package-list + style.css diff --git a/runners/gradle-integration-tests/testData/sourcesChange/fileTree1.txt b/runners/gradle-integration-tests/testData/sourcesChange/fileTree1.txt new file mode 100644 index 00000000..eeb377f7 --- /dev/null +++ b/runners/gradle-integration-tests/testData/sourcesChange/fileTree1.txt @@ -0,0 +1,11 @@ +/ + sources-change/ + alltypes.html + demo/ + hello.html + index.html + world.html + index-outline.html + index.html + package-list + style.css diff --git a/runners/gradle-integration-tests/testData/sourcesChange/settings.gradle b/runners/gradle-integration-tests/testData/sourcesChange/settings.gradle new file mode 100644 index 00000000..3fb032bf --- /dev/null +++ b/runners/gradle-integration-tests/testData/sourcesChange/settings.gradle @@ -0,0 +1 @@ +rootProject.name = "sourcesChange" \ No newline at end of file diff --git a/runners/gradle-integration-tests/testData/sourcesChange/src/main/kotlin/demo/HelloWorld.kt b/runners/gradle-integration-tests/testData/sourcesChange/src/main/kotlin/demo/HelloWorld.kt new file mode 100644 index 00000000..c54dea50 --- /dev/null +++ b/runners/gradle-integration-tests/testData/sourcesChange/src/main/kotlin/demo/HelloWorld.kt @@ -0,0 +1,6 @@ +package demo + +/** + * @return Hello + */ +fun hello(): String = "Hello" \ No newline at end of file diff --git a/runners/gradle-integration-tests/testData/sourcesChange/src1/main/kotlin/demo/HelloWorld.kt b/runners/gradle-integration-tests/testData/sourcesChange/src1/main/kotlin/demo/HelloWorld.kt new file mode 100644 index 00000000..53f22ff5 --- /dev/null +++ b/runners/gradle-integration-tests/testData/sourcesChange/src1/main/kotlin/demo/HelloWorld.kt @@ -0,0 +1,11 @@ +package demo + +/** + * @return Hello + */ +fun hello(): String = "Hello" + +/** + * @return World + */ +fun world(): String = "World" \ No newline at end of file diff --git a/runners/gradle-plugin/src/main/kotlin/main.kt b/runners/gradle-plugin/src/main/kotlin/main.kt index 02970ae0..1fbbb0e0 100644 --- a/runners/gradle-plugin/src/main/kotlin/main.kt +++ b/runners/gradle-plugin/src/main/kotlin/main.kt @@ -95,7 +95,8 @@ open class DokkaTask : DefaultTask() { @Input var sourceDirs: Iterable = emptyList() - @Input var sourceRoots: MutableList = arrayListOf() + @Input + var sourceRoots: MutableList = arrayListOf() @Input var dokkaFatJar: Any = "org.jetbrains.dokka:dokka-fatjar:$version" @@ -331,10 +332,17 @@ open class DokkaTask : DefaultTask() { @InputFiles - fun getInputFiles(): FileCollection = - project.files(collectSourceRoots().map { project.fileTree(File(it.path)) }) + - project.files(includes) + - project.files(samples.map { project.fileTree(it) }) + fun getInputFiles(): FileCollection { + val (tasksClasspath, tasksSourceRoots) = kotlinCompileBasedClasspathAndSourceRoots + + val fullClasspath = collectClasspathFromOldSources() + tasksClasspath + classpath + + return project.files(tasksSourceRoots.map { project.fileTree(it) }) + + project.files(collectSourceRoots().map { project.fileTree(File(it.path)) }) + + project.files(fullClasspath.map { project.fileTree(it) }) + + project.files(includes) + + project.files(samples.map { project.fileTree(it) }) + } @OutputDirectory fun getOutputDirectoryAsFile(): File = project.file(outputDirectory) -- cgit From c14f3b06788df7309ba7034b030598b111540cb2 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Fri, 3 Nov 2017 18:38:35 +0300 Subject: Fix early lazy computation --- runners/gradle-plugin/src/main/kotlin/main.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runners/gradle-plugin/src/main/kotlin/main.kt b/runners/gradle-plugin/src/main/kotlin/main.kt index 1fbbb0e0..fc5eb77c 100644 --- a/runners/gradle-plugin/src/main/kotlin/main.kt +++ b/runners/gradle-plugin/src/main/kotlin/main.kt @@ -333,7 +333,7 @@ open class DokkaTask : DefaultTask() { @InputFiles fun getInputFiles(): FileCollection { - val (tasksClasspath, tasksSourceRoots) = kotlinCompileBasedClasspathAndSourceRoots + val (tasksClasspath, tasksSourceRoots) = extractClasspathAndSourceRootsFromKotlinTasks() val fullClasspath = collectClasspathFromOldSources() + tasksClasspath + classpath -- cgit From 487dba687ad0891eebe61433c83c9ad5bf529b7b Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Fri, 3 Nov 2017 18:39:42 +0300 Subject: Fix pom generation for dokka-android-plugin Workaround for johnrengelman/shadow#334 --- .../org/jetbrains/CorrectShadowPublishing.groovy | 39 ++++++++++++++++++++++ runners/android-gradle-plugin/build.gradle | 7 ++-- 2 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 buildSrc/src/main/groovy/org/jetbrains/CorrectShadowPublishing.groovy diff --git a/buildSrc/src/main/groovy/org/jetbrains/CorrectShadowPublishing.groovy b/buildSrc/src/main/groovy/org/jetbrains/CorrectShadowPublishing.groovy new file mode 100644 index 00000000..3e1d2106 --- /dev/null +++ b/buildSrc/src/main/groovy/org/jetbrains/CorrectShadowPublishing.groovy @@ -0,0 +1,39 @@ +package org.jetbrains + +import org.gradle.api.Project +import org.gradle.api.artifacts.ModuleVersionIdentifier +import org.gradle.api.artifacts.ProjectDependency +import org.gradle.api.artifacts.SelfResolvingDependency +import org.gradle.api.publish.internal.ProjectDependencyPublicationResolver +import org.gradle.api.publish.maven.MavenPom +import org.gradle.api.publish.maven.MavenPublication + +static void configure(MavenPublication publication, Project project) { + publication.artifact(project.tasks.shadowJar) + + publication.pom { MavenPom pom -> + pom.withXml { xml -> + def dependenciesNode = xml.asNode().appendNode('dependencies') + + project.configurations.shadow.allDependencies.each { + //if (! (it instanceof SelfResolvingDependency)) { + if (it instanceof ProjectDependency) { + def projectDependencyResolver = project.gradle.services.get(ProjectDependencyPublicationResolver) + ModuleVersionIdentifier identifier = projectDependencyResolver.resolve(it) + addDependency(dependenciesNode, identifier) + } else if (!(it instanceof SelfResolvingDependency)) { + addDependency(dependenciesNode, it) + } + + } + } + } +} + +private static void addDependency(Node dependenciesNode, dep) { + def dependencyNode = dependenciesNode.appendNode('dependency') + dependencyNode.appendNode('groupId', dep.group) + dependencyNode.appendNode('artifactId', dep.name) + dependencyNode.appendNode('version', dep.version) + dependencyNode.appendNode('scope', 'runtime') +} \ No newline at end of file diff --git a/runners/android-gradle-plugin/build.gradle b/runners/android-gradle-plugin/build.gradle index 8e97d9d9..193b8eee 100644 --- a/runners/android-gradle-plugin/build.gradle +++ b/runners/android-gradle-plugin/build.gradle @@ -1,3 +1,5 @@ +import org.jetbrains.CorrectShadowPublishing + apply plugin: 'java' apply plugin: 'kotlin' @@ -47,13 +49,14 @@ apply plugin: 'maven-publish' publishing { publications { - dokkaAndroidGradlePlugin(MavenPublication) { publication -> + dokkaAndroidGradlePlugin(MavenPublication) { MavenPublication publication -> artifactId = 'dokka-android-gradle-plugin' artifact sourceJar { classifier "sources" } - project.shadow.component(publication) + + CorrectShadowPublishing.configure(publication, project) } } } -- cgit From ce7ebd213a56abd2be6beacbef26b339935baeb6 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Fri, 3 Nov 2017 21:30:01 +0300 Subject: Fix not suppressing Android generated files in javadoc format fixes #224, fixes #197 --- .../kotlin/Java/JavaPsiDocumentationBuilder.kt | 9 +++- .../dokka/gradle/AbstractAndroidAppTest.kt | 51 ++++++++++++++++++ .../dokka/gradle/AbstractDokkaAndroidGradleTest.kt | 2 + .../org/jetbrains/dokka/gradle/AndroidAppTest.kt | 59 +++------------------ .../dokka/gradle/AndroidMultiFlavourAppTest.kt | 4 +- .../dokka/gradle/JavadocRSuppressionTest.kt | 20 +++++++ .../testData/androidAppJavadoc/app/build.gradle | 50 +++++++++++++++++ .../app/src/main/AndroidManifest.xml | 26 +++++++++ .../org/example/kotlin/mixed/JavaActivity.java | 34 ++++++++++++ .../org/example/kotlin/mixed/KotlinActivity.kt | 28 ++++++++++ .../app/src/main/res/drawable-hdpi/ic_launcher.png | Bin 0 -> 9397 bytes .../app/src/main/res/drawable-mdpi/ic_launcher.png | Bin 0 -> 5237 bytes .../src/main/res/drawable-xhdpi/ic_launcher.png | Bin 0 -> 14383 bytes .../app/src/main/res/layout/activity_main.xml | 24 +++++++++ .../app/src/main/res/layout/activity_main2.xml | 24 +++++++++ .../app/src/main/res/menu/main.xml | 6 +++ .../app/src/main/res/menu/main_activity2.xml | 6 +++ .../app/src/main/res/values/dimens.xml | 5 ++ .../app/src/main/res/values/strings.xml | 10 ++++ .../app/src/main/res/values/styles.xml | 20 +++++++ .../testData/androidAppJavadoc/build.gradle | 21 ++++++++ .../testData/androidAppJavadoc/fileTree.txt | 21 ++++++++ .../testData/androidAppJavadoc/settings.gradle | 3 ++ 23 files changed, 367 insertions(+), 56 deletions(-) create mode 100644 runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AbstractAndroidAppTest.kt create mode 100644 runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/JavadocRSuppressionTest.kt create mode 100644 runners/gradle-integration-tests/testData/androidAppJavadoc/app/build.gradle create mode 100644 runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/AndroidManifest.xml create mode 100644 runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/java/org/example/kotlin/mixed/JavaActivity.java create mode 100644 runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/kotlin/org/example/kotlin/mixed/KotlinActivity.kt create mode 100644 runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/drawable-hdpi/ic_launcher.png create mode 100644 runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/drawable-mdpi/ic_launcher.png create mode 100644 runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/drawable-xhdpi/ic_launcher.png create mode 100644 runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/layout/activity_main.xml create mode 100644 runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/layout/activity_main2.xml create mode 100644 runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/menu/main.xml create mode 100644 runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/menu/main_activity2.xml create mode 100644 runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/values/dimens.xml create mode 100644 runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/values/strings.xml create mode 100644 runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/values/styles.xml create mode 100644 runners/gradle-integration-tests/testData/androidAppJavadoc/build.gradle create mode 100644 runners/gradle-integration-tests/testData/androidAppJavadoc/fileTree.txt create mode 100644 runners/gradle-integration-tests/testData/androidAppJavadoc/settings.gradle diff --git a/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt b/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt index a950e432..6b1f8cb4 100644 --- a/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt +++ b/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt @@ -11,6 +11,7 @@ import org.jetbrains.kotlin.kdoc.psi.impl.KDocTag import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.KtDeclaration import org.jetbrains.kotlin.psi.KtModifierListOwner +import java.io.File fun getSignature(element: PsiElement?) = when(element) { is PsiClass -> element.qualifiedName @@ -131,7 +132,10 @@ class JavaPsiDocumentationBuilder : JavaDocumentationBuilder { } } - private fun skipElement(element: Any) = skipElementByVisibility(element) || hasSuppressDocTag(element) + private fun skipElement(element: Any) = + skipElementByVisibility(element) || + hasSuppressDocTag(element) || + skipElementBySuppressedFiles(element) private fun skipElementByVisibility(element: Any): Boolean = element is PsiModifierListOwner && !(options.effectivePackageOptions((element.containingFile as? PsiJavaFile)?.packageName ?: "").includeNonPublic) && @@ -139,6 +143,9 @@ class JavaPsiDocumentationBuilder : JavaDocumentationBuilder { element.hasModifierProperty(PsiModifier.PACKAGE_LOCAL) || element.isInternal()) + private fun skipElementBySuppressedFiles(element: Any): Boolean = + element is PsiElement && File(element.containingFile.virtualFile.path).absoluteFile in options.suppressedFiles + private fun PsiElement.isInternal(): Boolean { val ktElement = (this as? KtLightElement<*, *>)?.kotlinOrigin ?: return false return (ktElement as? KtModifierListOwner)?.hasModifier(KtTokens.INTERNAL_KEYWORD) ?: false diff --git a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AbstractAndroidAppTest.kt b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AbstractAndroidAppTest.kt new file mode 100644 index 00000000..c3fe2ea9 --- /dev/null +++ b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AbstractAndroidAppTest.kt @@ -0,0 +1,51 @@ +package org.jetbrains.dokka.gradle + +import org.gradle.testkit.runner.TaskOutcome +import kotlin.test.assertEquals + +abstract class AbstractAndroidAppTest(val testDataRootPath: String) : AbstractDokkaAndroidGradleTest() { + + fun prepareTestData() { + val testDataRoot = testDataFolder.resolve(testDataRootPath) + val tmpRoot = testProjectDir.root.toPath() + + testDataRoot.resolve("app").copy(tmpRoot.resolve("app")) + testDataRoot.resolve("build.gradle").copy(tmpRoot.resolve("build.gradle")) + testDataRoot.resolve("settings.gradle").copy(tmpRoot.resolve("settings.gradle")) + + androidLocalProperties?.copy(tmpRoot.resolve("local.properties")) + } + + + data class AndroidPluginParams(val pluginVersion: String, val buildToolsVersion: String, val compileSdk: Int) { + fun asArguments(): List = listOf( + "-Pabt_plugin_version=$pluginVersion", + "-Pabt_version=$buildToolsVersion", + "-Psdk_version=$compileSdk" + ) + } + + + protected fun doTest(gradleVersion: String, kotlinVersion: String, androidPluginParams: AndroidPluginParams) { + prepareTestData() + + val result = configure(gradleVersion, kotlinVersion, + arguments = arrayOf("dokka", "--stacktrace") + androidPluginParams.asArguments()) + .build() + + println(result.output) + + assertEquals(TaskOutcome.SUCCESS, result.task(":app:dokka")?.outcome) + + val docsOutput = "app/build/dokka" + + checkOutputStructure("$testDataRootPath/fileTree.txt", docsOutput) + + checkNoErrorClasses(docsOutput) + checkNoUnresolvedLinks(docsOutput) + + checkExternalLink(docsOutput, "Activity", + """Activity""") + } + +} \ No newline at end of file diff --git a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaAndroidGradleTest.kt b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaAndroidGradleTest.kt index 52aa4f15..06753342 100644 --- a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaAndroidGradleTest.kt +++ b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaAndroidGradleTest.kt @@ -5,6 +5,8 @@ import java.io.File abstract class AbstractDokkaAndroidGradleTest : AbstractDokkaGradleTest() { + override val pluginClasspath: List = androidPluginClasspathData.toFile().readLines().map { File(it) } + companion object { @JvmStatic diff --git a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidAppTest.kt b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidAppTest.kt index 1975d6e2..ba70479f 100644 --- a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidAppTest.kt +++ b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidAppTest.kt @@ -1,65 +1,20 @@ package org.jetbrains.dokka.gradle -import org.gradle.testkit.runner.TaskOutcome import org.junit.Test -import java.io.File -import kotlin.test.assertEquals -class AndroidAppTest : AbstractDokkaAndroidGradleTest() { - override val pluginClasspath: List = androidPluginClasspathData.toFile().readLines().map { File(it) } - - fun prepareTestData(testDataRootPath: String) { - val testDataRoot = testDataFolder.resolve(testDataRootPath) - val tmpRoot = testProjectDir.root.toPath() - - testDataRoot.resolve("app").copy(tmpRoot.resolve("app")) - testDataRoot.resolve("build.gradle").copy(tmpRoot.resolve("build.gradle")) - testDataRoot.resolve("settings.gradle").copy(tmpRoot.resolve("settings.gradle")) - - androidLocalProperties?.copy(tmpRoot.resolve("local.properties")) - } - - - data class AndroidPluginParams(val pluginVersion: String, val buildToolsVersion: String, val compileSdk: Int) { - fun asArguments(): List = listOf( - "-Pabt_plugin_version=$pluginVersion", - "-Pabt_version=$buildToolsVersion", - "-Psdk_version=$compileSdk" - ) - } - - - private fun doTest(gradleVersion: String, kotlinVersion: String, androidPluginParams: AndroidPluginParams) { - prepareTestData("androidApp") - - val result = configure(gradleVersion, kotlinVersion, - arguments = arrayOf("dokka", "--stacktrace") + androidPluginParams.asArguments()) - .build() - - println(result.output) - - assertEquals(TaskOutcome.SUCCESS, result.task(":app:dokka")?.outcome) - - val docsOutput = "app/build/dokka" - - checkOutputStructure("androidApp/fileTree.txt", docsOutput) - - checkNoErrorClasses(docsOutput) - checkNoUnresolvedLinks(docsOutput) - - checkExternalLink(docsOutput, "Activity", - """Activity""") - } - - @Test fun `test kotlin 1_1_2-5 and gradle 4_0 and abt 3_0_0-alpha3`() { +class AndroidAppTest : AbstractAndroidAppTest("androidApp") { + @Test + fun `test kotlin 1_1_2-5 and gradle 4_0 and abt 3_0_0-alpha3`() { doTest("4.0", "1.1.2-5", AndroidPluginParams("3.0.0-alpha3", "25.0.2", 25)) } - @Test fun `test kotlin 1_1_2 and gradle 3_5 and abt 2_3_0`() { + @Test + fun `test kotlin 1_1_2 and gradle 3_5 and abt 2_3_0`() { doTest("3.5", "1.1.2", AndroidPluginParams("2.3.0", "25.0.0", 24)) } - @Test fun `test kotlin 1_0_7 and gradle 2_14_1 and abt 2_2_3`() { + @Test + fun `test kotlin 1_0_7 and gradle 2_14_1 and abt 2_2_3`() { doTest("2.14.1", "1.0.7", AndroidPluginParams("2.2.3", "25.0.0", 24)) } } \ No newline at end of file diff --git a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidMultiFlavourAppTest.kt b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidMultiFlavourAppTest.kt index 0a9b2427..28328af8 100644 --- a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidMultiFlavourAppTest.kt +++ b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidMultiFlavourAppTest.kt @@ -1,13 +1,11 @@ package org.jetbrains.dokka.gradle import org.gradle.testkit.runner.TaskOutcome -import org.jetbrains.dokka.gradle.AndroidAppTest.AndroidPluginParams +import org.jetbrains.dokka.gradle.AbstractAndroidAppTest.AndroidPluginParams import org.junit.Test -import java.io.File import kotlin.test.assertEquals class AndroidMultiFlavourAppTest : AbstractDokkaAndroidGradleTest() { - override val pluginClasspath: List = androidPluginClasspathData.toFile().readLines().map { File(it) } fun prepareTestData(testDataRootPath: String) { val testDataRoot = testDataFolder.resolve(testDataRootPath) diff --git a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/JavadocRSuppressionTest.kt b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/JavadocRSuppressionTest.kt new file mode 100644 index 00000000..511a033c --- /dev/null +++ b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/JavadocRSuppressionTest.kt @@ -0,0 +1,20 @@ +package org.jetbrains.dokka.gradle + +import org.junit.Test + +class JavadocRSuppressionTest : AbstractAndroidAppTest("androidAppJavadoc") { + @Test + fun `test kotlin 1_1_2-5 and gradle 4_0 and abt 3_0_0-alpha3`() { + doTest("4.0", "1.1.2-5", AndroidPluginParams("3.0.0-alpha3", "25.0.2", 25)) + } + + @Test + fun `test kotlin 1_1_2 and gradle 3_5 and abt 2_3_0`() { + doTest("3.5", "1.1.2", AndroidPluginParams("2.3.0", "25.0.0", 24)) + } + + @Test + fun `test kotlin 1_0_7 and gradle 2_14_1 and abt 2_2_3`() { + doTest("2.14.1", "1.0.7", AndroidPluginParams("2.2.3", "25.0.0", 24)) + } +} \ No newline at end of file diff --git a/runners/gradle-integration-tests/testData/androidAppJavadoc/app/build.gradle b/runners/gradle-integration-tests/testData/androidAppJavadoc/app/build.gradle new file mode 100644 index 00000000..6a053a5e --- /dev/null +++ b/runners/gradle-integration-tests/testData/androidAppJavadoc/app/build.gradle @@ -0,0 +1,50 @@ +buildscript { + repositories { + jcenter() + mavenLocal() + } + dependencies { + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$test_kotlin_version" + } +} + +plugins { + id 'org.jetbrains.dokka-android' +} + + +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'org.jetbrains.dokka-android' + +android { + compileSdkVersion Integer.parseInt(sdk_version) + buildToolsVersion abt_version + + defaultConfig { + applicationId "org.example.kotlin.mixed" + minSdkVersion 14 + targetSdkVersion Integer.parseInt(sdk_version) + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt') + } + } + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + } +} + +dependencies { + compile "org.jetbrains.kotlin:kotlin-stdlib:$test_kotlin_version" +} + + +dokka { + outputFormat = "javadoc" + dokkaFatJar = new File(dokka_fatjar) +} \ No newline at end of file diff --git a/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/AndroidManifest.xml b/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/AndroidManifest.xml new file mode 100644 index 00000000..b4e1a892 --- /dev/null +++ b/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/AndroidManifest.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + diff --git a/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/java/org/example/kotlin/mixed/JavaActivity.java b/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/java/org/example/kotlin/mixed/JavaActivity.java new file mode 100644 index 00000000..3668c594 --- /dev/null +++ b/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/java/org/example/kotlin/mixed/JavaActivity.java @@ -0,0 +1,34 @@ +package org.example.kotlin.mixed; + +import android.content.Intent; +import android.os.Bundle; +import android.app.Activity; +import android.view.Menu; +import android.view.View; +import android.widget.Button; + +public class JavaActivity extends Activity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + Button next = (Button) findViewById(R.id.Button01); + next.setOnClickListener(new View.OnClickListener() { + public void onClick(View view) { + Intent myIntent = new Intent(view.getContext(), KotlinActivity.class); + startActivityForResult(myIntent, 0); + } + }); + } + + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.main, menu); + return true; + } + +} diff --git a/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/kotlin/org/example/kotlin/mixed/KotlinActivity.kt b/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/kotlin/org/example/kotlin/mixed/KotlinActivity.kt new file mode 100644 index 00000000..ca2f27b0 --- /dev/null +++ b/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/kotlin/org/example/kotlin/mixed/KotlinActivity.kt @@ -0,0 +1,28 @@ +package org.example.kotlin.mixed + +import android.content.Intent +import android.os.Bundle +import android.app.Activity +import android.view.Menu +import android.widget.Button + +class KotlinActivity : Activity() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main2) + + val next = findViewById(R.id.Button02) as Button + next.setOnClickListener { + val intent: Intent = Intent() + setResult(RESULT_OK, intent) + finish() + } + } + + override fun onCreateOptionsMenu(menu: Menu?): Boolean { + // Inflate the menu; this adds items to the action bar if it is present. + menuInflater.inflate(R.menu.main_activity2, menu) + return true + } +} diff --git a/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/drawable-hdpi/ic_launcher.png b/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/drawable-hdpi/ic_launcher.png new file mode 100644 index 00000000..96a442e5 Binary files /dev/null and b/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/drawable-hdpi/ic_launcher.png differ diff --git a/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/drawable-mdpi/ic_launcher.png b/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/drawable-mdpi/ic_launcher.png new file mode 100644 index 00000000..359047df Binary files /dev/null and b/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/drawable-mdpi/ic_launcher.png differ diff --git a/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/drawable-xhdpi/ic_launcher.png b/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/drawable-xhdpi/ic_launcher.png new file mode 100644 index 00000000..71c6d760 Binary files /dev/null and b/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/drawable-xhdpi/ic_launcher.png differ diff --git a/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/layout/activity_main.xml b/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/layout/activity_main.xml new file mode 100644 index 00000000..ede57c39 --- /dev/null +++ b/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,24 @@ + + + + + + + diff --git a/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/layout/activity_main2.xml b/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/layout/activity_main2.xml new file mode 100644 index 00000000..d707536a --- /dev/null +++ b/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/layout/activity_main2.xml @@ -0,0 +1,24 @@ + + + + + + + diff --git a/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/menu/main.xml b/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/menu/main.xml new file mode 100644 index 00000000..f3b10b6c --- /dev/null +++ b/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/menu/main.xml @@ -0,0 +1,6 @@ + + + diff --git a/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/menu/main_activity2.xml b/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/menu/main_activity2.xml new file mode 100644 index 00000000..f3b10b6c --- /dev/null +++ b/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/menu/main_activity2.xml @@ -0,0 +1,6 @@ + + + diff --git a/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/values/dimens.xml b/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/values/dimens.xml new file mode 100644 index 00000000..47c82246 --- /dev/null +++ b/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/values/dimens.xml @@ -0,0 +1,5 @@ + + + 16dp + 16dp + diff --git a/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/values/strings.xml b/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/values/strings.xml new file mode 100644 index 00000000..d8f08bc2 --- /dev/null +++ b/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/values/strings.xml @@ -0,0 +1,10 @@ + + + + AndroidSample + Settings + Hello world! + JavaActivity + KotlinActivity + + diff --git a/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/values/styles.xml b/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/values/styles.xml new file mode 100644 index 00000000..6ce89c7b --- /dev/null +++ b/runners/gradle-integration-tests/testData/androidAppJavadoc/app/src/main/res/values/styles.xml @@ -0,0 +1,20 @@ + + + + + + + + + diff --git a/runners/gradle-integration-tests/testData/androidAppJavadoc/build.gradle b/runners/gradle-integration-tests/testData/androidAppJavadoc/build.gradle new file mode 100644 index 00000000..59477b52 --- /dev/null +++ b/runners/gradle-integration-tests/testData/androidAppJavadoc/build.gradle @@ -0,0 +1,21 @@ +buildscript { + repositories { + mavenCentral() + jcenter() + maven { url 'https://maven.google.com' } + maven { url "http://dl.bintray.com/kotlin/kotlin-eap-1.1" } + maven { url "https://dl.bintray.com/kotlin/kotlin-dev" } + } + dependencies { + classpath "com.android.tools.build:gradle:$abt_plugin_version" + } +} + +allprojects { + repositories { + mavenCentral() + jcenter() + maven { url "http://dl.bintray.com/kotlin/kotlin-eap-1.1" } + maven { url "https://dl.bintray.com/kotlin/kotlin-dev" } + } +} diff --git a/runners/gradle-integration-tests/testData/androidAppJavadoc/fileTree.txt b/runners/gradle-integration-tests/testData/androidAppJavadoc/fileTree.txt new file mode 100644 index 00000000..c5e79eba --- /dev/null +++ b/runners/gradle-integration-tests/testData/androidAppJavadoc/fileTree.txt @@ -0,0 +1,21 @@ +/ + allclasses-frame.html + allclasses-noframe.html + constant-values.html + deprecated-list.html + help-doc.html + index-all.html + index.html + org/ + example/ + kotlin/ + mixed/ + JavaActivity.html + KotlinActivity.html + package-frame.html + package-summary.html + package-tree.html + overview-tree.html + package-list + script.js + stylesheet.css diff --git a/runners/gradle-integration-tests/testData/androidAppJavadoc/settings.gradle b/runners/gradle-integration-tests/testData/androidAppJavadoc/settings.gradle new file mode 100644 index 00000000..a4e67fea --- /dev/null +++ b/runners/gradle-integration-tests/testData/androidAppJavadoc/settings.gradle @@ -0,0 +1,3 @@ +rootProject.name = "androidAppJavadoc" + +include ':app' \ No newline at end of file -- cgit From 694d51d7bb5a5900fb30d201a8d675cec0f5e92b Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Sat, 4 Nov 2017 02:09:16 +0300 Subject: Fix Can't find node by signature in asJava mode fixes #205 --- core/src/main/kotlin/Formats/FormatDescriptor.kt | 2 ++ core/src/main/kotlin/Formats/StandardFormats.kt | 5 +++++ core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt | 7 +++++-- .../Kotlin/KotlinAsJavaDescriptorSignatureProvider.kt | 17 +++++++++++++++++ .../kotlin/Kotlin/KotlinDescriptorSignatureProvider.kt | 9 +++++++++ .../main/kotlin/Model/DescriptorSignatureProvider.kt | 7 +++++++ core/src/main/kotlin/Utilities/DokkaModules.kt | 3 ++- core/src/main/kotlin/javadoc/dokka-adapters.kt | 3 +++ core/src/test/kotlin/javadoc/JavadocTest.kt | 10 ++++++++++ core/testdata/javadoc/companionMethodReference.kt | 13 +++++++++++++ runners/cli/src/main/kotlin/cli/main.kt | 4 +++- 11 files changed, 76 insertions(+), 4 deletions(-) create mode 100644 core/src/main/kotlin/Kotlin/KotlinAsJavaDescriptorSignatureProvider.kt create mode 100644 core/src/main/kotlin/Kotlin/KotlinDescriptorSignatureProvider.kt create mode 100644 core/src/main/kotlin/Model/DescriptorSignatureProvider.kt create mode 100644 core/testdata/javadoc/companionMethodReference.kt diff --git a/core/src/main/kotlin/Formats/FormatDescriptor.kt b/core/src/main/kotlin/Formats/FormatDescriptor.kt index fc925f40..da0156a7 100644 --- a/core/src/main/kotlin/Formats/FormatDescriptor.kt +++ b/core/src/main/kotlin/Formats/FormatDescriptor.kt @@ -1,6 +1,7 @@ package org.jetbrains.dokka.Formats import org.jetbrains.dokka.* +import org.jetbrains.dokka.Model.DescriptorSignatureProvider import org.jetbrains.dokka.Samples.SampleProcessingService import kotlin.reflect.KClass @@ -12,4 +13,5 @@ interface FormatDescriptor { val javaDocumentationBuilderClass: KClass val sampleProcessingService: KClass val packageListServiceClass: KClass? + val descriptorSignatureProvider: KClass } diff --git a/core/src/main/kotlin/Formats/StandardFormats.kt b/core/src/main/kotlin/Formats/StandardFormats.kt index fad65ff1..f3d638c6 100644 --- a/core/src/main/kotlin/Formats/StandardFormats.kt +++ b/core/src/main/kotlin/Formats/StandardFormats.kt @@ -1,6 +1,9 @@ package org.jetbrains.dokka.Formats import org.jetbrains.dokka.* +import org.jetbrains.dokka.Kotlin.KotlinAsJavaDescriptorSignatureProvider +import org.jetbrains.dokka.Kotlin.KotlinDescriptorSignatureProvider +import org.jetbrains.dokka.Model.DescriptorSignatureProvider import org.jetbrains.dokka.Samples.DefaultSampleProcessingService import org.jetbrains.dokka.Samples.KotlinWebsiteSampleProcessingService import org.jetbrains.dokka.Samples.SampleProcessingService @@ -14,6 +17,7 @@ abstract class KotlinFormatDescriptorBase : FormatDescriptor { override val outlineServiceClass: KClass? = null override val sampleProcessingService: KClass = DefaultSampleProcessingService::class override val packageListServiceClass: KClass? = DefaultPackageListService::class + override val descriptorSignatureProvider = KotlinDescriptorSignatureProvider::class } class HtmlFormatDescriptor : KotlinFormatDescriptorBase() { @@ -29,6 +33,7 @@ class HtmlAsJavaFormatDescriptor : FormatDescriptor { override val javaDocumentationBuilderClass = JavaPsiDocumentationBuilder::class override val sampleProcessingService: KClass = DefaultSampleProcessingService::class override val packageListServiceClass: KClass? = DefaultPackageListService::class + override val descriptorSignatureProvider = KotlinAsJavaDescriptorSignatureProvider::class } class KotlinWebsiteFormatDescriptor : KotlinFormatDescriptorBase() { diff --git a/core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt b/core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt index 2b085769..275972fa 100644 --- a/core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt +++ b/core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt @@ -1,6 +1,7 @@ package org.jetbrains.dokka import com.google.inject.Inject +import org.jetbrains.dokka.Model.DescriptorSignatureProvider import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.idea.kdoc.resolveKDocLink @@ -10,7 +11,8 @@ class DeclarationLinkResolver val refGraph: NodeReferenceGraph, val logger: DokkaLogger, val options: DocumentationOptions, - val externalDocumentationLinkResolver: ExternalDocumentationLinkResolver) { + val externalDocumentationLinkResolver: ExternalDocumentationLinkResolver, + val descriptorSignatureProvider: DescriptorSignatureProvider) { fun tryResolveContentLink(fromDescriptor: DeclarationDescriptor, href: String): ContentBlock? { @@ -29,7 +31,8 @@ class DeclarationLinkResolver if (externalHref != null) { return ContentExternalLink(externalHref) } - return ContentNodeLazyLink(href, { -> refGraph.lookupOrWarn(symbol.signature(), logger) }) + val signature = descriptorSignatureProvider.signature(symbol) + return ContentNodeLazyLink(href, { -> refGraph.lookupOrWarn(signature, logger) }) } if ("/" in href) { return ContentExternalLink(href) diff --git a/core/src/main/kotlin/Kotlin/KotlinAsJavaDescriptorSignatureProvider.kt b/core/src/main/kotlin/Kotlin/KotlinAsJavaDescriptorSignatureProvider.kt new file mode 100644 index 00000000..ca15b89f --- /dev/null +++ b/core/src/main/kotlin/Kotlin/KotlinAsJavaDescriptorSignatureProvider.kt @@ -0,0 +1,17 @@ +package org.jetbrains.dokka.Kotlin + +import org.jetbrains.dokka.Model.DescriptorSignatureProvider +import org.jetbrains.dokka.getSignature +import org.jetbrains.dokka.sourcePsi +import org.jetbrains.kotlin.asJava.toLightElements +import org.jetbrains.kotlin.descriptors.DeclarationDescriptor +import org.jetbrains.kotlin.psi.KtElement + +class KotlinAsJavaDescriptorSignatureProvider : DescriptorSignatureProvider { + override fun signature(forDesc: DeclarationDescriptor): String { + + val sourcePsi = forDesc.sourcePsi() as? KtElement + return getSignature(sourcePsi?.toLightElements().orEmpty().firstOrNull()) ?: + throw UnsupportedOperationException("Don't know how to calculate signature for $forDesc") + } +} \ No newline at end of file diff --git a/core/src/main/kotlin/Kotlin/KotlinDescriptorSignatureProvider.kt b/core/src/main/kotlin/Kotlin/KotlinDescriptorSignatureProvider.kt new file mode 100644 index 00000000..7ecd0389 --- /dev/null +++ b/core/src/main/kotlin/Kotlin/KotlinDescriptorSignatureProvider.kt @@ -0,0 +1,9 @@ +package org.jetbrains.dokka.Kotlin + +import org.jetbrains.dokka.Model.DescriptorSignatureProvider +import org.jetbrains.dokka.signature +import org.jetbrains.kotlin.descriptors.DeclarationDescriptor + +class KotlinDescriptorSignatureProvider : DescriptorSignatureProvider { + override fun signature(forDesc: DeclarationDescriptor): String = forDesc.signature() +} \ No newline at end of file diff --git a/core/src/main/kotlin/Model/DescriptorSignatureProvider.kt b/core/src/main/kotlin/Model/DescriptorSignatureProvider.kt new file mode 100644 index 00000000..85584e3c --- /dev/null +++ b/core/src/main/kotlin/Model/DescriptorSignatureProvider.kt @@ -0,0 +1,7 @@ +package org.jetbrains.dokka.Model + +import org.jetbrains.kotlin.descriptors.DeclarationDescriptor + +interface DescriptorSignatureProvider { + fun signature(forDesc: DeclarationDescriptor): String +} \ No newline at end of file diff --git a/core/src/main/kotlin/Utilities/DokkaModules.kt b/core/src/main/kotlin/Utilities/DokkaModules.kt index 28c5dc45..dfb114ec 100644 --- a/core/src/main/kotlin/Utilities/DokkaModules.kt +++ b/core/src/main/kotlin/Utilities/DokkaModules.kt @@ -7,6 +7,7 @@ import com.google.inject.TypeLiteral import com.google.inject.name.Names import org.jetbrains.dokka.* import org.jetbrains.dokka.Formats.FormatDescriptor +import org.jetbrains.dokka.Model.DescriptorSignatureProvider import org.jetbrains.dokka.Samples.SampleProcessingService import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment import java.io.File @@ -22,7 +23,7 @@ class DokkaAnalysisModule(val environment: AnalysisEnvironment, binder.bind().toInstance(logger) val descriptor = ServiceLocator.lookup("format", options.outputFormat) - + binder.bind().to(descriptor.descriptorSignatureProvider.java) binder.registerCategory("language") binder.bind().to(descriptor.packageDocumentationBuilderClass.java) binder.bind().to(descriptor.javaDocumentationBuilderClass.java) diff --git a/core/src/main/kotlin/javadoc/dokka-adapters.kt b/core/src/main/kotlin/javadoc/dokka-adapters.kt index 9555aeb9..c98a3801 100644 --- a/core/src/main/kotlin/javadoc/dokka-adapters.kt +++ b/core/src/main/kotlin/javadoc/dokka-adapters.kt @@ -4,6 +4,8 @@ import com.google.inject.Inject import com.sun.tools.doclets.formats.html.HtmlDoclet import org.jetbrains.dokka.* import org.jetbrains.dokka.Formats.FormatDescriptor +import org.jetbrains.dokka.Kotlin.KotlinAsJavaDescriptorSignatureProvider +import org.jetbrains.dokka.Model.DescriptorSignatureProvider import org.jetbrains.dokka.Samples.DefaultSampleProcessingService import kotlin.reflect.KClass @@ -36,4 +38,5 @@ class JavadocFormatDescriptor : FormatDescriptor { override val javaDocumentationBuilderClass = JavaPsiDocumentationBuilder::class override val sampleProcessingService = DefaultSampleProcessingService::class override val packageListServiceClass: KClass? = null + override val descriptorSignatureProvider = KotlinAsJavaDescriptorSignatureProvider::class } diff --git a/core/src/test/kotlin/javadoc/JavadocTest.kt b/core/src/test/kotlin/javadoc/JavadocTest.kt index 359c5fef..45c45aa4 100644 --- a/core/src/test/kotlin/javadoc/JavadocTest.kt +++ b/core/src/test/kotlin/javadoc/JavadocTest.kt @@ -151,6 +151,16 @@ class JavadocTest { } } + @Test + fun testCompanionMethodReference() { + verifyJavadoc("testdata/javadoc/companionMethodReference.kt") { doc -> + val classDoc = doc.classNamed("foo.TestClass")!! + val tag = classDoc.inlineTags().filterIsInstance().first() + assertEquals("TestClass.Companion", tag.referencedClassName()) + assertEquals("test", tag.referencedMemberName()) + } + } + private fun verifyJavadoc(name: String, withJdk: Boolean = false, withKotlinRuntime: Boolean = false, diff --git a/core/testdata/javadoc/companionMethodReference.kt b/core/testdata/javadoc/companionMethodReference.kt new file mode 100644 index 00000000..499e4492 --- /dev/null +++ b/core/testdata/javadoc/companionMethodReference.kt @@ -0,0 +1,13 @@ +package foo + + +/** + * Linking to [test] + */ +class TestClass { + + companion object { + + @JvmStatic fun test(arg: String) {} + } +} \ No newline at end of file diff --git a/runners/cli/src/main/kotlin/cli/main.kt b/runners/cli/src/main/kotlin/cli/main.kt index c12166c5..77ca57f6 100644 --- a/runners/cli/src/main/kotlin/cli/main.kt +++ b/runners/cli/src/main/kotlin/cli/main.kt @@ -139,8 +139,10 @@ object MainKt { fun createClassLoaderWithTools(): ClassLoader { val toolsJar = findToolsJar().canonicalFile.toURI().toURL() + val originalUrls = (javaClass.classLoader as? URLClassLoader)?.urLs val dokkaJar = javaClass.protectionDomain.codeSource.location - return URLClassLoader(arrayOf(toolsJar, dokkaJar), ClassLoader.getSystemClassLoader().parent) + val urls = if (originalUrls != null) arrayOf(toolsJar, *originalUrls) else arrayOf(toolsJar, dokkaJar) + return URLClassLoader(urls, ClassLoader.getSystemClassLoader().parent) } fun startWithToolsJar(args: Array) { -- cgit From 9c1d23b8bfa74b74a036d9500d8f8d57c978e553 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Tue, 7 Nov 2017 16:10:05 +0300 Subject: Fix problem with Java descriptors --- .../kotlin/Kotlin/KotlinAsJavaDescriptorSignatureProvider.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/src/main/kotlin/Kotlin/KotlinAsJavaDescriptorSignatureProvider.kt b/core/src/main/kotlin/Kotlin/KotlinAsJavaDescriptorSignatureProvider.kt index ca15b89f..266361f2 100644 --- a/core/src/main/kotlin/Kotlin/KotlinAsJavaDescriptorSignatureProvider.kt +++ b/core/src/main/kotlin/Kotlin/KotlinAsJavaDescriptorSignatureProvider.kt @@ -9,9 +9,14 @@ import org.jetbrains.kotlin.psi.KtElement class KotlinAsJavaDescriptorSignatureProvider : DescriptorSignatureProvider { override fun signature(forDesc: DeclarationDescriptor): String { + val sourcePsi = forDesc.sourcePsi() + val javaLikePsi = if (sourcePsi is KtElement) { + sourcePsi.toLightElements().firstOrNull() + } else { + sourcePsi + } - val sourcePsi = forDesc.sourcePsi() as? KtElement - return getSignature(sourcePsi?.toLightElements().orEmpty().firstOrNull()) ?: + return getSignature(javaLikePsi) ?: throw UnsupportedOperationException("Don't know how to calculate signature for $forDesc") } } \ No newline at end of file -- cgit From e1dd83ed777d121fc9627460f76d1b09fa0c9c3b Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Wed, 8 Nov 2017 18:53:50 +0300 Subject: Fix PluginXmlTransformer --- .../org/jetbrains/PluginXmlTransformer.groovy | 25 +++++++++++++--------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/buildSrc/src/main/groovy/org/jetbrains/PluginXmlTransformer.groovy b/buildSrc/src/main/groovy/org/jetbrains/PluginXmlTransformer.groovy index 7482a01a..e711388f 100644 --- a/buildSrc/src/main/groovy/org/jetbrains/PluginXmlTransformer.groovy +++ b/buildSrc/src/main/groovy/org/jetbrains/PluginXmlTransformer.groovy @@ -1,5 +1,6 @@ package org.jetbrains +import com.github.jengelman.gradle.plugins.shadow.relocation.RelocateClassContext import com.github.jengelman.gradle.plugins.shadow.relocation.Relocator import com.github.jengelman.gradle.plugins.shadow.transformers.Transformer import com.github.jengelman.gradle.plugins.shadow.transformers.TransformerContext @@ -22,7 +23,7 @@ public class PluginXmlTransformer implements Transformer { def inputStream = context.is System.out.println(path) Node node = new XmlParser().parse(inputStream) - relocateXml(node, context.relocators) + relocateXml(node, context) transformedPluginXmlFiles.put(path, node) } @@ -39,28 +40,32 @@ public class PluginXmlTransformer implements Transformer { } } - private static void relocateXml(Node node, List relocators) { + private static void relocateXml(Node node, TransformerContext context) { Map attributes = node.attributes() + RelocateClassContext relocateClassContext = new RelocateClassContext() + relocateClassContext.stats = context.stats for (Map.Entry entry : attributes.entrySet()) { - entry.setValue(relocateClassName((String) entry.getValue(), relocators)) + relocateClassContext.setClassName((String) entry.getValue()) + entry.setValue(relocateClassName(relocateClassContext, context)) } List localText = node.localText() if (localText.size() == 1) { - node.setValue(relocateClassName(localText[0], relocators)) + relocateClassContext.setClassName(localText[0]) + node.setValue(relocateClassName(relocateClassContext, context)) } node.children().each { if (it instanceof Node) { - relocateXml((Node) it, relocators) + relocateXml((Node) it, context) } } } - private static String relocateClassName(String className, List relocators) { - for (Relocator relocator : relocators) { - if (relocator.canRelocateClass(className)) { - return relocator.relocateClass(className) + private static String relocateClassName(RelocateClassContext relocateContext, TransformerContext context) { + for (Relocator relocator : context.relocators) { + if (relocator.canRelocateClass(relocateContext)) { + return relocator.relocateClass(relocateContext) } } - return className + return relocateContext.className } } \ No newline at end of file -- cgit From f3c83f4751814984fb9aedeb991725620a287f33 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Wed, 8 Nov 2017 19:51:23 +0300 Subject: Download dependencies from TeamCity --- build.gradle | 22 ++++++++++++---------- core/build.gradle | 15 ++++++++------- gradle.properties | 2 ++ lib/kotlin-ide-common.jar | Bin 469425 -> 0 bytes lib/markdown.jar | Bin 393003 -> 0 bytes runners/fatjar/build.gradle | 2 ++ 6 files changed, 24 insertions(+), 17 deletions(-) delete mode 100644 lib/kotlin-ide-common.jar delete mode 100644 lib/markdown.jar diff --git a/build.gradle b/build.gradle index 2acdec8f..b89a8c92 100644 --- a/build.gradle +++ b/build.gradle @@ -2,19 +2,20 @@ allprojects { group 'org.jetbrains.dokka' version dokka_version + def repo = { + artifactPattern("https://teamcity.jetbrains.com/guestAuth/repository/download/Kotlin_dev_CompilerAllPlugins/[revision]/maven/org/jetbrains/kotlin/[module]/[revision]/[module]-[revision](.[ext])") + artifactPattern("https://teamcity.jetbrains.com/guestAuth/repository/download/Kotlin_dev_CompilerAllPlugins/[revision]/maven/org/jetbrains/kotlin/[module]/[revision]/[module]-[revision]-source.jar") + artifactPattern("https://teamcity.jetbrains.com/guestAuth/repository/download/Kotlin_dev_CompilerAllPlugins/[revision]/internal/[module](.[ext])") + } + buildscript { repositories { mavenCentral() jcenter() - maven { - url "http://dl.bintray.com/kotlin/kotlin-eap-1.1" - } - maven { - url "https://dl.bintray.com/kotlin/kotlin-dev" - } - maven { - url "https://plugins.gradle.org/m2/" - } + maven { url "http://dl.bintray.com/kotlin/kotlin-eap" } + maven { url "https://dl.bintray.com/kotlin/kotlin-dev" } + maven { url "https://plugins.gradle.org/m2/" } + ivy(repo) } dependencies { classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7' @@ -27,9 +28,10 @@ allprojects { repositories { mavenCentral() mavenLocal() - maven { url "http://dl.bintray.com/kotlin/kotlin-eap-1.1" } + maven { url "http://dl.bintray.com/kotlin/kotlin-eap" } maven { url "https://dl.bintray.com/kotlin/kotlin-dev" } maven { url 'https://jitpack.io' } + ivy(repo) } } diff --git a/core/build.gradle b/core/build.gradle index c705e2cf..3d3e2317 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -2,7 +2,7 @@ import javax.tools.ToolProvider buildscript { dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_compiler_to_compile_core_version" } } @@ -11,18 +11,19 @@ apply plugin: 'kotlin' sourceCompatibility = 1.6 dependencies { - compile group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version: kotlin_version - compile group: 'org.jetbrains.kotlin', name: 'kotlin-reflect', version: kotlin_version + compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_compiler_version" + compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_compiler_version" compile group: 'com.google.inject', name: 'guice', version: '3.0' compile "org.jsoup:jsoup:1.8.3" compile files("../lib/intellij-core-analysis.jar") - compile group: 'org.jetbrains.kotlin', name: 'kotlin-compiler', version: kotlin_version - compile group: 'org.jetbrains.kotlin', name: 'kotlin-script-runtime', version: kotlin_version - compile files("../lib/kotlin-ide-common.jar") - compile files("../lib/markdown.jar") + compile "teamcity:kotlin-compiler:$kotlin_compiler_version" + compile "teamcity:kotlin-script-runtime:$kotlin_compiler_version" + + compile "teamcity:kotlin-ide-common:$kotlin_compiler_version" + compile "teamcity:markdown:$kotlin_compiler_version" //tools.jar def toolsJar = files(((URLClassLoader) ToolProvider.getSystemToolClassLoader()).getURLs().findAll { it.path.endsWith("jar") }) diff --git a/gradle.properties b/gradle.properties index 4d4e40ad..516cd0eb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,6 +3,8 @@ dokka_publication_channel=dokka #Kotlin compiler and plugin kotlin_version=1.1.51 +kotlin_compiler_version=1.2.20-dev-65 +kotlin_compiler_to_compile_core_version=1.2.0-rc-39 kotlin_for_gradle_version=1.0.7 ant_version=1.9.6 diff --git a/lib/kotlin-ide-common.jar b/lib/kotlin-ide-common.jar deleted file mode 100644 index 98648313..00000000 Binary files a/lib/kotlin-ide-common.jar and /dev/null differ diff --git a/lib/markdown.jar b/lib/markdown.jar deleted file mode 100644 index e61f954c..00000000 Binary files a/lib/markdown.jar and /dev/null differ diff --git a/runners/fatjar/build.gradle b/runners/fatjar/build.gradle index e3bea7ed..0656ba48 100644 --- a/runners/fatjar/build.gradle +++ b/runners/fatjar/build.gradle @@ -30,6 +30,8 @@ shadowJar { exclude 'fileTemplates/**' exclude 'inspectionDescriptions/**' exclude 'intentionDescriptions/**' + + relocate('kotlin.reflect.full', 'kotlin.reflect') } apply plugin: 'maven-publish' -- cgit From 4626531f95e60e03086da163cde5edf5411a8d9b Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Thu, 9 Nov 2017 21:43:37 +0300 Subject: Drop dependency on intellij-core-analysis Instead of it, download idea.jar and manually strip it Also, depends on same as kotlin-compiler openapi version --- build.gradle | 10 +++- buildSrc/build.gradle | 8 +--- .../org/jetbrains/DependenciesVersionGetter.groovy | 14 ++++++ core/build.gradle | 30 ++++++++++-- .../main/kotlin/Analysis/CoreProjectFileIndex.kt | 16 +++++-- gradle.properties | 3 ++ lib/intellij-core-analysis.jar | Bin 40325875 -> 0 bytes settings.gradle | 3 +- strippedIdeaJar/build.gradle | 52 +++++++++++++++++++++ strippedIdeaJar/ideaJar.pro | 8 ++++ 10 files changed, 129 insertions(+), 15 deletions(-) create mode 100644 buildSrc/src/main/groovy/org/jetbrains/DependenciesVersionGetter.groovy delete mode 100644 lib/intellij-core-analysis.jar create mode 100644 strippedIdeaJar/build.gradle create mode 100644 strippedIdeaJar/ideaJar.pro diff --git a/build.gradle b/build.gradle index b89a8c92..bd960ca8 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,5 @@ +import org.jetbrains.DependenciesVersionGetter + allprojects { group 'org.jetbrains.dokka' version dokka_version @@ -15,6 +17,8 @@ allprojects { maven { url "http://dl.bintray.com/kotlin/kotlin-eap" } maven { url "https://dl.bintray.com/kotlin/kotlin-dev" } maven { url "https://plugins.gradle.org/m2/" } + maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } + maven { url "http://dl.bintray.com/jetbrains/intellij-plugin-service" } ivy(repo) } dependencies { @@ -64,4 +68,8 @@ def bintrayPublication(project, List _publications) { task wrapper(type: Wrapper) { gradleVersion = '4.2.1' distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip" -} \ No newline at end of file +} + +def versions = DependenciesVersionGetter.getVersions(project, kotlin_compiler_version) + +ext.ideaVersion = versions["idea.build.id"] \ No newline at end of file diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 76c7c4ee..874dabc9 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -2,12 +2,8 @@ apply plugin: 'groovy' repositories { mavenCentral() jcenter() - maven { - url "https://dl.bintray.com/kotlin/kotlin-eap" - } - maven { - url "https://dl.bintray.com/kotlin/kotlin-dev" - } + maven { url "https://dl.bintray.com/kotlin/kotlin-eap" } + maven { url "https://dl.bintray.com/kotlin/kotlin-dev" } } dependencies { compile 'com.github.jengelman.gradle.plugins:shadow:2.0.1' diff --git a/buildSrc/src/main/groovy/org/jetbrains/DependenciesVersionGetter.groovy b/buildSrc/src/main/groovy/org/jetbrains/DependenciesVersionGetter.groovy new file mode 100644 index 00000000..194f11af --- /dev/null +++ b/buildSrc/src/main/groovy/org/jetbrains/DependenciesVersionGetter.groovy @@ -0,0 +1,14 @@ +package org.jetbrains + +import org.gradle.api.Project + +class DependenciesVersionGetter { + static Properties getVersions(Project project, String artifactVersionSelector) { + def dep = project.dependencies.create(group: 'teamcity', name: 'dependencies', version: artifactVersionSelector, ext: 'properties') + def file = project.configurations.detachedConfiguration(dep).resolve().first() + + def prop = new Properties() + prop.load(new FileReader(file)) + return prop + } +} diff --git a/core/build.gradle b/core/build.gradle index 3d3e2317..3420e4e7 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -3,6 +3,7 @@ import javax.tools.ToolProvider buildscript { dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_compiler_to_compile_core_version" + classpath "org.jetbrains.intellij.plugins:gradle-intellij-plugin:$gradle_intellij_plugin_version" } } @@ -17,8 +18,6 @@ dependencies { compile group: 'com.google.inject', name: 'guice', version: '3.0' compile "org.jsoup:jsoup:1.8.3" - compile files("../lib/intellij-core-analysis.jar") - compile "teamcity:kotlin-compiler:$kotlin_compiler_version" compile "teamcity:kotlin-script-runtime:$kotlin_compiler_version" @@ -33,7 +32,32 @@ dependencies { compile project(":integration") testCompile group: 'junit', name: 'junit', version: '4.12' - testCompile group: 'org.jetbrains.kotlin', name: 'kotlin-test-junit', version: kotlin_version + testCompile group: 'org.jetbrains.kotlin', name: 'kotlin-test-junit', version: kotlin_compiler_to_compile_core_version testCompile "com.nhaarman:mockito-kotlin-kt1.1:1.5.0" } +apply plugin: 'org.jetbrains.intellij' + +{ -> + intellij { + version = ideaVersion + instrumentCode = false + configureDefaultDependencies = false + extraDependencies 'intellij-core' + } + + ["patchPluginXml", "prepareSandbox", "prepareTestingSandbox", + "verifyPlugin", "runIde", "buildPlugin", "publishPlugin"].each { + tasks.remove(tasks.findByName(it)) + } +}() + +afterEvaluate { + dependencies { + compile intellij { + include("openapi.jar") + } + compile intellijExtra("intellij-core") { include("intellij-core.jar") } + compile project(path: ":strippedIdeaJar", configuration: "proguardOut") + } +} diff --git a/core/src/main/kotlin/Analysis/CoreProjectFileIndex.kt b/core/src/main/kotlin/Analysis/CoreProjectFileIndex.kt index 21f7e2da..2f2f94b3 100644 --- a/core/src/main/kotlin/Analysis/CoreProjectFileIndex.kt +++ b/core/src/main/kotlin/Analysis/CoreProjectFileIndex.kt @@ -32,7 +32,11 @@ import java.io.File * classes from projectModel-{api,impl}. */ class CoreProjectFileIndex(private val project: Project, contentRoots: List) : ProjectFileIndex, ModuleFileIndex { - override fun iterateContentUnderDirectory(p0: VirtualFile, p1: ContentIterator, p2: VirtualFileFilter): Boolean { + override fun iterateContent(p0: ContentIterator, p1: VirtualFileFilter?): Boolean { + throw UnsupportedOperationException() + } + + override fun iterateContentUnderDirectory(p0: VirtualFile, p1: ContentIterator, p2: VirtualFileFilter?): Boolean { throw UnsupportedOperationException() } @@ -74,7 +78,7 @@ class CoreProjectFileIndex(private val project: Project, contentRoots: List? { + override fun getRootFiles(p0: OrderRootType): Array { throw UnsupportedOperationException() } - override fun getRootUrls(p0: OrderRootType?): Array? { + override fun getRootUrls(p0: OrderRootType): Array { throw UnsupportedOperationException() } @@ -307,6 +311,10 @@ class CoreProjectFileIndex(private val project: Project, contentRoots: List { throw UnsupportedOperationException() } diff --git a/gradle.properties b/gradle.properties index 516cd0eb..29da4702 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,6 +7,9 @@ kotlin_compiler_version=1.2.20-dev-65 kotlin_compiler_to_compile_core_version=1.2.0-rc-39 kotlin_for_gradle_version=1.0.7 +#IntelliJ plugin to download openapi.jar +gradle_intellij_plugin_version=0.3.0-SNAPSHOT + ant_version=1.9.6 #Maven plugin dependencies diff --git a/lib/intellij-core-analysis.jar b/lib/intellij-core-analysis.jar deleted file mode 100644 index 50520e0c..00000000 Binary files a/lib/intellij-core-analysis.jar and /dev/null differ diff --git a/settings.gradle b/settings.gradle index 4dcfd255..e6694bf9 100644 --- a/settings.gradle +++ b/settings.gradle @@ -6,4 +6,5 @@ include 'core', 'runners:maven-plugin', 'runners:gradle-plugin', 'runners:android-gradle-plugin', - 'runners:gradle-integration-tests' + 'runners:gradle-integration-tests', + 'strippedIdeaJar' diff --git a/strippedIdeaJar/build.gradle b/strippedIdeaJar/build.gradle new file mode 100644 index 00000000..e8104d00 --- /dev/null +++ b/strippedIdeaJar/build.gradle @@ -0,0 +1,52 @@ +import proguard.gradle.ProGuardTask + +buildscript { + dependencies { + classpath "org.jetbrains.intellij.plugins:gradle-intellij-plugin:$gradle_intellij_plugin_version" + classpath "net.sf.proguard:proguard-gradle:5.3.3" + } +} + +apply plugin: 'org.jetbrains.intellij' + +{ -> + intellij { + version = ideaVersion + instrumentCode = false + configureDefaultDependencies = false + } + + ["patchPluginXml", "prepareSandbox", "prepareTestingSandbox", + "verifyPlugin", "runIde", "buildPlugin", "publishPlugin"].each { + tasks.remove(tasks.findByName(it)) + } +}() + +configurations { + proguardInput + proguardOut +} + +afterEvaluate { + dependencies { + proguardInput intellij { include("idea.jar") } + } +} + + +task strip(type: ProGuardTask) { + configuration file('ideaJar.pro') + afterEvaluate { + injars configurations.proguardInput.files, filter: "**.class" + outjars file("$buildDir/idea-stripped.jar") + } +} + + +afterEvaluate { + artifacts { + proguardOut(strip.outputs.files.singleFile) { + builtBy strip + } + } +} \ No newline at end of file diff --git a/strippedIdeaJar/ideaJar.pro b/strippedIdeaJar/ideaJar.pro new file mode 100644 index 00000000..63efbd95 --- /dev/null +++ b/strippedIdeaJar/ideaJar.pro @@ -0,0 +1,8 @@ + +-dontwarn ** + +-dontobfuscate +-dontoptimize + +-keep class com.intellij.openapi.roots.impl.ProjectOrderEnumerator { *; } +-keep class com.intellij.core.CoreModuleManager { *; } -- cgit From a89a21542d0603f89a8e61196891130416f75495 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Thu, 9 Nov 2017 22:38:02 +0300 Subject: Use maven to resolve kotlin-compiler dependency instead of ivy --- build.gradle | 3 +-- core/build.gradle | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index bd960ca8..92de25cc 100644 --- a/build.gradle +++ b/build.gradle @@ -5,8 +5,6 @@ allprojects { version dokka_version def repo = { - artifactPattern("https://teamcity.jetbrains.com/guestAuth/repository/download/Kotlin_dev_CompilerAllPlugins/[revision]/maven/org/jetbrains/kotlin/[module]/[revision]/[module]-[revision](.[ext])") - artifactPattern("https://teamcity.jetbrains.com/guestAuth/repository/download/Kotlin_dev_CompilerAllPlugins/[revision]/maven/org/jetbrains/kotlin/[module]/[revision]/[module]-[revision]-source.jar") artifactPattern("https://teamcity.jetbrains.com/guestAuth/repository/download/Kotlin_dev_CompilerAllPlugins/[revision]/internal/[module](.[ext])") } @@ -35,6 +33,7 @@ allprojects { maven { url "http://dl.bintray.com/kotlin/kotlin-eap" } maven { url "https://dl.bintray.com/kotlin/kotlin-dev" } maven { url 'https://jitpack.io' } + maven { url "https://teamcity.jetbrains.com/guestAuth/repository/download/Kotlin_dev_CompilerAllPlugins/$kotlin_compiler_version/maven" } ivy(repo) } } diff --git a/core/build.gradle b/core/build.gradle index 3420e4e7..c31b3945 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -18,8 +18,8 @@ dependencies { compile group: 'com.google.inject', name: 'guice', version: '3.0' compile "org.jsoup:jsoup:1.8.3" - compile "teamcity:kotlin-compiler:$kotlin_compiler_version" - compile "teamcity:kotlin-script-runtime:$kotlin_compiler_version" + compile "org.jetbrains.kotlin:kotlin-compiler:$kotlin_compiler_version" + compile "org.jetbrains.kotlin:kotlin-script-runtime:$kotlin_compiler_version" compile "teamcity:kotlin-ide-common:$kotlin_compiler_version" compile "teamcity:markdown:$kotlin_compiler_version" -- cgit From 7d9cba1e6707ff01eb407f87f59fdf400777cce2 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Thu, 9 Nov 2017 22:41:29 +0300 Subject: Exclude src from kotlin-ide-common in fatjar --- runners/fatjar/build.gradle | 2 ++ 1 file changed, 2 insertions(+) diff --git a/runners/fatjar/build.gradle b/runners/fatjar/build.gradle index 0656ba48..fc9abeda 100644 --- a/runners/fatjar/build.gradle +++ b/runners/fatjar/build.gradle @@ -31,6 +31,8 @@ shadowJar { exclude 'inspectionDescriptions/**' exclude 'intentionDescriptions/**' + exclude 'src/**' + relocate('kotlin.reflect.full', 'kotlin.reflect') } -- cgit From 17ab40f3854c3fa0b65e0fb3d881a2700a0b3d3d Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Tue, 14 Nov 2017 13:13:34 +0300 Subject: Take intellij-core-analysis back Use plain maven-like repository to resolve it, remove usage of gradle-intellij-plugin --- build.gradle | 2 -- core/build.gradle | 37 +++++++++++---------------- runners/gradle-plugin/build.gradle | 8 ++++++ settings.gradle | 3 +-- strippedIdeaJar/build.gradle | 52 -------------------------------------- strippedIdeaJar/ideaJar.pro | 8 ------ 6 files changed, 24 insertions(+), 86 deletions(-) delete mode 100644 strippedIdeaJar/build.gradle delete mode 100644 strippedIdeaJar/ideaJar.pro diff --git a/build.gradle b/build.gradle index 92de25cc..f9c2bd70 100644 --- a/build.gradle +++ b/build.gradle @@ -15,8 +15,6 @@ allprojects { maven { url "http://dl.bintray.com/kotlin/kotlin-eap" } maven { url "https://dl.bintray.com/kotlin/kotlin-dev" } maven { url "https://plugins.gradle.org/m2/" } - maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } - maven { url "http://dl.bintray.com/jetbrains/intellij-plugin-service" } ivy(repo) } dependencies { diff --git a/core/build.gradle b/core/build.gradle index c31b3945..3c602a6b 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -3,7 +3,6 @@ import javax.tools.ToolProvider buildscript { dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_compiler_to_compile_core_version" - classpath "org.jetbrains.intellij.plugins:gradle-intellij-plugin:$gradle_intellij_plugin_version" } } @@ -11,6 +10,15 @@ apply plugin: 'kotlin' sourceCompatibility = 1.6 +repositories { + maven { url 'https://www.jetbrains.com/intellij-repository/snapshots' } + maven { url 'https://www.jetbrains.com/intellij-repository/releases' } +} + +configurations { + intellijCore +} + dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_compiler_version" compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_compiler_version" @@ -34,30 +42,15 @@ dependencies { testCompile group: 'junit', name: 'junit', version: '4.12' testCompile group: 'org.jetbrains.kotlin', name: 'kotlin-test-junit', version: kotlin_compiler_to_compile_core_version testCompile "com.nhaarman:mockito-kotlin-kt1.1:1.5.0" -} -apply plugin: 'org.jetbrains.intellij' + intellijCore "com.jetbrains.intellij.idea:intellij-core:$ideaVersion" +} -{ -> - intellij { - version = ideaVersion - instrumentCode = false - configureDefaultDependencies = false - extraDependencies 'intellij-core' - } - - ["patchPluginXml", "prepareSandbox", "prepareTestingSandbox", - "verifyPlugin", "runIde", "buildPlugin", "publishPlugin"].each { - tasks.remove(tasks.findByName(it)) - } -}() afterEvaluate { dependencies { - compile intellij { - include("openapi.jar") - } - compile intellijExtra("intellij-core") { include("intellij-core.jar") } - compile project(path: ":strippedIdeaJar", configuration: "proguardOut") + compile zipTree(configurations.intellijCore.singleFile).matching ({ + include("intellij-core-analysis.jar") + }) } -} +} \ No newline at end of file diff --git a/runners/gradle-plugin/build.gradle b/runners/gradle-plugin/build.gradle index 5af6b427..fff58092 100644 --- a/runners/gradle-plugin/build.gradle +++ b/runners/gradle-plugin/build.gradle @@ -10,6 +10,14 @@ tasks.withType(AbstractCompile) { classpath += configurations.shadow } + +compileKotlin { + + kotlinOptions { + freeCompilerArgs += "-Xjsr305-annotations=strict" + } + +} dependencies { testCompile group: 'junit', name: 'junit', version: '4.12' diff --git a/settings.gradle b/settings.gradle index e6694bf9..4dcfd255 100644 --- a/settings.gradle +++ b/settings.gradle @@ -6,5 +6,4 @@ include 'core', 'runners:maven-plugin', 'runners:gradle-plugin', 'runners:android-gradle-plugin', - 'runners:gradle-integration-tests', - 'strippedIdeaJar' + 'runners:gradle-integration-tests' diff --git a/strippedIdeaJar/build.gradle b/strippedIdeaJar/build.gradle deleted file mode 100644 index e8104d00..00000000 --- a/strippedIdeaJar/build.gradle +++ /dev/null @@ -1,52 +0,0 @@ -import proguard.gradle.ProGuardTask - -buildscript { - dependencies { - classpath "org.jetbrains.intellij.plugins:gradle-intellij-plugin:$gradle_intellij_plugin_version" - classpath "net.sf.proguard:proguard-gradle:5.3.3" - } -} - -apply plugin: 'org.jetbrains.intellij' - -{ -> - intellij { - version = ideaVersion - instrumentCode = false - configureDefaultDependencies = false - } - - ["patchPluginXml", "prepareSandbox", "prepareTestingSandbox", - "verifyPlugin", "runIde", "buildPlugin", "publishPlugin"].each { - tasks.remove(tasks.findByName(it)) - } -}() - -configurations { - proguardInput - proguardOut -} - -afterEvaluate { - dependencies { - proguardInput intellij { include("idea.jar") } - } -} - - -task strip(type: ProGuardTask) { - configuration file('ideaJar.pro') - afterEvaluate { - injars configurations.proguardInput.files, filter: "**.class" - outjars file("$buildDir/idea-stripped.jar") - } -} - - -afterEvaluate { - artifacts { - proguardOut(strip.outputs.files.singleFile) { - builtBy strip - } - } -} \ No newline at end of file diff --git a/strippedIdeaJar/ideaJar.pro b/strippedIdeaJar/ideaJar.pro deleted file mode 100644 index 63efbd95..00000000 --- a/strippedIdeaJar/ideaJar.pro +++ /dev/null @@ -1,8 +0,0 @@ - --dontwarn ** - --dontobfuscate --dontoptimize - --keep class com.intellij.openapi.roots.impl.ProjectOrderEnumerator { *; } --keep class com.intellij.core.CoreModuleManager { *; } -- cgit From a3ea8698452c132ae4a756d617775f40f036b907 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Fri, 27 Oct 2017 01:55:09 +0300 Subject: Support assertFalse and message in assertTrue/assertFalse --- .../kotlin/Samples/KotlinWebsiteSampleProcessingService.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/core/src/main/kotlin/Samples/KotlinWebsiteSampleProcessingService.kt b/core/src/main/kotlin/Samples/KotlinWebsiteSampleProcessingService.kt index 4dd0bc7f..665a687f 100644 --- a/core/src/main/kotlin/Samples/KotlinWebsiteSampleProcessingService.kt +++ b/core/src/main/kotlin/Samples/KotlinWebsiteSampleProcessingService.kt @@ -35,14 +35,18 @@ open class KotlinWebsiteSampleProcessingService } } - fun convertAssertTrue(expression: KtCallExpression) { + fun convertAssertTrueFalse(expression: KtCallExpression, expectedResult: Boolean) { val (argument) = expression.valueArguments builder.apply { + expression.valueArguments.getOrNull(1)?.let { + appendln("// ${it.extractStringArgumentValue()}") + // TODO: append same amount of whitespace indentation + } append("println(\"") append(argument.text) append(" is \${") append(argument.text) - append("}\") // true") + append("}\") // $expectedResult") } } @@ -77,7 +81,8 @@ open class KotlinWebsiteSampleProcessingService override fun visitCallExpression(expression: KtCallExpression) { when (expression.calleeExpression?.text) { "assertPrints" -> convertAssertPrints(expression) - "assertTrue" -> convertAssertTrue(expression) + "assertTrue" -> convertAssertTrueFalse(expression, expectedResult = true) + "assertFalse" -> convertAssertTrueFalse(expression, expectedResult = false) "assertFails" -> convertAssertFails(expression) "assertFailsWith" -> convertAssertFailsWith(expression) else -> super.visitCallExpression(expression) -- cgit From ec40a94e76d33fb77c58e2b4fe8b9aa150885f0a Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Tue, 14 Nov 2017 16:33:41 +0300 Subject: Handle indent correctly, Add tests for assertTrue/False samples --- .../main/kotlin/Samples/KotlinWebsiteSampleProcessingService.kt | 7 +++++-- core/testdata/format/website-html/sampleWithAsserts.html | 7 +++++++ core/testdata/format/website-html/sampleWithAsserts.kt | 5 +++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/core/src/main/kotlin/Samples/KotlinWebsiteSampleProcessingService.kt b/core/src/main/kotlin/Samples/KotlinWebsiteSampleProcessingService.kt index 665a687f..b0988c35 100644 --- a/core/src/main/kotlin/Samples/KotlinWebsiteSampleProcessingService.kt +++ b/core/src/main/kotlin/Samples/KotlinWebsiteSampleProcessingService.kt @@ -2,11 +2,13 @@ package org.jetbrains.dokka.Samples import com.google.inject.Inject import com.intellij.psi.PsiElement +import com.intellij.psi.PsiWhiteSpace import com.intellij.psi.impl.source.tree.LeafPsiElement import com.intellij.psi.util.PsiTreeUtil import org.jetbrains.dokka.* import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.allChildren +import org.jetbrains.kotlin.psi.psiUtil.prevLeaf import org.jetbrains.kotlin.resolve.ImportPath open class KotlinWebsiteSampleProcessingService @@ -39,8 +41,9 @@ open class KotlinWebsiteSampleProcessingService val (argument) = expression.valueArguments builder.apply { expression.valueArguments.getOrNull(1)?.let { - appendln("// ${it.extractStringArgumentValue()}") - // TODO: append same amount of whitespace indentation + append("// ${it.extractStringArgumentValue()}") + val ws = expression.prevLeaf { it is PsiWhiteSpace } + append(ws?.text ?: "\n") } append("println(\"") append(argument.text) diff --git a/core/testdata/format/website-html/sampleWithAsserts.html b/core/testdata/format/website-html/sampleWithAsserts.html index e70d37c9..11a3a626 100644 --- a/core/testdata/format/website-html/sampleWithAsserts.html +++ b/core/testdata/format/website-html/sampleWithAsserts.html @@ -9,7 +9,14 @@ fun main(args: Array<String>) { //sampleStart println(a()) // Hello, Work println("a() == b() is ${a() == b()}") // true +// A eq B +println("a() == b() is ${a() == b()}") // true // readSomeFile(File("some.txt")) // reading file now will fail // readSomeFile(File("some.txt")) // will fail with FileNotFoundException + +fun indented() { + // A neq B + println("a() != b() is ${a() != b()}") // false +} //sampleEnd } diff --git a/core/testdata/format/website-html/sampleWithAsserts.kt b/core/testdata/format/website-html/sampleWithAsserts.kt index f5b03eb8..b3bce11d 100644 --- a/core/testdata/format/website-html/sampleWithAsserts.kt +++ b/core/testdata/format/website-html/sampleWithAsserts.kt @@ -22,6 +22,11 @@ fun readSomeFile(f: File) { fun sample() { assertPrints(a(), "Hello, Work") assertTrue(a() == b()) + assertTrue(a() == b(), "A eq B") assertFails("reading file now") { readSomeFile(File("some.txt")) } assertFailsWith { readSomeFile(File("some.txt")) } + + fun indented() { + assertFalse(a() != b(), "A neq B") + } } \ No newline at end of file -- cgit From bd92d65eba154d756c47c0ea2f304db04ac0ffae Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Mon, 20 Nov 2017 21:38:15 +0300 Subject: Advance Kotlin Compiler version to pinned --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 29da4702..154d7776 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ dokka_publication_channel=dokka #Kotlin compiler and plugin kotlin_version=1.1.51 -kotlin_compiler_version=1.2.20-dev-65 +kotlin_compiler_version=1.2.20-dev-175 kotlin_compiler_to_compile_core_version=1.2.0-rc-39 kotlin_for_gradle_version=1.0.7 -- cgit From 0298076ba9cf22b70b6c85846ad555e201ee95ee Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Mon, 20 Nov 2017 22:38:11 +0300 Subject: Support receiver reference --- core/src/main/kotlin/Kotlin/DocumentationBuilder.kt | 2 ++ core/src/test/kotlin/format/MarkdownFormatTest.kt | 4 ++++ core/testdata/format/receiverReference.kt | 6 ++++++ core/testdata/format/receiverReference.md | 6 ++++++ 4 files changed, 18 insertions(+) create mode 100644 core/testdata/format/receiverReference.kt create mode 100644 core/testdata/format/receiverReference.md diff --git a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt index fddf0814..04993ad4 100644 --- a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt +++ b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt @@ -746,6 +746,7 @@ class DocumentationBuilder val node = DocumentationNode(name.asString(), Content.Empty, NodeKind.Receiver) node.appendType(type) + register(this, node) return node } @@ -915,6 +916,7 @@ fun DeclarationDescriptor.signature(): String = when (this) { is FunctionDescriptor -> containingDeclaration.signature() + "$" + name + parameterSignature() is ValueParameterDescriptor -> containingDeclaration.signature() + "/" + name is TypeParameterDescriptor -> containingDeclaration.signature() + "*" + name + is ReceiverParameterDescriptor -> containingDeclaration.signature() + "*" + name else -> throw UnsupportedOperationException("Don't know how to calculate signature for $this") } diff --git a/core/src/test/kotlin/format/MarkdownFormatTest.kt b/core/src/test/kotlin/format/MarkdownFormatTest.kt index fbebfbfd..97a8ad4b 100644 --- a/core/src/test/kotlin/format/MarkdownFormatTest.kt +++ b/core/src/test/kotlin/format/MarkdownFormatTest.kt @@ -380,6 +380,10 @@ class MarkdownFormatTest { verifyMarkdownNode("indentedCodeBlock") } + @Test fun receiverReference() { + verifyMarkdownNode("receiverReference") + } + private fun buildMultiplePlatforms(path: String): DocumentationModule { val module = DocumentationModule("test") val options = DocumentationOptions("", "html", generateIndexPages = false, noStdlibLink = true) diff --git a/core/testdata/format/receiverReference.kt b/core/testdata/format/receiverReference.kt new file mode 100644 index 00000000..3e6e2056 --- /dev/null +++ b/core/testdata/format/receiverReference.kt @@ -0,0 +1,6 @@ +/** + * Prints [this] + */ +fun String.some() { + println(this) +} \ No newline at end of file diff --git a/core/testdata/format/receiverReference.md b/core/testdata/format/receiverReference.md new file mode 100644 index 00000000..1584b2b1 --- /dev/null +++ b/core/testdata/format/receiverReference.md @@ -0,0 +1,6 @@ +[test](test/index) / [kotlin.String](test/kotlin.-string/index) + +### Extensions for kotlin.String + +| [some](test/kotlin.-string/some) | `fun String.some(): Unit`
Prints [this](test/kotlin.-string/some/-this-) | + -- cgit From d0d5617669217c095858df0b5f1597aa5c230dcf Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Tue, 21 Nov 2017 01:19:34 +0300 Subject: Hard-code language version --- core/src/main/kotlin/Analysis/AnalysisEnvironment.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/core/src/main/kotlin/Analysis/AnalysisEnvironment.kt b/core/src/main/kotlin/Analysis/AnalysisEnvironment.kt index be4285c0..3eb235e5 100644 --- a/core/src/main/kotlin/Analysis/AnalysisEnvironment.kt +++ b/core/src/main/kotlin/Analysis/AnalysisEnvironment.kt @@ -69,6 +69,7 @@ class AnalysisEnvironment(val messageCollector: MessageCollector) : Disposable { val projectFileIndex = CoreProjectFileIndex(environment.project, environment.configuration.getList(JVMConfigurationKeys.CONTENT_ROOTS)) + environment.configuration.put(CommonConfigurationKeys.LANGUAGE_VERSION_SETTINGS, LanguageVersionSettingsImpl.DEFAULT) val moduleManager = object : CoreModuleManager(environment.project, this) { override fun getModules(): Array = arrayOf(projectFileIndex.module) -- cgit From 924832f8ae7a38ad7c6b105c04794195bf9d4f9f Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Tue, 21 Nov 2017 02:58:34 +0300 Subject: More info in can't find node by signature --- core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt b/core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt index 275972fa..24f50dac 100644 --- a/core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt +++ b/core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt @@ -32,7 +32,16 @@ class DeclarationLinkResolver return ContentExternalLink(externalHref) } val signature = descriptorSignatureProvider.signature(symbol) - return ContentNodeLazyLink(href, { -> refGraph.lookupOrWarn(signature, logger) }) + val referencedAt = fromDescriptor.sourceLocation()?.let { ", referenced at $it" }.orEmpty() + + return ContentNodeLazyLink(href, { -> + val target = refGraph.lookup(signature) + + if (target == null) { + logger.warn("Can't find node by signature $signature$referencedAt") + } + target + }) } if ("/" in href) { return ContentExternalLink(href) -- cgit From 80bde3cb243b324df162a16d23f9dfd3e0ab2597 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Tue, 21 Nov 2017 15:05:04 +0300 Subject: Fix find node by signature when linking to extension with Type Param --- .../src/main/kotlin/Kotlin/DocumentationBuilder.kt | 29 ++++++++++++---------- core/src/test/kotlin/format/MarkdownFormatTest.kt | 4 +++ core/testdata/format/extensionScope.kt | 14 +++++++++++ core/testdata/format/extensionScope.md | 8 ++++++ 4 files changed, 42 insertions(+), 13 deletions(-) create mode 100644 core/testdata/format/extensionScope.kt create mode 100644 core/testdata/format/extensionScope.md diff --git a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt index 04993ad4..177c6f50 100644 --- a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt +++ b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt @@ -906,18 +906,21 @@ fun CallableMemberDescriptor.getExtensionClassDescriptor(): ClassifierDescriptor return null } -fun DeclarationDescriptor.signature(): String = when (this) { - is ClassDescriptor, - is PackageFragmentDescriptor, - is PackageViewDescriptor, - is TypeAliasDescriptor -> DescriptorUtils.getFqName(this).asString() - - is PropertyDescriptor -> containingDeclaration.signature() + "$" + name + receiverSignature() - is FunctionDescriptor -> containingDeclaration.signature() + "$" + name + parameterSignature() - is ValueParameterDescriptor -> containingDeclaration.signature() + "/" + name - is TypeParameterDescriptor -> containingDeclaration.signature() + "*" + name - is ReceiverParameterDescriptor -> containingDeclaration.signature() + "*" + name - else -> throw UnsupportedOperationException("Don't know how to calculate signature for $this") +fun DeclarationDescriptor.signature(): String { + if (this != original) return original.signature() + return when (this) { + is ClassDescriptor, + is PackageFragmentDescriptor, + is PackageViewDescriptor, + is TypeAliasDescriptor -> DescriptorUtils.getFqName(this).asString() + + is PropertyDescriptor -> containingDeclaration.signature() + "$" + name + receiverSignature() + is FunctionDescriptor -> containingDeclaration.signature() + "$" + name + parameterSignature() + is ValueParameterDescriptor -> containingDeclaration.signature() + "/" + name + is TypeParameterDescriptor -> containingDeclaration.signature() + "*" + name + is ReceiverParameterDescriptor -> containingDeclaration.signature() + "*" + name + else -> throw UnsupportedOperationException("Don't know how to calculate signature for $this") + } } fun PropertyDescriptor.receiverSignature(): String { @@ -934,7 +937,7 @@ fun CallableMemberDescriptor.parameterSignature(): String { if (extensionReceiver != null) { params.add(0, extensionReceiver.type) } - return "(" + params.map { it.signature() }.joinToString() + ")" + return params.joinToString(prefix = "(", postfix = ")") { it.signature() } } fun KotlinType.signature(): String { diff --git a/core/src/test/kotlin/format/MarkdownFormatTest.kt b/core/src/test/kotlin/format/MarkdownFormatTest.kt index 97a8ad4b..5fbd80fb 100644 --- a/core/src/test/kotlin/format/MarkdownFormatTest.kt +++ b/core/src/test/kotlin/format/MarkdownFormatTest.kt @@ -384,6 +384,10 @@ class MarkdownFormatTest { verifyMarkdownNode("receiverReference") } + @Test fun extensionScope() { + verifyMarkdownNodeByName("extensionScope", "test") + } + private fun buildMultiplePlatforms(path: String): DocumentationModule { val module = DocumentationModule("test") val options = DocumentationOptions("", "html", generateIndexPages = false, noStdlibLink = true) diff --git a/core/testdata/format/extensionScope.kt b/core/testdata/format/extensionScope.kt new file mode 100644 index 00000000..9f3130b8 --- /dev/null +++ b/core/testdata/format/extensionScope.kt @@ -0,0 +1,14 @@ +/** + * Test class with Type-parameter + */ +class Foo + +/** + * Some extension on Foo + */ +fun Foo.ext() {} + +/** + * Correct link: [Foo.ext] + */ +fun test() {} \ No newline at end of file diff --git a/core/testdata/format/extensionScope.md b/core/testdata/format/extensionScope.md new file mode 100644 index 00000000..3515ed84 --- /dev/null +++ b/core/testdata/format/extensionScope.md @@ -0,0 +1,8 @@ +[test](test/index) / [test](test/test) + +# test + +`fun test(): Unit` + +Correct link: [Foo.ext](test/ext) + -- cgit From ebcea5c3ad6248c5a02adc5740103a23a5108c58 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Tue, 21 Nov 2017 15:24:32 +0300 Subject: Fix find node by signature when referencing type parameter --- core/src/main/kotlin/Kotlin/DocumentationBuilder.kt | 1 + core/src/test/kotlin/format/MarkdownFormatTest.kt | 4 ++++ core/src/test/kotlin/model/FunctionTest.kt | 14 ++++++++------ core/testdata/format/annotatedTypeParameter.md | 2 +- core/testdata/format/extensionFunctionParameter.md | 2 +- core/testdata/format/genericInheritedExtensions.md | 6 +++--- core/testdata/format/htmlEscaping.html | 2 +- core/testdata/format/nullability.md | 2 +- core/testdata/format/parameterAnchor.html | 2 +- core/testdata/format/receiverParameterTypeBound.md | 2 +- core/testdata/format/summarizeSignatures.md | 2 +- core/testdata/format/typeAliases.md | 4 ++-- core/testdata/format/typeAliases.package.md | 4 ++-- core/testdata/format/typeParameterBounds.md | 2 +- core/testdata/format/typeParameterReference.kt | 6 ++++++ core/testdata/format/typeParameterReference.md | 8 ++++++++ core/testdata/format/typeProjectionVariance.md | 2 +- 17 files changed, 43 insertions(+), 22 deletions(-) create mode 100644 core/testdata/format/typeParameterReference.kt create mode 100644 core/testdata/format/typeParameterReference.md diff --git a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt index 177c6f50..856127d3 100644 --- a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt +++ b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt @@ -726,6 +726,7 @@ class DocumentationBuilder } node.appendType(constraint, NodeKind.UpperBound) } + register(this, node) return node } diff --git a/core/src/test/kotlin/format/MarkdownFormatTest.kt b/core/src/test/kotlin/format/MarkdownFormatTest.kt index 5fbd80fb..a2891c47 100644 --- a/core/src/test/kotlin/format/MarkdownFormatTest.kt +++ b/core/src/test/kotlin/format/MarkdownFormatTest.kt @@ -388,6 +388,10 @@ class MarkdownFormatTest { verifyMarkdownNodeByName("extensionScope", "test") } + @Test fun typeParameterReference() { + verifyMarkdownNode("typeParameterReference") + } + private fun buildMultiplePlatforms(path: String): DocumentationModule { val module = DocumentationModule("test") val options = DocumentationOptions("", "html", generateIndexPages = false, noStdlibLink = true) diff --git a/core/src/test/kotlin/model/FunctionTest.kt b/core/src/test/kotlin/model/FunctionTest.kt index 065decef..32910682 100644 --- a/core/src/test/kotlin/model/FunctionTest.kt +++ b/core/src/test/kotlin/model/FunctionTest.kt @@ -5,6 +5,7 @@ import org.jetbrains.dokka.NodeKind import org.junit.Assert.assertEquals import org.junit.Assert.assertTrue import org.junit.Test +import kotlin.test.assertNotNull class FunctionTest { @Test fun function() { @@ -83,9 +84,10 @@ class FunctionTest { assertEquals(NodeKind.Function, kind) assertEquals("generic function", content.summary.toTestString()) - assertEquals("public", details.elementAt(0).name) - assertEquals("final", details.elementAt(1).name) - with(details.elementAt(3)) { + val functionDetails = details + assertEquals("public", functionDetails.elementAt(0).name) + assertEquals("final", functionDetails.elementAt(1).name) + with(functionDetails.elementAt(3)) { assertEquals("T", name) assertEquals(NodeKind.TypeParameter, kind) assertEquals(Content.Empty, content) @@ -95,19 +97,19 @@ class FunctionTest { assertEquals(Content.Empty, content) assertTrue(details.none()) assertTrue(members.none()) - assertTrue(links.none()) + assertTrue(links.singleOrNull() == functionDetails.elementAt(4)) } assertTrue(members.none()) assertTrue(links.none()) } - with(details.elementAt(4)) { + with(functionDetails.elementAt(4)) { assertEquals("R", name) assertEquals(NodeKind.TypeParameter, kind) assertEquals(Content.Empty, content) assertTrue(members.none()) assertTrue(links.none()) } - assertEquals("Unit", details.elementAt(5).name) + assertEquals("Unit", functionDetails.elementAt(5).name) assertTrue(members.none()) assertTrue(links.none()) diff --git a/core/testdata/format/annotatedTypeParameter.md b/core/testdata/format/annotatedTypeParameter.md index 0aa1b9d7..aa8b8592 100644 --- a/core/testdata/format/annotatedTypeParameter.md +++ b/core/testdata/format/annotatedTypeParameter.md @@ -2,4 +2,4 @@ # containsAll -`fun containsAll(elements: Collection<@UnsafeVariance E>): @UnsafeVariance E` \ No newline at end of file +`fun containsAll(elements: Collection<@UnsafeVariance `[`E`](test/contains-all#E)`>): @UnsafeVariance `[`E`](test/contains-all#E) \ No newline at end of file diff --git a/core/testdata/format/extensionFunctionParameter.md b/core/testdata/format/extensionFunctionParameter.md index b459d49e..501d731d 100644 --- a/core/testdata/format/extensionFunctionParameter.md +++ b/core/testdata/format/extensionFunctionParameter.md @@ -2,4 +2,4 @@ # apply -`inline fun T.apply(f: T.() -> Unit): T` \ No newline at end of file +`inline fun `[`T`](test/apply#T)`.apply(f: `[`T`](test/apply#T)`.() -> Unit): `[`T`](test/apply#T) \ No newline at end of file diff --git a/core/testdata/format/genericInheritedExtensions.md b/core/testdata/format/genericInheritedExtensions.md index a3091aeb..163ff0c9 100644 --- a/core/testdata/format/genericInheritedExtensions.md +++ b/core/testdata/format/genericInheritedExtensions.md @@ -2,7 +2,7 @@ # Bar -`class Bar : `[`Foo`](test/-foo/index)`` +`class Bar : `[`Foo`](test/-foo/index)`<`[`T`](test/-bar/index#T)`>` ### Constructors @@ -10,6 +10,6 @@ ### Extension Functions -| [first](test/first) | `fun `[`Foo`](test/-foo/index)`.first(): Unit` | -| [second](test/second) | `fun `[`Bar`](test/-bar/index)`.second(): Unit` | +| [first](test/first) | `fun `[`Foo`](test/-foo/index)`<`[`T`](test/first#T)`>.first(): Unit` | +| [second](test/second) | `fun `[`Bar`](test/-bar/index)`<`[`T`](test/second#T)`>.second(): Unit` | diff --git a/core/testdata/format/htmlEscaping.html b/core/testdata/format/htmlEscaping.html index fd9a3235..17d48161 100644 --- a/core/testdata/format/htmlEscaping.html +++ b/core/testdata/format/htmlEscaping.html @@ -8,7 +8,7 @@

x

-fun <T> x(): T? +fun <T> x(): T?

Special characters: < is "less than", > is "greater than", & is "ampersand"

diff --git a/core/testdata/format/nullability.md b/core/testdata/format/nullability.md index 6a4c3761..014eb485 100644 --- a/core/testdata/format/nullability.md +++ b/core/testdata/format/nullability.md @@ -10,5 +10,5 @@ ### Functions -| [foo](test/-c/foo) | `fun foo(): Comparable?` | +| [foo](test/-c/foo) | `fun foo(): Comparable<`[`T`](test/-c/index#T)`>?` | diff --git a/core/testdata/format/parameterAnchor.html b/core/testdata/format/parameterAnchor.html index ecb89fe6..3ffcf595 100644 --- a/core/testdata/format/parameterAnchor.html +++ b/core/testdata/format/parameterAnchor.html @@ -8,7 +8,7 @@

processFiles

-fun <T> processFiles(processor: () -> T): List<T> +fun <T> processFiles(processor: () -> T): List<T>

Runs processor for each file and collects its results into single list

Parameters

diff --git a/core/testdata/format/receiverParameterTypeBound.md b/core/testdata/format/receiverParameterTypeBound.md index 8a8c4220..9c767449 100644 --- a/core/testdata/format/receiverParameterTypeBound.md +++ b/core/testdata/format/receiverParameterTypeBound.md @@ -10,5 +10,5 @@ ### Extension Functions -| [xyzzy](test/xyzzy) | `fun T.xyzzy(): Unit` | +| [xyzzy](test/xyzzy) | `fun `[`T`](test/xyzzy#T)`.xyzzy(): Unit` | diff --git a/core/testdata/format/summarizeSignatures.md b/core/testdata/format/summarizeSignatures.md index d37f2301..c1830fb5 100644 --- a/core/testdata/format/summarizeSignatures.md +++ b/core/testdata/format/summarizeSignatures.md @@ -10,5 +10,5 @@ ### Functions -| [foo](test/kotlin/foo) | `fun any_array.foo(predicate: (T) -> Boolean): Boolean`
Returns true if foo. | +| [foo](test/kotlin/foo) | `fun any_array.foo(predicate: (`[`T`](test/kotlin/foo#T)`) -> Boolean): Boolean`
Returns true if foo. | diff --git a/core/testdata/format/typeAliases.md b/core/testdata/format/typeAliases.md index 55e9317e..2a813c32 100644 --- a/core/testdata/format/typeAliases.md +++ b/core/testdata/format/typeAliases.md @@ -30,11 +30,11 @@ # H -`typealias H = `[`C`](test/-c/index)``[test](test/index) / [I](test/-i) +`typealias H = `[`C`](test/-c/index)`<`[`T`](test/-h#T)`>`[test](test/index) / [I](test/-i) # I -`typealias I = `[`H`](test/-h)``[test](test/index) / [J](test/-j) +`typealias I = `[`H`](test/-h)`<`[`T`](test/-i#T)`>`[test](test/index) / [J](test/-j) # J diff --git a/core/testdata/format/typeAliases.package.md b/core/testdata/format/typeAliases.package.md index 0eff1ed5..9407588b 100644 --- a/core/testdata/format/typeAliases.package.md +++ b/core/testdata/format/typeAliases.package.md @@ -14,8 +14,8 @@ | [E](test/-e) | `typealias E = `[`D`](test/-d) | | [F](test/-f) | `typealias F = (`[`A`](test/-a/index)`) -> `[`B`](test/-b/index) | | [G](test/-g) | `typealias G = `[`C`](test/-c/index)`<`[`A`](test/-a/index)`>` | -| [H](test/-h) | `typealias H = `[`C`](test/-c/index)`` | -| [I](test/-i) | `typealias I = `[`H`](test/-h)`` | +| [H](test/-h) | `typealias H = `[`C`](test/-c/index)`<`[`T`](test/-h#T)`>` | +| [I](test/-i) | `typealias I = `[`H`](test/-h)`<`[`T`](test/-i#T)`>` | | [J](test/-j) | `typealias J = `[`H`](test/-h)`<`[`A`](test/-a/index)`>` | | [K](test/-k) | `typealias K = `[`H`](test/-h)`<`[`J`](test/-j)`>` | | [L](test/-l) | `typealias L = (`[`K`](test/-k)`, `[`B`](test/-b/index)`) -> `[`J`](test/-j) | diff --git a/core/testdata/format/typeParameterBounds.md b/core/testdata/format/typeParameterBounds.md index 58df82a3..8f369ed6 100644 --- a/core/testdata/format/typeParameterBounds.md +++ b/core/testdata/format/typeParameterBounds.md @@ -2,7 +2,7 @@ # generic -`fun generic(): Unit` +`fun generic(): Unit` generic function diff --git a/core/testdata/format/typeParameterReference.kt b/core/testdata/format/typeParameterReference.kt new file mode 100644 index 00000000..f196112d --- /dev/null +++ b/core/testdata/format/typeParameterReference.kt @@ -0,0 +1,6 @@ +/** + * Correct ref to [T] + */ +fun T.tt() { + println("T.tt") +} \ No newline at end of file diff --git a/core/testdata/format/typeParameterReference.md b/core/testdata/format/typeParameterReference.md new file mode 100644 index 00000000..ea49d48a --- /dev/null +++ b/core/testdata/format/typeParameterReference.md @@ -0,0 +1,8 @@ +[test](test/index) / [tt](test/tt) + +# tt + +`fun `[`T`](test/tt#T)`.tt(): Unit` + +Correct ref to [T](test/tt#T) + diff --git a/core/testdata/format/typeProjectionVariance.md b/core/testdata/format/typeProjectionVariance.md index 5b8fc190..072b9fc7 100644 --- a/core/testdata/format/typeProjectionVariance.md +++ b/core/testdata/format/typeProjectionVariance.md @@ -2,5 +2,5 @@ ### Extensions for kotlin.Array -| [foo](test/kotlin.-array/foo) | `fun Array.foo(): Unit` | +| [foo](test/kotlin.-array/foo) | `fun Array.foo(): Unit` | -- cgit From afea8e9e9c4b88af8c7eb7fc2d993d2eca29c4a1 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Tue, 21 Nov 2017 16:46:59 +0300 Subject: Fix reporting of FileComparisonFailure by adding idea_rt dependency --- build.gradle | 29 +++++++++++++++- core/build.gradle | 22 ++---------- .../rt/execution/junit/FileComparisonFailure.java | 39 ---------------------- .../rt/execution/junit/KnownException.java | 6 ---- runners/gradle-integration-tests/build.gradle | 1 + .../rt/execution/junit/FileComparisonFailure.java | 39 ---------------------- .../rt/execution/junit/KnownException.java | 6 ---- 7 files changed, 32 insertions(+), 110 deletions(-) delete mode 100644 core/src/test/java/com/intellij/rt/execution/junit/FileComparisonFailure.java delete mode 100644 core/src/test/java/com/intellij/rt/execution/junit/KnownException.java delete mode 100644 runners/gradle-integration-tests/src/test/java/com/intellij/rt/execution/junit/FileComparisonFailure.java delete mode 100644 runners/gradle-integration-tests/src/test/java/com/intellij/rt/execution/junit/KnownException.java diff --git a/build.gradle b/build.gradle index f9c2bd70..e64427b7 100644 --- a/build.gradle +++ b/build.gradle @@ -69,4 +69,31 @@ task wrapper(type: Wrapper) { def versions = DependenciesVersionGetter.getVersions(project, kotlin_compiler_version) -ext.ideaVersion = versions["idea.build.id"] \ No newline at end of file +ext.ideaVersion = versions["idea.build.id"] + +configurations { + ideaIC + intellijCore +} + +repositories { + maven { url 'https://www.jetbrains.com/intellij-repository/snapshots' } + maven { url 'https://www.jetbrains.com/intellij-repository/releases' } +} + +dependencies { + intellijCore "com.jetbrains.intellij.idea:intellij-core:$ideaVersion" + ideaIC "com.jetbrains.intellij.idea:ideaIC:$ideaVersion" +} + +def intellijCoreAnalysis() { + return zipTree(configurations.intellijCore.singleFile).matching ({ + include("intellij-core-analysis.jar") + }) +} + +def ideaRT() { + return zipTree(project.configurations.ideaIC.singleFile).matching ({ + include("lib/idea_rt.jar") + }) +} \ No newline at end of file diff --git a/core/build.gradle b/core/build.gradle index 3c602a6b..68d3da89 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -10,15 +10,6 @@ apply plugin: 'kotlin' sourceCompatibility = 1.6 -repositories { - maven { url 'https://www.jetbrains.com/intellij-repository/snapshots' } - maven { url 'https://www.jetbrains.com/intellij-repository/releases' } -} - -configurations { - intellijCore -} - dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_compiler_version" compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_compiler_version" @@ -32,6 +23,8 @@ dependencies { compile "teamcity:kotlin-ide-common:$kotlin_compiler_version" compile "teamcity:markdown:$kotlin_compiler_version" + compile intellijCoreAnalysis() + //tools.jar def toolsJar = files(((URLClassLoader) ToolProvider.getSystemToolClassLoader()).getURLs().findAll { it.path.endsWith("jar") }) compileOnly toolsJar @@ -43,14 +36,5 @@ dependencies { testCompile group: 'org.jetbrains.kotlin', name: 'kotlin-test-junit', version: kotlin_compiler_to_compile_core_version testCompile "com.nhaarman:mockito-kotlin-kt1.1:1.5.0" - intellijCore "com.jetbrains.intellij.idea:intellij-core:$ideaVersion" -} - - -afterEvaluate { - dependencies { - compile zipTree(configurations.intellijCore.singleFile).matching ({ - include("intellij-core-analysis.jar") - }) - } + testCompile ideaRT() } \ No newline at end of file diff --git a/core/src/test/java/com/intellij/rt/execution/junit/FileComparisonFailure.java b/core/src/test/java/com/intellij/rt/execution/junit/FileComparisonFailure.java deleted file mode 100644 index cbb1cc3c..00000000 --- a/core/src/test/java/com/intellij/rt/execution/junit/FileComparisonFailure.java +++ /dev/null @@ -1,39 +0,0 @@ - -package com.intellij.rt.execution.junit; - -import junit.framework.ComparisonFailure; - -public class FileComparisonFailure extends ComparisonFailure implements KnownException { - private final String myExpected; - private final String myActual; - private final String myFilePath; - private final String myActualFilePath; - - public FileComparisonFailure(String message, String expected, String actual, String filePath) { - this(message, expected, actual, filePath, (String)null); - } - - public FileComparisonFailure(String message, String expected, String actual, String expectedFilePath, String actualFilePath) { - super(message, expected, actual); - this.myExpected = expected; - this.myActual = actual; - this.myFilePath = expectedFilePath; - this.myActualFilePath = actualFilePath; - } - - public String getFilePath() { - return this.myFilePath; - } - - public String getActualFilePath() { - return this.myActualFilePath; - } - - public String getExpected() { - return this.myExpected; - } - - public String getActual() { - return this.myActual; - } -} diff --git a/core/src/test/java/com/intellij/rt/execution/junit/KnownException.java b/core/src/test/java/com/intellij/rt/execution/junit/KnownException.java deleted file mode 100644 index c24653ea..00000000 --- a/core/src/test/java/com/intellij/rt/execution/junit/KnownException.java +++ /dev/null @@ -1,6 +0,0 @@ - -package com.intellij.rt.execution.junit; - -interface KnownException { - -} diff --git a/runners/gradle-integration-tests/build.gradle b/runners/gradle-integration-tests/build.gradle index 1b4ff5ed..f807c12b 100644 --- a/runners/gradle-integration-tests/build.gradle +++ b/runners/gradle-integration-tests/build.gradle @@ -14,6 +14,7 @@ dependencies { testCompile group: 'org.jetbrains.kotlin', name: 'kotlin-runtime', version: kotlin_for_gradle_version testCompile group: 'org.jetbrains.kotlin', name: 'kotlin-reflect', version: kotlin_for_gradle_version testCompile group: 'org.jetbrains.kotlin', name: 'kotlin-test', version: kotlin_for_gradle_version + testCompile ideaRT() dokkaPlugin project(path: ':runners:gradle-plugin', configuration: 'shadow') dokkaAndroidPlugin project(path: ':runners:android-gradle-plugin', configuration: 'shadow') diff --git a/runners/gradle-integration-tests/src/test/java/com/intellij/rt/execution/junit/FileComparisonFailure.java b/runners/gradle-integration-tests/src/test/java/com/intellij/rt/execution/junit/FileComparisonFailure.java deleted file mode 100644 index cbb1cc3c..00000000 --- a/runners/gradle-integration-tests/src/test/java/com/intellij/rt/execution/junit/FileComparisonFailure.java +++ /dev/null @@ -1,39 +0,0 @@ - -package com.intellij.rt.execution.junit; - -import junit.framework.ComparisonFailure; - -public class FileComparisonFailure extends ComparisonFailure implements KnownException { - private final String myExpected; - private final String myActual; - private final String myFilePath; - private final String myActualFilePath; - - public FileComparisonFailure(String message, String expected, String actual, String filePath) { - this(message, expected, actual, filePath, (String)null); - } - - public FileComparisonFailure(String message, String expected, String actual, String expectedFilePath, String actualFilePath) { - super(message, expected, actual); - this.myExpected = expected; - this.myActual = actual; - this.myFilePath = expectedFilePath; - this.myActualFilePath = actualFilePath; - } - - public String getFilePath() { - return this.myFilePath; - } - - public String getActualFilePath() { - return this.myActualFilePath; - } - - public String getExpected() { - return this.myExpected; - } - - public String getActual() { - return this.myActual; - } -} diff --git a/runners/gradle-integration-tests/src/test/java/com/intellij/rt/execution/junit/KnownException.java b/runners/gradle-integration-tests/src/test/java/com/intellij/rt/execution/junit/KnownException.java deleted file mode 100644 index c24653ea..00000000 --- a/runners/gradle-integration-tests/src/test/java/com/intellij/rt/execution/junit/KnownException.java +++ /dev/null @@ -1,6 +0,0 @@ - -package com.intellij.rt.execution.junit; - -interface KnownException { - -} -- cgit From b6d79cf83917e6a8c843209df3ffa7d9e54d0917 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Tue, 21 Nov 2017 17:18:25 +0300 Subject: Do not suppress Companions when it's extends/implements something --- core/src/main/kotlin/Kotlin/DocumentationBuilder.kt | 8 +++++--- core/testdata/format/inheritedCompanionObjectProperties.md | 4 ++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt index 856127d3..24840a9d 100644 --- a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt +++ b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt @@ -20,9 +20,7 @@ import org.jetbrains.kotlin.psi.KtModifierListOwner import org.jetbrains.kotlin.psi.KtParameter import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.constants.ConstantValue -import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns -import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe -import org.jetbrains.kotlin.resolve.descriptorUtil.isDocumentedAnnotation +import org.jetbrains.kotlin.resolve.descriptorUtil.* import org.jetbrains.kotlin.resolve.findTopMostOverriddenDescriptors import org.jetbrains.kotlin.resolve.jvm.JavaDescriptorResolver import org.jetbrains.kotlin.resolve.source.PsiSourceElement @@ -576,6 +574,10 @@ class DocumentationBuilder descriptorsToDocument.mapTo(result) { ClassMember(it, inheritedLinkKind = RefKind.InheritedCompanionObjectMember) } + + if (companionObjectDescriptor.getAllSuperclassesWithoutAny().isNotEmpty()) { + result += ClassMember(companionObjectDescriptor) + } } return result } diff --git a/core/testdata/format/inheritedCompanionObjectProperties.md b/core/testdata/format/inheritedCompanionObjectProperties.md index b3b3230e..db764ff0 100644 --- a/core/testdata/format/inheritedCompanionObjectProperties.md +++ b/core/testdata/format/inheritedCompanionObjectProperties.md @@ -4,6 +4,10 @@ `class C : `[`A`](test/-a/index) +### Types + +| [Companion](test/-c/-companion/index) | `companion object Companion : `[`B`](test/-b/index) | + ### Constructors | [<init>](test/-c/-init-) | `C()` | -- cgit From 46af59cc658e4f56b6d2909ab4dc93f43af77dc2 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Tue, 21 Nov 2017 18:58:06 +0300 Subject: Auto-expand type-aliases excluded from documentation --- .../main/kotlin/Kotlin/DeclarationLinkResolver.kt | 10 ++++++-- core/src/test/kotlin/TestAPI.kt | 20 ++++++++++++++-- core/src/test/kotlin/format/MarkdownFormatTest.kt | 27 ++++++++++++++++++---- .../format/notPublishedTypeAliasAutoExpansion.kt | 13 +++++++++++ .../format/notPublishedTypeAliasAutoExpansion.md | 9 ++++++++ 5 files changed, 71 insertions(+), 8 deletions(-) create mode 100644 core/testdata/format/notPublishedTypeAliasAutoExpansion.kt create mode 100644 core/testdata/format/notPublishedTypeAliasAutoExpansion.md diff --git a/core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt b/core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt index 24f50dac..ffef399d 100644 --- a/core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt +++ b/core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt @@ -4,7 +4,10 @@ import com.google.inject.Inject import org.jetbrains.dokka.Model.DescriptorSignatureProvider import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor import org.jetbrains.kotlin.descriptors.DeclarationDescriptor +import org.jetbrains.kotlin.descriptors.TypeAliasDescriptor import org.jetbrains.kotlin.idea.kdoc.resolveKDocLink +import org.jetbrains.kotlin.resolve.descriptorUtil.isEffectivelyPrivateApi +import org.jetbrains.kotlin.resolve.descriptorUtil.isEffectivelyPublicApi class DeclarationLinkResolver @Inject constructor(val resolutionFacade: DokkaResolutionFacade, @@ -32,13 +35,13 @@ class DeclarationLinkResolver return ContentExternalLink(externalHref) } val signature = descriptorSignatureProvider.signature(symbol) - val referencedAt = fromDescriptor.sourceLocation()?.let { ", referenced at $it" }.orEmpty() + val referencedAt = fromDescriptor.signatureWithSourceLocation() return ContentNodeLazyLink(href, { -> val target = refGraph.lookup(signature) if (target == null) { - logger.warn("Can't find node by signature $signature$referencedAt") + logger.warn("Can't find node by signature $signature, referenced at $referencedAt") } target }) @@ -63,6 +66,9 @@ class DeclarationLinkResolver if (symbol is CallableMemberDescriptor && symbol.kind == CallableMemberDescriptor.Kind.FAKE_OVERRIDE) { return symbol.overriddenDescriptors.firstOrNull() } + if (symbol is TypeAliasDescriptor && !symbol.isDocumented(options)) { + return symbol.classDescriptor + } return symbol } diff --git a/core/src/test/kotlin/TestAPI.kt b/core/src/test/kotlin/TestAPI.kt index a1a98ec7..6c62c998 100644 --- a/core/src/test/kotlin/TestAPI.kt +++ b/core/src/test/kotlin/TestAPI.kt @@ -151,8 +151,15 @@ fun verifyOutput(roots: Array, withJdk: Boolean = false, withKotlinRuntime: Boolean = false, format: String = "html", + includeNonPublic: Boolean = true, outputGenerator: (DocumentationModule, StringBuilder) -> Unit) { - verifyModel(*roots, withJdk = withJdk, withKotlinRuntime = withKotlinRuntime, format = format) { + verifyModel( + *roots, + withJdk = withJdk, + withKotlinRuntime = withKotlinRuntime, + format = format, + includeNonPublic = includeNonPublic + ) { verifyModelOutput(it, outputExtension, roots.first().path, outputGenerator) } } @@ -173,8 +180,17 @@ fun verifyOutput(path: String, withJdk: Boolean = false, withKotlinRuntime: Boolean = false, format: String = "html", + includeNonPublic: Boolean = true, outputGenerator: (DocumentationModule, StringBuilder) -> Unit) { - verifyOutput(arrayOf(contentRootFromPath(path)), outputExtension, withJdk, withKotlinRuntime, format, outputGenerator) + verifyOutput( + arrayOf(contentRootFromPath(path)), + outputExtension, + withJdk, + withKotlinRuntime, + format, + includeNonPublic, + outputGenerator + ) } fun verifyJavaOutput(path: String, diff --git a/core/src/test/kotlin/format/MarkdownFormatTest.kt b/core/src/test/kotlin/format/MarkdownFormatTest.kt index a2891c47..f572922c 100644 --- a/core/src/test/kotlin/format/MarkdownFormatTest.kt +++ b/core/src/test/kotlin/format/MarkdownFormatTest.kt @@ -392,6 +392,10 @@ class MarkdownFormatTest { verifyMarkdownNode("typeParameterReference") } + @Test fun notPublishedTypeAliasAutoExpansion() { + verifyMarkdownNodeByName("notPublishedTypeAliasAutoExpansion", "foo", includeNonPublic = false) + } + private fun buildMultiplePlatforms(path: String): DocumentationModule { val module = DocumentationModule("test") val options = DocumentationOptions("", "html", generateIndexPages = false, noStdlibLink = true) @@ -428,8 +432,18 @@ class MarkdownFormatTest { verifyMarkdownNodes(fileName, withKotlinRuntime) { model -> model.members.single().members } } - private fun verifyMarkdownNodes(fileName: String, withKotlinRuntime: Boolean = false, nodeFilter: (DocumentationModule) -> List) { - verifyOutput("testdata/format/$fileName.kt", ".md", withKotlinRuntime = withKotlinRuntime) { model, output -> + private fun verifyMarkdownNodes( + fileName: String, + withKotlinRuntime: Boolean = false, + includeNonPublic: Boolean = true, + nodeFilter: (DocumentationModule) -> List + ) { + verifyOutput( + "testdata/format/$fileName.kt", + ".md", + withKotlinRuntime = withKotlinRuntime, + includeNonPublic = includeNonPublic + ) { model, output -> markdownService.createOutputBuilder(output, tempLocation).appendNodes(nodeFilter(model)) } } @@ -444,8 +458,13 @@ class MarkdownFormatTest { } } - private fun verifyMarkdownNodeByName(fileName: String, name: String, withKotlinRuntime: Boolean = false) { - verifyMarkdownNodes(fileName, withKotlinRuntime) { model-> + private fun verifyMarkdownNodeByName( + fileName: String, + name: String, + withKotlinRuntime: Boolean = false, + includeNonPublic: Boolean = true + ) { + verifyMarkdownNodes(fileName, withKotlinRuntime, includeNonPublic) { model-> val nodesWithName = model.members.single().members.filter { it.name == name } if (nodesWithName.isEmpty()) { throw IllegalArgumentException("Found no nodes named $name") diff --git a/core/testdata/format/notPublishedTypeAliasAutoExpansion.kt b/core/testdata/format/notPublishedTypeAliasAutoExpansion.kt new file mode 100644 index 00000000..1f29e110 --- /dev/null +++ b/core/testdata/format/notPublishedTypeAliasAutoExpansion.kt @@ -0,0 +1,13 @@ + +class A +class B + + +internal typealias TA = A +private typealias TB = B + +/** + * Correct ref [TA] + * Correct ref [TB] + */ +fun foo() {} \ No newline at end of file diff --git a/core/testdata/format/notPublishedTypeAliasAutoExpansion.md b/core/testdata/format/notPublishedTypeAliasAutoExpansion.md new file mode 100644 index 00000000..9e0f1560 --- /dev/null +++ b/core/testdata/format/notPublishedTypeAliasAutoExpansion.md @@ -0,0 +1,9 @@ +[test](test/index) / [foo](test/foo) + +# foo + +`fun foo(): Unit` + +Correct ref [TA](test/-a/index) +Correct ref [TB](test/-b/index) + -- cgit From 454b4a4c8490a04fcfe17309596c6316cd321113 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Tue, 21 Nov 2017 19:46:20 +0300 Subject: Fix suppressing of companion when it implements some interface --- core/src/main/kotlin/Kotlin/DocumentationBuilder.kt | 3 ++- core/src/test/kotlin/format/MarkdownFormatTest.kt | 4 ++++ core/testdata/format/companionImplements.kt | 9 +++++++++ core/testdata/format/companionImplements.md | 16 ++++++++++++++++ 4 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 core/testdata/format/companionImplements.kt create mode 100644 core/testdata/format/companionImplements.md diff --git a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt index 24840a9d..0f6f217e 100644 --- a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt +++ b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt @@ -575,7 +575,8 @@ class DocumentationBuilder ClassMember(it, inheritedLinkKind = RefKind.InheritedCompanionObjectMember) } - if (companionObjectDescriptor.getAllSuperclassesWithoutAny().isNotEmpty()) { + if (companionObjectDescriptor.getAllSuperclassesWithoutAny().isNotEmpty() + || companionObjectDescriptor.getSuperInterfaces().isNotEmpty()) { result += ClassMember(companionObjectDescriptor) } } diff --git a/core/src/test/kotlin/format/MarkdownFormatTest.kt b/core/src/test/kotlin/format/MarkdownFormatTest.kt index f572922c..d2ab5b5c 100644 --- a/core/src/test/kotlin/format/MarkdownFormatTest.kt +++ b/core/src/test/kotlin/format/MarkdownFormatTest.kt @@ -396,6 +396,10 @@ class MarkdownFormatTest { verifyMarkdownNodeByName("notPublishedTypeAliasAutoExpansion", "foo", includeNonPublic = false) } + @Test fun companionImplements() { + verifyMarkdownNodeByName("companionImplements", "Foo") + } + private fun buildMultiplePlatforms(path: String): DocumentationModule { val module = DocumentationModule("test") val options = DocumentationOptions("", "html", generateIndexPages = false, noStdlibLink = true) diff --git a/core/testdata/format/companionImplements.kt b/core/testdata/format/companionImplements.kt new file mode 100644 index 00000000..154ef9b1 --- /dev/null +++ b/core/testdata/format/companionImplements.kt @@ -0,0 +1,9 @@ + +interface Bar + +/** + * Correct ref [Foo.Companion] + */ +class Foo { + companion object : Bar +} \ No newline at end of file diff --git a/core/testdata/format/companionImplements.md b/core/testdata/format/companionImplements.md new file mode 100644 index 00000000..8a93ed6b --- /dev/null +++ b/core/testdata/format/companionImplements.md @@ -0,0 +1,16 @@ +[test](test/index) / [Foo](test/-foo/index) + +# Foo + +`class Foo` + +Correct ref [Foo.Companion](test/-foo/-companion) + +### Types + +| [Companion](test/-foo/-companion) | `companion object Companion : `[`Bar`](test/-bar) | + +### Constructors + +| [<init>](test/-foo/-init-) | `Foo()`
Correct ref [Foo.Companion](test/-foo/-companion) | + -- cgit From c821247cf3c342788e372470cf9c3ff9c2665a7f Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Wed, 22 Nov 2017 17:52:32 +0300 Subject: Use / for receiver parameter signature --- core/src/main/kotlin/Kotlin/DocumentationBuilder.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt index 0f6f217e..8f8c08a4 100644 --- a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt +++ b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt @@ -922,7 +922,7 @@ fun DeclarationDescriptor.signature(): String { is FunctionDescriptor -> containingDeclaration.signature() + "$" + name + parameterSignature() is ValueParameterDescriptor -> containingDeclaration.signature() + "/" + name is TypeParameterDescriptor -> containingDeclaration.signature() + "*" + name - is ReceiverParameterDescriptor -> containingDeclaration.signature() + "*" + name + is ReceiverParameterDescriptor -> containingDeclaration.signature() + "/" + name else -> throw UnsupportedOperationException("Don't know how to calculate signature for $this") } } -- cgit From 2a62816f1a50f03927dad34eb0ee80a889cb9e7e Mon Sep 17 00:00:00 2001 From: Chris Rankin Date: Thu, 5 Oct 2017 17:51:24 +0100 Subject: Add "suppress" to the per-package configuration options. --- core/src/main/kotlin/DokkaBootstrapImpl.kt | 3 ++- core/src/main/kotlin/Generation/configurationImpl.kt | 3 ++- integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt | 1 + runners/ant/src/main/kotlin/ant/dokka.kt | 3 ++- runners/cli/src/main/kotlin/cli/main.kt | 2 +- runners/gradle-plugin/src/main/kotlin/main.kt | 1 + runners/maven-plugin/src/main/kotlin/DokkaMojo.kt | 2 ++ 7 files changed, 11 insertions(+), 4 deletions(-) diff --git a/core/src/main/kotlin/DokkaBootstrapImpl.kt b/core/src/main/kotlin/DokkaBootstrapImpl.kt index e9d0f3d5..0aea4422 100644 --- a/core/src/main/kotlin/DokkaBootstrapImpl.kt +++ b/core/src/main/kotlin/DokkaBootstrapImpl.kt @@ -17,7 +17,8 @@ fun parsePerPackageOptions(arg: String): List { val deprecated = args.find { it.endsWith("deprecated") }?.startsWith("+") ?: true val reportUndocumented = args.find { it.endsWith("warnUndocumented") }?.startsWith("+") ?: true val privateApi = args.find { it.endsWith("privateApi") }?.startsWith("+") ?: false - PackageOptionsImpl(prefix, includeNonPublic = privateApi, reportUndocumented = reportUndocumented, skipDeprecated = !deprecated) + val suppress = args.find { it.endsWith("suppress") }?.startsWith("+") ?: false + PackageOptionsImpl(prefix, includeNonPublic = privateApi, reportUndocumented = reportUndocumented, skipDeprecated = !deprecated, suppress = suppress) } } diff --git a/core/src/main/kotlin/Generation/configurationImpl.kt b/core/src/main/kotlin/Generation/configurationImpl.kt index f67582a7..befe7e72 100644 --- a/core/src/main/kotlin/Generation/configurationImpl.kt +++ b/core/src/main/kotlin/Generation/configurationImpl.kt @@ -32,7 +32,8 @@ class SourceRootImpl(path: String, override val platforms: List = emptyL data class PackageOptionsImpl(override val prefix: String, override val includeNonPublic: Boolean = false, override val reportUndocumented: Boolean = true, - override val skipDeprecated: Boolean = false) : DokkaConfiguration.PackageOptions + override val skipDeprecated: Boolean = false, + override val suppress: Boolean = false) : DokkaConfiguration.PackageOptions data class DokkaConfigurationImpl(override val moduleName: String, override val classpath: List, diff --git a/integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt b/integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt index 4c4d479f..fd6a4209 100644 --- a/integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt +++ b/integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt @@ -56,6 +56,7 @@ interface DokkaConfiguration { val includeNonPublic: Boolean val reportUndocumented: Boolean val skipDeprecated: Boolean + val suppress: Boolean } interface ExternalDocumentationLink { diff --git a/runners/ant/src/main/kotlin/ant/dokka.kt b/runners/ant/src/main/kotlin/ant/dokka.kt index fb70aefd..2872f845 100644 --- a/runners/ant/src/main/kotlin/ant/dokka.kt +++ b/runners/ant/src/main/kotlin/ant/dokka.kt @@ -28,7 +28,8 @@ class AntPackageOptions( override var prefix: String = "", override var includeNonPublic: Boolean = false, override var reportUndocumented: Boolean = true, - override var skipDeprecated: Boolean = false) : DokkaConfiguration.PackageOptions + override var skipDeprecated: Boolean = false, + override var suppress: Boolean = false) : DokkaConfiguration.PackageOptions class DokkaAntTask: Task() { diff --git a/runners/cli/src/main/kotlin/cli/main.kt b/runners/cli/src/main/kotlin/cli/main.kt index 77ca57f6..b6eb1564 100644 --- a/runners/cli/src/main/kotlin/cli/main.kt +++ b/runners/cli/src/main/kotlin/cli/main.kt @@ -44,7 +44,7 @@ class DokkaArguments { @set:Argument(value = "impliedPlatforms", description = "List of implied platforms (comma-separated)") var impliedPlatforms: String = "" - @set:Argument(value = "packageOptions", description = "List of package options in format \"prefix,-deprecated,-privateApi,+warnUndocumented;...\" ") + @set:Argument(value = "packageOptions", description = "List of package options in format \"prefix,-deprecated,-privateApi,+warnUndocumented,+suppress;...\" ") var packageOptions: String = "" @set:Argument(value = "links", description = "External documentation links in format url^packageListUrl^^url2...") diff --git a/runners/gradle-plugin/src/main/kotlin/main.kt b/runners/gradle-plugin/src/main/kotlin/main.kt index fc5eb77c..48d874a8 100644 --- a/runners/gradle-plugin/src/main/kotlin/main.kt +++ b/runners/gradle-plugin/src/main/kotlin/main.kt @@ -422,4 +422,5 @@ class PackageOptions : Serializable, DokkaConfiguration.PackageOptions { override var includeNonPublic: Boolean = false override var reportUndocumented: Boolean = true override var skipDeprecated: Boolean = false + override var suppress: Boolean = false } diff --git a/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt b/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt index 345de523..c0904396 100644 --- a/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt +++ b/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt @@ -50,6 +50,8 @@ abstract class AbstractDokkaMojo : AbstractMojo() { override var reportUndocumented: Boolean = true @Parameter override var skipDeprecated: Boolean = false + @Parameter + override var suppress: Boolean = false } @Parameter(required = true, defaultValue = "\${project.compileSourceRoots}") -- cgit From f941d6adefa71d2b3b1cc69120edf7eae70187ba Mon Sep 17 00:00:00 2001 From: Chris Rankin Date: Fri, 6 Oct 2017 14:14:09 +0100 Subject: Add new "suppress" per-package option. --- .../kotlin/Java/JavaPsiDocumentationBuilder.kt | 4 ++- .../src/main/kotlin/Kotlin/DocumentationBuilder.kt | 2 +- core/src/test/kotlin/TestAPI.kt | 2 ++ core/src/test/kotlin/model/PackageTest.kt | 35 ++++++++++++++++++++-- core/testdata/packages/classInPackage.kt | 3 ++ 5 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 core/testdata/packages/classInPackage.kt diff --git a/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt b/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt index 6b1f8cb4..cf2b0514 100644 --- a/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt +++ b/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt @@ -58,7 +58,7 @@ class JavaPsiDocumentationBuilder : JavaDocumentationBuilder { } override fun appendFile(file: PsiJavaFile, module: DocumentationModule, packageContent: Map) { - if (file.classes.all { skipElement(it) }) { + if (skipFile(file) || file.classes.all { skipElement(it) }) { return } val packageNode = module.findOrCreatePackageNode(file.packageName, emptyMap(), refGraph) @@ -132,6 +132,8 @@ class JavaPsiDocumentationBuilder : JavaDocumentationBuilder { } } + private fun skipFile(javaFile: PsiJavaFile): Boolean = options.effectivePackageOptions(javaFile.packageName).suppress + private fun skipElement(element: Any) = skipElementByVisibility(element) || hasSuppressDocTag(element) || diff --git a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt index 8f8c08a4..8d34a6f1 100644 --- a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt +++ b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt @@ -790,7 +790,7 @@ fun DeclarationDescriptor.isDocumented(options: DocumentationOptions): Boolean { return (options.effectivePackageOptions(fqNameSafe).includeNonPublic || this !is MemberDescriptor || this.visibility in visibleToDocumentation) && - !isDocumentationSuppressed(options) && + !isDocumentationSuppressed(options) && !options.effectivePackageOptions(fqNameSafe).suppress && (!options.effectivePackageOptions(fqNameSafe).skipDeprecated || !isDeprecated()) } diff --git a/core/src/test/kotlin/TestAPI.kt b/core/src/test/kotlin/TestAPI.kt index 6c62c998..8bbeb2f2 100644 --- a/core/src/test/kotlin/TestAPI.kt +++ b/core/src/test/kotlin/TestAPI.kt @@ -24,6 +24,7 @@ fun verifyModel(vararg roots: ContentRoot, withKotlinRuntime: Boolean = false, format: String = "html", includeNonPublic: Boolean = true, + perPackageOptions: List = emptyList(), verifier: (DocumentationModule) -> Unit) { val documentation = DocumentationModule("test") @@ -32,6 +33,7 @@ fun verifyModel(vararg roots: ContentRoot, skipEmptyPackages = false, includeRootPackage = true, sourceLinks = listOf(), + perPackageOptions = perPackageOptions, generateIndexPages = false, noStdlibLink = true, cacheRoot = "default") diff --git a/core/src/test/kotlin/model/PackageTest.kt b/core/src/test/kotlin/model/PackageTest.kt index 97810e80..052f0d28 100644 --- a/core/src/test/kotlin/model/PackageTest.kt +++ b/core/src/test/kotlin/model/PackageTest.kt @@ -2,10 +2,10 @@ package org.jetbrains.dokka.tests import org.jetbrains.dokka.Content import org.jetbrains.dokka.NodeKind +import org.jetbrains.dokka.PackageOptionsImpl import org.jetbrains.kotlin.config.KotlinSourceRoot +import org.junit.Assert.* import org.junit.Test -import org.junit.Assert.assertEquals -import org.junit.Assert.assertTrue public class PackageTest { @Test fun rootPackage() { @@ -83,4 +83,33 @@ public class PackageTest { } } } -} \ No newline at end of file + + @Test fun classAtPackageLevel() { + verifyModel(KotlinSourceRoot("testdata/packages/classInPackage.kt")) { model -> + assertEquals(1, model.members.count()) + with(model.members.elementAt(0)) { + assertEquals(NodeKind.Package, kind) + assertEquals("simple.name", name) + assertEquals(Content.Empty, content) + assertTrue(details.none()) + assertEquals(1, members.size) + assertTrue(links.none()) + } + } + } + + @Test fun suppressAtPackageLevel() { + verifyModel(KotlinSourceRoot("testdata/packages/classInPackage.kt"), + perPackageOptions = listOf(PackageOptionsImpl(prefix = "simple.name", suppress = true))) { model -> + assertEquals(1, model.members.count()) + with(model.members.elementAt(0)) { + assertEquals(NodeKind.Package, kind) + assertEquals("simple.name", name) + assertEquals(Content.Empty, content) + assertTrue(details.none()) + assertTrue(members.none()) + assertTrue(links.none()) + } + } + } +} diff --git a/core/testdata/packages/classInPackage.kt b/core/testdata/packages/classInPackage.kt new file mode 100644 index 00000000..b22273af --- /dev/null +++ b/core/testdata/packages/classInPackage.kt @@ -0,0 +1,3 @@ +package simple.name + +class Foo {} -- cgit From dc7ddcc57f07fc72e2c42f820b7852dd555a2891 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Thu, 23 Nov 2017 15:36:01 +0300 Subject: Cleanup GH-222 a bit --- core/src/main/kotlin/Kotlin/DocumentationBuilder.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt index 8d34a6f1..2998e314 100644 --- a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt +++ b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt @@ -789,9 +789,9 @@ val visibleToDocumentation = setOf(Visibilities.PROTECTED, Visibilities.PUBLIC) fun DeclarationDescriptor.isDocumented(options: DocumentationOptions): Boolean { return (options.effectivePackageOptions(fqNameSafe).includeNonPublic || this !is MemberDescriptor - || this.visibility in visibleToDocumentation) && - !isDocumentationSuppressed(options) && !options.effectivePackageOptions(fqNameSafe).suppress && - (!options.effectivePackageOptions(fqNameSafe).skipDeprecated || !isDeprecated()) + || this.visibility in visibleToDocumentation) + && !isDocumentationSuppressed(options) + && (!options.effectivePackageOptions(fqNameSafe).skipDeprecated || !isDeprecated()) } private fun DeclarationDescriptor.isGenerated() = this is CallableMemberDescriptor && kind != CallableMemberDescriptor.Kind.DECLARATION @@ -861,6 +861,8 @@ fun AnnotationDescriptor.mustBeDocumented(): Boolean { fun DeclarationDescriptor.isDocumentationSuppressed(options: DocumentationOptions): Boolean { + if (options.effectivePackageOptions(fqNameSafe).suppress) return true + val path = this.findPsi()?.containingFile?.virtualFile?.path if (path != null) { if (File(path).absoluteFile in options.suppressedFiles) return true -- cgit From ac00e0375473a5de711f7866cb17ea5c82f4e7a5 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Tue, 14 Nov 2017 13:32:46 +0300 Subject: Fix bundling of kotlin-runtime & reflect into Gradle plugin Fix #219 --- integration/build.gradle | 8 +++++--- runners/gradle-plugin/build.gradle | 7 +------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/integration/build.gradle b/integration/build.gradle index 55ac9dca..571ad0b3 100644 --- a/integration/build.gradle +++ b/integration/build.gradle @@ -7,7 +7,9 @@ buildscript { apply plugin: 'kotlin' dependencies { - compile group: 'org.jetbrains.kotlin', name: 'kotlin-runtime', version: kotlin_for_gradle_version - compile group: 'org.jetbrains.kotlin', name: 'kotlin-reflect', version: kotlin_for_gradle_version - compile 'com.github.yole:jkid:7d9c529c87' + compileOnly group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version: kotlin_for_gradle_version + compileOnly group: 'org.jetbrains.kotlin', name: 'kotlin-reflect', version: kotlin_for_gradle_version + compile('com.github.yole:jkid:7d9c529c87') { + transitive = false + } } \ No newline at end of file diff --git a/runners/gradle-plugin/build.gradle b/runners/gradle-plugin/build.gradle index fff58092..21603a26 100644 --- a/runners/gradle-plugin/build.gradle +++ b/runners/gradle-plugin/build.gradle @@ -6,18 +6,13 @@ sourceCompatibility = 1.8 apply plugin: 'com.github.johnrengelman.shadow' apply plugin: "com.gradle.plugin-publish" -tasks.withType(AbstractCompile) { - classpath += configurations.shadow -} - compileKotlin { - kotlinOptions { freeCompilerArgs += "-Xjsr305-annotations=strict" } - } + dependencies { testCompile group: 'junit', name: 'junit', version: '4.12' -- cgit From f94beaa25f07333ad47738d5d7fafdd3dd302b04 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Tue, 14 Nov 2017 16:19:46 +0300 Subject: Clarify Kotlin Versions and config in project --- build.gradle | 4 ++-- core/build.gradle | 26 +++++++++++++++++--------- gradle.properties | 7 +++---- integration/build.gradle | 17 ++++++++++++++--- runners/android-gradle-plugin/build.gradle | 12 +++++++++--- runners/ant/build.gradle | 11 ++++++++++- runners/build.gradle | 12 ++---------- runners/cli/build.gradle | 10 +++++++++- runners/fatjar/build.gradle | 2 +- runners/gradle-integration-tests/build.gradle | 16 +++++++++++++--- runners/gradle-plugin/build.gradle | 13 ++++++++----- runners/maven-plugin/build.gradle | 15 ++++++++++----- 12 files changed, 98 insertions(+), 47 deletions(-) diff --git a/build.gradle b/build.gradle index e64427b7..0002ee69 100644 --- a/build.gradle +++ b/build.gradle @@ -31,7 +31,7 @@ allprojects { maven { url "http://dl.bintray.com/kotlin/kotlin-eap" } maven { url "https://dl.bintray.com/kotlin/kotlin-dev" } maven { url 'https://jitpack.io' } - maven { url "https://teamcity.jetbrains.com/guestAuth/repository/download/Kotlin_dev_CompilerAllPlugins/$kotlin_compiler_version/maven" } + maven { url "https://teamcity.jetbrains.com/guestAuth/repository/download/Kotlin_dev_CompilerAllPlugins/$bundled_kotlin_compiler_version/maven" } ivy(repo) } } @@ -67,7 +67,7 @@ task wrapper(type: Wrapper) { distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip" } -def versions = DependenciesVersionGetter.getVersions(project, kotlin_compiler_version) +def versions = DependenciesVersionGetter.getVersions(project, bundled_kotlin_compiler_version) ext.ideaVersion = versions["idea.build.id"] diff --git a/core/build.gradle b/core/build.gradle index 68d3da89..a8f0f275 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -2,26 +2,34 @@ import javax.tools.ToolProvider buildscript { dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_compiler_to_compile_core_version" + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } apply plugin: 'kotlin' -sourceCompatibility = 1.6 +sourceCompatibility = 1.8 + +tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { + kotlinOptions { + languageVersion = "1.2" + apiVersion = languageVersion + jvmTarget = "1.8" + } +} dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_compiler_version" - compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_compiler_version" + compile "org.jetbrains.kotlin:kotlin-stdlib:$bundled_kotlin_compiler_version" + compile "org.jetbrains.kotlin:kotlin-reflect:$bundled_kotlin_compiler_version" compile group: 'com.google.inject', name: 'guice', version: '3.0' compile "org.jsoup:jsoup:1.8.3" - compile "org.jetbrains.kotlin:kotlin-compiler:$kotlin_compiler_version" - compile "org.jetbrains.kotlin:kotlin-script-runtime:$kotlin_compiler_version" + compile "org.jetbrains.kotlin:kotlin-compiler:$bundled_kotlin_compiler_version" + compile "org.jetbrains.kotlin:kotlin-script-runtime:$bundled_kotlin_compiler_version" - compile "teamcity:kotlin-ide-common:$kotlin_compiler_version" - compile "teamcity:markdown:$kotlin_compiler_version" + compile "teamcity:kotlin-ide-common:$bundled_kotlin_compiler_version" + compile "teamcity:markdown:$bundled_kotlin_compiler_version" compile intellijCoreAnalysis() @@ -33,7 +41,7 @@ dependencies { compile project(":integration") testCompile group: 'junit', name: 'junit', version: '4.12' - testCompile group: 'org.jetbrains.kotlin', name: 'kotlin-test-junit', version: kotlin_compiler_to_compile_core_version + testCompile group: 'org.jetbrains.kotlin', name: 'kotlin-test-junit', version: kotlin_version testCompile "com.nhaarman:mockito-kotlin-kt1.1:1.5.0" testCompile ideaRT() diff --git a/gradle.properties b/gradle.properties index 154d7776..d109426b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,10 +2,9 @@ dokka_version=0.9.16 dokka_publication_channel=dokka #Kotlin compiler and plugin -kotlin_version=1.1.51 -kotlin_compiler_version=1.2.20-dev-175 -kotlin_compiler_to_compile_core_version=1.2.0-rc-39 -kotlin_for_gradle_version=1.0.7 +bundled_kotlin_compiler_version=1.2.20-dev-175 +kotlin_version=1.2.0-rc-39 +kotlin_for_gradle_runtime_version=1.0.7 #IntelliJ plugin to download openapi.jar gradle_intellij_plugin_version=0.3.0-SNAPSHOT diff --git a/integration/build.gradle b/integration/build.gradle index 571ad0b3..32ca3454 100644 --- a/integration/build.gradle +++ b/integration/build.gradle @@ -1,14 +1,25 @@ buildscript { dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_for_gradle_version" + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } apply plugin: 'kotlin' + +sourceCompatibility = 1.8 + +tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { + kotlinOptions { + languageVersion = "1.2" + apiVersion = "1.0" + jvmTarget = "1.8" + } +} + dependencies { - compileOnly group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version: kotlin_for_gradle_version - compileOnly group: 'org.jetbrains.kotlin', name: 'kotlin-reflect', version: kotlin_for_gradle_version + compileOnly group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version: kotlin_for_gradle_runtime_version + compileOnly group: 'org.jetbrains.kotlin', name: 'kotlin-reflect', version: kotlin_for_gradle_runtime_version compile('com.github.yole:jkid:7d9c529c87') { transitive = false } diff --git a/runners/android-gradle-plugin/build.gradle b/runners/android-gradle-plugin/build.gradle index 193b8eee..5050fd87 100644 --- a/runners/android-gradle-plugin/build.gradle +++ b/runners/android-gradle-plugin/build.gradle @@ -3,13 +3,19 @@ import org.jetbrains.CorrectShadowPublishing apply plugin: 'java' apply plugin: 'kotlin' -sourceCompatibility = 1.8 apply plugin: 'com.github.johnrengelman.shadow' apply plugin: "com.gradle.plugin-publish" -tasks.withType(AbstractCompile) { - classpath += configurations.shadow +sourceCompatibility = 1.8 + +tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { + kotlinOptions { + freeCompilerArgs += "-Xjsr305=strict" + languageVersion = "1.2" + apiVersion = "1.0" + jvmTarget = "1.8" + } } repositories { diff --git a/runners/ant/build.gradle b/runners/ant/build.gradle index 85328d95..e7dcd441 100644 --- a/runners/ant/build.gradle +++ b/runners/ant/build.gradle @@ -1,6 +1,15 @@ apply plugin: 'kotlin' -sourceCompatibility = 1.6 +sourceCompatibility = 1.8 + +tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { + kotlinOptions { + freeCompilerArgs += "-Xjsr305=strict" + languageVersion = "1.2" + apiVersion = languageVersion + jvmTarget = "1.8" + } +} dependencies { compile project(":core") diff --git a/runners/build.gradle b/runners/build.gradle index f1d2873c..23d232d2 100644 --- a/runners/build.gradle +++ b/runners/build.gradle @@ -1,15 +1,7 @@ -configure([project("ant"), project("cli"), project("fatjar"), project("maven-plugin")]) { +subprojects { buildscript { dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } -} - -configure([project("gradle-plugin"), project("android-gradle-plugin"), project("gradle-integration-tests")]) { - buildscript { - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_for_gradle_version" - } - } -} +} \ No newline at end of file diff --git a/runners/cli/build.gradle b/runners/cli/build.gradle index 13b0c941..7f733140 100644 --- a/runners/cli/build.gradle +++ b/runners/cli/build.gradle @@ -1,6 +1,14 @@ apply plugin: 'kotlin' -sourceCompatibility = 1.6 +sourceCompatibility = 1.8 + +tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { + kotlinOptions { + languageVersion = "1.2" + apiVersion = languageVersion + jvmTarget = "1.8" + } +} dependencies { compile project(":core") diff --git a/runners/fatjar/build.gradle b/runners/fatjar/build.gradle index fc9abeda..4ce0416c 100644 --- a/runners/fatjar/build.gradle +++ b/runners/fatjar/build.gradle @@ -1,7 +1,7 @@ import com.github.jengelman.gradle.plugins.shadow.transformers.ServiceFileTransformer import org.jetbrains.PluginXmlTransformer -apply plugin: 'kotlin' +apply plugin: 'java' apply plugin: 'com.github.johnrengelman.shadow' dependencies { diff --git a/runners/gradle-integration-tests/build.gradle b/runners/gradle-integration-tests/build.gradle index f807c12b..1809589f 100644 --- a/runners/gradle-integration-tests/build.gradle +++ b/runners/gradle-integration-tests/build.gradle @@ -2,6 +2,16 @@ apply plugin: 'kotlin' +sourceCompatibility = 1.8 + +tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { + kotlinOptions { + freeCompilerArgs += "-Xjsr305=strict" + languageVersion = "1.2" + apiVersion = "1.0" + jvmTarget = "1.8" + } +} configurations { dokkaPlugin @@ -11,9 +21,9 @@ configurations { dependencies { - testCompile group: 'org.jetbrains.kotlin', name: 'kotlin-runtime', version: kotlin_for_gradle_version - testCompile group: 'org.jetbrains.kotlin', name: 'kotlin-reflect', version: kotlin_for_gradle_version - testCompile group: 'org.jetbrains.kotlin', name: 'kotlin-test', version: kotlin_for_gradle_version + testCompile group: 'org.jetbrains.kotlin', name: 'kotlin-runtime', version: kotlin_for_gradle_runtime_version + testCompile group: 'org.jetbrains.kotlin', name: 'kotlin-reflect', version: kotlin_for_gradle_runtime_version + testCompile group: 'org.jetbrains.kotlin', name: 'kotlin-test', version: kotlin_for_gradle_runtime_version testCompile ideaRT() dokkaPlugin project(path: ':runners:gradle-plugin', configuration: 'shadow') diff --git a/runners/gradle-plugin/build.gradle b/runners/gradle-plugin/build.gradle index 21603a26..790f3132 100644 --- a/runners/gradle-plugin/build.gradle +++ b/runners/gradle-plugin/build.gradle @@ -1,23 +1,26 @@ apply plugin: 'java' apply plugin: 'kotlin' -sourceCompatibility = 1.8 apply plugin: 'com.github.johnrengelman.shadow' apply plugin: "com.gradle.plugin-publish" +sourceCompatibility = 1.8 -compileKotlin { +tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { kotlinOptions { - freeCompilerArgs += "-Xjsr305-annotations=strict" + freeCompilerArgs += "-Xjsr305=strict" + languageVersion = "1.2" + apiVersion = "1.0" + jvmTarget = "1.8" } } dependencies { testCompile group: 'junit', name: 'junit', version: '4.12' - shadow group: 'org.jetbrains.kotlin', name: 'kotlin-runtime', version: kotlin_for_gradle_version - shadow group: 'org.jetbrains.kotlin', name: 'kotlin-reflect', version: kotlin_for_gradle_version + shadow group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version: kotlin_for_gradle_runtime_version + shadow group: 'org.jetbrains.kotlin', name: 'kotlin-reflect', version: kotlin_for_gradle_runtime_version compile project(":integration") diff --git a/runners/maven-plugin/build.gradle b/runners/maven-plugin/build.gradle index a9a77a8b..0e8d6a4d 100644 --- a/runners/maven-plugin/build.gradle +++ b/runners/maven-plugin/build.gradle @@ -1,17 +1,22 @@ import groovy.io.FileType import org.jetbrains.CrossPlatformExec -import shadow.org.apache.commons.io.FileUtils -import java.nio.file.FileVisitResult import java.nio.file.Files -import java.nio.file.Paths import java.nio.file.StandardCopyOption -import java.nio.file.attribute.BasicFileAttributes - apply plugin: 'kotlin' apply plugin: 'com.github.johnrengelman.shadow' +sourceCompatibility = 1.8 + +tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { + kotlinOptions { + freeCompilerArgs += "-Xjsr305=strict" + languageVersion = "1.2" + apiVersion = languageVersion + jvmTarget = "1.8" + } +} dependencies { shadow project(":runners:fatjar") -- cgit From 9733b4be121ae2cf21af99d63be4cdd7f87d1b2f Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Wed, 22 Nov 2017 17:16:05 +0300 Subject: Fix compilation, after enabling JSR305 --- runners/gradle-plugin/src/main/kotlin/main.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runners/gradle-plugin/src/main/kotlin/main.kt b/runners/gradle-plugin/src/main/kotlin/main.kt index 48d874a8..3269395d 100644 --- a/runners/gradle-plugin/src/main/kotlin/main.kt +++ b/runners/gradle-plugin/src/main/kotlin/main.kt @@ -341,7 +341,7 @@ open class DokkaTask : DefaultTask() { project.files(collectSourceRoots().map { project.fileTree(File(it.path)) }) + project.files(fullClasspath.map { project.fileTree(it) }) + project.files(includes) + - project.files(samples.map { project.fileTree(it) }) + project.files(samples.filterNotNull().map { project.fileTree(it) }) } @OutputDirectory -- cgit From a88cd9d682866df1f379447ea07928463ee0f696 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Thu, 23 Nov 2017 18:55:33 +0300 Subject: Don't require JavaPluginConvention --- runners/gradle-plugin/src/main/kotlin/main.kt | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/runners/gradle-plugin/src/main/kotlin/main.kt b/runners/gradle-plugin/src/main/kotlin/main.kt index 3269395d..623a627c 100644 --- a/runners/gradle-plugin/src/main/kotlin/main.kt +++ b/runners/gradle-plugin/src/main/kotlin/main.kt @@ -307,9 +307,7 @@ open class DokkaTask : DefaultTask() { val allConfigurations = project.configurations val fromConfigurations = - processConfigurations.map { - allConfigurations?.getByName(it.toString()) ?: throw IllegalArgumentException("No configuration $it found") - }.flatten() + processConfigurations.flatMap { allConfigurations.getByName(it.toString()) } return fromConfigurations } @@ -319,10 +317,11 @@ open class DokkaTask : DefaultTask() { logger.info("Dokka: Taking source directories provided by the user") sourceDirs.toSet() } else if (kotlinTasks.isEmpty()) { - logger.info("Dokka: Taking source directories from default java plugin") - val javaPluginConvention = project.convention.getPlugin(JavaPluginConvention::class.java) - val sourceSets = javaPluginConvention.sourceSets?.findByName(SourceSet.MAIN_SOURCE_SET_NAME) - sourceSets?.allSource?.srcDirs + project.convention.findPlugin(JavaPluginConvention::class.java)?.let { javaPluginConvention -> + logger.info("Dokka: Taking source directories from default java plugin") + val sourceSets = javaPluginConvention.sourceSets.findByName(SourceSet.MAIN_SOURCE_SET_NAME) + sourceSets?.allSource?.srcDirs + } } else { emptySet() } -- cgit From d3632025ad78af2809f751543f78013c8a4e6def Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Fri, 24 Nov 2017 22:30:08 +0300 Subject: Add warning on unresolved link in packageDocs --- core/src/main/kotlin/Model/PackageDocs.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/main/kotlin/Model/PackageDocs.kt b/core/src/main/kotlin/Model/PackageDocs.kt index 3b03324c..1f6bdcb9 100644 --- a/core/src/main/kotlin/Model/PackageDocs.kt +++ b/core/src/main/kotlin/Model/PackageDocs.kt @@ -32,7 +32,7 @@ class PackageDocs targetContent = findTargetContent(headingText.trimStart()) } } else { - buildContentTo(it, targetContent, LinkResolver(linkMap, { resolveContentLink(it, linkResolveContext) })) + buildContentTo(it, targetContent, LinkResolver(linkMap, { resolveContentLink(fileName, it, linkResolveContext) })) } } } else { @@ -53,7 +53,7 @@ class PackageDocs private fun findOrCreatePackageContent(packageName: String) = _packageContent.getOrPut(packageName) { -> MutableContent() } - private fun resolveContentLink(href: String, linkResolveContext: List): ContentBlock { + private fun resolveContentLink(fileName: String, href: String, linkResolveContext: List): ContentBlock { if (linkResolver != null) { linkResolveContext .asSequence() @@ -62,6 +62,7 @@ class PackageDocs .firstOrNull() ?.let { return it } } + logger.warn("Unresolved link to `$href` in include ($fileName)") return ContentExternalLink("#") } } \ No newline at end of file -- cgit From 63c9a7b4641e3306c01a1a000b683ef3103e958c Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Fri, 24 Nov 2017 23:55:47 +0300 Subject: Set readTimeout in ExternalDocumentationLinkResolver --- core/src/main/kotlin/Kotlin/ExternalDocumentationLinkResolver.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/core/src/main/kotlin/Kotlin/ExternalDocumentationLinkResolver.kt b/core/src/main/kotlin/Kotlin/ExternalDocumentationLinkResolver.kt index f28fcc16..108cee78 100644 --- a/core/src/main/kotlin/Kotlin/ExternalDocumentationLinkResolver.kt +++ b/core/src/main/kotlin/Kotlin/ExternalDocumentationLinkResolver.kt @@ -43,6 +43,7 @@ class ExternalDocumentationLinkResolver @Inject constructor( fun URL.doOpenConnectionToReadContent(timeout: Int = 10000, redirectsAllowed: Int = 16): URLConnection { val connection = this.openConnection() connection.connectTimeout = timeout + connection.readTimeout = timeout when (connection) { is HttpURLConnection -> { -- cgit From cc2a478ff0f1831be2333bf97712e1ffe9d764fe Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Fri, 24 Nov 2017 23:57:04 +0300 Subject: Use kotlin-ide-common with fixed package docs resolution --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index d109426b..e046e1a3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ dokka_version=0.9.16 dokka_publication_channel=dokka #Kotlin compiler and plugin -bundled_kotlin_compiler_version=1.2.20-dev-175 +bundled_kotlin_compiler_version=1.2.20-dev-419 kotlin_version=1.2.0-rc-39 kotlin_for_gradle_runtime_version=1.0.7 -- cgit From 13c4cb93f55693f3bfa396ccad9549d8654ec3f9 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Mon, 27 Nov 2017 16:05:59 +0300 Subject: Add language version arguments --- .../main/kotlin/Analysis/AnalysisEnvironment.kt | 9 +++- core/src/main/kotlin/DokkaBootstrapImpl.kt | 2 + core/src/main/kotlin/Generation/DokkaGenerator.kt | 2 + .../main/kotlin/Generation/configurationImpl.kt | 46 +++++++++++---------- .../src/main/kotlin/Kotlin/DocumentationBuilder.kt | 2 + core/src/test/kotlin/TestAPI.kt | 13 ++++-- .../test/kotlin/format/KotlinWebSiteFormatTest.kt | 9 +++- .../kotlin/format/KotlinWebSiteHtmlFormatTest.kt | 9 +++- core/src/test/kotlin/format/MarkdownFormatTest.kt | 18 +++++++- .../kotlin/org/jetbrains/dokka/configuration.kt | 48 ++++++++++++---------- runners/ant/src/main/kotlin/ant/dokka.kt | 11 ++++- runners/cli/src/main/kotlin/cli/main.kt | 11 ++++- runners/gradle-plugin/src/main/kotlin/main.kt | 14 ++++++- runners/maven-plugin/src/main/kotlin/DokkaMojo.kt | 10 ++++- 14 files changed, 147 insertions(+), 57 deletions(-) diff --git a/core/src/main/kotlin/Analysis/AnalysisEnvironment.kt b/core/src/main/kotlin/Analysis/AnalysisEnvironment.kt index 3eb235e5..003c6835 100644 --- a/core/src/main/kotlin/Analysis/AnalysisEnvironment.kt +++ b/core/src/main/kotlin/Analysis/AnalysisEnvironment.kt @@ -69,7 +69,6 @@ class AnalysisEnvironment(val messageCollector: MessageCollector) : Disposable { val projectFileIndex = CoreProjectFileIndex(environment.project, environment.configuration.getList(JVMConfigurationKeys.CONTENT_ROOTS)) - environment.configuration.put(CommonConfigurationKeys.LANGUAGE_VERSION_SETTINGS, LanguageVersionSettingsImpl.DEFAULT) val moduleManager = object : CoreModuleManager(environment.project, this) { override fun getModules(): Array = arrayOf(projectFileIndex.module) @@ -142,7 +141,7 @@ class AnalysisEnvironment(val messageCollector: MessageCollector) : Disposable { }, CompilerEnvironment, packagePartProviderFactory = { info, content -> - JvmPackagePartProvider(LanguageVersionSettingsImpl.DEFAULT, content.moduleContentScope).apply { + JvmPackagePartProvider(configuration.languageVersionSettings, content.moduleContentScope).apply { addRoots(javaRoots) } }, @@ -157,6 +156,12 @@ class AnalysisEnvironment(val messageCollector: MessageCollector) : Disposable { return DokkaResolutionFacade(environment.project, moduleDescriptor, resolverForModule) } + fun loadLanguageVersionSettings(languageVersionString: String?, apiVersionString: String?) { + val languageVersion = LanguageVersion.fromVersionString(languageVersionString) ?: LanguageVersion.LATEST_STABLE + val apiVersion = apiVersionString?.let { ApiVersion.parse(it) } ?: ApiVersion.createByLanguageVersion(languageVersion) + configuration.languageVersionSettings = LanguageVersionSettingsImpl(languageVersion, apiVersion) + } + /** * Classpath for this environment. */ diff --git a/core/src/main/kotlin/DokkaBootstrapImpl.kt b/core/src/main/kotlin/DokkaBootstrapImpl.kt index 0aea4422..126a0175 100644 --- a/core/src/main/kotlin/DokkaBootstrapImpl.kt +++ b/core/src/main/kotlin/DokkaBootstrapImpl.kt @@ -66,6 +66,8 @@ class DokkaBootstrapImpl : DokkaBootstrap { perPackageOptions, externalDocumentationLinks, noStdlibLink, + languageVersion, + apiVersion, cacheRoot, suppressedFiles.map { File(it) } ) diff --git a/core/src/main/kotlin/Generation/DokkaGenerator.kt b/core/src/main/kotlin/Generation/DokkaGenerator.kt index 17b6b156..09e5cedf 100644 --- a/core/src/main/kotlin/Generation/DokkaGenerator.kt +++ b/core/src/main/kotlin/Generation/DokkaGenerator.kt @@ -94,6 +94,8 @@ class DokkaGenerator(val logger: DokkaLogger, addSources(sourcePaths) addSources(this@DokkaGenerator.samples) + + loadLanguageVersionSettings(options.languageVersion, options.apiVersion) } return environment diff --git a/core/src/main/kotlin/Generation/configurationImpl.kt b/core/src/main/kotlin/Generation/configurationImpl.kt index befe7e72..34d4154e 100644 --- a/core/src/main/kotlin/Generation/configurationImpl.kt +++ b/core/src/main/kotlin/Generation/configurationImpl.kt @@ -35,24 +35,28 @@ data class PackageOptionsImpl(override val prefix: String, override val skipDeprecated: Boolean = false, override val suppress: Boolean = false) : DokkaConfiguration.PackageOptions -data class DokkaConfigurationImpl(override val moduleName: String, - override val classpath: List, - override val sourceRoots: List, - override val samples: List, - override val includes: List, - override val outputDir: String, - override val format: String, - override val includeNonPublic: Boolean, - override val includeRootPackage: Boolean, - override val reportUndocumented: Boolean, - override val skipEmptyPackages: Boolean, - override val skipDeprecated: Boolean, - override val jdkVersion: Int, - override val generateIndexPages: Boolean, - override val sourceLinks: List, - override val impliedPlatforms: List, - override val perPackageOptions: List, - override val externalDocumentationLinks: List, - override val noStdlibLink: Boolean, - override val cacheRoot: String?, - override val suppressedFiles: List) : DokkaConfiguration \ No newline at end of file +data class DokkaConfigurationImpl( + override val moduleName: String, + override val classpath: List, + override val sourceRoots: List, + override val samples: List, + override val includes: List, + override val outputDir: String, + override val format: String, + override val includeNonPublic: Boolean, + override val includeRootPackage: Boolean, + override val reportUndocumented: Boolean, + override val skipEmptyPackages: Boolean, + override val skipDeprecated: Boolean, + override val jdkVersion: Int, + override val generateIndexPages: Boolean, + override val sourceLinks: List, + override val impliedPlatforms: List, + override val perPackageOptions: List, + override val externalDocumentationLinks: List, + override val noStdlibLink: Boolean, + override val cacheRoot: String?, + override val suppressedFiles: List, + override val languageVersion: String?, + override val apiVersion: String? +) : DokkaConfiguration \ No newline at end of file diff --git a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt index 2998e314..61bf50d6 100644 --- a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt +++ b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt @@ -48,6 +48,8 @@ class DocumentationOptions(val outputDir: String, perPackageOptions: List = emptyList(), externalDocumentationLinks: List = emptyList(), noStdlibLink: Boolean, + val languageVersion: String?, + val apiVersion: String?, cacheRoot: String? = null, val suppressedFiles: List = emptyList()) { init { diff --git a/core/src/test/kotlin/TestAPI.kt b/core/src/test/kotlin/TestAPI.kt index 8bbeb2f2..ff8a5260 100644 --- a/core/src/test/kotlin/TestAPI.kt +++ b/core/src/test/kotlin/TestAPI.kt @@ -28,15 +28,20 @@ fun verifyModel(vararg roots: ContentRoot, verifier: (DocumentationModule) -> Unit) { val documentation = DocumentationModule("test") - val options = DocumentationOptions("", format, + val options = DocumentationOptions( + "", + format, includeNonPublic = includeNonPublic, skipEmptyPackages = false, includeRootPackage = true, - sourceLinks = listOf(), + sourceLinks = listOf(), perPackageOptions = perPackageOptions, generateIndexPages = false, noStdlibLink = true, - cacheRoot = "default") + cacheRoot = "default", + languageVersion = null, + apiVersion = null + ) appendDocumentation(documentation, *roots, withJdk = withJdk, @@ -88,6 +93,8 @@ fun appendDocumentation(documentation: DocumentationModule, addClasspath(File(kotlinStrictfpRoot)) } addRoots(roots.toList()) + + loadLanguageVersionSettings(options.languageVersion, options.apiVersion) } val defaultPlatformsProvider = object : DefaultPlatformsProvider { override fun getDefaultPlatforms(descriptor: DeclarationDescriptor) = defaultPlatforms diff --git a/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt b/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt index f4ca2982..af44b048 100644 --- a/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt +++ b/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt @@ -42,7 +42,14 @@ class KotlinWebSiteFormatTest { private fun buildMultiplePlatforms(path: String): DocumentationModule { val module = DocumentationModule("test") - val options = DocumentationOptions("", "html", generateIndexPages = false, noStdlibLink = true) + val options = DocumentationOptions( + outputDir = "", + outputFormat = "html", + generateIndexPages = false, + noStdlibLink = true, + languageVersion = null, + apiVersion = null + ) appendDocumentation(module, contentRootFromPath("testdata/format/website/$path/jvm.kt"), defaultPlatforms = listOf("JVM"), options = options) appendDocumentation(module, contentRootFromPath("testdata/format/website/$path/jre7.kt"), defaultPlatforms = listOf("JVM", "JRE7"), options = options) appendDocumentation(module, contentRootFromPath("testdata/format/website/$path/js.kt"), defaultPlatforms = listOf("JS"), options = options) diff --git a/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt b/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt index b4b133f4..433c9c13 100644 --- a/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt +++ b/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt @@ -57,7 +57,14 @@ class KotlinWebSiteHtmlFormatTest { private fun buildMultiplePlatforms(path: String): DocumentationModule { val module = DocumentationModule("test") - val options = DocumentationOptions("", "html", generateIndexPages = false, noStdlibLink = true) + val options = DocumentationOptions( + outputDir = "", + outputFormat = "kotlin-website-html", + generateIndexPages = false, + noStdlibLink = true, + languageVersion = null, + apiVersion = null + ) appendDocumentation(module, contentRootFromPath("testdata/format/website-html/$path/jvm.kt"), defaultPlatforms = listOf("JVM"), options = options) appendDocumentation(module, contentRootFromPath("testdata/format/website-html/$path/jre7.kt"), defaultPlatforms = listOf("JVM", "JRE7"), options = options) appendDocumentation(module, contentRootFromPath("testdata/format/website-html/$path/js.kt"), defaultPlatforms = listOf("JS"), options = options) diff --git a/core/src/test/kotlin/format/MarkdownFormatTest.kt b/core/src/test/kotlin/format/MarkdownFormatTest.kt index d2ab5b5c..2c5422c5 100644 --- a/core/src/test/kotlin/format/MarkdownFormatTest.kt +++ b/core/src/test/kotlin/format/MarkdownFormatTest.kt @@ -300,7 +300,14 @@ class MarkdownFormatTest { @Test fun packagePlatformsWithExtExtensions() { val path = "multiplatform/packagePlatformsWithExtExtensions" val module = DocumentationModule("test") - val options = DocumentationOptions("", "html", generateIndexPages = false, noStdlibLink = true) + val options = DocumentationOptions( + outputDir = "", + outputFormat = "html", + generateIndexPages = false, + noStdlibLink = true, + languageVersion = null, + apiVersion = null + ) appendDocumentation(module, contentRootFromPath("testdata/format/$path/jvm.kt"), defaultPlatforms = listOf("JVM"), withKotlinRuntime = true, options = options) verifyMultiplatformIndex(module, path) verifyMultiplatformPackage(module, path) @@ -402,7 +409,14 @@ class MarkdownFormatTest { private fun buildMultiplePlatforms(path: String): DocumentationModule { val module = DocumentationModule("test") - val options = DocumentationOptions("", "html", generateIndexPages = false, noStdlibLink = true) + val options = DocumentationOptions( + outputDir = "", + outputFormat = "html", + generateIndexPages = false, + noStdlibLink = true, + languageVersion = null, + apiVersion = null + ) appendDocumentation(module, contentRootFromPath("testdata/format/$path/jvm.kt"), defaultPlatforms = listOf("JVM"), options = options) appendDocumentation(module, contentRootFromPath("testdata/format/$path/js.kt"), defaultPlatforms = listOf("JS"), options = options) return module diff --git a/integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt b/integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt index fd6a4209..90e5b5fc 100644 --- a/integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt +++ b/integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt @@ -36,6 +36,8 @@ interface DokkaConfiguration { val impliedPlatforms: List val perPackageOptions: List val externalDocumentationLinks: List + val languageVersion: String? + val apiVersion: String? val noStdlibLink: Boolean val cacheRoot: String? val suppressedFiles: List @@ -79,27 +81,31 @@ interface DokkaConfiguration { } } -data class SerializeOnlyDokkaConfiguration(override val moduleName: String, - override val classpath: List, - override val sourceRoots: List, - override val samples: List, - override val includes: List, - override val outputDir: String, - override val format: String, - override val includeNonPublic: Boolean, - override val includeRootPackage: Boolean, - override val reportUndocumented: Boolean, - override val skipEmptyPackages: Boolean, - override val skipDeprecated: Boolean, - override val jdkVersion: Int, - override val generateIndexPages: Boolean, - override val sourceLinks: List, - override val impliedPlatforms: List, - override val perPackageOptions: List, - override val externalDocumentationLinks: List, - override val noStdlibLink: Boolean, - override val cacheRoot: String?, - override val suppressedFiles: List) : DokkaConfiguration +data class SerializeOnlyDokkaConfiguration( + override val moduleName: String, + override val classpath: List, + override val sourceRoots: List, + override val samples: List, + override val includes: List, + override val outputDir: String, + override val format: String, + override val includeNonPublic: Boolean, + override val includeRootPackage: Boolean, + override val reportUndocumented: Boolean, + override val skipEmptyPackages: Boolean, + override val skipDeprecated: Boolean, + override val jdkVersion: Int, + override val generateIndexPages: Boolean, + override val sourceLinks: List, + override val impliedPlatforms: List, + override val perPackageOptions: List, + override val externalDocumentationLinks: List, + override val noStdlibLink: Boolean, + override val cacheRoot: String?, + override val suppressedFiles: List, + override val languageVersion: String?, + override val apiVersion: String? +) : DokkaConfiguration data class ExternalDocumentationLinkImpl(@CustomSerializer(UrlSerializer::class) override val url: URL, diff --git a/runners/ant/src/main/kotlin/ant/dokka.kt b/runners/ant/src/main/kotlin/ant/dokka.kt index 2872f845..d1b6bef5 100644 --- a/runners/ant/src/main/kotlin/ant/dokka.kt +++ b/runners/ant/src/main/kotlin/ant/dokka.kt @@ -45,6 +45,9 @@ class DokkaAntTask: Task() { var cacheRoot: String? = null + var languageVersion: String? = null + var apiVersion: String? = null + val compileClasspath: Path by lazy { Path(getProject()) } val sourcePath: Path by lazy { Path(getProject()) } val samplesPath: Path by lazy { Path(getProject()) } @@ -118,7 +121,9 @@ class DokkaAntTask: Task() { samplesPath.list().toList(), includesPath.list().toList(), moduleName!!, - DocumentationOptions(outputDir!!, outputFormat, + DocumentationOptions( + outputDir!!, + outputFormat, skipDeprecated = skipDeprecated, sourceLinks = sourceLinks, jdkVersion = jdkVersion, @@ -126,7 +131,9 @@ class DokkaAntTask: Task() { perPackageOptions = antPackageOptions, externalDocumentationLinks = antExternalDocumentationLinks.map { it.build() }, noStdlibLink = noStdlibLink, - cacheRoot = cacheRoot + cacheRoot = cacheRoot, + languageVersion = languageVersion, + apiVersion = apiVersion ) ) generator.generate() diff --git a/runners/cli/src/main/kotlin/cli/main.kt b/runners/cli/src/main/kotlin/cli/main.kt index b6eb1564..fe945ed3 100644 --- a/runners/cli/src/main/kotlin/cli/main.kt +++ b/runners/cli/src/main/kotlin/cli/main.kt @@ -55,6 +55,13 @@ class DokkaArguments { @set:Argument(value = "cacheRoot", description = "Path to cache folder, or 'default' to use ~/.cache/dokka, if not provided caching is disabled") var cacheRoot: String? = null + + @set:Argument(value = "languageVersion", description = "Language Version to pass to Kotlin Analysis") + var languageVersion: String? = null + + @set:Argument(value = "apiVersion", description = "Kotlin Api Version to pass to Kotlin Analysis") + var apiVersion: String? = null + } @@ -108,7 +115,9 @@ object MainKt { jdkVersion = arguments.jdkVersion, externalDocumentationLinks = parseLinks(arguments.links), noStdlibLink = arguments.noStdlibLink, - cacheRoot = arguments.cacheRoot + cacheRoot = arguments.cacheRoot, + languageVersion = arguments.languageVersion, + apiVersion = arguments.apiVersion ) val generator = DokkaGenerator( diff --git a/runners/gradle-plugin/src/main/kotlin/main.kt b/runners/gradle-plugin/src/main/kotlin/main.kt index 623a627c..bdecc3f6 100644 --- a/runners/gradle-plugin/src/main/kotlin/main.kt +++ b/runners/gradle-plugin/src/main/kotlin/main.kt @@ -112,7 +112,15 @@ open class DokkaTask : DefaultTask() { @Input var noStdlibLink: Boolean = false - @Optional @Input var cacheRoot: String? = null + @Optional @Input + var cacheRoot: String? = null + + + @Optional @Input + var languageVersion: String? = null + + @Optional @Input + var apiVersion: String? = null @get:Input internal val kotlinCompileBasedClasspathAndSourceRoots: ClasspathAndSourceRoots by lazy { extractClasspathAndSourceRootsFromKotlinTasks() } @@ -281,7 +289,9 @@ open class DokkaTask : DefaultTask() { externalDocumentationLinks, noStdlibLink, cacheRoot, - collectSuppressedFiles(sourceRoots)) + collectSuppressedFiles(sourceRoots), + languageVersion, + apiVersion) bootstrapProxy.configure( diff --git a/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt b/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt index c0904396..09da90c6 100644 --- a/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt +++ b/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt @@ -107,6 +107,12 @@ abstract class AbstractDokkaMojo : AbstractMojo() { @Parameter var cacheRoot: String? = null + @Parameter + var languageVersion: String? = null + + @Parameter + var apiVersion: String? = null + protected abstract fun getOutDir(): String protected abstract fun getOutFormat(): String @@ -133,7 +139,9 @@ abstract class AbstractDokkaMojo : AbstractMojo() { perPackageOptions = perPackageOptions, externalDocumentationLinks = externalDocumentationLinks.map { it.build() }, noStdlibLink = noStdlibLink, - cacheRoot = cacheRoot + cacheRoot = cacheRoot, + languageVersion = languageVersion, + apiVersion = apiVersion ) ) -- cgit From dc85d80e264370d0747f17613b259735f14a2fe1 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Wed, 29 Nov 2017 18:38:34 +0300 Subject: Support wide-range Since Kotlin versions --- .../main/kotlin/Formats/StructuredFormatService.kt | 25 +++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/core/src/main/kotlin/Formats/StructuredFormatService.kt b/core/src/main/kotlin/Formats/StructuredFormatService.kt index a8b000b7..5167a102 100644 --- a/core/src/main/kotlin/Formats/StructuredFormatService.kt +++ b/core/src/main/kotlin/Formats/StructuredFormatService.kt @@ -398,10 +398,29 @@ abstract class StructuredOutputBuilder(val to: StringBuilder, else -> it.platformsToShow.toSet() } } + + fun String.isKotlinVersion() = this.startsWith("Kotlin") + // Calculating common platforms for items - return platforms.fold(platforms.first()) { - result, platforms -> - result.intersect(platforms) + return platforms.reduce { result, platformsOfItem -> + val otherKotlinVersion = result.find { it.isKotlinVersion() } + val (kotlinVersions, otherPlatforms) = platformsOfItem.partition { it.isKotlinVersion() } + + // When no Kotlin version specified, it means that version is 1.0 + if (otherKotlinVersion != null && kotlinVersions.isNotEmpty()) { + val allKotlinVersions = (kotlinVersions + otherKotlinVersion).distinct() + + val minVersion = allKotlinVersions.min()!! + val resultVersion = when { + allKotlinVersions.size == 1 -> allKotlinVersions.single() + minVersion.endsWith("+") -> minVersion + else -> minVersion + "+" + } + + result.intersect(otherPlatforms) + resultVersion + } else { + result.intersect(platformsOfItem) + } } } -- cgit From 46e6c270c4100bcca0cc376791bd515b07483fa6 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Wed, 29 Nov 2017 20:00:22 +0300 Subject: Add test for wide range since kotlin versions --- core/src/test/kotlin/format/MarkdownFormatTest.kt | 4 ++++ core/testdata/format/sinceKotlinWide.kt | 11 +++++++++++ 2 files changed, 15 insertions(+) create mode 100644 core/testdata/format/sinceKotlinWide.kt diff --git a/core/src/test/kotlin/format/MarkdownFormatTest.kt b/core/src/test/kotlin/format/MarkdownFormatTest.kt index 2c5422c5..820af361 100644 --- a/core/src/test/kotlin/format/MarkdownFormatTest.kt +++ b/core/src/test/kotlin/format/MarkdownFormatTest.kt @@ -251,6 +251,10 @@ class MarkdownFormatTest { verifyMarkdownPackage("sinceKotlin") } + @Test fun sinceKotlinWide() { + verifyMarkdownPackage("sinceKotlinWide") + } + @Test fun dynamicType() { verifyMarkdownNode("dynamicType") } diff --git a/core/testdata/format/sinceKotlinWide.kt b/core/testdata/format/sinceKotlinWide.kt new file mode 100644 index 00000000..fa1eb7de --- /dev/null +++ b/core/testdata/format/sinceKotlinWide.kt @@ -0,0 +1,11 @@ +/** + * Useful + */ +@SinceKotlin("1.1") +class `Since1.1` + +/** + * Useful also + */ +@SinceKotlin("1.2") +class `Since1.2` \ No newline at end of file -- cgit From 880fb1095e1b6881ff4e891553de0cc9b92e3167 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Thu, 30 Nov 2017 19:03:02 +0300 Subject: Add missing test data --- core/testdata/format/sinceKotlinWide.package.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 core/testdata/format/sinceKotlinWide.package.md diff --git a/core/testdata/format/sinceKotlinWide.package.md b/core/testdata/format/sinceKotlinWide.package.md new file mode 100644 index 00000000..f683b178 --- /dev/null +++ b/core/testdata/format/sinceKotlinWide.package.md @@ -0,0 +1,11 @@ +[test](test/index) + +## Package <root> + +**Platform and version requirements:** Kotlin 1.1+ + +### Types + +| [Since1.1](test/-since1.1/index)
(Kotlin 1.1) | `class Since1.1`
Useful | +| [Since1.2](test/-since1.2/index)
(Kotlin 1.2) | `class Since1.2`
Useful also | + -- cgit From 0b3595a8e38d5f5b1d280eec4c35eea4976023f5 Mon Sep 17 00:00:00 2001 From: Colin Hebert Date: Sun, 26 Nov 2017 09:25:46 +1100 Subject: Pick correct closure type in the gradle plugin Replace Closure with Closure in the gradle plugin. Fixes #241 --- runners/gradle-plugin/src/main/kotlin/main.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/runners/gradle-plugin/src/main/kotlin/main.kt b/runners/gradle-plugin/src/main/kotlin/main.kt index bdecc3f6..505b2baf 100644 --- a/runners/gradle-plugin/src/main/kotlin/main.kt +++ b/runners/gradle-plugin/src/main/kotlin/main.kt @@ -133,7 +133,7 @@ open class DokkaTask : DefaultTask() { kotlinTasksConfigurator = { closure.call() as? List } } - fun linkMapping(closure: Closure) { + fun linkMapping(closure: Closure) { val mapping = LinkMapping() closure.delegate = mapping closure.call() @@ -148,21 +148,21 @@ open class DokkaTask : DefaultTask() { linkMappings.add(mapping) } - fun sourceRoot(closure: Closure) { + fun sourceRoot(closure: Closure) { val sourceRoot = SourceRoot() closure.delegate = sourceRoot closure.call() sourceRoots.add(sourceRoot) } - fun packageOptions(closure: Closure) { + fun packageOptions(closure: Closure) { val packageOptions = PackageOptions() closure.delegate = packageOptions closure.call() perPackageOptions.add(packageOptions) } - fun externalDocumentationLink(closure: Closure) { + fun externalDocumentationLink(closure: Closure) { val builder = DokkaConfiguration.ExternalDocumentationLink.Builder() closure.delegate = builder closure.call() -- cgit From 9dc46252c40b64b094ca3c53ccf4750d1b31e221 Mon Sep 17 00:00:00 2001 From: Colin Hebert Date: Sun, 26 Nov 2017 09:32:25 +1100 Subject: Fix ReportNotDocumented in the Gradle plugin Replace ReportNotDocumented with ReportUndocumented in the Gradle plugin for consistency. Fixes #243 --- runners/gradle-plugin/src/main/kotlin/main.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runners/gradle-plugin/src/main/kotlin/main.kt b/runners/gradle-plugin/src/main/kotlin/main.kt index 505b2baf..20d99c47 100644 --- a/runners/gradle-plugin/src/main/kotlin/main.kt +++ b/runners/gradle-plugin/src/main/kotlin/main.kt @@ -104,7 +104,7 @@ open class DokkaTask : DefaultTask() { @Input var includeNonPublic = false @Input var skipDeprecated = false @Input var skipEmptyPackages = true - @Input var reportNotDocumented = true + @Input var reportUndocumented = true @Input var perPackageOptions: MutableList = arrayListOf() @Input var impliedPlatforms: MutableList = arrayListOf() @@ -278,7 +278,7 @@ open class DokkaTask : DefaultTask() { outputFormat, includeNonPublic, false, - reportNotDocumented, + reportUndocumented, skipEmptyPackages, skipDeprecated, jdkVersion, -- cgit From 5eb7059566ef8d674eda8b7a7dfb01425c9739c9 Mon Sep 17 00:00:00 2001 From: Colin Hebert Date: Sun, 26 Nov 2017 09:35:36 +1100 Subject: Update documentation for reportUndocumented change Update documentation to reflect the reportUndocumented change --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 383d238b..158ce430 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ dokka { skipDeprecated = false // Emit warnings about not documented members. Applies globally, also can be overridden by packageOptions - reportNotDocumented = true + reportUndocumented = true skipEmptyPackages = true // Do not create index pages for empty packages -- cgit From 7485016705c4364dcea0212b5bc816f326ad7a87 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Mon, 11 Dec 2017 19:03:28 +0300 Subject: Add deprecation message for reportNotDocumented, in sake of #243 --- runners/gradle-plugin/src/main/kotlin/main.kt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/runners/gradle-plugin/src/main/kotlin/main.kt b/runners/gradle-plugin/src/main/kotlin/main.kt index 20d99c47..057efb98 100644 --- a/runners/gradle-plugin/src/main/kotlin/main.kt +++ b/runners/gradle-plugin/src/main/kotlin/main.kt @@ -51,6 +51,8 @@ object ClassloaderContainer { var fatJarClassLoader: ClassLoader? = null } +const val `deprecationMessage reportNotDocumented` = "Will be removed in 0.9.17, see dokka#243" + open class DokkaTask : DefaultTask() { fun defaultKotlinTasks() = with(ReflectDsl) { @@ -104,6 +106,15 @@ open class DokkaTask : DefaultTask() { @Input var includeNonPublic = false @Input var skipDeprecated = false @Input var skipEmptyPackages = true + + @Deprecated(`deprecationMessage reportNotDocumented`, replaceWith = ReplaceWith("reportUndocumented")) + var reportNotDocumented + get() = reportUndocumented + set(value) { + logger.warn("Dokka: reportNotDocumented is deprecated and " + `deprecationMessage reportNotDocumented`.decapitalize()) + reportUndocumented = value + } + @Input var reportUndocumented = true @Input var perPackageOptions: MutableList = arrayListOf() @Input var impliedPlatforms: MutableList = arrayListOf() -- cgit From d552647b6a51241aa5d5e9e50b87e22564c069e7 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Wed, 13 Dec 2017 23:22:05 +0300 Subject: Fix adding class directories to classpath Fixes #252 --- core/src/main/kotlin/Analysis/AnalysisEnvironment.kt | 15 ++++++++++----- .../test/kotlin/org/jetbrains/dokka/gradle/BasicTest.kt | 1 + .../gradle-integration-tests/testData/basic/build.gradle | 1 + .../gradle-integration-tests/testData/basic/fileTree.txt | 3 +++ .../testData/basic/src/main/kotlin/demo/HelloWorld.kt | 4 ++++ 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/core/src/main/kotlin/Analysis/AnalysisEnvironment.kt b/core/src/main/kotlin/Analysis/AnalysisEnvironment.kt index 003c6835..3b9b9149 100644 --- a/core/src/main/kotlin/Analysis/AnalysisEnvironment.kt +++ b/core/src/main/kotlin/Analysis/AnalysisEnvironment.kt @@ -13,7 +13,6 @@ import com.intellij.openapi.roots.ProjectFileIndex import com.intellij.openapi.roots.ProjectRootManager import com.intellij.openapi.util.Disposer import com.intellij.openapi.vfs.StandardFileSystems -import com.intellij.openapi.vfs.VirtualFileManager import com.intellij.psi.PsiElement import com.intellij.psi.search.GlobalSearchScope import com.intellij.util.io.URLUtil @@ -114,11 +113,17 @@ class AnalysisEnvironment(val messageCollector: MessageCollector) : Disposable { val builtIns = JvmBuiltIns(projectContext.storageManager) - val javaRoots = run { - val jvfs = VirtualFileManager.getInstance().getFileSystem(StandardFileSystems.JAR_PROTOCOL) + val javaRoots = classpath + .map { + val rootFile = when { + it.extension == "jar" -> + StandardFileSystems.jar().findFileByPath("${it.absolutePath}${URLUtil.JAR_SEPARATOR}")!! + else -> + StandardFileSystems.local().findFileByPath(it.absolutePath)!! + } - classpath.map { JavaRoot(jvfs.findFileByPath("${it.absolutePath}${URLUtil.JAR_SEPARATOR}")!!, JavaRoot.RootType.BINARY) } - } + JavaRoot(rootFile, JavaRoot.RootType.BINARY) + } val resolverForProject = ResolverForProjectImpl( "Dokka", diff --git a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/BasicTest.kt b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/BasicTest.kt index f9801c82..b1364004 100644 --- a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/BasicTest.kt +++ b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/BasicTest.kt @@ -11,6 +11,7 @@ class BasicTest : AbstractDokkaGradleTest() { val tmpRoot = testProjectDir.root.toPath() testDataRoot.resolve("src").copy(tmpRoot.resolve("src")) + testDataRoot.resolve("classDir").copy(tmpRoot.resolve("classDir")) testDataRoot.resolve("build.gradle").copy(tmpRoot.resolve("build.gradle")) testDataRoot.resolve("settings.gradle").copy(tmpRoot.resolve("settings.gradle")) } diff --git a/runners/gradle-integration-tests/testData/basic/build.gradle b/runners/gradle-integration-tests/testData/basic/build.gradle index bc20e1cf..4a259f50 100644 --- a/runners/gradle-integration-tests/testData/basic/build.gradle +++ b/runners/gradle-integration-tests/testData/basic/build.gradle @@ -36,4 +36,5 @@ dependencies { dokka { dokkaFatJar = new File(dokka_fatjar) + classpath += files("$projectDir/classDir") } \ No newline at end of file diff --git a/runners/gradle-integration-tests/testData/basic/fileTree.txt b/runners/gradle-integration-tests/testData/basic/fileTree.txt index 1a483d4e..2ceae371 100644 --- a/runners/gradle-integration-tests/testData/basic/fileTree.txt +++ b/runners/gradle-integration-tests/testData/basic/fileTree.txt @@ -22,6 +22,9 @@ constructor.html index.html main.html + p1.-my-binary-class/ + index.html + test.html str.html x.html index-outline.html diff --git a/runners/gradle-integration-tests/testData/basic/src/main/kotlin/demo/HelloWorld.kt b/runners/gradle-integration-tests/testData/basic/src/main/kotlin/demo/HelloWorld.kt index 7492e2a8..3d7bcb51 100644 --- a/runners/gradle-integration-tests/testData/basic/src/main/kotlin/demo/HelloWorld.kt +++ b/runners/gradle-integration-tests/testData/basic/src/main/kotlin/demo/HelloWorld.kt @@ -1,5 +1,7 @@ package demo +import p1.MyBinaryClass + /** * This class supports greeting people by name. * @@ -39,3 +41,5 @@ fun SomeType.constructor(): SomeType { annotation class A(val p: String) +val MyBinaryClass.test get() = s() + -- cgit From 9b90007eff1bd046afa8dd4be71502f8038cf292 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Wed, 13 Dec 2017 23:22:32 +0300 Subject: Update Kotlin version --- gradle.properties | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/gradle.properties b/gradle.properties index e046e1a3..6b9383bf 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,12 +3,9 @@ dokka_publication_channel=dokka #Kotlin compiler and plugin bundled_kotlin_compiler_version=1.2.20-dev-419 -kotlin_version=1.2.0-rc-39 +kotlin_version=1.2.0 kotlin_for_gradle_runtime_version=1.0.7 -#IntelliJ plugin to download openapi.jar -gradle_intellij_plugin_version=0.3.0-SNAPSHOT - ant_version=1.9.6 #Maven plugin dependencies -- cgit From 0cd45fb746de1c94e009b15082480e869e59e295 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Fri, 15 Dec 2017 00:27:23 +0300 Subject: Add forgotten part of testData --- .gitignore | 4 +++- .../testData/basic/classDir/p1/MyBinaryClass.class | Bin 0 -> 670 bytes 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 runners/gradle-integration-tests/testData/basic/classDir/p1/MyBinaryClass.class diff --git a/.gitignore b/.gitignore index a4f7f56b..fe5edc3b 100644 --- a/.gitignore +++ b/.gitignore @@ -89,4 +89,6 @@ gradle-app.setting !lib/*.jar local.properties -android.local.properties \ No newline at end of file +android.local.properties + +!runners/gradle-integration-tests/testData/basic/classDir/**/*.class \ No newline at end of file diff --git a/runners/gradle-integration-tests/testData/basic/classDir/p1/MyBinaryClass.class b/runners/gradle-integration-tests/testData/basic/classDir/p1/MyBinaryClass.class new file mode 100644 index 00000000..ccfff300 Binary files /dev/null and b/runners/gradle-integration-tests/testData/basic/classDir/p1/MyBinaryClass.class differ -- cgit From dcaa940db179cf346f9a0e8f98988d17a3cb2719 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Tue, 19 Dec 2017 19:02:27 +0300 Subject: Fix crash in as Java mode, just show ugly warning --- core/src/main/kotlin/Kotlin/KotlinAsJavaDescriptorSignatureProvider.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/kotlin/Kotlin/KotlinAsJavaDescriptorSignatureProvider.kt b/core/src/main/kotlin/Kotlin/KotlinAsJavaDescriptorSignatureProvider.kt index 266361f2..a3be658e 100644 --- a/core/src/main/kotlin/Kotlin/KotlinAsJavaDescriptorSignatureProvider.kt +++ b/core/src/main/kotlin/Kotlin/KotlinAsJavaDescriptorSignatureProvider.kt @@ -17,6 +17,6 @@ class KotlinAsJavaDescriptorSignatureProvider : DescriptorSignatureProvider { } return getSignature(javaLikePsi) ?: - throw UnsupportedOperationException("Don't know how to calculate signature for $forDesc") + "not implemented for $forDesc with psi: $sourcePsi" } } \ No newline at end of file -- cgit From 4a425e29fba4030d9cde7072ee6bf39ab7ae3668 Mon Sep 17 00:00:00 2001 From: Roman Elizarov Date: Fri, 22 Dec 2017 16:15:02 +0300 Subject: Supports hacks for MPP documentation generation --- core/src/main/kotlin/Analysis/AnalysisEnvironment.kt | 8 ++++---- runners/gradle-plugin/src/main/kotlin/main.kt | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/src/main/kotlin/Analysis/AnalysisEnvironment.kt b/core/src/main/kotlin/Analysis/AnalysisEnvironment.kt index 3b9b9149..56249ac4 100644 --- a/core/src/main/kotlin/Analysis/AnalysisEnvironment.kt +++ b/core/src/main/kotlin/Analysis/AnalysisEnvironment.kt @@ -114,15 +114,15 @@ class AnalysisEnvironment(val messageCollector: MessageCollector) : Disposable { val javaRoots = classpath - .map { + .mapNotNull { val rootFile = when { it.extension == "jar" -> - StandardFileSystems.jar().findFileByPath("${it.absolutePath}${URLUtil.JAR_SEPARATOR}")!! + StandardFileSystems.jar().findFileByPath("${it.absolutePath}${URLUtil.JAR_SEPARATOR}") else -> - StandardFileSystems.local().findFileByPath(it.absolutePath)!! + StandardFileSystems.local().findFileByPath(it.absolutePath) } - JavaRoot(rootFile, JavaRoot.RootType.BINARY) + rootFile?.let { JavaRoot(it, JavaRoot.RootType.BINARY) } } val resolverForProject = ResolverForProjectImpl( diff --git a/runners/gradle-plugin/src/main/kotlin/main.kt b/runners/gradle-plugin/src/main/kotlin/main.kt index 057efb98..78bf4978 100644 --- a/runners/gradle-plugin/src/main/kotlin/main.kt +++ b/runners/gradle-plugin/src/main/kotlin/main.kt @@ -379,7 +379,7 @@ open class DokkaTask : DefaultTask() { } } -class SourceRoot : DokkaConfiguration.SourceRoot { +class SourceRoot : DokkaConfiguration.SourceRoot, Serializable { override var path: String = "" set(value) { field = File(value).absolutePath -- cgit From 56213b9d66a78fdd35c2826c6edc3f36d491ff32 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Mon, 29 Jan 2018 19:53:23 +0300 Subject: Update Gradle Kotlin Runtime dependencies version to 1.1 Dokka drops support for Gradle less then 3.5 --- gradle.properties | 2 +- integration/build.gradle | 2 +- integration/src/main/kotlin/org/jetbrains/dokka/ReflectDsl.kt | 2 ++ runners/android-gradle-plugin/build.gradle | 2 +- runners/gradle-integration-tests/build.gradle | 3 +-- .../src/test/kotlin/org/jetbrains/dokka/gradle/AndroidAppTest.kt | 5 +++++ .../kotlin/org/jetbrains/dokka/gradle/AndroidMultiFlavourAppTest.kt | 4 ++++ .../src/test/kotlin/org/jetbrains/dokka/gradle/BasicTest.kt | 3 +++ .../kotlin/org/jetbrains/dokka/gradle/JavadocRSuppressionTest.kt | 4 ++++ .../kotlin/org/jetbrains/dokka/gradle/MultiProjectSingleOutTest.kt | 3 +++ .../org/jetbrains/dokka/gradle/RebuildAfterSourceChangeTest.kt | 5 +++++ runners/gradle-plugin/build.gradle | 2 +- 12 files changed, 31 insertions(+), 6 deletions(-) diff --git a/gradle.properties b/gradle.properties index 6b9383bf..4a6475b1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ dokka_publication_channel=dokka #Kotlin compiler and plugin bundled_kotlin_compiler_version=1.2.20-dev-419 kotlin_version=1.2.0 -kotlin_for_gradle_runtime_version=1.0.7 +kotlin_for_gradle_runtime_version=1.1.60 ant_version=1.9.6 diff --git a/integration/build.gradle b/integration/build.gradle index 32ca3454..026cfbc0 100644 --- a/integration/build.gradle +++ b/integration/build.gradle @@ -12,7 +12,7 @@ sourceCompatibility = 1.8 tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { kotlinOptions { languageVersion = "1.2" - apiVersion = "1.0" + apiVersion = "1.1" jvmTarget = "1.8" } } diff --git a/integration/src/main/kotlin/org/jetbrains/dokka/ReflectDsl.kt b/integration/src/main/kotlin/org/jetbrains/dokka/ReflectDsl.kt index 3c9bf156..1984a3e5 100644 --- a/integration/src/main/kotlin/org/jetbrains/dokka/ReflectDsl.kt +++ b/integration/src/main/kotlin/org/jetbrains/dokka/ReflectDsl.kt @@ -1,6 +1,8 @@ package org.jetbrains.dokka import kotlin.reflect.* +import kotlin.reflect.full.memberFunctions +import kotlin.reflect.full.memberProperties import kotlin.reflect.jvm.isAccessible object ReflectDsl { diff --git a/runners/android-gradle-plugin/build.gradle b/runners/android-gradle-plugin/build.gradle index 5050fd87..7d286cc7 100644 --- a/runners/android-gradle-plugin/build.gradle +++ b/runners/android-gradle-plugin/build.gradle @@ -13,7 +13,7 @@ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { kotlinOptions { freeCompilerArgs += "-Xjsr305=strict" languageVersion = "1.2" - apiVersion = "1.0" + apiVersion = "1.1" jvmTarget = "1.8" } } diff --git a/runners/gradle-integration-tests/build.gradle b/runners/gradle-integration-tests/build.gradle index 1809589f..cb734db3 100644 --- a/runners/gradle-integration-tests/build.gradle +++ b/runners/gradle-integration-tests/build.gradle @@ -21,8 +21,7 @@ configurations { dependencies { - testCompile group: 'org.jetbrains.kotlin', name: 'kotlin-runtime', version: kotlin_for_gradle_runtime_version - testCompile group: 'org.jetbrains.kotlin', name: 'kotlin-reflect', version: kotlin_for_gradle_runtime_version + testCompileOnly group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version: kotlin_for_gradle_runtime_version testCompile group: 'org.jetbrains.kotlin', name: 'kotlin-test', version: kotlin_for_gradle_runtime_version testCompile ideaRT() diff --git a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidAppTest.kt b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidAppTest.kt index ba70479f..bbb63909 100644 --- a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidAppTest.kt +++ b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidAppTest.kt @@ -17,4 +17,9 @@ class AndroidAppTest : AbstractAndroidAppTest("androidApp") { fun `test kotlin 1_0_7 and gradle 2_14_1 and abt 2_2_3`() { doTest("2.14.1", "1.0.7", AndroidPluginParams("2.2.3", "25.0.0", 24)) } + + @Test + fun `test kotlin 1_2_20 and gradle 4_5 and abt 3_0_1`() { + doTest("4.5", "1.2.20", AndroidPluginParams("3.0.1", "27.0.0", 27)) + } } \ No newline at end of file diff --git a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidMultiFlavourAppTest.kt b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidMultiFlavourAppTest.kt index 28328af8..ef1b94d8 100644 --- a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidMultiFlavourAppTest.kt +++ b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidMultiFlavourAppTest.kt @@ -53,4 +53,8 @@ class AndroidMultiFlavourAppTest : AbstractDokkaAndroidGradleTest() { doTest("2.14.1", "1.0.7", AndroidPluginParams("2.2.3", "25.0.0", 24)) } + @Test fun `test kotlin 1_2_20 and gradle 4_5 and abt 3_0_1`() { + doTest("4.5", "1.2.20", AndroidPluginParams("3.0.1", "27.0.0", 27)) + } + } \ No newline at end of file diff --git a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/BasicTest.kt b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/BasicTest.kt index b1364004..ebaf1653 100644 --- a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/BasicTest.kt +++ b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/BasicTest.kt @@ -49,4 +49,7 @@ class BasicTest : AbstractDokkaGradleTest() { doTest("4.0", "1.1.2") } + @Test fun `test kotlin 1_2_20 and gradle 4_5`() { + doTest("4.5", "1.2.20") + } } \ No newline at end of file diff --git a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/JavadocRSuppressionTest.kt b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/JavadocRSuppressionTest.kt index 511a033c..3a4d08b8 100644 --- a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/JavadocRSuppressionTest.kt +++ b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/JavadocRSuppressionTest.kt @@ -17,4 +17,8 @@ class JavadocRSuppressionTest : AbstractAndroidAppTest("androidAppJavadoc") { fun `test kotlin 1_0_7 and gradle 2_14_1 and abt 2_2_3`() { doTest("2.14.1", "1.0.7", AndroidPluginParams("2.2.3", "25.0.0", 24)) } + + @Test fun `test kotlin 1_2_20 and gradle 4_5 and abt 3_0_1`() { + doTest("4.5", "1.2.20", AndroidPluginParams("3.0.1", "27.0.0", 27)) + } } \ No newline at end of file diff --git a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/MultiProjectSingleOutTest.kt b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/MultiProjectSingleOutTest.kt index 13c7c37e..9458528c 100644 --- a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/MultiProjectSingleOutTest.kt +++ b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/MultiProjectSingleOutTest.kt @@ -51,4 +51,7 @@ class MultiProjectSingleOutTest : AbstractDokkaGradleTest() { doTest("4.0", "1.1.2") } + @Test fun `test kotlin 1_2_20 and gradle 4_5`() { + doTest("4.5", "1.2.20") + } } \ No newline at end of file diff --git a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/RebuildAfterSourceChangeTest.kt b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/RebuildAfterSourceChangeTest.kt index 42e79696..f712998c 100644 --- a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/RebuildAfterSourceChangeTest.kt +++ b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/RebuildAfterSourceChangeTest.kt @@ -66,4 +66,9 @@ class RebuildAfterSourceChangeTest : AbstractDokkaGradleTest() { fun `test kotlin 1_1_2 and gradle 4_0`() { doTest("4.0", "1.1.2") } + + @Test + fun `test kotlin 1_2_20 and gradle 4_5`() { + doTest("4.5", "1.2.20") + } } \ No newline at end of file diff --git a/runners/gradle-plugin/build.gradle b/runners/gradle-plugin/build.gradle index 790f3132..d3dbae22 100644 --- a/runners/gradle-plugin/build.gradle +++ b/runners/gradle-plugin/build.gradle @@ -11,7 +11,7 @@ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { kotlinOptions { freeCompilerArgs += "-Xjsr305=strict" languageVersion = "1.2" - apiVersion = "1.0" + apiVersion = "1.1" jvmTarget = "1.8" } } -- cgit From 7c80cf7ab7f578f4221597ff9fab1f688a85cc54 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Tue, 30 Jan 2018 22:33:19 +0300 Subject: Use kotlin-test-junit in gradle-integration-tests --- runners/gradle-integration-tests/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runners/gradle-integration-tests/build.gradle b/runners/gradle-integration-tests/build.gradle index cb734db3..a681c82e 100644 --- a/runners/gradle-integration-tests/build.gradle +++ b/runners/gradle-integration-tests/build.gradle @@ -22,7 +22,7 @@ configurations { dependencies { testCompileOnly group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version: kotlin_for_gradle_runtime_version - testCompile group: 'org.jetbrains.kotlin', name: 'kotlin-test', version: kotlin_for_gradle_runtime_version + testCompile group: 'org.jetbrains.kotlin', name: 'kotlin-test-junit', version: kotlin_for_gradle_runtime_version testCompile ideaRT() dokkaPlugin project(path: ':runners:gradle-plugin', configuration: 'shadow') -- cgit From 6fa36fde9628685c274fd6af0aebc467e76c79e9 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Wed, 31 Jan 2018 00:49:52 +0300 Subject: Update jkid --- integration/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/build.gradle b/integration/build.gradle index 026cfbc0..24d59edf 100644 --- a/integration/build.gradle +++ b/integration/build.gradle @@ -20,7 +20,7 @@ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { dependencies { compileOnly group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version: kotlin_for_gradle_runtime_version compileOnly group: 'org.jetbrains.kotlin', name: 'kotlin-reflect', version: kotlin_for_gradle_runtime_version - compile('com.github.yole:jkid:7d9c529c87') { + compile('com.github.yole:jkid:8fc7f12e1a') { transitive = false } } \ No newline at end of file -- cgit From f1536cc86b9cedebb10664e63783eb45e60c4856 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Wed, 31 Jan 2018 14:35:28 +0300 Subject: Fix dependencies in Gradle 4.5 --- gradle/wrapper/gradle-wrapper.properties | 2 +- runners/gradle-plugin/src/main/kotlin/main.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 590f0e81..610ad4c5 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.5-all.zip diff --git a/runners/gradle-plugin/src/main/kotlin/main.kt b/runners/gradle-plugin/src/main/kotlin/main.kt index 78bf4978..8c7f608e 100644 --- a/runners/gradle-plugin/src/main/kotlin/main.kt +++ b/runners/gradle-plugin/src/main/kotlin/main.kt @@ -71,7 +71,7 @@ open class DokkaTask : DefaultTask() { description = "Generates dokka documentation for Kotlin" @Suppress("LeakingThis") - dependsOn(Callable { kotlinTasks.flatMap { it.dependsOn } }) + dependsOn(Callable { kotlinTasks.map { it.taskDependencies } }) } @Input -- cgit From a9230650654229443c1e4d0896188f887e43077d Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Thu, 1 Feb 2018 16:11:47 +0300 Subject: Fix publication POM for maven-plugin --- runners/maven-plugin/build.gradle | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/runners/maven-plugin/build.gradle b/runners/maven-plugin/build.gradle index 0e8d6a4d..f3b9e79c 100644 --- a/runners/maven-plugin/build.gradle +++ b/runners/maven-plugin/build.gradle @@ -1,4 +1,5 @@ import groovy.io.FileType +import org.jetbrains.CorrectShadowPublishing import org.jetbrains.CrossPlatformExec import java.nio.file.Files @@ -92,14 +93,14 @@ apply plugin: 'maven-publish' publishing { publications { - dokkaMavenPlugin(MavenPublication) { publication -> + dokkaMavenPlugin(MavenPublication) { MavenPublication publication -> artifactId = 'dokka-maven-plugin' artifact sourceJar { classifier "sources" } - project.shadow.component(publication) + CorrectShadowPublishing.configure(publication, project) pom.withXml { Node root = asNode() -- cgit From 428a95b391cf313f8a57d3cd27a81665cf92cba6 Mon Sep 17 00:00:00 2001 From: Flamenco Date: Wed, 10 Jan 2018 17:41:07 -0500 Subject: Add information on suppress package option --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 158ce430..a50866bb 100644 --- a/README.md +++ b/README.md @@ -132,6 +132,11 @@ dokka { reportUndocumented = true // Emit warnings about not documented members includeNonPublic = false } + // Suppress a package + packageOptions { + prefix = "kotlin.internal" // will match kotlin.internal and all sub-packages of it + suppress = true + } } ``` -- cgit From 5dd8433a27ad6e50f79b66709480be02696af57d Mon Sep 17 00:00:00 2001 From: Tim Yates Date: Fri, 8 Dec 2017 16:54:57 +0000 Subject: Update plugin-publish-plugin Hiya, Tim from Gradle here. There was a [bug in versions prior to 0.9.7](https://discuss.gradle.org/t/plugin-authors-please-use-the-latest-plugin-publish-plugin-others-may-result-in-a-broken-upload/23573) of the gradle `plugin-publish-plugin`, where artifacts would sometimes silently not be pushed into the repo. Your plugin has not been affected by the bug yet, but you should still upgrade. This won't fix issue 146 (I'm not sure what has caused the pom differences seen in that issue), but it should avoid any problems publishing future versions --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 0002ee69..f3e2cc52 100644 --- a/build.gradle +++ b/build.gradle @@ -21,7 +21,7 @@ allprojects { classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7' classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.1' - classpath "com.gradle.publish:plugin-publish-plugin:0.9.6" + classpath "com.gradle.publish:plugin-publish-plugin:0.9.9" } } -- cgit From 9530cb367eb1ad92b6ca5aa5261e28f76e7d4bad Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Tue, 20 Feb 2018 00:11:30 +0300 Subject: Update publish-plugin and fix publishing --- build.gradle | 2 +- runners/android-gradle-plugin/build.gradle | 7 +++++++ runners/gradle-plugin/build.gradle | 8 ++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index f3e2cc52..ee76c9cb 100644 --- a/build.gradle +++ b/build.gradle @@ -21,7 +21,7 @@ allprojects { classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7' classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.1' - classpath "com.gradle.publish:plugin-publish-plugin:0.9.9" + classpath "com.gradle.publish:plugin-publish-plugin:0.9.10" } } diff --git a/runners/android-gradle-plugin/build.gradle b/runners/android-gradle-plugin/build.gradle index 7d286cc7..72d1be9e 100644 --- a/runners/android-gradle-plugin/build.gradle +++ b/runners/android-gradle-plugin/build.gradle @@ -1,3 +1,4 @@ +import com.gradle.publish.DependenciesBuilder import org.jetbrains.CorrectShadowPublishing apply plugin: 'java' @@ -87,6 +88,12 @@ pluginBundle { } } + withDependencies { List list -> + list.clear() + def builder = new DependenciesBuilder() + builder.addUniqueScopedDependencies(list, configurations.shadow, "compile") + } + mavenCoordinates { groupId = "org.jetbrains.dokka" artifactId = "dokka-android-gradle-plugin" diff --git a/runners/gradle-plugin/build.gradle b/runners/gradle-plugin/build.gradle index d3dbae22..661d432b 100644 --- a/runners/gradle-plugin/build.gradle +++ b/runners/gradle-plugin/build.gradle @@ -1,3 +1,5 @@ +import com.gradle.publish.DependenciesBuilder + apply plugin: 'java' apply plugin: 'kotlin' @@ -84,6 +86,12 @@ pluginBundle { } } + withDependencies { List list -> + list.clear() + def builder = new DependenciesBuilder() + builder.addUniqueScopedDependencies(list, configurations.shadow, "compile") + } + mavenCoordinates { groupId = "org.jetbrains.dokka" artifactId = "dokka-gradle-plugin" -- cgit From 3eb23215edcd1cf92966f8d39afe754fef0c7a19 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Wed, 21 Feb 2018 11:51:06 +0300 Subject: Update bundled kotlin compiler --- build.gradle | 2 + core/build.gradle | 2 +- .../main/kotlin/Analysis/AnalysisEnvironment.kt | 53 ++++++++++++++++++++-- .../main/kotlin/Analysis/CoreKotlinCacheService.kt | 30 ++++++++++++ .../main/kotlin/Analysis/CoreProjectFileIndex.kt | 30 ++++++------ .../kotlin/Kotlin/DescriptorDocumentationParser.kt | 2 +- .../src/main/kotlin/Kotlin/DocumentationBuilder.kt | 10 ++++ gradle.properties | 4 +- 8 files changed, 111 insertions(+), 22 deletions(-) create mode 100644 core/src/main/kotlin/Analysis/CoreKotlinCacheService.kt diff --git a/build.gradle b/build.gradle index ee76c9cb..f1748259 100644 --- a/build.gradle +++ b/build.gradle @@ -6,6 +6,7 @@ allprojects { def repo = { artifactPattern("https://teamcity.jetbrains.com/guestAuth/repository/download/Kotlin_dev_CompilerAllPlugins/[revision]/internal/[module](.[ext])") + artifactPattern("https://teamcity.jetbrains.com/guestAuth/repository/download/IntelliJMarkdownParser_Build/[revision]/([module]_[ext]/)[module](.[ext])") } buildscript { @@ -70,6 +71,7 @@ task wrapper(type: Wrapper) { def versions = DependenciesVersionGetter.getVersions(project, bundled_kotlin_compiler_version) ext.ideaVersion = versions["idea.build.id"] +ext.markdownVersion = versions["markdown.build.id"].replace("%20", " ") configurations { ideaIC diff --git a/core/build.gradle b/core/build.gradle index a8f0f275..1a93bb48 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -29,7 +29,7 @@ dependencies { compile "org.jetbrains.kotlin:kotlin-script-runtime:$bundled_kotlin_compiler_version" compile "teamcity:kotlin-ide-common:$bundled_kotlin_compiler_version" - compile "teamcity:markdown:$bundled_kotlin_compiler_version" + compile "teamcity:markdown:$markdownVersion" compile intellijCoreAnalysis() diff --git a/core/src/main/kotlin/Analysis/AnalysisEnvironment.kt b/core/src/main/kotlin/Analysis/AnalysisEnvironment.kt index 56249ac4..5522d4f0 100644 --- a/core/src/main/kotlin/Analysis/AnalysisEnvironment.kt +++ b/core/src/main/kotlin/Analysis/AnalysisEnvironment.kt @@ -1,5 +1,6 @@ package org.jetbrains.dokka +import com.google.common.collect.ImmutableMap import com.intellij.core.CoreApplicationEnvironment import com.intellij.core.CoreModuleManager import com.intellij.mock.MockComponentManager @@ -17,6 +18,7 @@ import com.intellij.psi.PsiElement import com.intellij.psi.search.GlobalSearchScope import com.intellij.util.io.URLUtil import org.jetbrains.kotlin.analyzer.* +import org.jetbrains.kotlin.caches.resolve.KotlinCacheService import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys import org.jetbrains.kotlin.cli.common.messages.MessageCollector import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles @@ -34,16 +36,19 @@ import org.jetbrains.kotlin.idea.resolve.ResolutionFacade import org.jetbrains.kotlin.load.java.structure.impl.JavaClassImpl import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.platform.JvmBuiltIns -import org.jetbrains.kotlin.psi.KtDeclaration -import org.jetbrains.kotlin.psi.KtElement -import org.jetbrains.kotlin.psi.KtFile +import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.resolve.BindingContext +import org.jetbrains.kotlin.resolve.BindingTrace import org.jetbrains.kotlin.resolve.CompilerEnvironment +import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics import org.jetbrains.kotlin.resolve.jvm.JvmAnalyzerFacade import org.jetbrains.kotlin.resolve.jvm.JvmPlatformParameters import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.resolve.lazy.ResolveSession +import org.jetbrains.kotlin.types.KotlinType +import org.jetbrains.kotlin.util.slicedMap.ReadOnlySlice +import org.jetbrains.kotlin.util.slicedMap.WritableSlice import java.io.File /** @@ -158,7 +163,11 @@ class AnalysisEnvironment(val messageCollector: MessageCollector) : Disposable { val resolverForModule = resolverForProject.resolverForModule(module) val moduleDescriptor = resolverForProject.descriptorForModule(module) builtIns.initialize(moduleDescriptor, true) - return DokkaResolutionFacade(environment.project, moduleDescriptor, resolverForModule) + val created = DokkaResolutionFacade(environment.project, moduleDescriptor, resolverForModule) + val projectComponentManager = environment.project as MockComponentManager + projectComponentManager.registerService(KotlinCacheService::class.java, CoreKotlinCacheService(created)) + + return created } fun loadLanguageVersionSettings(languageVersionString: String?, apiVersionString: String?) { @@ -247,6 +256,42 @@ class DokkaResolutionFacade(override val project: Project, val resolveSession: ResolveSession get() = getFrontendService(ResolveSession::class.java) override fun analyze(element: KtElement, bodyResolveMode: BodyResolveMode): BindingContext { + if (element is KtDeclaration) { + val descriptor = resolveToDescriptor(element) + return object : BindingContext { + override fun getKeys(p0: WritableSlice?): Collection { + throw UnsupportedOperationException() + } + + override fun getType(p0: KtExpression): KotlinType? { + throw UnsupportedOperationException() + } + + override fun get(slice: ReadOnlySlice?, key: K): V? { + if (key != element) { + throw UnsupportedOperationException() + } + return when { + slice == BindingContext.DECLARATION_TO_DESCRIPTOR -> descriptor as V + slice == BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER && (element as KtParameter).hasValOrVar() -> descriptor as V + else -> null + } + } + + override fun getDiagnostics(): Diagnostics { + throw UnsupportedOperationException() + } + + override fun addOwnDataTo(p0: BindingTrace, p1: Boolean) { + throw UnsupportedOperationException() + } + + override fun getSliceContents(p0: ReadOnlySlice): ImmutableMap { + throw UnsupportedOperationException() + } + + } + } throw UnsupportedOperationException() } diff --git a/core/src/main/kotlin/Analysis/CoreKotlinCacheService.kt b/core/src/main/kotlin/Analysis/CoreKotlinCacheService.kt new file mode 100644 index 00000000..31b8ffc7 --- /dev/null +++ b/core/src/main/kotlin/Analysis/CoreKotlinCacheService.kt @@ -0,0 +1,30 @@ +package org.jetbrains.dokka + +import com.intellij.psi.PsiFile +import org.jetbrains.kotlin.analyzer.ModuleInfo +import org.jetbrains.kotlin.caches.resolve.KotlinCacheService +import org.jetbrains.kotlin.idea.resolve.ResolutionFacade +import org.jetbrains.kotlin.psi.KtElement +import org.jetbrains.kotlin.resolve.TargetPlatform +import org.jetbrains.kotlin.resolve.diagnostics.KotlinSuppressCache + + +class CoreKotlinCacheService(private val resolutionFacade: DokkaResolutionFacade) : KotlinCacheService { + override fun getResolutionFacade(elements: List): ResolutionFacade { + return resolutionFacade + } + + override fun getResolutionFacadeByFile(file: PsiFile, platform: TargetPlatform): ResolutionFacade { + return resolutionFacade + } + + override fun getResolutionFacadeByModuleInfo(moduleInfo: ModuleInfo, platform: TargetPlatform): ResolutionFacade? { + return resolutionFacade + } + + override fun getSuppressionCache(): KotlinSuppressCache { + throw UnsupportedOperationException() + } + +} + diff --git a/core/src/main/kotlin/Analysis/CoreProjectFileIndex.kt b/core/src/main/kotlin/Analysis/CoreProjectFileIndex.kt index 2f2f94b3..4f6a7c76 100644 --- a/core/src/main/kotlin/Analysis/CoreProjectFileIndex.kt +++ b/core/src/main/kotlin/Analysis/CoreProjectFileIndex.kt @@ -228,24 +228,26 @@ class CoreProjectFileIndex(private val project: Project, contentRoots: List { + override fun getFiles(p0: OrderRootType): Array { throw UnsupportedOperationException() } - override fun getPresentableName(): String { + override fun getUrls(p0: OrderRootType): Array { throw UnsupportedOperationException() } - override fun getUrls(p0: OrderRootType?): Array { + override fun accept(p0: RootPolicy, p1: R?): R { throw UnsupportedOperationException() } - override fun getOwnerModule(): Module = module - override fun accept(p0: RootPolicy?, p1: R?): R { + override fun getPresentableName(): String { throw UnsupportedOperationException() } + override fun getOwnerModule(): Module = module + + override fun isValid(): Boolean { throw UnsupportedOperationException() } @@ -262,29 +264,29 @@ class CoreProjectFileIndex(private val project: Project, contentRoots: List { throw UnsupportedOperationException() } - override fun getJdk(): Sdk = sdk - - override fun getFiles(p0: OrderRootType?): Array { + override fun getUrls(p0: OrderRootType): Array { throw UnsupportedOperationException() } - override fun getPresentableName(): String { + override fun accept(p0: RootPolicy, p1: R?): R { throw UnsupportedOperationException() } - override fun getUrls(p0: OrderRootType?): Array { + override fun getJdkName(): String? { throw UnsupportedOperationException() } - override fun getOwnerModule(): Module { + override fun getJdk(): Sdk = sdk + + override fun getPresentableName(): String { throw UnsupportedOperationException() } - override fun accept(p0: RootPolicy?, p1: R?): R { + override fun getOwnerModule(): Module { throw UnsupportedOperationException() } @@ -358,7 +360,7 @@ class CoreProjectFileIndex(private val project: Project, contentRoots: List getModuleExtension(p0: Class?): T { + override fun getModuleExtension(p0: Class): T { throw UnsupportedOperationException() } diff --git a/core/src/main/kotlin/Kotlin/DescriptorDocumentationParser.kt b/core/src/main/kotlin/Kotlin/DescriptorDocumentationParser.kt index eb8c12d0..f2d9d3a7 100644 --- a/core/src/main/kotlin/Kotlin/DescriptorDocumentationParser.kt +++ b/core/src/main/kotlin/Kotlin/DescriptorDocumentationParser.kt @@ -81,7 +81,7 @@ class DescriptorDocumentationParser val suppressAnnotation = annotations.findAnnotation(FqName(Suppress::class.qualifiedName!!)) return if (suppressAnnotation != null) { @Suppress("UNCHECKED_CAST") - (suppressAnnotation.argumentValue("names") as List).any { it.value == "NOT_DOCUMENTED" } + (suppressAnnotation.argumentValue("names")?.value as List).any { it.value == "NOT_DOCUMENTED" } } else containingDeclaration?.isSuppressWarning() ?: false } diff --git a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt index 61bf50d6..916f89c9 100644 --- a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt +++ b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt @@ -15,7 +15,9 @@ import org.jetbrains.kotlin.js.resolve.diagnostics.findPsi import org.jetbrains.kotlin.kdoc.psi.impl.KDocSection import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.load.java.structure.impl.JavaClassImpl +import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.KtModifierListOwner import org.jetbrains.kotlin.psi.KtParameter import org.jetbrains.kotlin.resolve.DescriptorUtils @@ -779,6 +781,14 @@ class DocumentationBuilder "\"" + StringUtil.escapeStringCharacters(value) + "\"" is EnumEntrySyntheticClassDescriptor -> value.containingDeclaration.name.asString() + "." + value.name.asString() + is Pair<*, *> -> { + val (classId, name) = value + if (classId is ClassId && name is Name) { + classId.shortClassName.asString() + "." + name.asString() + } else { + value.toString() + } + } else -> value.toString() }.let { valueString -> DocumentationNode(valueString, Content.Empty, NodeKind.Value) diff --git a/gradle.properties b/gradle.properties index 4a6475b1..cabae269 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,8 +2,8 @@ dokka_version=0.9.16 dokka_publication_channel=dokka #Kotlin compiler and plugin -bundled_kotlin_compiler_version=1.2.20-dev-419 -kotlin_version=1.2.0 +bundled_kotlin_compiler_version=1.2.40-dev-529 +kotlin_version=1.2.21 kotlin_for_gradle_runtime_version=1.1.60 ant_version=1.9.6 -- cgit