aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Kotlin/KotlinLanguageService.kt25
-rw-r--r--test/data/format/annotationClass.md2
-rw-r--r--test/data/format/annotations.md2
-rw-r--r--test/data/format/classWithDefaultObject.html2
-rw-r--r--test/data/format/classWithDefaultObject.md2
-rw-r--r--test/data/format/crossLanguage/kotlinExtendsJava.html2
-rw-r--r--test/data/format/deprecated.class.html2
-rw-r--r--test/data/format/javaLinkTag.html2
-rw-r--r--test/data/format/javaSeeTag.html2
-rw-r--r--test/data/format/javaSupertype.html2
-rw-r--r--test/data/format/typeLink.html2
-rw-r--r--test/data/format/typeParameterVariance.md2
12 files changed, 26 insertions, 21 deletions
diff --git a/src/Kotlin/KotlinLanguageService.kt b/src/Kotlin/KotlinLanguageService.kt
index 9836bbda..fd31988d 100644
--- a/src/Kotlin/KotlinLanguageService.kt
+++ b/src/Kotlin/KotlinLanguageService.kt
@@ -6,6 +6,8 @@ import org.jetbrains.dokka.LanguageService.RenderMode
* Implements [LanguageService] and provides rendering of symbols in Kotlin language
*/
class KotlinLanguageService : LanguageService {
+ private val visibilityModifiers = setOf("public", "protected", "private")
+
override fun render(node: DocumentationNode, renderMode: RenderMode): ContentNode {
return content {
when (node.kind) {
@@ -14,7 +16,7 @@ class KotlinLanguageService : LanguageService {
DocumentationNode.Kind.Interface,
DocumentationNode.Kind.Enum,
DocumentationNode.Kind.AnnotationClass,
- DocumentationNode.Kind.Object -> renderClass(node)
+ DocumentationNode.Kind.Object -> renderClass(node, renderMode)
DocumentationNode.Kind.EnumItem,
DocumentationNode.Kind.ExternalClass -> if (renderMode == RenderMode.FULL) identifier(node.name)
@@ -26,9 +28,9 @@ class KotlinLanguageService : LanguageService {
DocumentationNode.Kind.Modifier -> renderModifier(node)
DocumentationNode.Kind.Constructor,
DocumentationNode.Kind.Function,
- DocumentationNode.Kind.DefaultObjectFunction -> renderFunction(node)
+ DocumentationNode.Kind.DefaultObjectFunction -> renderFunction(node, renderMode)
DocumentationNode.Kind.Property,
- DocumentationNode.Kind.DefaultObjectProperty -> renderProperty(node)
+ DocumentationNode.Kind.DefaultObjectProperty -> renderProperty(node, renderMode)
else -> identifier(node.name)
}
}
@@ -187,11 +189,14 @@ class KotlinLanguageService : LanguageService {
}
}
- private fun ContentBlock.renderModifiersForNode(node: DocumentationNode) {
+ private fun ContentBlock.renderModifiersForNode(node: DocumentationNode, renderMode: RenderMode) {
val modifiers = node.details(DocumentationNode.Kind.Modifier)
for (it in modifiers) {
if (node.kind == org.jetbrains.dokka.DocumentationNode.Kind.Interface && it.name == "abstract")
continue
+ if (renderMode == RenderMode.SUMMARY && it.name in visibilityModifiers) {
+ continue
+ }
renderModifier(it)
}
}
@@ -215,8 +220,8 @@ class KotlinLanguageService : LanguageService {
text(" ")
}
- private fun ContentBlock.renderClass(node: DocumentationNode) {
- renderModifiersForNode(node)
+ private fun ContentBlock.renderClass(node: DocumentationNode, renderMode: RenderMode) {
+ renderModifiersForNode(node, renderMode)
renderAnnotationsForNode(node)
when (node.kind) {
DocumentationNode.Kind.Class -> keyword("class ")
@@ -233,8 +238,8 @@ class KotlinLanguageService : LanguageService {
renderSupertypesForNode(node)
}
- private fun ContentBlock.renderFunction(node: DocumentationNode) {
- renderModifiersForNode(node)
+ private fun ContentBlock.renderFunction(node: DocumentationNode, renderMode: RenderMode) {
+ renderModifiersForNode(node, renderMode)
renderAnnotationsForNode(node)
when (node.kind) {
DocumentationNode.Kind.Constructor -> identifier(node.owner!!.name)
@@ -268,8 +273,8 @@ class KotlinLanguageService : LanguageService {
else -> true
}
- private fun ContentBlock.renderProperty(node: DocumentationNode) {
- renderModifiersForNode(node)
+ private fun ContentBlock.renderProperty(node: DocumentationNode, renderMode: RenderMode) {
+ renderModifiersForNode(node, renderMode)
renderAnnotationsForNode(node)
when (node.kind) {
DocumentationNode.Kind.Property,
diff --git a/test/data/format/annotationClass.md b/test/data/format/annotationClass.md
index 936217d2..03548aa3 100644
--- a/test/data/format/annotationClass.md
+++ b/test/data/format/annotationClass.md
@@ -10,5 +10,5 @@
### Constructors
-| [<init>](test/fancy/-init-) | `public fancy()` |
+| [<init>](test/fancy/-init-) | `fancy()` |
diff --git a/test/data/format/annotations.md b/test/data/format/annotations.md
index 9e32eb24..caf84084 100644
--- a/test/data/format/annotations.md
+++ b/test/data/format/annotations.md
@@ -10,7 +10,7 @@
### Constructors
-| [<init>](test/-foo/-init-) | `public Foo()` |
+| [<init>](test/-foo/-init-) | `Foo()` |
### Properties
diff --git a/test/data/format/classWithDefaultObject.html b/test/data/format/classWithDefaultObject.html
index ca6f2305..663d8f64 100644
--- a/test/data/format/classWithDefaultObject.html
+++ b/test/data/format/classWithDefaultObject.html
@@ -16,7 +16,7 @@
<td>
<a href="test/-klass/-init-">&lt;init&gt;</a></td>
<td>
-<code><span class="keyword">public</span> <span class="identifier">Klass</span><span class="symbol">(</span><span class="symbol">)</span></code></td>
+<code><span class="identifier">Klass</span><span class="symbol">(</span><span class="symbol">)</span></code></td>
</tr>
</tbody>
</table>
diff --git a/test/data/format/classWithDefaultObject.md b/test/data/format/classWithDefaultObject.md
index d9f6a8fe..645f4755 100644
--- a/test/data/format/classWithDefaultObject.md
+++ b/test/data/format/classWithDefaultObject.md
@@ -10,7 +10,7 @@
### Constructors
-| [&lt;init&gt;](test/-klass/-init-) | `public Klass()` |
+| [&lt;init&gt;](test/-klass/-init-) | `Klass()` |
### Default Object Properties
diff --git a/test/data/format/crossLanguage/kotlinExtendsJava.html b/test/data/format/crossLanguage/kotlinExtendsJava.html
index 035b66b0..5b93d837 100644
--- a/test/data/format/crossLanguage/kotlinExtendsJava.html
+++ b/test/data/format/crossLanguage/kotlinExtendsJava.html
@@ -17,7 +17,7 @@
<td>
<a href="test/test/-bar/-init-">&lt;init&gt;</a></td>
<td>
-<code><span class="keyword">public</span> <span class="identifier">Bar</span><span class="symbol">(</span><span class="symbol">)</span></code><p>See <a href="test/test/-foo/xyzzy">xyzzy</a></p>
+<code><span class="identifier">Bar</span><span class="symbol">(</span><span class="symbol">)</span></code><p>See <a href="test/test/-foo/xyzzy">xyzzy</a></p>
</td>
</tr>
</tbody>
diff --git a/test/data/format/deprecated.class.html b/test/data/format/deprecated.class.html
index 600b362f..69da63a1 100644
--- a/test/data/format/deprecated.class.html
+++ b/test/data/format/deprecated.class.html
@@ -33,7 +33,7 @@
<td>
<a href="test/-c/-init-">&lt;init&gt;</a></td>
<td>
-<code><span class="keyword">public</span> <span class="identifier">C</span><span class="symbol">(</span><span class="symbol">)</span></code></td>
+<code><span class="identifier">C</span><span class="symbol">(</span><span class="symbol">)</span></code></td>
</tr>
</tbody>
</table>
diff --git a/test/data/format/javaLinkTag.html b/test/data/format/javaLinkTag.html
index e5d5b01d..d6ced4ce 100644
--- a/test/data/format/javaLinkTag.html
+++ b/test/data/format/javaLinkTag.html
@@ -18,7 +18,7 @@
<td>
<a href="test/test/-foo/bar">bar</a></td>
<td>
-<code><span class="keyword">public</span> <span class="keyword">open</span> <span class="keyword">fun </span><span class="identifier">bar</span><span class="symbol">(</span><span class="symbol">)</span><span class="symbol">: </span><span class="identifier">Unit</span></code></td>
+<code><span class="keyword">open</span> <span class="keyword">fun </span><span class="identifier">bar</span><span class="symbol">(</span><span class="symbol">)</span><span class="symbol">: </span><span class="identifier">Unit</span></code></td>
</tr>
</tbody>
</table>
diff --git a/test/data/format/javaSeeTag.html b/test/data/format/javaSeeTag.html
index c1ebb740..cf7b7941 100644
--- a/test/data/format/javaSeeTag.html
+++ b/test/data/format/javaSeeTag.html
@@ -19,7 +19,7 @@
<td>
<a href="test/test/-foo/bar">bar</a></td>
<td>
-<code><span class="keyword">public</span> <span class="keyword">open</span> <span class="keyword">fun </span><span class="identifier">bar</span><span class="symbol">(</span><span class="symbol">)</span><span class="symbol">: </span><span class="identifier">Unit</span></code></td>
+<code><span class="keyword">open</span> <span class="keyword">fun </span><span class="identifier">bar</span><span class="symbol">(</span><span class="symbol">)</span><span class="symbol">: </span><span class="identifier">Unit</span></code></td>
</tr>
</tbody>
</table>
diff --git a/test/data/format/javaSupertype.html b/test/data/format/javaSupertype.html
index 92a53a44..3a93da0a 100644
--- a/test/data/format/javaSupertype.html
+++ b/test/data/format/javaSupertype.html
@@ -16,7 +16,7 @@
<td>
<a href="test/test/-c/-bar/return-foo">returnFoo</a></td>
<td>
-<code><span class="keyword">public</span> <span class="keyword">open</span> <span class="keyword">fun </span><span class="identifier">returnFoo</span><span class="symbol">(</span><span class="identifier">foo</span><span class="symbol">:</span>&nbsp;<a href="test/test/-c/-foo"><span class="identifier">Foo</span></a><span class="symbol">)</span><span class="symbol">: </span><a href="test/test/-c/-foo"><span class="identifier">Foo</span></a></code></td>
+<code><span class="keyword">open</span> <span class="keyword">fun </span><span class="identifier">returnFoo</span><span class="symbol">(</span><span class="identifier">foo</span><span class="symbol">:</span>&nbsp;<a href="test/test/-c/-foo"><span class="identifier">Foo</span></a><span class="symbol">)</span><span class="symbol">: </span><a href="test/test/-c/-foo"><span class="identifier">Foo</span></a></code></td>
</tr>
</tbody>
</table>
diff --git a/test/data/format/typeLink.html b/test/data/format/typeLink.html
index 9df615c8..ff99090a 100644
--- a/test/data/format/typeLink.html
+++ b/test/data/format/typeLink.html
@@ -16,7 +16,7 @@
<td>
<a href="test/-bar/-init-">&lt;init&gt;</a></td>
<td>
-<code><span class="keyword">public</span> <span class="identifier">Bar</span><span class="symbol">(</span><span class="symbol">)</span></code></td>
+<code><span class="identifier">Bar</span><span class="symbol">(</span><span class="symbol">)</span></code></td>
</tr>
</tbody>
</table>
diff --git a/test/data/format/typeParameterVariance.md b/test/data/format/typeParameterVariance.md
index a46929ce..9ba871a8 100644
--- a/test/data/format/typeParameterVariance.md
+++ b/test/data/format/typeParameterVariance.md
@@ -10,5 +10,5 @@
### Constructors
-| [&lt;init&gt;](test/-foo/-init-) | `public Foo()` |
+| [&lt;init&gt;](test/-foo/-init-) | `Foo()` |