aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/src/main/kotlin/Formats/StructuredFormatService.kt2
-rw-r--r--core/src/main/kotlin/Kotlin/DocumentationBuilder.kt7
-rw-r--r--core/src/main/kotlin/Model/DocumentationNode.kt3
-rw-r--r--core/src/main/kotlin/Model/DocumentationReference.kt1
-rw-r--r--core/src/test/kotlin/format/MarkdownFormatTest.kt4
-rw-r--r--core/testdata/format/inheritedCompanionObjectProperties.kt18
-rw-r--r--core/testdata/format/inheritedCompanionObjectProperties.md38
7 files changed, 70 insertions, 3 deletions
diff --git a/core/src/main/kotlin/Formats/StructuredFormatService.kt b/core/src/main/kotlin/Formats/StructuredFormatService.kt
index faa0b1ef..01f38605 100644
--- a/core/src/main/kotlin/Formats/StructuredFormatService.kt
+++ b/core/src/main/kotlin/Formats/StructuredFormatService.kt
@@ -287,7 +287,9 @@ abstract class StructuredFormatService(locationService: LocationService,
appendSection("Functions", node.members(NodeKind.Function))
appendSection("Inherited Functions", node.inheritedMembers(NodeKind.Function))
appendSection("Companion Object Properties", node.members(NodeKind.CompanionObjectProperty))
+ appendSection("Inherited Companion Object Properties", node.inheritedCompanionObjectMembers(NodeKind.Property))
appendSection("Companion Object Functions", node.members(NodeKind.CompanionObjectFunction))
+ appendSection("Inherited Companion Object Functions", node.inheritedCompanionObjectMembers(NodeKind.Function))
appendSection("Other members", node.members.filter {
it.kind !in setOf(
NodeKind.Class,
diff --git a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
index 3a35b764..a9701778 100644
--- a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
+++ b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
@@ -235,12 +235,13 @@ class DocumentationBuilder
(!options.skipDeprecated || !isDeprecated())
}
- fun DocumentationNode.appendMembers(descriptors: Iterable<DeclarationDescriptor>): List<DocumentationNode> {
+ fun DocumentationNode.appendMembers(descriptors: Iterable<DeclarationDescriptor>,
+ inheritedLinkKind: RefKind = RefKind.InheritedMember): List<DocumentationNode> {
val nodes = descriptors.map { descriptor ->
if (descriptor is CallableMemberDescriptor && descriptor.kind == CallableMemberDescriptor.Kind.FAKE_OVERRIDE) {
val baseDescriptor = descriptor.overriddenDescriptors.firstOrNull()
if (baseDescriptor != null) {
- link(this, baseDescriptor, RefKind.InheritedMember)
+ link(this, baseDescriptor, inheritedLinkKind)
}
null
}
@@ -314,7 +315,7 @@ class DocumentationBuilder
if (companionObjectDescriptor != null) {
val descriptors = companionObjectDescriptor.defaultType.memberScope.getContributedDescriptors()
val descriptorsToDocument = descriptors.filter { it !is CallableDescriptor || !it.isInheritedFromAny() }
- node.appendMembers(descriptorsToDocument)
+ node.appendMembers(descriptorsToDocument, RefKind.InheritedCompanionObjectMember)
}
node.appendAnnotations(this)
node.appendModifiers(this)
diff --git a/core/src/main/kotlin/Model/DocumentationNode.kt b/core/src/main/kotlin/Model/DocumentationNode.kt
index 121a5764..dcb50e8f 100644
--- a/core/src/main/kotlin/Model/DocumentationNode.kt
+++ b/core/src/main/kotlin/Model/DocumentationNode.kt
@@ -73,6 +73,8 @@ open class DocumentationNode(val name: String,
get() = references(RefKind.Member).map { it.to }
val inheritedMembers: List<DocumentationNode>
get() = references(RefKind.InheritedMember).map { it.to }
+ val inheritedCompanionObjectMembers: List<DocumentationNode>
+ get() = references(RefKind.InheritedCompanionObjectMember).map { it.to }
val extensions: List<DocumentationNode>
get() = references(RefKind.Extension).map { it.to }
val inheritors: List<DocumentationNode>
@@ -107,6 +109,7 @@ open class DocumentationNode(val name: String,
fun details(kind: NodeKind): List<DocumentationNode> = details.filter { it.kind == kind }
fun members(kind: NodeKind): List<DocumentationNode> = members.filter { it.kind == kind }
fun inheritedMembers(kind: NodeKind): List<DocumentationNode> = inheritedMembers.filter { it.kind == kind }
+ fun inheritedCompanionObjectMembers(kind: NodeKind): List<DocumentationNode> = inheritedCompanionObjectMembers.filter { it.kind == kind }
fun links(kind: NodeKind): List<DocumentationNode> = links.filter { it.kind == kind }
fun detail(kind: NodeKind): DocumentationNode = details.filter { it.kind == kind }.single()
diff --git a/core/src/main/kotlin/Model/DocumentationReference.kt b/core/src/main/kotlin/Model/DocumentationReference.kt
index 6db6d303..0b40e83a 100644
--- a/core/src/main/kotlin/Model/DocumentationReference.kt
+++ b/core/src/main/kotlin/Model/DocumentationReference.kt
@@ -6,6 +6,7 @@ enum class RefKind {
Owner,
Member,
InheritedMember,
+ InheritedCompanionObjectMember,
Detail,
Link,
HiddenLink,
diff --git a/core/src/test/kotlin/format/MarkdownFormatTest.kt b/core/src/test/kotlin/format/MarkdownFormatTest.kt
index a723cb2a..58b80cee 100644
--- a/core/src/test/kotlin/format/MarkdownFormatTest.kt
+++ b/core/src/test/kotlin/format/MarkdownFormatTest.kt
@@ -226,6 +226,10 @@ public class MarkdownFormatTest {
verifyMarkdownNode("multipleTypeParameterConstraints", withKotlinRuntime = true)
}
+ @Test fun inheritedCompanionObjectProperties() {
+ verifyMarkdownNodeByName("inheritedCompanionObjectProperties", "C")
+ }
+
private fun verifyMarkdownPackage(fileName: String, withKotlinRuntime: Boolean = false) {
verifyOutput("testdata/format/$fileName.kt", ".package.md", withKotlinRuntime = withKotlinRuntime) { model, output ->
markdownService.appendNodes(tempLocation, output, model.members)
diff --git a/core/testdata/format/inheritedCompanionObjectProperties.kt b/core/testdata/format/inheritedCompanionObjectProperties.kt
new file mode 100644
index 00000000..74a3749c
--- /dev/null
+++ b/core/testdata/format/inheritedCompanionObjectProperties.kt
@@ -0,0 +1,18 @@
+open class A {
+ fun foo() {
+ }
+}
+
+open class B {
+ fun bar() {
+ }
+}
+
+class C : A {
+ fun xyzzy() {
+ }
+
+ companion object : B () {
+ fun shazam()
+ }
+}
diff --git a/core/testdata/format/inheritedCompanionObjectProperties.md b/core/testdata/format/inheritedCompanionObjectProperties.md
new file mode 100644
index 00000000..9ec24edb
--- /dev/null
+++ b/core/testdata/format/inheritedCompanionObjectProperties.md
@@ -0,0 +1,38 @@
+[test](test/index) / [C](test/-c/index)
+
+
+# C
+
+`class C&nbsp;:&nbsp;[A](test/-a/index)`
+
+
+
+### Constructors
+
+
+| [&lt;init&gt;](test/-c/-init-) | `C()` |
+
+
+### Functions
+
+
+| [xyzzy](test/-c/xyzzy) | `fun xyzzy(): Unit` |
+
+
+### Inherited Functions
+
+
+| [foo](test/-a/foo) | `fun foo(): Unit` |
+
+
+### Companion Object Functions
+
+
+| [shazam](test/-c/shazam) | `fun shazam(): Unit` |
+
+
+### Inherited Companion Object Functions
+
+
+| [bar](test/-b/bar) | `fun bar(): Unit` |
+