aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorChris Rankin <chris.rankin@r3.com>2017-10-06 14:14:09 +0100
committerSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2017-11-22 21:54:14 +0300
commitf941d6adefa71d2b3b1cc69120edf7eae70187ba (patch)
tree0b943db512486c5cb39e0d3d59c3984090cf5c33 /core
parent2a62816f1a50f03927dad34eb0ee80a889cb9e7e (diff)
downloaddokka-f941d6adefa71d2b3b1cc69120edf7eae70187ba.tar.gz
dokka-f941d6adefa71d2b3b1cc69120edf7eae70187ba.tar.bz2
dokka-f941d6adefa71d2b3b1cc69120edf7eae70187ba.zip
Add new "suppress" per-package option.
Diffstat (limited to 'core')
-rw-r--r--core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt4
-rw-r--r--core/src/main/kotlin/Kotlin/DocumentationBuilder.kt2
-rw-r--r--core/src/test/kotlin/TestAPI.kt2
-rw-r--r--core/src/test/kotlin/model/PackageTest.kt35
-rw-r--r--core/testdata/packages/classInPackage.kt3
5 files changed, 41 insertions, 5 deletions
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<String, Content>) {
- 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<DokkaConfiguration.PackageOptions> = emptyList(),
verifier: (DocumentationModule) -> Unit) {
val documentation = DocumentationModule("test")
@@ -32,6 +33,7 @@ fun verifyModel(vararg roots: ContentRoot,
skipEmptyPackages = false,
includeRootPackage = true,
sourceLinks = listOf<SourceLinkDefinition>(),
+ 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 {}